audioflinger: fix OutputTrack initial check
Call initCheck() on newly created OutputTrack in
DuplicatingThread::addOutputTrack() to make sure that
the track is successfully attached to the AudioMixer.
Also make invalid track name always fatal in AudioMixer::deleteTrackName().
Bug: 29953737
Change-Id: I47f2517bd53de940e125391de99c40611ad0fc9d
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index d093c32..aa2561e 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -5772,12 +5772,15 @@
mChannelMask,
frameCount,
IPCThreadState::self()->getCallingUid());
- if (outputTrack->cblk() != NULL) {
- thread->setStreamVolume(AUDIO_STREAM_PATCH, 1.0f);
- mOutputTracks.add(outputTrack);
- ALOGV("addOutputTrack() track %p, on thread %p", outputTrack.get(), thread);
- updateWaitTime_l();
+ status_t status = outputTrack != 0 ? outputTrack->initCheck() : (status_t) NO_MEMORY;
+ if (status != NO_ERROR) {
+ ALOGE("addOutputTrack() initCheck failed %d", status);
+ return;
}
+ thread->setStreamVolume(AUDIO_STREAM_PATCH, 1.0f);
+ mOutputTracks.add(outputTrack);
+ ALOGV("addOutputTrack() track %p, on thread %p", outputTrack.get(), thread);
+ updateWaitTime_l();
}
void AudioFlinger::DuplicatingThread::removeOutputTrack(MixerThread *thread)