Loading media/libmedia/AudioRecord.cpp +24 −18 Original line number Diff line number Diff line Loading @@ -203,23 +203,6 @@ status_t AudioRecord::set( mFrameSize = sizeof(uint8_t); } // validate framecount size_t minFrameCount; status_t status = AudioRecord::getMinFrameCount(&minFrameCount, sampleRate, format, channelMask); if (status != NO_ERROR) { ALOGE("getMinFrameCount() failed for sampleRate %u, format %#x, channelMask %#x; status %d", sampleRate, format, channelMask, status); return status; } ALOGV("AudioRecord::set() minFrameCount = %d", minFrameCount); if (frameCount == 0) { frameCount = minFrameCount; } else if (frameCount < minFrameCount) { ALOGE("frameCount %u < minFrameCount %u", frameCount, minFrameCount); return BAD_VALUE; } // mFrameCount is initialized in openRecord_l mReqFrameCount = frameCount; Loading @@ -242,7 +225,7 @@ status_t AudioRecord::set( } // create the IAudioRecord status = openRecord_l(0 /*epoch*/); status_t status = openRecord_l(0 /*epoch*/); if (status != NO_ERROR) { if (mAudioRecordThread != 0) { Loading Loading @@ -464,6 +447,29 @@ status_t AudioRecord::openRecord_l(size_t epoch) size_t frameCount = mReqFrameCount; if (!(mFlags & AUDIO_INPUT_FLAG_FAST)) { // validate framecount // If fast track was not requested, this preserves // the old behavior of validating on client side. // FIXME Eventually the validation should be done on server side // regardless of whether it's a fast or normal track. It's debatable // whether to account for the input latency to provision buffers appropriately. size_t minFrameCount; status = AudioRecord::getMinFrameCount(&minFrameCount, mSampleRate, mFormat, mChannelMask); if (status != NO_ERROR) { ALOGE("getMinFrameCount() failed for sampleRate %u, format %#x, channelMask %#x; " "status %d", mSampleRate, mFormat, mChannelMask, status); return status; } if (frameCount == 0) { frameCount = minFrameCount; } else if (frameCount < minFrameCount) { ALOGE("frameCount %u < minFrameCount %u", frameCount, minFrameCount); return BAD_VALUE; } // Make sure that application is notified with sufficient margin before overrun if (mNotificationFramesAct == 0 || mNotificationFramesAct > frameCount/2) { mNotificationFramesAct = frameCount/2; Loading media/libmedia/AudioTrackShared.cpp +11 −4 Original line number Diff line number Diff line Loading @@ -134,11 +134,18 @@ status_t ClientProxy::obtainBuffer(Buffer* buffer, const struct timespec *reques ssize_t filled = rear - front; // pipe should not be overfull if (!(0 <= filled && (size_t) filled <= mFrameCount)) { ALOGE("Shared memory control block is corrupt (filled=%d); shutting down", filled); if (mIsOut) { ALOGE("Shared memory control block is corrupt (filled=%d, mFrameCount=%u); " "shutting down", filled, mFrameCount); mIsShutdown = true; status = NO_INIT; goto end; } // for input, sync up on overrun filled = 0; cblk->u.mStreaming.mFront = rear; (void) android_atomic_or(CBLK_OVERRUN, &cblk->mFlags); } // don't allow filling pipe beyond the nominal size size_t avail = mIsOut ? mFrameCount - filled : filled; if (avail > 0) { Loading services/audioflinger/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ LOCAL_32_BIT_ONLY := true LOCAL_SRC_FILES += FastMixer.cpp FastMixerState.cpp AudioWatchdog.cpp LOCAL_SRC_FILES += FastThread.cpp FastThreadState.cpp LOCAL_SRC_FILES += FastCapture.cpp FastCaptureState.cpp LOCAL_CFLAGS += -DSTATE_QUEUE_INSTANTIATIONS='"StateQueueInstantiations.cpp"' Loading services/audioflinger/AudioFlinger.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -169,7 +169,8 @@ AudioFlinger::AudioFlinger() mBtNrecIsOff(false), mIsLowRamDevice(true), mIsDeviceTypeKnown(false), mGlobalEffectEnableTime(0) mGlobalEffectEnableTime(0), mPrimaryOutputSampleRate(0) { getpid_cached = getpid(); char value[PROPERTY_VALUE_MAX]; Loading Loading @@ -1679,6 +1680,8 @@ audio_io_handle_t AudioFlinger::openOutput(audio_module_handle_t module, mHardwareStatus = AUDIO_HW_SET_MODE; hwDevHal->set_mode(hwDevHal, mMode); mHardwareStatus = AUDIO_HW_IDLE; mPrimaryOutputSampleRate = config.sample_rate; } return id; } Loading services/audioflinger/AudioFlinger.h +5 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ #include <media/AudioBufferProvider.h> #include <media/ExtendedAudioBufferProvider.h> #include "FastCapture.h" #include "FastMixer.h" #include <media/nbaio/NBAIO.h> #include "AudioWatchdog.h" Loading Loading @@ -691,6 +693,9 @@ private: nsecs_t mGlobalEffectEnableTime; // when a global effect was last enabled sp<PatchPanel> mPatchPanel; uint32_t mPrimaryOutputSampleRate; // sample rate of the primary output, or zero if none // protected by mHardwareLock }; #undef INCLUDING_FROM_AUDIOFLINGER_H Loading Loading
media/libmedia/AudioRecord.cpp +24 −18 Original line number Diff line number Diff line Loading @@ -203,23 +203,6 @@ status_t AudioRecord::set( mFrameSize = sizeof(uint8_t); } // validate framecount size_t minFrameCount; status_t status = AudioRecord::getMinFrameCount(&minFrameCount, sampleRate, format, channelMask); if (status != NO_ERROR) { ALOGE("getMinFrameCount() failed for sampleRate %u, format %#x, channelMask %#x; status %d", sampleRate, format, channelMask, status); return status; } ALOGV("AudioRecord::set() minFrameCount = %d", minFrameCount); if (frameCount == 0) { frameCount = minFrameCount; } else if (frameCount < minFrameCount) { ALOGE("frameCount %u < minFrameCount %u", frameCount, minFrameCount); return BAD_VALUE; } // mFrameCount is initialized in openRecord_l mReqFrameCount = frameCount; Loading @@ -242,7 +225,7 @@ status_t AudioRecord::set( } // create the IAudioRecord status = openRecord_l(0 /*epoch*/); status_t status = openRecord_l(0 /*epoch*/); if (status != NO_ERROR) { if (mAudioRecordThread != 0) { Loading Loading @@ -464,6 +447,29 @@ status_t AudioRecord::openRecord_l(size_t epoch) size_t frameCount = mReqFrameCount; if (!(mFlags & AUDIO_INPUT_FLAG_FAST)) { // validate framecount // If fast track was not requested, this preserves // the old behavior of validating on client side. // FIXME Eventually the validation should be done on server side // regardless of whether it's a fast or normal track. It's debatable // whether to account for the input latency to provision buffers appropriately. size_t minFrameCount; status = AudioRecord::getMinFrameCount(&minFrameCount, mSampleRate, mFormat, mChannelMask); if (status != NO_ERROR) { ALOGE("getMinFrameCount() failed for sampleRate %u, format %#x, channelMask %#x; " "status %d", mSampleRate, mFormat, mChannelMask, status); return status; } if (frameCount == 0) { frameCount = minFrameCount; } else if (frameCount < minFrameCount) { ALOGE("frameCount %u < minFrameCount %u", frameCount, minFrameCount); return BAD_VALUE; } // Make sure that application is notified with sufficient margin before overrun if (mNotificationFramesAct == 0 || mNotificationFramesAct > frameCount/2) { mNotificationFramesAct = frameCount/2; Loading
media/libmedia/AudioTrackShared.cpp +11 −4 Original line number Diff line number Diff line Loading @@ -134,11 +134,18 @@ status_t ClientProxy::obtainBuffer(Buffer* buffer, const struct timespec *reques ssize_t filled = rear - front; // pipe should not be overfull if (!(0 <= filled && (size_t) filled <= mFrameCount)) { ALOGE("Shared memory control block is corrupt (filled=%d); shutting down", filled); if (mIsOut) { ALOGE("Shared memory control block is corrupt (filled=%d, mFrameCount=%u); " "shutting down", filled, mFrameCount); mIsShutdown = true; status = NO_INIT; goto end; } // for input, sync up on overrun filled = 0; cblk->u.mStreaming.mFront = rear; (void) android_atomic_or(CBLK_OVERRUN, &cblk->mFlags); } // don't allow filling pipe beyond the nominal size size_t avail = mIsOut ? mFrameCount - filled : filled; if (avail > 0) { Loading
services/audioflinger/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ LOCAL_32_BIT_ONLY := true LOCAL_SRC_FILES += FastMixer.cpp FastMixerState.cpp AudioWatchdog.cpp LOCAL_SRC_FILES += FastThread.cpp FastThreadState.cpp LOCAL_SRC_FILES += FastCapture.cpp FastCaptureState.cpp LOCAL_CFLAGS += -DSTATE_QUEUE_INSTANTIATIONS='"StateQueueInstantiations.cpp"' Loading
services/audioflinger/AudioFlinger.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -169,7 +169,8 @@ AudioFlinger::AudioFlinger() mBtNrecIsOff(false), mIsLowRamDevice(true), mIsDeviceTypeKnown(false), mGlobalEffectEnableTime(0) mGlobalEffectEnableTime(0), mPrimaryOutputSampleRate(0) { getpid_cached = getpid(); char value[PROPERTY_VALUE_MAX]; Loading Loading @@ -1679,6 +1680,8 @@ audio_io_handle_t AudioFlinger::openOutput(audio_module_handle_t module, mHardwareStatus = AUDIO_HW_SET_MODE; hwDevHal->set_mode(hwDevHal, mMode); mHardwareStatus = AUDIO_HW_IDLE; mPrimaryOutputSampleRate = config.sample_rate; } return id; } Loading
services/audioflinger/AudioFlinger.h +5 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ #include <media/AudioBufferProvider.h> #include <media/ExtendedAudioBufferProvider.h> #include "FastCapture.h" #include "FastMixer.h" #include <media/nbaio/NBAIO.h> #include "AudioWatchdog.h" Loading Loading @@ -691,6 +693,9 @@ private: nsecs_t mGlobalEffectEnableTime; // when a global effect was last enabled sp<PatchPanel> mPatchPanel; uint32_t mPrimaryOutputSampleRate; // sample rate of the primary output, or zero if none // protected by mHardwareLock }; #undef INCLUDING_FROM_AUDIOFLINGER_H Loading