Fix issue 1743700
: AudioTrack: setPlaybackRate can not set the playback rate to twice of the ouputSR
Store sample rate on 32 bits instead of 16 bits in audio_track_cblk_t. Removed sampleRate() methods from AudioTrack and AudioRecord: replaced by getSampleRate(). AudioTrack::setSampleRate() no returns a status.
This commit is contained in:
@ -243,7 +243,6 @@ status_t AudioTrack::set(
|
||||
mCblk->volume[0] = mCblk->volume[1] = 0x1000;
|
||||
mVolume[LEFT] = 1.0f;
|
||||
mVolume[RIGHT] = 1.0f;
|
||||
mSampleRate = sampleRate;
|
||||
mStreamType = streamType;
|
||||
mFormat = format;
|
||||
mChannelCount = channelCount;
|
||||
@ -254,7 +253,7 @@ status_t AudioTrack::set(
|
||||
mNotificationFrames = notificationFrames;
|
||||
mRemainingFrames = notificationFrames;
|
||||
mUserData = user;
|
||||
mLatency = afLatency + (1000*mFrameCount) / mSampleRate;
|
||||
mLatency = afLatency + (1000*mFrameCount) / sampleRate;
|
||||
mLoopCount = 0;
|
||||
mMarkerPosition = 0;
|
||||
mMarkerReached = false;
|
||||
@ -281,11 +280,6 @@ int AudioTrack::streamType() const
|
||||
return mStreamType;
|
||||
}
|
||||
|
||||
uint32_t AudioTrack::sampleRate() const
|
||||
{
|
||||
return mSampleRate;
|
||||
}
|
||||
|
||||
int AudioTrack::format() const
|
||||
{
|
||||
return mFormat;
|
||||
@ -438,24 +432,23 @@ void AudioTrack::getVolume(float* left, float* right)
|
||||
*right = mVolume[RIGHT];
|
||||
}
|
||||
|
||||
void AudioTrack::setSampleRate(int rate)
|
||||
status_t AudioTrack::setSampleRate(int rate)
|
||||
{
|
||||
int afSamplingRate;
|
||||
|
||||
if (AudioSystem::getOutputSamplingRate(&afSamplingRate, mStreamType) != NO_ERROR) {
|
||||
return;
|
||||
return NO_INIT;
|
||||
}
|
||||
// Resampler implementation limits input sampling rate to 2 x output sampling rate.
|
||||
if (rate <= 0) rate = 1;
|
||||
if (rate > afSamplingRate*2) rate = afSamplingRate*2;
|
||||
if (rate > MAX_SAMPLE_RATE) rate = MAX_SAMPLE_RATE;
|
||||
if (rate <= 0 || rate > afSamplingRate*2 ) return BAD_VALUE;
|
||||
|
||||
mCblk->sampleRate = (uint16_t)rate;
|
||||
mCblk->sampleRate = rate;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
uint32_t AudioTrack::getSampleRate()
|
||||
{
|
||||
return uint32_t(mCblk->sampleRate);
|
||||
return mCblk->sampleRate;
|
||||
}
|
||||
|
||||
status_t AudioTrack::setLoop(uint32_t loopStart, uint32_t loopEnd, int loopCount)
|
||||
@ -866,7 +859,7 @@ status_t AudioTrack::dump(int fd, const Vector<String16>& args) const
|
||||
result.append(buffer);
|
||||
snprintf(buffer, 255, " format(%d), channel count(%d), frame count(%d)\n", mFormat, mChannelCount, mFrameCount);
|
||||
result.append(buffer);
|
||||
snprintf(buffer, 255, " sample rate(%d), status(%d), muted(%d)\n", mSampleRate, mStatus, mMuted);
|
||||
snprintf(buffer, 255, " sample rate(%d), status(%d), muted(%d)\n", (mCblk == 0) ? 0 : mCblk->sampleRate, mStatus, mMuted);
|
||||
result.append(buffer);
|
||||
snprintf(buffer, 255, " active(%d), latency (%d)\n", mActive, mLatency);
|
||||
result.append(buffer);
|
||||
|
Reference in New Issue
Block a user