Avoid draining audio processors while reset
If the DefaultAudioSink was reconfigured in a way that was compatible with the previous configuration just after having been reset, we would try to drain audio processors despite not having an AudioTrack. This could result in a NullPointerException if speed adjustment was active. Fix this behavior by only trying to drain audio processors if we actually have an AudioTrack. PiperOrigin-RevId: 235355466
This commit is contained in:
parent
e8077fb3f4
commit
caeaa9574e
@ -465,14 +465,17 @@ public final class DefaultAudioSink implements AudioSink {
|
||||
processingEnabled,
|
||||
canApplyPlaybackParameters,
|
||||
availableAudioProcessors);
|
||||
if (configuration == null || !pendingConfiguration.canReuseAudioTrack(configuration)) {
|
||||
// We need a new AudioTrack before we can handle more input. We should first stop() the track
|
||||
// (if we have one) and wait for audio to play out. Tracked by [Internal: b/33161961].
|
||||
flush();
|
||||
} else if (flushAudioProcessors) {
|
||||
// We don't need a new AudioTrack but audio processors need to be flushed.
|
||||
this.pendingConfiguration = pendingConfiguration;
|
||||
return;
|
||||
if (isInitialized()) {
|
||||
if (!pendingConfiguration.canReuseAudioTrack(configuration)) {
|
||||
// We need a new AudioTrack before we can handle more input. We should first stop() the
|
||||
// track and wait for audio to play out (tracked by [Internal: b/33161961]), but for now we
|
||||
// discard the audio track immediately.
|
||||
flush();
|
||||
} else if (flushAudioProcessors) {
|
||||
// We don't need a new AudioTrack but audio processors need to be drained and flushed.
|
||||
this.pendingConfiguration = pendingConfiguration;
|
||||
return;
|
||||
}
|
||||
}
|
||||
configuration = pendingConfiguration;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user