diff options
author | Glenn Kasten <gkasten@google.com> | 2013-02-26 09:20:22 -0800 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2013-02-26 11:36:38 -0800 |
commit | dd0bda0c47871d4964b5035a096c7c8c27fa7469 (patch) | |
tree | fc9f45ab9ef280f0d84a32a6d5b116b0cd40be69 /services | |
parent | 48af7e8dd40883d6154e7029d9500072b551b5fa (diff) | |
download | frameworks_av-dd0bda0c47871d4964b5035a096c7c8c27fa7469.zip frameworks_av-dd0bda0c47871d4964b5035a096c7c8c27fa7469.tar.gz frameworks_av-dd0bda0c47871d4964b5035a096c7c8c27fa7469.tar.bz2 |
Remove tee sink debugging at compile time
Bug: 8223560
Change-Id: Iddbfb06c45d43d9f20bb428215dd4094931e19a7
Diffstat (limited to 'services')
-rw-r--r-- | services/audioflinger/Android.mk | 3 | ||||
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 17 | ||||
-rw-r--r-- | services/audioflinger/AudioFlinger.h | 6 | ||||
-rw-r--r-- | services/audioflinger/Threads.cpp | 24 | ||||
-rw-r--r-- | services/audioflinger/Threads.h | 9 | ||||
-rw-r--r-- | services/audioflinger/Tracks.cpp | 34 |
6 files changed, 70 insertions, 23 deletions
diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk index 0855db6..7daef99 100644 --- a/services/audioflinger/Android.mk +++ b/services/audioflinger/Android.mk @@ -66,6 +66,9 @@ LOCAL_CFLAGS += -DSTATE_QUEUE_INSTANTIATIONS='"StateQueueInstantiations.cpp"' LOCAL_CFLAGS += -UFAST_TRACKS_AT_NON_NATIVE_SAMPLE_RATE +# uncomment to allow tee sink debugging to be enabled by property +# LOCAL_CFLAGS += -DTEE_SINK + # uncomment to enable the audio watchdog # LOCAL_SRC_FILES += AudioWatchdog.cpp # LOCAL_CFLAGS += -DAUDIO_WATCHDOG diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index e0ab8cd..e81267f 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -90,6 +90,7 @@ nsecs_t AudioFlinger::mStandbyTimeInNsecs = kDefaultStandbyTimeInNsecs; uint32_t AudioFlinger::mScreenState; +#ifdef TEE_SINK bool AudioFlinger::mTeeSinkInputEnabled = false; bool AudioFlinger::mTeeSinkOutputEnabled = false; bool AudioFlinger::mTeeSinkTrackEnabled = false; @@ -97,6 +98,7 @@ bool AudioFlinger::mTeeSinkTrackEnabled = false; size_t AudioFlinger::mTeeSinkInputFrames = kTeeSinkInputFramesDefault; size_t AudioFlinger::mTeeSinkOutputFrames = kTeeSinkOutputFramesDefault; size_t AudioFlinger::mTeeSinkTrackFrames = kTeeSinkTrackFramesDefault; +#endif // ---------------------------------------------------------------------------- @@ -146,6 +148,7 @@ AudioFlinger::AudioFlinger() if (doLog) { mLogMemoryDealer = new MemoryDealer(kLogMemorySize, "LogWriters"); } +#ifdef TEE_SINK (void) property_get("ro.debuggable", value, "0"); int debuggable = atoi(value); int teeEnabled = 0; @@ -159,6 +162,7 @@ AudioFlinger::AudioFlinger() mTeeSinkOutputEnabled = true; if (teeEnabled & 4) mTeeSinkTrackEnabled = true; +#endif } void AudioFlinger::onFirstRef() @@ -347,10 +351,12 @@ status_t AudioFlinger::dump(int fd, const Vector<String16>& args) dev->dump(dev, fd); } +#ifdef TEE_SINK // dump the serially shared record tee sink if (mRecordTeeSource != 0) { dumpTee(fd, mRecordTeeSource); } +#endif if (locked) { mLock.unlock(); @@ -1624,6 +1630,7 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module, if (status == NO_ERROR && inStream != NULL) { +#ifdef TEE_SINK // Try to re-use most recently used Pipe to archive a copy of input for dumpsys, // or (re-)create if current Pipe is idle and does not match the new format sp<NBAIO_Sink> teeSink; @@ -1670,6 +1677,7 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module, default: break; } +#endif AudioStreamIn *input = new AudioStreamIn(inHwDev, inStream); @@ -1682,8 +1690,11 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module, reqChannels, id, primaryOutputDevice_l(), - *pDevices, - teeSink); + *pDevices +#ifdef TEE_SINK + , teeSink +#endif + ); mRecordThreads.add(id, thread); ALOGV("openInput() created record thread: ID %d thread %p", id, thread); if (pSamplingRate != NULL) *pSamplingRate = reqSamplingRate; @@ -2235,6 +2246,7 @@ int comparEntry(const void *p1, const void *p2) return strcmp(((const Entry *) p1)->mName, ((const Entry *) p2)->mName); } +#ifdef TEE_SINK void AudioFlinger::dumpTee(int fd, const sp<NBAIO_Source>& source, audio_io_handle_t id) { NBAIO_Source *teeSource = source.get(); @@ -2350,6 +2362,7 @@ void AudioFlinger::dumpTee(int fd, const sp<NBAIO_Source>& source, audio_io_hand } } } +#endif // ---------------------------------------------------------------------------- diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index 44bd260..d0ef922 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -588,11 +588,15 @@ private: status_t closeOutput_nonvirtual(audio_io_handle_t output); status_t closeInput_nonvirtual(audio_io_handle_t input); +#ifdef TEE_SINK // all record threads serially share a common tee sink, which is re-created on format change sp<NBAIO_Sink> mRecordTeeSink; sp<NBAIO_Source> mRecordTeeSource; +#endif public: + +#ifdef TEE_SINK // tee sink, if enabled by property, allows dumpsys to write most recent audio to .wav file static void dumpTee(int fd, const sp<NBAIO_Source>& source, audio_io_handle_t id = 0); @@ -611,6 +615,8 @@ public: static const size_t kTeeSinkInputFramesDefault = 0x200000; static const size_t kTeeSinkOutputFramesDefault = 0x200000; static const size_t kTeeSinkTrackFramesDefault = 0x1000; +#endif + }; #undef INCLUDING_FROM_AUDIOFLINGER_H diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 1209ea6..267241f 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -2124,6 +2124,7 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud (monoPipe->maxFrames() * 7) / 8 : mNormalFrameCount * 2); mPipeSink = monoPipe; +#ifdef TEE_SINK if (mTeeSinkOutputEnabled) { // create a Pipe to archive a copy of FastMixer's output for dumpsys Pipe *teeSink = new Pipe(mTeeSinkOutputFrames, format); @@ -2137,6 +2138,7 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud ALOG_ASSERT(index == 0); mTeeSource = teeSource; } +#endif // create fast mixer and configure it initially with just one fast track for our submix mFastMixer = new FastMixer(); @@ -2163,7 +2165,9 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud state->mColdFutexAddr = &mFastMixerFutex; state->mColdGen++; state->mDumpState = &mFastMixerDumpState; +#ifdef TEE_SINK state->mTeeSink = mTeeSink.get(); +#endif mFastMixerNBLogWriter = audioFlinger->newWriter_l(kFastMixerLogSize, "FastMixer"); state->mNBLogWriter = mFastMixerNBLogWriter.get(); sq->end(); @@ -3076,8 +3080,10 @@ void AudioFlinger::MixerThread::dumpInternals(int fd, const Vector<String16>& ar mutatorCopy.dump(fd); #endif +#ifdef TEE_SINK // Write the tee output to a .wav file dumpTee(fd, mTeeSource, mId); +#endif #ifdef AUDIO_WATCHDOG if (mAudioWatchdog != 0) { @@ -3574,16 +3580,21 @@ AudioFlinger::RecordThread::RecordThread(const sp<AudioFlinger>& audioFlinger, audio_channel_mask_t channelMask, audio_io_handle_t id, audio_devices_t outDevice, - audio_devices_t inDevice, - const sp<NBAIO_Sink>& teeSink) : + audio_devices_t inDevice +#ifdef TEE_SINK + , const sp<NBAIO_Sink>& teeSink +#endif + ) : ThreadBase(audioFlinger, id, outDevice, inDevice, RECORD), mInput(input), mResampler(NULL), mRsmpOutBuffer(NULL), mRsmpInBuffer(NULL), // mRsmpInIndex and mInputBytes set by readInputParameters() mReqChannelCount(popcount(channelMask)), - mReqSampleRate(sampleRate), + mReqSampleRate(sampleRate) // mBytesRead is only meaningful while active, and so is cleared in start() // (but might be better to also clear here for dump?) - mTeeSink(teeSink) +#ifdef TEE_SINK + , mTeeSink(teeSink) +#endif { snprintf(mName, kNameLength, "AudioIn_%X", id); @@ -3740,10 +3751,13 @@ bool AudioFlinger::RecordThread::threadLoop() mRsmpInIndex = mFrameCount; framesOut = 0; buffer.frameCount = 0; - } else if (mTeeSink != 0) { + } +#ifdef TEE_SINK + else if (mTeeSink != 0) { (void) mTeeSink->write(readInto, mBytesRead >> Format_frameBitShift(mTeeSink->format())); } +#endif } } } else { diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h index fa1e336..caac882 100644 --- a/services/audioflinger/Threads.h +++ b/services/audioflinger/Threads.h @@ -542,9 +542,11 @@ private: sp<NBAIO_Sink> mPipeSink; // The current sink for the normal mixer to write it's (sub)mix, mOutputSink or mPipeSink sp<NBAIO_Sink> mNormalSink; +#ifdef TEE_SINK // For dumpsys sp<NBAIO_Sink> mTeeSink; sp<NBAIO_Source> mTeeSource; +#endif uint32_t mScreenState; // cached copy of gScreenState static const size_t kFastMixerLogSize = 8 * 1024; sp<NBLog::Writer> mFastMixerNBLogWriter; @@ -703,8 +705,11 @@ public: audio_channel_mask_t channelMask, audio_io_handle_t id, audio_devices_t outDevice, - audio_devices_t inDevice, - const sp<NBAIO_Sink>& teeSink); + audio_devices_t inDevice +#ifdef TEE_SINK + , const sp<NBAIO_Sink>& teeSink +#endif + ); virtual ~RecordThread(); // no addTrack_l ? diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp index 724ce38..dad9114 100644 --- a/services/audioflinger/Tracks.cpp +++ b/services/audioflinger/Tracks.cpp @@ -141,29 +141,33 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase( mBufferEnd = (uint8_t *)mBuffer + bufferSize; mServerProxy = new ServerProxy(mCblk, mBuffer, frameCount, mFrameSize, isOut); +#ifdef TEE_SINK if (mTeeSinkTrackEnabled) { - NBAIO_Format pipeFormat = Format_from_SR_C(mSampleRate, mChannelCount); - if (pipeFormat != Format_Invalid) { - Pipe *pipe = new Pipe(mTeeSinkTrackFrames, pipeFormat); - size_t numCounterOffers = 0; - const NBAIO_Format offers[1] = {pipeFormat}; - ssize_t index = pipe->negotiate(offers, 1, NULL, numCounterOffers); - ALOG_ASSERT(index == 0); - PipeReader *pipeReader = new PipeReader(*pipe); - numCounterOffers = 0; - index = pipeReader->negotiate(offers, 1, NULL, numCounterOffers); - ALOG_ASSERT(index == 0); - mTeeSink = pipe; - mTeeSource = pipeReader; - } + NBAIO_Format pipeFormat = Format_from_SR_C(mSampleRate, mChannelCount); + if (pipeFormat != Format_Invalid) { + Pipe *pipe = new Pipe(mTeeSinkTrackFrames, pipeFormat); + size_t numCounterOffers = 0; + const NBAIO_Format offers[1] = {pipeFormat}; + ssize_t index = pipe->negotiate(offers, 1, NULL, numCounterOffers); + ALOG_ASSERT(index == 0); + PipeReader *pipeReader = new PipeReader(*pipe); + numCounterOffers = 0; + index = pipeReader->negotiate(offers, 1, NULL, numCounterOffers); + ALOG_ASSERT(index == 0); + mTeeSink = pipe; + mTeeSource = pipeReader; + } } +#endif } } AudioFlinger::ThreadBase::TrackBase::~TrackBase() { +#ifdef TEE_SINK dumpTee(-1, mTeeSource, mId); +#endif // delete the proxy before deleting the shared memory it refers to, to avoid dangling reference delete mServerProxy; if (mCblk != NULL) { @@ -189,9 +193,11 @@ AudioFlinger::ThreadBase::TrackBase::~TrackBase() // This implementation of releaseBuffer() is used by Track and RecordTrack, but not TimedTrack void AudioFlinger::ThreadBase::TrackBase::releaseBuffer(AudioBufferProvider::Buffer* buffer) { +#ifdef TEE_SINK if (mTeeSink != 0) { (void) mTeeSink->write(buffer->raw, buffer->frameCount); } +#endif buffer->raw = NULL; mStepCount = buffer->frameCount; |