Skip to content

Silence ringer during recording transition#26

Open
ghost wants to merge 1 commit intomasterfrom
unknown repository
Open

Silence ringer during recording transition#26
ghost wants to merge 1 commit intomasterfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Mar 13, 2016

MediaRecorder produces a "chime" sound on state changes (e.g. on the
stop and start of recordings). Some versions of Android use
STREAM_SYSTEM to produce the sound, but others such as version 4.2.1 on
the Galaxy Nexus use STREAM_RING. This patch silences the ringer during
recording transitions in order to prevent the "chime" sound from being
heard on each RestartRecording method call on relevant Android versions.

MediaRecorder produces a "chime" sound on state changes (e.g. on the
stop and start of recordings). Some versions of Android use
STREAM_SYSTEM to produce the sound, but others such as version 4.2.1 on
the Galaxy Nexus use STREAM_RING. This patch silences the ringer during
recording transitions in order to prevent the "chime" sound from being
heard on each RestartRecording method call on relevant Android versions.
@ghost
Copy link
Author

ghost commented Mar 13, 2016

This patch should theoretically not be necessary when setStreamSolo is used, but setStreamSolo appears to work as a no-op on newer versions of Android. A more encompassing solution may be necessary to cover Android versions where MediaRecorder uses a stream other than STREAM_SYSTEM or STREAM_RING.

The setStreamVolume method should not be used on STREAM_RING since a vibration may occur on every transition if the ringer mode is set to RINGER_MODE_NORMAL.

@sergstetsuk
Copy link
Owner

Yes. I've found that on different devices MediaRecorder uses different streams. That's why Solo+Mute method was chosen. But if you confirm that it doesn't work on newer devices and your patch fixes this issue, let me know what exact device is it and of course your patch will be merged to upstream.

@ghost
Copy link
Author

ghost commented Mar 14, 2016

The setStreamSolo method appears to be a no-op (or at the very least does not isolate the audio stream) on Android version 5.0.1 running on a Samsung Galaxy S4 as well as on Android version 5.1.1 running on a Samsung Galaxy S6. I haven't tested the setStreamSolo method on a Android version 4.x.x device, so it's possible that it behaves correctly on those. Regardless, this patch should work for either version series of Android.

It's important to note that this patch is only a partial solution, fixing the issue only for those devices whose MediaRecorder uses STREAM_RING. A more complete solution would use the requestAudioFocus adjustStreamVolume + ADJUST_MUTE or ADJUST_UNMUTE approach you've mentioned previous closed pull request. However, setRingerMode may still be necessary in such case (I'm unsure of the behavior of requestAudioFocus) in order to avoid the vibration that occurs when bringing the ringer volume down to 0 when the ringer mode is set to RINGER_MODE_NORMAL as is default on most devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant