How to check if another recorder works or not?

I am using the AudioRecord API to record audio (WAV) in my application and it is successfully recorded. But my application behaves strangely when I try to record, while other recording applications are running in the background.

The MediaRecorder API throws an exception when trying to start recording while another recorder is running, but the AudioRecord API initializes the instance of the recorder and does not take any action, throw any exceptions, so I can not determine if any instance of the recorder is working or not.

This script was processed in Samsung S3 Voice Recorder when I try to record it,

"Unable to start a new recording. Other applications are already recording."

How can I determine if any other recorder is running or not before my application recorder starts?

+4
source share
1 answer

I found a solution to this problem

Since AudioRecord does not throw any exceptions, unlike the MediaRecorder API, I switched to another workaround.

When another instance of the recorder is running, I find that the read method returns 0 instead of ERROR_INVALID_OPERATION or ERROR_BAD_VALUE . Therefore, if the first read operation returns 0 , I found an error message because "Recorder cannot be initialized."

+6
source

Source: https://habr.com/ru/post/1489728/


All Articles