|
|
|
@ -1277,6 +1277,24 @@ bool CCodecBufferChannel::handleWork(
|
|
|
|
|
std::unique_ptr<C2Work> work,
|
|
|
|
|
const sp<AMessage> &outputFormat,
|
|
|
|
|
const C2StreamInitDataInfo::output *initData) {
|
|
|
|
|
if (outputFormat != nullptr) {
|
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
|
ALOGD("[%s] onWorkDone: output format changed to %s",
|
|
|
|
|
mName, outputFormat->debugString().c_str());
|
|
|
|
|
output->buffers->setFormat(outputFormat);
|
|
|
|
|
|
|
|
|
|
AString mediaType;
|
|
|
|
|
if (outputFormat->findString(KEY_MIME, &mediaType)
|
|
|
|
|
&& mediaType == MIMETYPE_AUDIO_RAW) {
|
|
|
|
|
int32_t channelCount;
|
|
|
|
|
int32_t sampleRate;
|
|
|
|
|
if (outputFormat->findInt32(KEY_CHANNEL_COUNT, &channelCount)
|
|
|
|
|
&& outputFormat->findInt32(KEY_SAMPLE_RATE, &sampleRate)) {
|
|
|
|
|
output->buffers->updateSkipCutBuffer(sampleRate, channelCount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((work->input.ordinal.frameIndex - mFirstValidFrameIndex.load()).peek() < 0) {
|
|
|
|
|
// Discard frames from previous generation.
|
|
|
|
|
ALOGD("[%s] Discard frames from previous generation.", mName);
|
|
|
|
@ -1454,24 +1472,6 @@ bool CCodecBufferChannel::handleWork(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (outputFormat != nullptr) {
|
|
|
|
|
Mutexed<Output>::Locked output(mOutput);
|
|
|
|
|
ALOGD("[%s] onWorkDone: output format changed to %s",
|
|
|
|
|
mName, outputFormat->debugString().c_str());
|
|
|
|
|
output->buffers->setFormat(outputFormat);
|
|
|
|
|
|
|
|
|
|
AString mediaType;
|
|
|
|
|
if (outputFormat->findString(KEY_MIME, &mediaType)
|
|
|
|
|
&& mediaType == MIMETYPE_AUDIO_RAW) {
|
|
|
|
|
int32_t channelCount;
|
|
|
|
|
int32_t sampleRate;
|
|
|
|
|
if (outputFormat->findInt32(KEY_CHANNEL_COUNT, &channelCount)
|
|
|
|
|
&& outputFormat->findInt32(KEY_SAMPLE_RATE, &sampleRate)) {
|
|
|
|
|
output->buffers->updateSkipCutBuffer(sampleRate, channelCount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t flags = 0;
|
|
|
|
|
if (worklet->output.flags & C2FrameData::FLAG_END_OF_STREAM) {
|
|
|
|
|
flags |= MediaCodec::BUFFER_FLAG_EOS;
|
|
|
|
|