void SurfaceMediaSource::signalBufferReturned(MediaBuffer *buffer) { ALOGV("signalBufferReturned"); bool foundBuffer = false; Mutex::Autolock lock(mMutex); buffer_handle_t bufferHandle = getMediaBufferHandle(buffer); for (size_t i = 0; i < mCurrentBuffers.size(); i++) { if (mCurrentBuffers[i]->handle == bufferHandle) { mCurrentBuffers.removeAt(i); foundBuffer = true; break; } } if (!foundBuffer) { ALOGW("returned buffer was not found in the current buffer list"); } for (int id = 0; id < BufferQueue::NUM_BUFFER_SLOTS; id++) { if (mSlots[id].mGraphicBuffer == NULL) { continue; } if (bufferHandle == mSlots[id].mGraphicBuffer->handle) { ALOGV("Slot %d returned, matches handle = %p", id, mSlots[id].mGraphicBuffer->handle); mBufferQueue->releaseBuffer(id, mSlots[id].mFrameNumber, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, Fence::NO_FENCE); buffer->setObserver(0); buffer->release(); foundBuffer = true; break; } } if (!foundBuffer) { CHECK(!"signalBufferReturned: bogus buffer"); } #if DEBUG_PENDING_BUFFERS for (size_t i = 0; i < mPendingBuffers.size(); ++i) { if (mPendingBuffers.itemAt(i) == buffer) { mPendingBuffers.removeAt(i); break; } } #endif --mNumPendingBuffers; mMediaBuffersAvailableCondition.broadcast(); }
void SurfaceMediaSource::signalBufferReturned(MediaBuffer *buffer) { ALOGV("signalBufferReturned"); bool foundBuffer = false; Mutex::Autolock lock(mMutex); buffer_handle_t bufferHandle = getMediaBufferHandle(buffer); for (size_t i = 0; i < mCurrentBuffers.size(); i++) { if (mCurrentBuffers[i]->handle == bufferHandle) { mCurrentBuffers.removeAt(i); foundBuffer = true; break; } } if (!foundBuffer) { ALOGW("returned buffer was not found in the current buffer list"); } for (int id = 0; id < BufferQueue::NUM_BUFFER_SLOTS; id++) { if (mBufferSlot[id] == NULL) { continue; } if (bufferHandle == mBufferSlot[id]->handle) { ALOGV("Slot %d returned, matches handle = %p", id, mBufferSlot[id]->handle); mBufferQueue->releaseBuffer(id, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR); buffer->setObserver(0); buffer->release(); foundBuffer = true; break; } } if (!foundBuffer) { CHECK(!"signalBufferReturned: bogus buffer"); } }