Analizo
view release on metacpan or search on metacpan
t/samples/android-framework/android-5.1.1_r38/AudioTrackShared.cpp view on Meta::CPAN
}
// As mFramesReady is the total remaining frames in the static audio track,
// it is always larger or equal to avail.
LOG_ALWAYS_FATAL_IF(mFramesReady < avail);
buffer->mNonContig = mFramesReady == INT64_MAX ? SIZE_MAX : clampToSize(mFramesReady - avail);
mUnreleased = avail;
return NO_ERROR;
}
void StaticAudioTrackServerProxy::releaseBuffer(Buffer* buffer)
{
size_t stepCount = buffer->mFrameCount;
LOG_ALWAYS_FATAL_IF(!(stepCount <= mFramesReady));
LOG_ALWAYS_FATAL_IF(!(stepCount <= mUnreleased));
if (stepCount == 0) {
// prevent accidental re-use of buffer
buffer->mRaw = NULL;
buffer->mNonContig = 0;
return;
}
mUnreleased -= stepCount;
audio_track_cblk_t* cblk = mCblk;
size_t position = mPosition;
size_t newPosition = position + stepCount;
int32_t setFlags = 0;
if (!(position <= newPosition && newPosition <= mFrameCount)) {
ALOGW("%s newPosition %zu outside [%zu, %zu]", __func__, newPosition, position, mFrameCount);
newPosition = mFrameCount;
} else if (mState.mLoopCount != 0 && newPosition == mState.mLoopEnd) {
newPosition = mState.mLoopStart;
if (mState.mLoopCount == -1 || --mState.mLoopCount != 0) {
setFlags = CBLK_LOOP_CYCLE;
} else {
setFlags = CBLK_LOOP_FINAL;
}
}
if (newPosition == mFrameCount) {
setFlags |= CBLK_BUFFER_END;
}
mPosition = newPosition;
if (mFramesReady != INT64_MAX) {
mFramesReady -= stepCount;
}
mFramesReadySafe = clampToSize(mFramesReady);
cblk->mServer += stepCount;
// This may overflow, but client is not supposed to rely on it
cblk->u.mStatic.mBufferPosition = (uint32_t) newPosition;
if (setFlags != 0) {
(void) android_atomic_or(setFlags, &cblk->mFlags);
// this would be a good place to wake a futex
}
buffer->mFrameCount = 0;
buffer->mRaw = NULL;
buffer->mNonContig = 0;
}
void StaticAudioTrackServerProxy::tallyUnderrunFrames(uint32_t frameCount __unused)
{
// Unlike AudioTrackServerProxy::tallyUnderrunFrames() used for streaming tracks,
// we don't have a location to count underrun frames. The underrun frame counter
// only exists in AudioTrackSharedStreaming. Fortunately, underruns are not
// possible for static buffer tracks other than at end of buffer, so this is not a loss.
// FIXME also wake futex so that underrun is noticed more quickly
(void) android_atomic_or(CBLK_UNDERRUN, &mCblk->mFlags);
}
// ---------------------------------------------------------------------------
} // namespace android
( run in 2.283 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )