|
|
@ -713,7 +713,7 @@ void CCodecBufferChannel::feedInputBufferIfAvailableInternal() {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
if (output->buffers->numClientBuffers() >= output->numSlots) {
|
|
|
|
if (!output->buffers || output->buffers->numClientBuffers() >= output->numSlots) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1401,6 +1401,30 @@ void CCodecBufferChannel::stop() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CCodecBufferChannel::reset() {
|
|
|
|
|
|
|
|
stop();
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Mutexed<Input>::Locked input(mInput);
|
|
|
|
|
|
|
|
input->buffers.reset(new DummyInputBuffers(""));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
|
|
|
|
output->buffers.reset();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CCodecBufferChannel::release() {
|
|
|
|
|
|
|
|
mComponent.reset();
|
|
|
|
|
|
|
|
mInputAllocator.reset();
|
|
|
|
|
|
|
|
mOutputSurface.lock()->surface.clear();
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Mutexed<BlockPools>::Locked blockPools{mBlockPools};
|
|
|
|
|
|
|
|
blockPools->inputPool.reset();
|
|
|
|
|
|
|
|
blockPools->outputPoolIntf.reset();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CCodecBufferChannel::flush(const std::list<std::unique_ptr<C2Work>> &flushedWork) {
|
|
|
|
void CCodecBufferChannel::flush(const std::list<std::unique_ptr<C2Work>> &flushedWork) {
|
|
|
|
ALOGV("[%s] flush", mName);
|
|
|
|
ALOGV("[%s] flush", mName);
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1431,7 +1455,9 @@ void CCodecBufferChannel::flush(const std::list<std::unique_ptr<C2Work>> &flushe
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
output->buffers->flush(flushedWork);
|
|
|
|
if (output->buffers) {
|
|
|
|
|
|
|
|
output->buffers->flush(flushedWork);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mReorderStash.lock()->flush();
|
|
|
|
mReorderStash.lock()->flush();
|
|
|
|
mPipelineWatcher.lock()->flush();
|
|
|
|
mPipelineWatcher.lock()->flush();
|
|
|
@ -1469,20 +1495,25 @@ bool CCodecBufferChannel::handleWork(
|
|
|
|
std::unique_ptr<C2Work> work,
|
|
|
|
std::unique_ptr<C2Work> work,
|
|
|
|
const sp<AMessage> &outputFormat,
|
|
|
|
const sp<AMessage> &outputFormat,
|
|
|
|
const C2StreamInitDataInfo::output *initData) {
|
|
|
|
const C2StreamInitDataInfo::output *initData) {
|
|
|
|
if (outputFormat != nullptr) {
|
|
|
|
{
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
ALOGD("[%s] onWorkDone: output format changed to %s",
|
|
|
|
if (!output->buffers) {
|
|
|
|
mName, outputFormat->debugString().c_str());
|
|
|
|
return false;
|
|
|
|
output->buffers->setFormat(outputFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (outputFormat != nullptr) {
|
|
|
|
AString mediaType;
|
|
|
|
ALOGD("[%s] onWorkDone: output format changed to %s",
|
|
|
|
if (outputFormat->findString(KEY_MIME, &mediaType)
|
|
|
|
mName, outputFormat->debugString().c_str());
|
|
|
|
&& mediaType == MIMETYPE_AUDIO_RAW) {
|
|
|
|
output->buffers->setFormat(outputFormat);
|
|
|
|
int32_t channelCount;
|
|
|
|
|
|
|
|
int32_t sampleRate;
|
|
|
|
AString mediaType;
|
|
|
|
if (outputFormat->findInt32(KEY_CHANNEL_COUNT, &channelCount)
|
|
|
|
if (outputFormat->findString(KEY_MIME, &mediaType)
|
|
|
|
&& outputFormat->findInt32(KEY_SAMPLE_RATE, &sampleRate)) {
|
|
|
|
&& mediaType == MIMETYPE_AUDIO_RAW) {
|
|
|
|
output->buffers->updateSkipCutBuffer(sampleRate, channelCount);
|
|
|
|
int32_t channelCount;
|
|
|
|
|
|
|
|
int32_t sampleRate;
|
|
|
|
|
|
|
|
if (outputFormat->findInt32(KEY_CHANNEL_COUNT, &channelCount)
|
|
|
|
|
|
|
|
&& outputFormat->findInt32(KEY_SAMPLE_RATE, &sampleRate)) {
|
|
|
|
|
|
|
|
output->buffers->updateSkipCutBuffer(sampleRate, channelCount);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1606,6 +1637,9 @@ bool CCodecBufferChannel::handleWork(
|
|
|
|
size_t numInputSlots = mInput.lock()->numSlots;
|
|
|
|
size_t numInputSlots = mInput.lock()->numSlots;
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
|
|
|
|
if (!output->buffers) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
output->outputDelay = outputDelay.value;
|
|
|
|
output->outputDelay = outputDelay.value;
|
|
|
|
numOutputSlots = outputDelay.value + kSmoothnessFactor;
|
|
|
|
numOutputSlots = outputDelay.value + kSmoothnessFactor;
|
|
|
|
if (output->numSlots < numOutputSlots) {
|
|
|
|
if (output->numSlots < numOutputSlots) {
|
|
|
@ -1695,7 +1729,7 @@ bool CCodecBufferChannel::handleWork(
|
|
|
|
|
|
|
|
|
|
|
|
if (initData != nullptr) {
|
|
|
|
if (initData != nullptr) {
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
if (output->buffers->registerCsd(initData, &index, &outBuffer) == OK) {
|
|
|
|
if (output->buffers && output->buffers->registerCsd(initData, &index, &outBuffer) == OK) {
|
|
|
|
outBuffer->meta()->setInt64("timeUs", timestamp.peek());
|
|
|
|
outBuffer->meta()->setInt64("timeUs", timestamp.peek());
|
|
|
|
outBuffer->meta()->setInt32("flags", MediaCodec::BUFFER_FLAG_CODECCONFIG);
|
|
|
|
outBuffer->meta()->setInt32("flags", MediaCodec::BUFFER_FLAG_CODECCONFIG);
|
|
|
|
ALOGV("[%s] onWorkDone: csd index = %zu [%p]", mName, index, outBuffer.get());
|
|
|
|
ALOGV("[%s] onWorkDone: csd index = %zu [%p]", mName, index, outBuffer.get());
|
|
|
@ -1758,6 +1792,9 @@ void CCodecBufferChannel::sendOutputBuffers() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
|
|
|
|
if (!output->buffers) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
status_t err = output->buffers->registerBuffer(entry.buffer, &index, &outBuffer);
|
|
|
|
status_t err = output->buffers->registerBuffer(entry.buffer, &index, &outBuffer);
|
|
|
|
if (err != OK) {
|
|
|
|
if (err != OK) {
|
|
|
|
bool outputBuffersChanged = false;
|
|
|
|
bool outputBuffersChanged = false;
|
|
|
|