termux / termux/termux-api

Filename of MIC recording in progress, reported erroneously

Open
#290 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug report
Dominant language
Java
Stars
4.3k
Forks
920
PR merge metrics
No merged PRs in 30d

Description

Problem description
When a previous termux-microphone-record is active, another call to it -with a different filename argument- will overwrite the filename reported when calling termux-microphone-record -q or termux-microphone-record -i, before the initial recording ends.

Steps to reproduce

$ pwd
/storage/emulated/0/tmp


$ termux-microphone-record -l 100 -f first.mp4
Recording started: /storage/emulated/0/tmp/first.mp4 
Max Duration: 01:40

$ termux-microphone-record -f second.mp4

Recording already in progress!


$ termux-microphone-record -i
{
  "isRecording": true,
  "outputFile": "\/storage\/emulated\/0\/tmp\/second.mp4"
}

$ ls first.mp4 second.mp4
ls: cannot access 'second.mp4': No such file or directory
first.mp4


$ termux-microphone-record -q
Recording finished: /storage/emulated/0/tmp/second.mp4

$ ls first.mp4 second.mp4
ls: cannot access 'second.mp4': No such file or directory
first.mp4

Expected behavior
Should report first.mp4, as is actually written.

Suggested solution

I suggest that you use another, temporary variable in recordHandler#L239-265 to create the file and assign it to file only if you're going to use it (#L250).

Lines in the code involved
(all in /app/src/main/java/com/termux/api/MicRecorderAPI.java)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in app/src/main/java/com/termux/api/MicRecorderAPI.java, reading MicRecorderService, getRecordingInfoJSONString, recordHandler, and quitHandler at the referenced lines. Reproduce the two-recording command sequence, then verify that status and quit output retain the first filename while the recording is active and after it ends.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
cli, mobile-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.