mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Workaround AudioTrack incorrect error code
#exo-offload PiperOrigin-RevId: 333513385
This commit is contained in:
parent
aa7309cdea
commit
fad2846d1c
1 changed files with 14 additions and 1 deletions
|
|
@ -234,6 +234,18 @@ public final class DefaultAudioSink implements AudioSink {
|
||||||
/** To avoid underruns on some devices (e.g., Broadcom 7271), scale up the AC3 buffer duration. */
|
/** To avoid underruns on some devices (e.g., Broadcom 7271), scale up the AC3 buffer duration. */
|
||||||
private static final int AC3_BUFFER_MULTIPLICATION_FACTOR = 2;
|
private static final int AC3_BUFFER_MULTIPLICATION_FACTOR = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Native error code equivalent of {@link AudioTrack#ERROR_DEAD_OBJECT} to workaround missing
|
||||||
|
* error code translation on some devices.
|
||||||
|
*
|
||||||
|
* <p>On some devices, AudioTrack native error codes are not always converted to their SDK
|
||||||
|
* equivalent.
|
||||||
|
*
|
||||||
|
* <p>For example: {@link AudioTrack#write(byte[], int, int)} can return -32 instead of {@link
|
||||||
|
* AudioTrack#ERROR_DEAD_OBJECT}.
|
||||||
|
*/
|
||||||
|
private static final int ERROR_NATIVE_DEAD_OBJECT = -32;
|
||||||
|
|
||||||
private static final String TAG = "AudioTrack";
|
private static final String TAG = "AudioTrack";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -966,7 +978,8 @@ public final class DefaultAudioSink implements AudioSink {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isAudioTrackDeadObject(int status) {
|
private static boolean isAudioTrackDeadObject(int status) {
|
||||||
return Util.SDK_INT >= 24 && status == AudioTrack.ERROR_DEAD_OBJECT;
|
return (Util.SDK_INT >= 24 && status == AudioTrack.ERROR_DEAD_OBJECT)
|
||||||
|
|| status == ERROR_NATIVE_DEAD_OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean drainToEndOfStream() throws WriteException {
|
private boolean drainToEndOfStream() throws WriteException {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue