diff options
-rw-r--r-- | include/media/AudioResamplerPublic.h | 10 | ||||
-rw-r--r-- | services/audioflinger/AudioMixer.cpp | 7 | ||||
-rw-r--r-- | services/audioflinger/Threads.cpp | 7 | ||||
-rwxr-xr-x | services/audiopolicy/common/include/policy.h | 2 | ||||
-rw-r--r-- | services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp | 4 |
5 files changed, 23 insertions, 7 deletions
diff --git a/include/media/AudioResamplerPublic.h b/include/media/AudioResamplerPublic.h index 53b8c13..6cf2ca9 100644 --- a/include/media/AudioResamplerPublic.h +++ b/include/media/AudioResamplerPublic.h @@ -143,6 +143,16 @@ static inline size_t sourceFramesNeededWithTimestretch( return required * (double)speed + 1 + 1; // accounting for rounding dependencies } +// Identifies sample rates that we associate with music +// and thus eligible for better resampling and fast capture. +// This is somewhat less than 44100 to allow for pitch correction +// involving resampling as well as asynchronous resampling. +#define AUDIO_PROCESSING_MUSIC_RATE 40000 + +static inline bool isMusicRate(uint32_t sampleRate) { + return sampleRate >= AUDIO_PROCESSING_MUSIC_RATE; +} + } // namespace android // --------------------------------------------------------------------------- diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index 959c140..586c737 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -708,11 +708,10 @@ bool AudioMixer::track_t::setResampler(uint32_t trackSampleRate, uint32_t devSam // FIXME this is flawed for dynamic sample rates, as we choose the resampler // quality level based on the initial ratio, but that could change later. // Should have a way to distinguish tracks with static ratios vs. dynamic ratios. - if (!((trackSampleRate == 44100 && devSampleRate == 48000) || - (trackSampleRate == 48000 && devSampleRate == 44100))) { - quality = AudioResampler::DYN_LOW_QUALITY; - } else { + if (isMusicRate(trackSampleRate)) { quality = AudioResampler::DEFAULT_QUALITY; + } else { + quality = AudioResampler::DYN_LOW_QUALITY; } // TODO: Remove MONO_HACK. Resampler sees #channels after the downmixer diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 2722d32..594ed05 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -5345,11 +5345,11 @@ AudioFlinger::RecordThread::RecordThread(const sp<AudioFlinger>& audioFlinger, } initFastCapture = // either capture sample rate is same as (a reasonable) primary output sample rate - (((primaryOutputSampleRate == 44100 || primaryOutputSampleRate == 48000) && + ((isMusicRate(primaryOutputSampleRate) && (mSampleRate == primaryOutputSampleRate)) || // or primary output sample rate is unknown, and capture sample rate is reasonable ((primaryOutputSampleRate == 0) && - ((mSampleRate == 44100 || mSampleRate == 48000)))) && + isMusicRate(mSampleRate))) && // and the buffer size is < 12 ms (mFrameCount * 1000) / mSampleRate < 12; break; @@ -6452,6 +6452,9 @@ status_t AudioFlinger::RecordThread::RecordBufferConverter::updateParameters( return NO_ERROR; } + ALOGV("RecordBufferConverter updateParameters srcMask:%#x dstMask:%#x" + " srcFormat:%#x dstFormat:%#x srcRate:%u dstRate:%u", + srcChannelMask, dstChannelMask, srcFormat, dstFormat, srcSampleRate, dstSampleRate); const bool valid = audio_is_input_channel(srcChannelMask) && audio_is_input_channel(dstChannelMask) diff --git a/services/audiopolicy/common/include/policy.h b/services/audiopolicy/common/include/policy.h index e6a767f..4eef02f 100755 --- a/services/audiopolicy/common/include/policy.h +++ b/services/audiopolicy/common/include/policy.h @@ -20,7 +20,7 @@ // For mixed output and inputs, the policy will use max mixer sampling rates. // Do not limit sampling rate otherwise -#define MAX_MIXER_SAMPLING_RATE 48000 +#define MAX_MIXER_SAMPLING_RATE 192000 // For mixed output and inputs, the policy will use max mixer channel count. // Do not limit channel count otherwise diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp index 2e4d423..afcd073 100644 --- a/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp +++ b/services/audiopolicy/common/managerdefinitions/src/AudioPort.cpp @@ -611,9 +611,13 @@ uint32_t AudioPort::pickSamplingRate() const // For mixed output and inputs, use max mixer sampling rates. Do not // limit sampling rate otherwise + // For inputs, also see checkCompatibleSamplingRate(). if (mType != AUDIO_PORT_TYPE_MIX) { maxRate = UINT_MAX; } + // TODO: should mSamplingRates[] be ordered in terms of our preference + // and we return the first (and hence most preferred) match? This is of concern if + // we want to choose 96kHz over 192kHz for USB driver stability or resource constraints. for (size_t i = 0; i < mSamplingRates.size(); i ++) { if ((mSamplingRates[i] > samplingRate) && (mSamplingRates[i] <= maxRate)) { samplingRate = mSamplingRates[i]; |