diff options
author | Glenn Kasten <gkasten@google.com> | 2015-07-24 20:28:43 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-07-24 20:28:43 +0000 |
commit | 5ce059661dcbab8924edab400681fc408ee76123 (patch) | |
tree | 82709f0f74d4c8e89e8acdd751784a5f9103d620 /services/audioflinger | |
parent | 9f00e69c5f2702b66e9bdf8f4f75f99a338738d7 (diff) | |
parent | eb9487e10294a4e73977f460f30eeaff503acd21 (diff) | |
download | frameworks_av-5ce059661dcbab8924edab400681fc408ee76123.zip frameworks_av-5ce059661dcbab8924edab400681fc408ee76123.tar.gz frameworks_av-5ce059661dcbab8924edab400681fc408ee76123.tar.bz2 |
Merge "Fix capture overruns at non-primary sample rate" into mnc-dev
Diffstat (limited to 'services/audioflinger')
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 3 | ||||
-rw-r--r-- | services/audioflinger/AudioFlinger.h | 4 | ||||
-rw-r--r-- | services/audioflinger/Threads.cpp | 20 |
3 files changed, 7 insertions, 20 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 8f1e050..9ec5802 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -181,7 +181,6 @@ AudioFlinger::AudioFlinger() mIsLowRamDevice(true), mIsDeviceTypeKnown(false), mGlobalEffectEnableTime(0), - mPrimaryOutputSampleRate(0), mSystemReady(false) { getpid_cached = getpid(); @@ -1869,8 +1868,6 @@ status_t AudioFlinger::openOutput(audio_module_handle_t module, mHardwareStatus = AUDIO_HW_SET_MODE; mPrimaryHardwareDev->hwDevice()->set_mode(mPrimaryHardwareDev->hwDevice(), mMode); mHardwareStatus = AUDIO_HW_IDLE; - - mPrimaryOutputSampleRate = config->sample_rate; } return NO_ERROR; } diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index 4f7e27d..20c34ef 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -763,9 +763,7 @@ private: sp<PatchPanel> mPatchPanel; - uint32_t mPrimaryOutputSampleRate; // sample rate of the primary output, or zero if none - // protected by mHardwareLock - bool mSystemReady; + bool mSystemReady; }; #undef INCLUDING_FROM_AUDIOFLINGER_H diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 43dd53c..0a7d4a2 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -125,10 +125,15 @@ static const uint32_t kMinThreadSleepTimeUs = 5000; static const uint32_t kMaxThreadSleepTimeShift = 2; // minimum normal sink buffer size, expressed in milliseconds rather than frames +// FIXME This should be based on experimentally observed scheduling jitter static const uint32_t kMinNormalSinkBufferSizeMs = 20; // maximum normal sink buffer size static const uint32_t kMaxNormalSinkBufferSizeMs = 24; +// minimum capture buffer size in milliseconds to _not_ need a fast capture thread +// FIXME This should be based on experimentally observed scheduling jitter +static const uint32_t kMinNormalCaptureBufferSizeMs = 12; + // Offloaded output thread standby delay: allows track transition without going to standby static const nsecs_t kOffloadStandbyDelayNs = seconds(1); @@ -5490,20 +5495,7 @@ AudioFlinger::RecordThread::RecordThread(const sp<AudioFlinger>& audioFlinger, initFastCapture = true; break; case FastCapture_Static: - uint32_t primaryOutputSampleRate; - { - AutoMutex _l(audioFlinger->mHardwareLock); - primaryOutputSampleRate = audioFlinger->mPrimaryOutputSampleRate; - } - initFastCapture = - // either capture sample rate is same as (a reasonable) primary output sample rate - ((isMusicRate(primaryOutputSampleRate) && - (mSampleRate == primaryOutputSampleRate)) || - // or primary output sample rate is unknown, and capture sample rate is reasonable - ((primaryOutputSampleRate == 0) && - isMusicRate(mSampleRate))) && - // and the buffer size is < 12 ms - (mFrameCount * 1000) / mSampleRate < 12; + initFastCapture = (mFrameCount * 1000) / mSampleRate < kMinNormalCaptureBufferSizeMs; break; // case FastCapture_Dynamic: } |