AudioFlinger: Do not permit fast patch tracks if not compatible

Test: atest AudioPlaybackCaptureTest
Bug: 132346038
Change-Id: I67939ed7f98c546d41148d36764d93723353c893
gugelfrei
Andy Hung 5 years ago
parent e905b6b187
commit ae22b4843b

@ -827,6 +827,12 @@ sp<IAudioTrack> AudioFlinger::createTrack(const CreateTrackInput& input,
ALOGE("Secondary output patchRecord init failed: %d", status);
continue;
}
// TODO: We could check compatibility of the secondaryThread with the PatchTrack
// for fast usage: thread has fast mixer, sample rate matches, etc.;
// for now, we exclude fast tracks by removing the Fast flag.
const audio_output_flags_t outputFlags =
(audio_output_flags_t)(output.flags & ~AUDIO_OUTPUT_FLAG_FAST);
sp patchTrack = new PlaybackThread::PatchTrack(secondaryThread,
streamType,
output.sampleRate,
@ -835,7 +841,7 @@ sp<IAudioTrack> AudioFlinger::createTrack(const CreateTrackInput& input,
frameCount,
patchRecord->buffer(),
patchRecord->bufferSize(),
output.flags,
outputFlags,
0ns /* timeout */);
status = patchTrack->initCheck();
if (status != NO_ERROR) {

@ -506,7 +506,10 @@ status_t AudioFlinger::PatchPanel::Patch::createConnections(PatchPanel *panel)
}
if (mPlayback.thread()->hasFastMixer()) {
// Create a fast track if the playback thread has fast mixer to get better performance.
// Note: we should have matching channel mask, sample rate, and format by the logic above.
outputFlags = (audio_output_flags_t) (outputFlags | AUDIO_OUTPUT_FLAG_FAST);
} else {
outputFlags = (audio_output_flags_t) (outputFlags & ~AUDIO_OUTPUT_FLAG_FAST);
}
// create a special playback track to render to playback thread.

@ -4618,6 +4618,10 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac
// process fast tracks
if (track->isFastTrack()) {
LOG_ALWAYS_FATAL_IF(mFastMixer.get() == nullptr,
"%s(%d): FastTrack(%d) present without FastMixer",
__func__, id(), track->id());
if (track->getHapticPlaybackEnabled()) {
noFastHapticTrack = false;
}

Loading…
Cancel
Save