diff options
Diffstat (limited to 'services/audioflinger')
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 94 | ||||
-rw-r--r-- | services/audioflinger/AudioFlinger.h | 108 | ||||
-rw-r--r-- | services/audioflinger/AudioPolicyService.cpp | 6 | ||||
-rw-r--r-- | services/audioflinger/AudioResampler.cpp | 24 | ||||
-rw-r--r-- | services/audioflinger/AudioResampler.h | 6 | ||||
-rw-r--r-- | services/audioflinger/AudioResamplerCubic.cpp | 4 | ||||
-rw-r--r-- | services/audioflinger/AudioResamplerSinc.cpp | 23 |
7 files changed, 122 insertions, 143 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 93c91fb..285f7a1 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -748,7 +748,7 @@ status_t AudioFlinger::setParameters(audio_io_handle_t ioHandle, const String8& { status_t result; - ALOGV("setParameters(): io %d, keyvalue %s, tid %d, calling tid %d", + ALOGV("setParameters(): io %d, keyvalue %s, tid %d, calling pid %d", ioHandle, keyValuePairs.string(), gettid(), IPCThreadState::self()->getCallingPid()); // check calling permissions if (!settingsAllowed()) { @@ -821,7 +821,7 @@ status_t AudioFlinger::setParameters(audio_io_handle_t ioHandle, const String8& String8 AudioFlinger::getParameters(audio_io_handle_t ioHandle, const String8& keys) const { -// ALOGV("getParameters() io %d, keys %s, tid %d, calling tid %d", +// ALOGV("getParameters() io %d, keys %s, tid %d, calling pid %d", // ioHandle, keys.string(), gettid(), IPCThreadState::self()->getCallingPid()); if (ioHandle == 0) { @@ -1524,12 +1524,11 @@ sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTra // all tracks in same audio session must share the same routing strategy otherwise // conflicts will happen when tracks are moved from one output to another by audio policy // manager - uint32_t strategy = - AudioSystem::getStrategyForStream((audio_stream_type_t)streamType); + uint32_t strategy = AudioSystem::getStrategyForStream(streamType); for (size_t i = 0; i < mTracks.size(); ++i) { sp<Track> t = mTracks[i]; if (t != 0) { - uint32_t actual = AudioSystem::getStrategyForStream((audio_stream_type_t)t->type()); + uint32_t actual = AudioSystem::getStrategyForStream(t->streamType()); if (sessionId == t->sessionId() && strategy != actual) { ALOGE("createTrack_l() mismatched strategy; expected %u but found %u", strategy, actual); @@ -1551,7 +1550,7 @@ sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTra if (chain != 0) { ALOGV("createTrack_l() setting main buffer %p", chain->inBuffer()); track->setMainBuffer(chain->inBuffer()); - chain->setStrategy(AudioSystem::getStrategyForStream((audio_stream_type_t)track->type())); + chain->setStrategy(AudioSystem::getStrategyForStream(track->streamType())); chain->incTrackCnt(); } @@ -1781,7 +1780,7 @@ uint32_t AudioFlinger::PlaybackThread::getStrategyForSession_l(int sessionId) sp<Track> track = mTracks[i]; if (sessionId == track->sessionId() && !(track->mCblk->flags & CBLK_INVALID_MSK)) { - return AudioSystem::getStrategyForStream((audio_stream_type_t) track->type()); + return AudioSystem::getStrategyForStream(track->streamType()); } } return AudioSystem::getStrategyForStream(AUDIO_STREAM_MUSIC); @@ -1920,7 +1919,7 @@ bool AudioFlinger::MixerThread::threadLoop() if (CC_UNLIKELY((!activeTracks.size() && systemTime() > standbyTime) || mSuspended)) { if (!mStandby) { - ALOGV("Audio hardware entering standby, mixer %p, mSuspended %d\n", this, mSuspended); + ALOGV("Audio hardware entering standby, mixer %p, mSuspended %d", this, mSuspended); mOutput->stream->common.standby(&mOutput->stream->common); mStandby = true; mBytesWritten = 0; @@ -1934,9 +1933,9 @@ bool AudioFlinger::MixerThread::threadLoop() releaseWakeLock_l(); // wait until we have something to do... - ALOGV("MixerThread %p TID %d going to sleep\n", this, gettid()); + ALOGV("MixerThread %p TID %d going to sleep", this, gettid()); mWaitWorkCV.wait(mLock); - ALOGV("MixerThread %p TID %d waking up\n", this, gettid()); + ALOGV("MixerThread %p TID %d waking up", this, gettid()); acquireWakeLock_l(); mPrevMixerStatus = MIXER_IDLE; @@ -2162,7 +2161,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac // compute volume for this track uint32_t vl, vr, va; if (track->isMuted() || track->isPausing() || - mStreamTypes[track->type()].mute) { + mStreamTypes[track->streamType()].mute) { vl = vr = va = 0; if (track->isPausing()) { track->setPaused(); @@ -2170,7 +2169,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac } else { // read original volumes with volume control - float typeVolume = mStreamTypes[track->type()].volume; + float typeVolume = mStreamTypes[track->streamType()].volume; float v = masterVolume * typeVolume; uint32_t vlr = cblk->getVolumeLR(); vl = vlr & 0xFFFF; @@ -2331,7 +2330,7 @@ void AudioFlinger::MixerThread::invalidateTracks(audio_stream_type_t streamType) size_t size = mTracks.size(); for (size_t i = 0; i < size; i++) { sp<Track> t = mTracks[i]; - if (t->type() == streamType) { + if (t->streamType() == streamType) { android_atomic_or(CBLK_INVALID_ON, &t->mCblk->flags); t->mCblk->cv.signal(); } @@ -2505,21 +2504,6 @@ AudioFlinger::DirectOutputThread::~DirectOutputThread() { } -static inline -int32_t mul(int16_t in, int16_t v) -{ -#if defined(__arm__) && !defined(__thumb__) - int32_t out; - asm( "smulbb %[out], %[in], %[v] \n" - : [out]"=r"(out) - : [in]"%r"(in), [v]"r"(v) - : ); - return out; -#else - return in * int32_t(v); -#endif -} - void AudioFlinger::DirectOutputThread::applyVolume(uint16_t leftVol, uint16_t rightVol, bool ramp) { // Do not apply volume on compressed audio @@ -2638,7 +2622,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop() mSuspended)) { // wait until we have something to do... if (!mStandby) { - ALOGV("Audio hardware entering standby, mixer %p\n", this); + ALOGV("Audio hardware entering standby, mixer %p", this); mOutput->stream->common.standby(&mOutput->stream->common); mStandby = true; mBytesWritten = 0; @@ -2651,9 +2635,9 @@ bool AudioFlinger::DirectOutputThread::threadLoop() if (exitPending()) break; releaseWakeLock_l(); - ALOGV("DirectOutputThread %p TID %d going to sleep\n", this, gettid()); + ALOGV("DirectOutputThread %p TID %d going to sleep", this, gettid()); mWaitWorkCV.wait(mLock); - ALOGV("DirectOutputThread %p TID %d waking up in active mode\n", this, gettid()); + ALOGV("DirectOutputThread %p TID %d waking up in active mode", this, gettid()); acquireWakeLock_l(); if (!mMasterMute) { @@ -2704,13 +2688,13 @@ bool AudioFlinger::DirectOutputThread::threadLoop() // compute volume for this track float left, right; if (track->isMuted() || mMasterMute || track->isPausing() || - mStreamTypes[track->type()].mute) { + mStreamTypes[track->streamType()].mute) { left = right = 0; if (track->isPausing()) { track->setPaused(); } } else { - float typeVolume = mStreamTypes[track->type()].volume; + float typeVolume = mStreamTypes[track->streamType()].volume; float v = mMasterVolume * typeVolume; uint32_t vlr = cblk->getVolumeLR(); float v_clamped = v * (vlr & 0xFFFF); @@ -3046,9 +3030,9 @@ bool AudioFlinger::DuplicatingThread::threadLoop() if (exitPending()) break; releaseWakeLock_l(); - ALOGV("DuplicatingThread %p TID %d going to sleep\n", this, gettid()); + ALOGV("DuplicatingThread %p TID %d going to sleep", this, gettid()); mWaitWorkCV.wait(mLock); - ALOGV("DuplicatingThread %p TID %d waking up\n", this, gettid()); + ALOGV("DuplicatingThread %p TID %d waking up", this, gettid()); acquireWakeLock_l(); mPrevMixerStatus = MIXER_IDLE; @@ -3391,7 +3375,7 @@ AudioFlinger::PlaybackThread::Track::Track( mName = playbackThread->getTrackName_l(); mMainBuffer = playbackThread->mixBuffer(); } - ALOGV("Track constructor name %d, calling thread %d", mName, IPCThreadState::self()->getCallingPid()); + ALOGV("Track constructor name %d, calling pid %d", mName, IPCThreadState::self()->getCallingPid()); if (mName < 0) { ALOGE("no more track names available"); } @@ -3428,9 +3412,7 @@ void AudioFlinger::PlaybackThread::Track::destroy() if (thread != 0) { if (!isOutputTrack()) { if (mState == ACTIVE || mState == RESUMING) { - AudioSystem::stopOutput(thread->id(), - (audio_stream_type_t)mStreamType, - mSessionId); + AudioSystem::stopOutput(thread->id(), mStreamType, mSessionId); // to track the speaker usage addBatteryData(IMediaPlayerService::kBatteryDataAudioFlingerStop); @@ -3523,7 +3505,7 @@ bool AudioFlinger::PlaybackThread::Track::isReady() const { status_t AudioFlinger::PlaybackThread::Track::start() { status_t status = NO_ERROR; - ALOGV("start(%d), calling thread %d session %d", + ALOGV("start(%d), calling pid %d session %d", mName, IPCThreadState::self()->getCallingPid(), mSessionId); sp<ThreadBase> thread = mThread.promote(); if (thread != 0) { @@ -3541,9 +3523,7 @@ status_t AudioFlinger::PlaybackThread::Track::start() if (!isOutputTrack() && state != ACTIVE && state != RESUMING) { thread->mLock.unlock(); - status = AudioSystem::startOutput(thread->id(), - (audio_stream_type_t)mStreamType, - mSessionId); + status = AudioSystem::startOutput(thread->id(), mStreamType, mSessionId); thread->mLock.lock(); // to track the speaker usage @@ -3565,7 +3545,7 @@ status_t AudioFlinger::PlaybackThread::Track::start() void AudioFlinger::PlaybackThread::Track::stop() { - ALOGV("stop(%d), calling thread %d", mName, IPCThreadState::self()->getCallingPid()); + ALOGV("stop(%d), calling pid %d", mName, IPCThreadState::self()->getCallingPid()); sp<ThreadBase> thread = mThread.promote(); if (thread != 0) { Mutex::Autolock _l(thread->mLock); @@ -3581,9 +3561,7 @@ void AudioFlinger::PlaybackThread::Track::stop() } if (!isOutputTrack() && (state == ACTIVE || state == RESUMING)) { thread->mLock.unlock(); - AudioSystem::stopOutput(thread->id(), - (audio_stream_type_t)mStreamType, - mSessionId); + AudioSystem::stopOutput(thread->id(), mStreamType, mSessionId); thread->mLock.lock(); // to track the speaker usage @@ -3594,7 +3572,7 @@ void AudioFlinger::PlaybackThread::Track::stop() void AudioFlinger::PlaybackThread::Track::pause() { - ALOGV("pause(%d), calling thread %d", mName, IPCThreadState::self()->getCallingPid()); + ALOGV("pause(%d), calling pid %d", mName, IPCThreadState::self()->getCallingPid()); sp<ThreadBase> thread = mThread.promote(); if (thread != 0) { Mutex::Autolock _l(thread->mLock); @@ -3603,9 +3581,7 @@ void AudioFlinger::PlaybackThread::Track::pause() ALOGV("ACTIVE/RESUMING => PAUSING (%d) on thread %p", mName, thread.get()); if (!isOutputTrack()) { thread->mLock.unlock(); - AudioSystem::stopOutput(thread->id(), - (audio_stream_type_t)mStreamType, - mSessionId); + AudioSystem::stopOutput(thread->id(), mStreamType, mSessionId); thread->mLock.lock(); // to track the speaker usage @@ -5885,13 +5861,13 @@ void AudioFlinger::ThreadBase::setMode(audio_mode_t mode) void AudioFlinger::ThreadBase::disconnectEffect(const sp<EffectModule>& effect, const wp<EffectHandle>& handle, - bool unpiniflast) { + bool unpinIfLast) { Mutex::Autolock _l(mLock); ALOGV("disconnectEffect() %p effect %p", this, effect.get()); // delete the effect module if removing last handle on it if (effect->removeHandle(handle) == 0) { - if (!effect->isPinned() || unpiniflast) { + if (!effect->isPinned() || unpinIfLast) { removeEffect_l(effect); AudioSystem::unregisterEffect(effect->id()); } @@ -6207,16 +6183,16 @@ sp<AudioFlinger::EffectHandle> AudioFlinger::EffectModule::controlHandle() return mHandles.size() != 0 ? mHandles[0].promote() : 0; } -void AudioFlinger::EffectModule::disconnect(const wp<EffectHandle>& handle, bool unpiniflast) +void AudioFlinger::EffectModule::disconnect(const wp<EffectHandle>& handle, bool unpinIfLast) { - ALOGV("disconnect() %p handle %p ", this, handle.unsafe_get()); + ALOGV("disconnect() %p handle %p", this, handle.unsafe_get()); // keep a strong reference on this EffectModule to avoid calling the // destructor before we exit sp<EffectModule> keep(this); { sp<ThreadBase> thread = mThread.promote(); if (thread != 0) { - thread->disconnectEffect(keep, handle, unpiniflast); + thread->disconnectEffect(keep, handle, unpinIfLast); } } } @@ -6888,13 +6864,13 @@ void AudioFlinger::EffectHandle::disconnect() disconnect(true); } -void AudioFlinger::EffectHandle::disconnect(bool unpiniflast) +void AudioFlinger::EffectHandle::disconnect(bool unpinIfLast) { - ALOGV("disconnect(%s)", unpiniflast ? "true" : "false"); + ALOGV("disconnect(%s)", unpinIfLast ? "true" : "false"); if (mEffect == 0) { return; } - mEffect->disconnect(this, unpiniflast); + mEffect->disconnect(this, unpinIfLast); if (mHasControl && mEnabled) { sp<ThreadBase> thread = mEffect->thread().promote(); diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index 97103c4..45df893 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -67,7 +67,7 @@ public: virtual status_t dump(int fd, const Vector<String16>& args); - // IAudioFlinger interface + // IAudioFlinger interface, in binder opcode order virtual sp<IAudioTrack> createTrack( pid_t pid, audio_stream_type_t streamType, @@ -81,6 +81,17 @@ public: int *sessionId, status_t *status); + virtual sp<IAudioRecord> openRecord( + pid_t pid, + audio_io_handle_t input, + uint32_t sampleRate, + audio_format_t format, + uint32_t channelMask, + int frameCount, + uint32_t flags, + int *sessionId, + status_t *status); + virtual uint32_t sampleRate(audio_io_handle_t output) const; virtual int channelCount(audio_io_handle_t output) const; virtual audio_format_t format(audio_io_handle_t output) const; @@ -112,7 +123,6 @@ public: virtual void registerClient(const sp<IAudioFlingerClient>& client); virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount) const; - virtual unsigned int getInputFramesLost(audio_io_handle_t ioHandle) const; virtual audio_io_handle_t openOutput(uint32_t *pDevices, uint32_t *pSamplingRate, @@ -145,6 +155,8 @@ public: virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, audio_io_handle_t output) const; + virtual unsigned int getInputFramesLost(audio_io_handle_t ioHandle) const; + virtual int newAudioSessionId(); virtual void acquireAudioSessionId(int audioSession); @@ -171,49 +183,19 @@ public: virtual status_t moveEffects(int sessionId, audio_io_handle_t srcOutput, audio_io_handle_t dstOutput); - enum hardware_call_state { - AUDIO_HW_IDLE = 0, - AUDIO_HW_INIT, - AUDIO_HW_OUTPUT_OPEN, - AUDIO_HW_OUTPUT_CLOSE, - AUDIO_HW_INPUT_OPEN, - AUDIO_HW_INPUT_CLOSE, - AUDIO_HW_STANDBY, - AUDIO_HW_SET_MASTER_VOLUME, - AUDIO_HW_GET_ROUTING, - AUDIO_HW_SET_ROUTING, - AUDIO_HW_GET_MODE, - AUDIO_HW_SET_MODE, - AUDIO_HW_GET_MIC_MUTE, - AUDIO_HW_SET_MIC_MUTE, - AUDIO_SET_VOICE_VOLUME, - AUDIO_SET_PARAMETER, - }; - - // record interface - virtual sp<IAudioRecord> openRecord( - pid_t pid, - audio_io_handle_t input, - uint32_t sampleRate, - audio_format_t format, - uint32_t channelMask, - int frameCount, - uint32_t flags, - int *sessionId, - status_t *status); - virtual status_t onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags); + // end of IAudioFlinger interface + +private: audio_mode_t getMode() const { return mMode; } bool btNrecIsOff() const { return mBtNrecIsOff; } -private: - AudioFlinger(); virtual ~AudioFlinger(); @@ -442,7 +424,7 @@ private: status_t *status); void disconnectEffect(const sp< EffectModule>& effect, const wp<EffectHandle>& handle, - bool unpiniflast); + bool unpinIfLast); // return values for hasAudioSession (bit field) enum effect_state { @@ -564,6 +546,18 @@ private: KeyedVector< int, KeyedVector< int, sp<SuspendedSessionDesc> > > mSuspendedSessions; }; + struct stream_type_t { + stream_type_t() + : volume(1.0f), + mute(false), + valid(true) + { + } + float volume; + bool mute; + bool valid; + }; + // --- PlaybackThread --- class PlaybackThread : public ThreadBase { public: @@ -600,7 +594,7 @@ private: return mName; } - audio_stream_type_t type() const { + audio_stream_type_t streamType() const { return mStreamType; } status_t attachAuxEffect(int EffectId); @@ -758,18 +752,6 @@ private: void setStreamValid(audio_stream_type_t streamType, bool valid); - struct stream_type_t { - stream_type_t() - : volume(1.0f), - mute(false), - valid(true) - { - } - float volume; - bool mute; - bool valid; - }; - protected: int16_t* mMixBuffer; int mSuspended; @@ -1120,7 +1102,7 @@ private: const wp<ThreadBase>& thread() { return mThread; } status_t addHandle(const sp<EffectHandle>& handle); - void disconnect(const wp<EffectHandle>& handle, bool unpiniflast); + void disconnect(const wp<EffectHandle>& handle, bool unpinIfLast); size_t removeHandle (const wp<EffectHandle>& handle); effect_descriptor_t& desc() { return mDescriptor; } @@ -1196,7 +1178,9 @@ mutable Mutex mLock; // mutex for process, commands and handl uint32_t *replySize, void *pReplyData); virtual void disconnect(); - virtual void disconnect(bool unpiniflast); + private: + void disconnect(bool unpinIfLast); + public: virtual sp<IMemory> getCblk() const { return mCblkMemory; } virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags); @@ -1408,11 +1392,31 @@ mutable Mutex mLock; // mutex for process, commands and handl mutable Mutex mHardwareLock; audio_hw_device_t* mPrimaryHardwareDev; Vector<audio_hw_device_t*> mAudioHwDevs; + + enum hardware_call_state { + AUDIO_HW_IDLE = 0, + AUDIO_HW_INIT, + AUDIO_HW_OUTPUT_OPEN, + AUDIO_HW_OUTPUT_CLOSE, + AUDIO_HW_INPUT_OPEN, + AUDIO_HW_INPUT_CLOSE, + AUDIO_HW_STANDBY, + AUDIO_HW_SET_MASTER_VOLUME, + AUDIO_HW_GET_ROUTING, + AUDIO_HW_SET_ROUTING, + AUDIO_HW_GET_MODE, + AUDIO_HW_SET_MODE, + AUDIO_HW_GET_MIC_MUTE, + AUDIO_HW_SET_MIC_MUTE, + AUDIO_SET_VOICE_VOLUME, + AUDIO_SET_PARAMETER, + }; + mutable hardware_call_state mHardwareStatus; // for dump only DefaultKeyedVector< audio_io_handle_t, sp<PlaybackThread> > mPlaybackThreads; - PlaybackThread::stream_type_t mStreamTypes[AUDIO_STREAM_CNT]; + stream_type_t mStreamTypes[AUDIO_STREAM_CNT]; // both are protected by mLock float mMasterVolume; diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp index 10efd85..f8b430e 100644 --- a/services/audioflinger/AudioPolicyService.cpp +++ b/services/audioflinger/AudioPolicyService.cpp @@ -542,7 +542,7 @@ status_t AudioPolicyService::queryDefaultPreProcessing(int audioSession, } void AudioPolicyService::binderDied(const wp<IBinder>& who) { - ALOGW("binderDied() %p, tid %d, calling tid %d", who.unsafe_get(), gettid(), + ALOGW("binderDied() %p, tid %d, calling pid %d", who.unsafe_get(), gettid(), IPCThreadState::self()->getCallingPid()); } @@ -588,10 +588,10 @@ status_t AudioPolicyService::dump(int fd, const Vector<String16>& args) } dumpInternals(fd); - if (mAudioCommandThread != NULL) { + if (mAudioCommandThread != 0) { mAudioCommandThread->dump(fd); } - if (mTonePlaybackThread != NULL) { + if (mTonePlaybackThread != 0) { mTonePlaybackThread->dump(fd); } diff --git a/services/audioflinger/AudioResampler.cpp b/services/audioflinger/AudioResampler.cpp index 0a52939..9486b9c 100644 --- a/services/audioflinger/AudioResampler.cpp +++ b/services/audioflinger/AudioResampler.cpp @@ -188,7 +188,7 @@ void AudioResamplerOrder1::resampleStereo16(int32_t* out, size_t outFrameCount, size_t outputSampleCount = outFrameCount * 2; size_t inFrameCount = (outFrameCount*mInSampleRate)/mSampleRate; - // ALOGE("starting resample %d frames, inputIndex=%d, phaseFraction=%d, phaseIncrement=%d\n", + // ALOGE("starting resample %d frames, inputIndex=%d, phaseFraction=%d, phaseIncrement=%d", // outFrameCount, inputIndex, phaseFraction, phaseIncrement); while (outputIndex < outputSampleCount) { @@ -201,7 +201,7 @@ void AudioResamplerOrder1::resampleStereo16(int32_t* out, size_t outFrameCount, goto resampleStereo16_exit; } - // ALOGE("New buffer fetched: %d frames\n", mBuffer.frameCount); + // ALOGE("New buffer fetched: %d frames", mBuffer.frameCount); if (mBuffer.frameCount > inputIndex) break; inputIndex -= mBuffer.frameCount; @@ -215,7 +215,7 @@ void AudioResamplerOrder1::resampleStereo16(int32_t* out, size_t outFrameCount, // handle boundary case while (inputIndex == 0) { - // ALOGE("boundary case\n"); + // ALOGE("boundary case"); out[outputIndex++] += vl * Interp(mX0L, in[0], phaseFraction); out[outputIndex++] += vr * Interp(mX0R, in[1], phaseFraction); Advance(&inputIndex, &phaseFraction, phaseIncrement); @@ -224,7 +224,7 @@ void AudioResamplerOrder1::resampleStereo16(int32_t* out, size_t outFrameCount, } // process input samples - // ALOGE("general case\n"); + // ALOGE("general case"); #ifdef ASM_ARM_RESAMP1 // asm optimisation for ResamplerOrder1 if (inputIndex + 2 < mBuffer.frameCount) { @@ -246,7 +246,7 @@ void AudioResamplerOrder1::resampleStereo16(int32_t* out, size_t outFrameCount, Advance(&inputIndex, &phaseFraction, phaseIncrement); } - // ALOGE("loop done - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex); + // ALOGE("loop done - outputIndex=%d, inputIndex=%d", outputIndex, inputIndex); // if done with buffer, save samples if (inputIndex >= mBuffer.frameCount) { @@ -263,7 +263,7 @@ void AudioResamplerOrder1::resampleStereo16(int32_t* out, size_t outFrameCount, } } - // ALOGE("output buffer full - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex); + // ALOGE("output buffer full - outputIndex=%d, inputIndex=%d", outputIndex, inputIndex); resampleStereo16_exit: // save state @@ -284,7 +284,7 @@ void AudioResamplerOrder1::resampleMono16(int32_t* out, size_t outFrameCount, size_t outputSampleCount = outFrameCount * 2; size_t inFrameCount = (outFrameCount*mInSampleRate)/mSampleRate; - // ALOGE("starting resample %d frames, inputIndex=%d, phaseFraction=%d, phaseIncrement=%d\n", + // ALOGE("starting resample %d frames, inputIndex=%d, phaseFraction=%d, phaseIncrement=%d", // outFrameCount, inputIndex, phaseFraction, phaseIncrement); while (outputIndex < outputSampleCount) { // buffer is empty, fetch a new one @@ -296,7 +296,7 @@ void AudioResamplerOrder1::resampleMono16(int32_t* out, size_t outFrameCount, mPhaseFraction = phaseFraction; goto resampleMono16_exit; } - // ALOGE("New buffer fetched: %d frames\n", mBuffer.frameCount); + // ALOGE("New buffer fetched: %d frames", mBuffer.frameCount); if (mBuffer.frameCount > inputIndex) break; inputIndex -= mBuffer.frameCount; @@ -308,7 +308,7 @@ void AudioResamplerOrder1::resampleMono16(int32_t* out, size_t outFrameCount, // handle boundary case while (inputIndex == 0) { - // ALOGE("boundary case\n"); + // ALOGE("boundary case"); int32_t sample = Interp(mX0L, in[0], phaseFraction); out[outputIndex++] += vl * sample; out[outputIndex++] += vr * sample; @@ -318,7 +318,7 @@ void AudioResamplerOrder1::resampleMono16(int32_t* out, size_t outFrameCount, } // process input samples - // ALOGE("general case\n"); + // ALOGE("general case"); #ifdef ASM_ARM_RESAMP1 // asm optimisation for ResamplerOrder1 if (inputIndex + 2 < mBuffer.frameCount) { @@ -341,7 +341,7 @@ void AudioResamplerOrder1::resampleMono16(int32_t* out, size_t outFrameCount, } - // ALOGE("loop done - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex); + // ALOGE("loop done - outputIndex=%d, inputIndex=%d", outputIndex, inputIndex); // if done with buffer, save samples if (inputIndex >= mBuffer.frameCount) { @@ -357,7 +357,7 @@ void AudioResamplerOrder1::resampleMono16(int32_t* out, size_t outFrameCount, } } - // ALOGE("output buffer full - outputIndex=%d, inputIndex=%d\n", outputIndex, inputIndex); + // ALOGE("output buffer full - outputIndex=%d, inputIndex=%d", outputIndex, inputIndex); resampleMono16_exit: // save state diff --git a/services/audioflinger/AudioResampler.h b/services/audioflinger/AudioResampler.h index ee171ff..c23016e 100644 --- a/services/audioflinger/AudioResampler.h +++ b/services/audioflinger/AudioResampler.h @@ -72,9 +72,9 @@ protected: AudioResampler(const AudioResampler&); AudioResampler& operator=(const AudioResampler&); - int32_t mBitDepth; - int32_t mChannelCount; - int32_t mSampleRate; + const int32_t mBitDepth; + const int32_t mChannelCount; + const int32_t mSampleRate; int32_t mInSampleRate; AudioBufferProvider::Buffer mBuffer; union { diff --git a/services/audioflinger/AudioResamplerCubic.cpp b/services/audioflinger/AudioResamplerCubic.cpp index 47205ba..c0e760e 100644 --- a/services/audioflinger/AudioResamplerCubic.cpp +++ b/services/audioflinger/AudioResamplerCubic.cpp @@ -99,7 +99,7 @@ void AudioResamplerCubic::resampleStereo16(int32_t* out, size_t outFrameCount, if (mBuffer.raw == NULL) goto save_state; // ugly, but efficient in = mBuffer.i16; - // ALOGW("New buffer: offset=%p, frames=%d\n", mBuffer.raw, mBuffer.frameCount); + // ALOGW("New buffer: offset=%p, frames=%d", mBuffer.raw, mBuffer.frameCount); } // advance sample state @@ -133,7 +133,7 @@ void AudioResamplerCubic::resampleMono16(int32_t* out, size_t outFrameCount, provider->getNextBuffer(&mBuffer); if (mBuffer.raw == NULL) return; - // ALOGW("New buffer: offset=%p, frames=%d\n", mBuffer.raw, mBuffer.frameCount); + // ALOGW("New buffer: offset=%p, frames=%d", mBuffer.raw, mBuffer.frameCount); } int16_t *in = mBuffer.i16; diff --git a/services/audioflinger/AudioResamplerSinc.cpp b/services/audioflinger/AudioResamplerSinc.cpp index d012433..7a27b81 100644 --- a/services/audioflinger/AudioResamplerSinc.cpp +++ b/services/audioflinger/AudioResamplerSinc.cpp @@ -199,33 +199,32 @@ void AudioResamplerSinc::resample(int32_t* out, size_t outFrameCount, size_t outputSampleCount = outFrameCount * 2; size_t inFrameCount = (outFrameCount*mInSampleRate)/mSampleRate; - AudioBufferProvider::Buffer& buffer(mBuffer); while (outputIndex < outputSampleCount) { // buffer is empty, fetch a new one - while (buffer.frameCount == 0) { - buffer.frameCount = inFrameCount; - provider->getNextBuffer(&buffer); - if (buffer.raw == NULL) { + while (mBuffer.frameCount == 0) { + mBuffer.frameCount = inFrameCount; + provider->getNextBuffer(&mBuffer); + if (mBuffer.raw == NULL) { goto resample_exit; } const uint32_t phaseIndex = phaseFraction >> kNumPhaseBits; if (phaseIndex == 1) { // read one frame - read<CHANNELS>(impulse, phaseFraction, buffer.i16, inputIndex); + read<CHANNELS>(impulse, phaseFraction, mBuffer.i16, inputIndex); } else if (phaseIndex == 2) { // read 2 frames - read<CHANNELS>(impulse, phaseFraction, buffer.i16, inputIndex); + read<CHANNELS>(impulse, phaseFraction, mBuffer.i16, inputIndex); inputIndex++; if (inputIndex >= mBuffer.frameCount) { inputIndex -= mBuffer.frameCount; - provider->releaseBuffer(&buffer); + provider->releaseBuffer(&mBuffer); } else { - read<CHANNELS>(impulse, phaseFraction, buffer.i16, inputIndex); + read<CHANNELS>(impulse, phaseFraction, mBuffer.i16, inputIndex); } } } - int16_t *in = buffer.i16; - const size_t frameCount = buffer.frameCount; + int16_t *in = mBuffer.i16; + const size_t frameCount = mBuffer.frameCount; // Always read-in the first samples from the input buffer int16_t* head = impulse + halfNumCoefs*CHANNELS; @@ -264,7 +263,7 @@ void AudioResamplerSinc::resample(int32_t* out, size_t outFrameCount, // if done with buffer, save samples if (inputIndex >= frameCount) { inputIndex -= frameCount; - provider->releaseBuffer(&buffer); + provider->releaseBuffer(&mBuffer); } } |