Loading services/audioflinger/Tracks.cpp +19 −0 Original line number Original line Diff line number Diff line Loading @@ -1872,6 +1872,25 @@ void AudioFlinger::PlaybackThread::PatchTrack::releaseBuffer(Proxy::Buffer* buff { { mProxy->releaseBuffer(buffer); mProxy->releaseBuffer(buffer); restartIfDisabled(); restartIfDisabled(); // Check if the PatchTrack has enough data to write once in releaseBuffer(). // If not, prevent an underrun from occurring by moving the track into FS_FILLING; // this logic avoids glitches when suspending A2DP with AudioPlaybackCapture. // TODO: perhaps underrun avoidance could be a track property checked in isReady() instead. if (mFillingUpStatus == FS_ACTIVE && audio_is_linear_pcm(mFormat) && !isOffloadedOrDirect()) { if (sp<ThreadBase> thread = mThread.promote(); thread != 0) { PlaybackThread *playbackThread = (PlaybackThread *)thread.get(); const size_t frameCount = playbackThread->frameCount() * sampleRate() / playbackThread->sampleRate(); if (framesReady() < frameCount) { ALOGD("%s(%d) Not enough data, wait for buffer to fill", __func__, mId); mFillingUpStatus = FS_FILLING; } } } } } void AudioFlinger::PlaybackThread::PatchTrack::restartIfDisabled() void AudioFlinger::PlaybackThread::PatchTrack::restartIfDisabled() Loading Loading
services/audioflinger/Tracks.cpp +19 −0 Original line number Original line Diff line number Diff line Loading @@ -1872,6 +1872,25 @@ void AudioFlinger::PlaybackThread::PatchTrack::releaseBuffer(Proxy::Buffer* buff { { mProxy->releaseBuffer(buffer); mProxy->releaseBuffer(buffer); restartIfDisabled(); restartIfDisabled(); // Check if the PatchTrack has enough data to write once in releaseBuffer(). // If not, prevent an underrun from occurring by moving the track into FS_FILLING; // this logic avoids glitches when suspending A2DP with AudioPlaybackCapture. // TODO: perhaps underrun avoidance could be a track property checked in isReady() instead. if (mFillingUpStatus == FS_ACTIVE && audio_is_linear_pcm(mFormat) && !isOffloadedOrDirect()) { if (sp<ThreadBase> thread = mThread.promote(); thread != 0) { PlaybackThread *playbackThread = (PlaybackThread *)thread.get(); const size_t frameCount = playbackThread->frameCount() * sampleRate() / playbackThread->sampleRate(); if (framesReady() < frameCount) { ALOGD("%s(%d) Not enough data, wait for buffer to fill", __func__, mId); mFillingUpStatus = FS_FILLING; } } } } } void AudioFlinger::PlaybackThread::PatchTrack::restartIfDisabled() void AudioFlinger::PlaybackThread::PatchTrack::restartIfDisabled() Loading