2 * Copyright 2012 Michael Chen <omxcodec@gmail.com>
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #define LOG_TAG "SoftFFmpegAudio"
19 #include <utils/Log.h>
21 #include "SoftFFmpegAudio.h"
23 #include <media/stagefright/foundation/ADebug.h>
24 #include <media/stagefright/foundation/hexdump.h>
25 #include <media/stagefright/MediaDefs.h>
27 #include "utils/ffmpeg_utils.h"
35 static void InitOMXParams(T *params) {
36 params->nSize = sizeof(T);
37 params->nVersion.s.nVersionMajor = 1;
38 params->nVersion.s.nVersionMinor = 0;
39 params->nVersion.s.nRevision = 0;
40 params->nVersion.s.nStep = 0;
43 void SoftFFmpegAudio::setMode(const char *name) {
44 if (!strcmp(name, "OMX.ffmpeg.aac.decoder")) {
46 } else if (!strcmp(name, "OMX.ffmpeg.mp3.decoder")) {
48 mIgnoreExtradata = true;
49 } else if (!strcmp(name, "OMX.ffmpeg.vorbis.decoder")) {
51 } else if (!strcmp(name, "OMX.ffmpeg.wma.decoder")) {
53 } else if (!strcmp(name, "OMX.ffmpeg.ra.decoder")) {
55 } else if (!strcmp(name, "OMX.ffmpeg.flac.decoder")) {
57 } else if (!strcmp(name, "OMX.ffmpeg.mp2.decoder")) {
59 } else if (!strcmp(name, "OMX.ffmpeg.ac3.decoder")) {
61 } else if (!strcmp(name, "OMX.ffmpeg.ape.decoder")) {
63 } else if (!strcmp(name, "OMX.ffmpeg.dts.decoder")) {
65 } else if (!strcmp(name, "OMX.ffmpeg.atrial.decoder")) {
72 SoftFFmpegAudio::SoftFFmpegAudio(
74 const OMX_CALLBACKTYPE *callbacks,
76 OMX_COMPONENTTYPE **component)
77 : SimpleSoftOMXComponent(name, callbacks, appData, component),
79 mFFmpegAlreadyInited(false),
80 mCodecAlreadyOpened(false),
81 mExtradataReady(false),
82 mIgnoreExtradata(false),
86 mEOSStatus(INPUT_DATA_AVAILABLE),
87 mSignalledError(false),
91 mResampledDataSize(0),
92 mOutputPortSettingsChange(NONE) {
96 ALOGD("SoftFFmpegAudio component: %s mMode: %d", name, mMode);
99 CHECK_EQ(initDecoder(), (status_t)OK);
102 SoftFFmpegAudio::~SoftFFmpegAudio() {
103 ALOGV("~SoftFFmpegAudio");
105 if (mFFmpegAlreadyInited) {
110 void SoftFFmpegAudio::initInputFormat(uint32_t mode,
111 OMX_PARAM_PORTDEFINITIONTYPE &def) {
114 def.format.audio.cMIMEType = const_cast<char *>(MEDIA_MIMETYPE_AUDIO_AAC);
115 def.format.audio.eEncoding = OMX_AUDIO_CodingAAC;
118 def.format.audio.cMIMEType = const_cast<char *>(MEDIA_MIMETYPE_AUDIO_MPEG);
119 def.format.audio.eEncoding = OMX_AUDIO_CodingMP3;
122 def.format.audio.cMIMEType = const_cast<char *>(MEDIA_MIMETYPE_AUDIO_VORBIS);
123 def.format.audio.eEncoding = OMX_AUDIO_CodingVORBIS;
126 def.format.audio.cMIMEType = const_cast<char *>(MEDIA_MIMETYPE_AUDIO_WMA);
127 def.format.audio.eEncoding = OMX_AUDIO_CodingWMA;
130 def.format.audio.cMIMEType = const_cast<char *>(MEDIA_MIMETYPE_AUDIO_RA);
131 def.format.audio.eEncoding = OMX_AUDIO_CodingRA;
134 def.format.audio.cMIMEType = const_cast<char *>(MEDIA_MIMETYPE_AUDIO_FLAC);
135 def.format.audio.eEncoding = OMX_AUDIO_CodingFLAC;
138 def.format.audio.cMIMEType = const_cast<char *>(MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II);
139 def.format.audio.eEncoding = OMX_AUDIO_CodingMP3;
142 def.format.audio.cMIMEType = const_cast<char *>(MEDIA_MIMETYPE_AUDIO_AC3);
143 def.format.audio.eEncoding = OMX_AUDIO_CodingAC3;
146 def.format.audio.cMIMEType = const_cast<char *>(MEDIA_MIMETYPE_AUDIO_APE);
147 def.format.audio.eEncoding = OMX_AUDIO_CodingAPE;
150 def.format.audio.cMIMEType = const_cast<char *>(MEDIA_MIMETYPE_AUDIO_DTS);
151 def.format.audio.eEncoding = OMX_AUDIO_CodingDTS;
154 def.format.audio.cMIMEType = const_cast<char *>(MEDIA_MIMETYPE_AUDIO_FFMPEG);
155 def.format.audio.eEncoding = OMX_AUDIO_CodingAutoDetect;
158 CHECK(!"Should not be here. Unsupported mime type and compression format");
162 def.format.audio.pNativeRender = NULL;
163 def.format.audio.bFlagErrorConcealment = OMX_FALSE;
166 void SoftFFmpegAudio::initPorts() {
167 OMX_PARAM_PORTDEFINITIONTYPE def;
171 def.eDir = OMX_DirInput;
172 def.nBufferCountMin = kNumInputBuffers;
173 def.nBufferCountActual = def.nBufferCountMin;
174 if (mMode == MODE_APE) {
175 def.nBufferSize = 1000000; // ape!
176 } else if (mMode == MODE_DTS) {
177 def.nBufferSize = 1000000; // dts!
179 def.nBufferSize = 20480; // 8192 is too small
181 def.bEnabled = OMX_TRUE;
182 def.bPopulated = OMX_FALSE;
183 def.eDomain = OMX_PortDomainAudio;
184 def.bBuffersContiguous = OMX_FALSE;
185 def.nBufferAlignment = 1;
187 initInputFormat(mMode, def);
192 def.eDir = OMX_DirOutput;
193 def.nBufferCountMin = kNumOutputBuffers;
194 def.nBufferCountActual = def.nBufferCountMin;
195 def.nBufferSize = kOutputBufferSize;
196 def.bEnabled = OMX_TRUE;
197 def.bPopulated = OMX_FALSE;
198 def.eDomain = OMX_PortDomainAudio;
199 def.bBuffersContiguous = OMX_FALSE;
200 def.nBufferAlignment = 2;
202 def.format.audio.cMIMEType = const_cast<char *>("audio/raw");
203 def.format.audio.pNativeRender = NULL;
204 def.format.audio.bFlagErrorConcealment = OMX_FALSE;
205 def.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
210 void SoftFFmpegAudio::setDefaultCtx(AVCodecContext *avctx, const AVCodec *codec) {
213 avctx->workaround_bugs = 1;
215 if(avctx->lowres > codec->max_lowres){
216 ALOGW("The maximum value for lowres supported by the decoder is %d",
218 avctx->lowres= codec->max_lowres;
220 avctx->idct_algo = 0;
221 avctx->skip_frame = AVDISCARD_DEFAULT;
222 avctx->skip_idct = AVDISCARD_DEFAULT;
223 avctx->skip_loop_filter = AVDISCARD_DEFAULT;
224 avctx->error_concealment = 3;
226 if(avctx->lowres) avctx->flags |= CODEC_FLAG_EMU_EDGE;
227 if (fast) avctx->flags2 |= CODEC_FLAG2_FAST;
228 if(codec->capabilities & CODEC_CAP_DR1)
229 avctx->flags |= CODEC_FLAG_EMU_EDGE;
232 bool SoftFFmpegAudio::isConfigured() {
233 return mAudioSrcChannels != -1;
236 void SoftFFmpegAudio::resetCtx() {
238 mCtx->sample_rate = -1;
240 mCtx->sample_fmt = AV_SAMPLE_FMT_NONE;
242 mAudioSrcChannels = mAudioTgtChannels = -1;
243 mAudioSrcFreq = mAudioTgtFreq = -1;
244 mAudioSrcFmt = mAudioTgtFmt = AV_SAMPLE_FMT_NONE;
245 mAudioSrcChannelLayout = mAudioTgtChannelLayout = 0;
248 status_t SoftFFmpegAudio::initDecoder() {
251 status = initFFmpeg();
255 mFFmpegAlreadyInited = true;
257 mCtx = avcodec_alloc_context3(NULL);
259 ALOGE("avcodec_alloc_context failed.");
263 mCtx->codec_type = AVMEDIA_TYPE_AUDIO;
266 mCtx->codec_id = AV_CODEC_ID_AAC;
269 mCtx->codec_id = AV_CODEC_ID_MP3;
272 mCtx->codec_id = AV_CODEC_ID_VORBIS;
275 mCtx->codec_id = AV_CODEC_ID_WMAV2; //should be adjusted later
278 mCtx->codec_id = AV_CODEC_ID_COOK;
281 mCtx->codec_id = AV_CODEC_ID_FLAC;
284 mCtx->codec_id = AV_CODEC_ID_MP2;
287 mCtx->codec_id = AV_CODEC_ID_AC3;
290 mCtx->codec_id = AV_CODEC_ID_APE;
293 mCtx->codec_id = AV_CODEC_ID_DTS;
296 mCtx->codec_id = AV_CODEC_ID_NONE;
299 CHECK(!"Should not be here. Unsupported codec");
306 mCtx->extradata = NULL;
307 mCtx->extradata_size = 0;
309 memset(mSilenceBuffer, 0, kOutputBufferSize);
314 void SoftFFmpegAudio::deInitDecoder() {
316 if (!mCtx->extradata) {
317 av_free(mCtx->extradata);
318 mCtx->extradata = NULL;
319 mCtx->extradata_size = 0;
321 if (mCodecAlreadyOpened) {
337 OMX_ERRORTYPE SoftFFmpegAudio::internalGetParameter(
338 OMX_INDEXTYPE index, OMX_PTR params) {
339 //ALOGV("internalGetParameter index:0x%x", index);
341 case OMX_IndexParamAudioPcm:
343 OMX_AUDIO_PARAM_PCMMODETYPE *profile =
344 (OMX_AUDIO_PARAM_PCMMODETYPE *)params;
346 if (profile->nPortIndex > kOutputPortIndex) {
347 return OMX_ErrorUndefined;
350 profile->eNumData = OMX_NumericalDataSigned;
351 profile->eEndian = OMX_EndianBig;
352 profile->bInterleaved = OMX_TRUE;
353 profile->nBitPerSample = 16;
354 profile->ePCMMode = OMX_AUDIO_PCMModeLinear;
355 profile->eChannelMapping[0] = OMX_AUDIO_ChannelLF;
356 profile->eChannelMapping[1] = OMX_AUDIO_ChannelRF;
358 CHECK(isConfigured());
360 profile->nChannels = mAudioSrcChannels;
361 profile->nSamplingRate = mAudioSrcFreq;
363 //mCtx has been updated(adjustAudioParams)!
364 ALOGV("get pcm params, nChannels:%lu, nSamplingRate:%lu",
365 profile->nChannels, profile->nSamplingRate);
367 return OMX_ErrorNone;
370 case OMX_IndexParamAudioAac:
372 OMX_AUDIO_PARAM_AACPROFILETYPE *profile =
373 (OMX_AUDIO_PARAM_AACPROFILETYPE *)params;
375 if (profile->nPortIndex != kInputPortIndex) {
376 return OMX_ErrorUndefined;
379 CHECK(!isConfigured());
381 profile->nBitRate = 0;
382 profile->nAudioBandWidth = 0;
383 profile->nAACtools = 0;
384 profile->nAACERtools = 0;
385 profile->eAACProfile = OMX_AUDIO_AACObjectMain;
386 profile->eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4FF;
387 profile->eChannelMode = OMX_AUDIO_ChannelModeStereo;
389 profile->nChannels = 0;
390 profile->nSampleRate = 0;
392 return OMX_ErrorNone;
395 case OMX_IndexParamAudioMp3:
397 OMX_AUDIO_PARAM_MP3TYPE *profile =
398 (OMX_AUDIO_PARAM_MP3TYPE *)params;
400 if (profile->nPortIndex != kInputPortIndex) {
401 return OMX_ErrorUndefined;
404 CHECK(!isConfigured());
406 profile->nChannels = 0;
407 profile->nSampleRate = 0;
408 profile->nBitRate = 0;
409 profile->nAudioBandWidth = 0;
410 profile->eChannelMode = OMX_AUDIO_ChannelModeStereo;
411 profile->eFormat = OMX_AUDIO_MP3StreamFormatMP1Layer3;
413 return OMX_ErrorNone;
415 case OMX_IndexParamAudioVorbis:
417 OMX_AUDIO_PARAM_VORBISTYPE *profile =
418 (OMX_AUDIO_PARAM_VORBISTYPE *)params;
420 if (profile->nPortIndex != kInputPortIndex) {
421 return OMX_ErrorUndefined;
424 CHECK(!isConfigured());
426 profile->nBitRate = 0;
427 profile->nMinBitRate = 0;
428 profile->nMaxBitRate = 0;
429 profile->nAudioBandWidth = 0;
430 profile->nQuality = 3;
431 profile->bManaged = OMX_FALSE;
432 profile->bDownmix = OMX_FALSE;
434 profile->nChannels = 0;
435 profile->nSampleRate = 0;
437 return OMX_ErrorNone;
440 case OMX_IndexParamAudioWma:
442 OMX_AUDIO_PARAM_WMATYPE *profile =
443 (OMX_AUDIO_PARAM_WMATYPE *)params;
445 if (profile->nPortIndex != kInputPortIndex) {
446 return OMX_ErrorUndefined;
449 CHECK(!isConfigured());
451 profile->nChannels = 0;
452 profile->nSamplingRate = 0;
453 profile->nBitRate = 0;
454 profile->eFormat = OMX_AUDIO_WMAFormatUnused;
456 return OMX_ErrorNone;
459 case OMX_IndexParamAudioRa:
461 OMX_AUDIO_PARAM_RATYPE *profile =
462 (OMX_AUDIO_PARAM_RATYPE *)params;
464 if (profile->nPortIndex != kInputPortIndex) {
465 return OMX_ErrorUndefined;
468 CHECK(!isConfigured());
470 profile->nChannels = 0;
471 profile->nSamplingRate = 0;
472 profile->eFormat = OMX_AUDIO_RAFormatUnused;
474 return OMX_ErrorNone;
477 case OMX_IndexParamAudioFlac:
479 OMX_AUDIO_PARAM_FLACTYPE *profile =
480 (OMX_AUDIO_PARAM_FLACTYPE *)params;
482 if (profile->nPortIndex != kInputPortIndex) {
483 return OMX_ErrorUndefined;
486 CHECK(!isConfigured());
488 profile->nChannels = 0;
489 profile->nSampleRate = 0;
491 return OMX_ErrorNone;
494 case OMX_IndexParamAudioMp2:
496 OMX_AUDIO_PARAM_MP2TYPE *profile =
497 (OMX_AUDIO_PARAM_MP2TYPE *)params;
499 if (profile->nPortIndex != kInputPortIndex) {
500 return OMX_ErrorUndefined;
503 CHECK(!isConfigured());
505 profile->nChannels = 0;
506 profile->nSampleRate = 0;
508 return OMX_ErrorNone;
511 case OMX_IndexParamAudioAc3:
513 OMX_AUDIO_PARAM_AC3TYPE *profile =
514 (OMX_AUDIO_PARAM_AC3TYPE *)params;
516 if (profile->nPortIndex != kInputPortIndex) {
517 return OMX_ErrorUndefined;
520 CHECK(!isConfigured());
522 profile->nChannels = 0;
523 profile->nSamplingRate = 0;
525 return OMX_ErrorNone;
528 case OMX_IndexParamAudioApe:
530 OMX_AUDIO_PARAM_APETYPE *profile =
531 (OMX_AUDIO_PARAM_APETYPE *)params;
533 if (profile->nPortIndex != kInputPortIndex) {
534 return OMX_ErrorUndefined;
537 CHECK(!isConfigured());
539 profile->nChannels = 0;
540 profile->nSamplingRate = 0;
542 return OMX_ErrorNone;
545 case OMX_IndexParamAudioDts:
547 OMX_AUDIO_PARAM_DTSTYPE *profile =
548 (OMX_AUDIO_PARAM_DTSTYPE *)params;
550 if (profile->nPortIndex != kInputPortIndex) {
551 return OMX_ErrorUndefined;
554 CHECK(!isConfigured());
556 profile->nChannels = 0;
557 profile->nSamplingRate = 0;
559 return OMX_ErrorNone;
562 case OMX_IndexParamAudioFFmpeg:
564 OMX_AUDIO_PARAM_FFMPEGTYPE *profile =
565 (OMX_AUDIO_PARAM_FFMPEGTYPE *)params;
567 if (profile->nPortIndex != kInputPortIndex) {
568 return OMX_ErrorUndefined;
571 CHECK(!isConfigured());
573 profile->eCodecId = 0;
574 profile->nChannels = 0;
575 profile->nBitRate = 0;
576 profile->nBitsPerSample = 0;
577 profile->nSampleRate = 0;
578 profile->nBlockAlign = 0;
579 profile->eSampleFormat = 0;
581 return OMX_ErrorNone;
586 return SimpleSoftOMXComponent::internalGetParameter(index, params);
590 OMX_ERRORTYPE SoftFFmpegAudio::isRoleSupported(
591 const OMX_PARAM_COMPONENTROLETYPE *roleParams) {
592 bool supported = true;
596 if (strncmp((const char *)roleParams->cRole,
597 "audio_decoder.aac", OMX_MAX_STRINGNAME_SIZE - 1))
601 if (strncmp((const char *)roleParams->cRole,
602 "audio_decoder.mp3", OMX_MAX_STRINGNAME_SIZE - 1))
606 if (strncmp((const char *)roleParams->cRole,
607 "audio_decoder.vorbis", OMX_MAX_STRINGNAME_SIZE - 1))
611 if (strncmp((const char *)roleParams->cRole,
612 "audio_decoder.wma", OMX_MAX_STRINGNAME_SIZE - 1))
616 if (strncmp((const char *)roleParams->cRole,
617 "audio_decoder.ra", OMX_MAX_STRINGNAME_SIZE - 1))
621 if (strncmp((const char *)roleParams->cRole,
622 "audio_decoder.flac", OMX_MAX_STRINGNAME_SIZE - 1))
626 if (strncmp((const char *)roleParams->cRole,
627 "audio_decoder.mp2", OMX_MAX_STRINGNAME_SIZE - 1))
631 if (strncmp((const char *)roleParams->cRole,
632 "audio_decoder.ac3", OMX_MAX_STRINGNAME_SIZE - 1))
636 if (strncmp((const char *)roleParams->cRole,
637 "audio_decoder.ape", OMX_MAX_STRINGNAME_SIZE - 1))
641 if (strncmp((const char *)roleParams->cRole,
642 "audio_decoder.dts", OMX_MAX_STRINGNAME_SIZE - 1))
646 if (strncmp((const char *)roleParams->cRole,
647 "audio_decoder.trial", OMX_MAX_STRINGNAME_SIZE - 1))
651 CHECK(!"Should not be here. Unsupported role.");
656 ALOGE("unsupported role: %s", (const char *)roleParams->cRole);
657 return OMX_ErrorUndefined;
660 return OMX_ErrorNone;
663 void SoftFFmpegAudio::adjustAudioParams() {
664 int32_t channels = 0;
665 int32_t sampling_rate = 0;
667 CHECK(!isConfigured());
669 sampling_rate = mCtx->sample_rate;
671 //channels support 1 or 2 only
672 channels = mCtx->channels >= 2 ? 2 : 1;
674 //4000 <= sampling rate <= 48000
675 if (sampling_rate < 4000) {
676 sampling_rate = 4000;
677 } else if (sampling_rate > 48000) {
678 sampling_rate = 48000;
681 mAudioSrcChannels = mAudioTgtChannels = channels;
682 mAudioSrcFreq = mAudioTgtFreq = sampling_rate;
683 mAudioSrcFmt = mAudioTgtFmt = AV_SAMPLE_FMT_S16;
684 mAudioSrcChannelLayout = mAudioTgtChannelLayout =
685 av_get_default_channel_layout(channels);
688 OMX_ERRORTYPE SoftFFmpegAudio::internalSetParameter(
689 OMX_INDEXTYPE index, const OMX_PTR params) {
690 //ALOGV("internalSetParameter index:0x%x", index);
692 case OMX_IndexParamStandardComponentRole:
694 const OMX_PARAM_COMPONENTROLETYPE *roleParams =
695 (const OMX_PARAM_COMPONENTROLETYPE *)params;
696 return isRoleSupported(roleParams);
699 case OMX_IndexParamAudioPcm:
701 const OMX_AUDIO_PARAM_PCMMODETYPE *profile =
702 (const OMX_AUDIO_PARAM_PCMMODETYPE *)params;
704 if (profile->nPortIndex != kOutputPortIndex) {
705 return OMX_ErrorUndefined;
708 CHECK(!isConfigured());
710 mCtx->channels = profile->nChannels;
711 mCtx->sample_rate = profile->nSamplingRate;
712 mCtx->bits_per_coded_sample = profile->nBitPerSample;
714 ALOGV("set OMX_IndexParamAudioPcm, nChannels:%lu, "
715 "nSampleRate:%lu, nBitsPerSample:%lu",
716 profile->nChannels, profile->nSamplingRate,
717 profile->nBitPerSample);
719 return OMX_ErrorNone;
722 case OMX_IndexParamAudioAac:
724 const OMX_AUDIO_PARAM_AACPROFILETYPE *profile =
725 (const OMX_AUDIO_PARAM_AACPROFILETYPE *)params;
727 if (profile->nPortIndex != kInputPortIndex) {
728 return OMX_ErrorUndefined;
731 CHECK(!isConfigured());
733 mCtx->channels = profile->nChannels;
734 mCtx->sample_rate = profile->nSampleRate;
738 ALOGV("set OMX_IndexParamAudioAac, nChannels:%lu, nSampleRate:%lu",
739 profile->nChannels, profile->nSampleRate);
741 return OMX_ErrorNone;
744 case OMX_IndexParamAudioMp3:
746 const OMX_AUDIO_PARAM_MP3TYPE *profile =
747 (const OMX_AUDIO_PARAM_MP3TYPE *)params;
749 if (profile->nPortIndex != kInputPortIndex) {
750 return OMX_ErrorUndefined;
753 CHECK(!isConfigured());
755 mCtx->channels = profile->nChannels;
756 mCtx->sample_rate = profile->nSampleRate;
760 ALOGV("set OMX_IndexParamAudioMp3, nChannels:%lu, nSampleRate:%lu",
761 profile->nChannels, profile->nSampleRate);
763 return OMX_ErrorNone;
766 case OMX_IndexParamAudioVorbis:
768 const OMX_AUDIO_PARAM_VORBISTYPE *profile =
769 (const OMX_AUDIO_PARAM_VORBISTYPE *)params;
771 if (profile->nPortIndex != kInputPortIndex) {
772 return OMX_ErrorUndefined;
775 CHECK(!isConfigured());
777 mCtx->channels = profile->nChannels;
778 mCtx->sample_rate = profile->nSampleRate;
782 ALOGD("set OMX_IndexParamAudioVorbis, "
783 "nChannels=%lu, nSampleRate=%lu, nBitRate=%lu, "
784 "nMinBitRate=%lu, nMaxBitRate=%lu",
785 profile->nChannels, profile->nSampleRate,
786 profile->nBitRate, profile->nMinBitRate,
787 profile->nMaxBitRate);
789 return OMX_ErrorNone;
792 case OMX_IndexParamAudioWma:
794 OMX_AUDIO_PARAM_WMATYPE *profile =
795 (OMX_AUDIO_PARAM_WMATYPE *)params;
797 if (profile->nPortIndex != kInputPortIndex) {
798 return OMX_ErrorUndefined;
801 CHECK(!isConfigured());
803 if (profile->eFormat == OMX_AUDIO_WMAFormat7) {
804 mCtx->codec_id = AV_CODEC_ID_WMAV2;
805 } else if (profile->eFormat == OMX_AUDIO_WMAFormat8) {
806 mCtx->codec_id = AV_CODEC_ID_WMAPRO;
807 } else if (profile->eFormat == OMX_AUDIO_WMAFormat9) {
808 mCtx->codec_id = AV_CODEC_ID_WMALOSSLESS;
810 ALOGE("unsupported wma codec: 0x%x", profile->eFormat);
811 return OMX_ErrorUndefined;
814 mCtx->channels = profile->nChannels;
815 mCtx->sample_rate = profile->nSamplingRate;
817 // wmadec needs bitrate, block_align
818 mCtx->bit_rate = profile->nBitRate;
819 mCtx->block_align = profile->nBlockAlign;
823 ALOGV("set OMX_IndexParamAudioWma, nChannels:%u, "
824 "nSampleRate:%lu, nBitRate:%lu, nBlockAlign:%u",
825 profile->nChannels, profile->nSamplingRate,
826 profile->nBitRate, profile->nBlockAlign);
828 return OMX_ErrorNone;
831 case OMX_IndexParamAudioRa:
833 OMX_AUDIO_PARAM_RATYPE *profile =
834 (OMX_AUDIO_PARAM_RATYPE *)params;
836 if (profile->nPortIndex != kInputPortIndex) {
837 return OMX_ErrorUndefined;
840 CHECK(!isConfigured());
842 mCtx->channels = profile->nChannels;
843 mCtx->sample_rate = profile->nSamplingRate;
845 // FIXME, HACK!!!, I use the nNumRegions parameter pass blockAlign!!!
846 // the cook audio codec need blockAlign!
847 mCtx->block_align = profile->nNumRegions;
851 ALOGV("set OMX_IndexParamAudioRa, nChannels:%lu, "
852 "nSampleRate:%lu, nBlockAlign:%d",
853 profile->nChannels, profile->nSamplingRate, mCtx->block_align);
855 return OMX_ErrorNone;
858 case OMX_IndexParamAudioFlac:
860 OMX_AUDIO_PARAM_FLACTYPE *profile =
861 (OMX_AUDIO_PARAM_FLACTYPE *)params;
863 if (profile->nPortIndex != kInputPortIndex) {
864 return OMX_ErrorUndefined;
867 CHECK(!isConfigured());
869 mCtx->channels = profile->nChannels;
870 mCtx->sample_rate = profile->nSampleRate;
874 ALOGV("set OMX_IndexParamAudioFlac, nChannels:%lu, nSampleRate:%lu",
875 profile->nChannels, profile->nSampleRate);
877 return OMX_ErrorNone;
880 case OMX_IndexParamAudioMp2:
882 OMX_AUDIO_PARAM_MP2TYPE *profile =
883 (OMX_AUDIO_PARAM_MP2TYPE *)params;
885 if (profile->nPortIndex != kInputPortIndex) {
886 return OMX_ErrorUndefined;
889 CHECK(!isConfigured());
891 mCtx->channels = profile->nChannels;
892 mCtx->sample_rate = profile->nSampleRate;
896 ALOGV("set OMX_IndexParamAudioMp2, nChannels:%lu, nSampleRate:%lu",
897 profile->nChannels, profile->nSampleRate);
899 return OMX_ErrorNone;
902 case OMX_IndexParamAudioAc3:
904 OMX_AUDIO_PARAM_AC3TYPE *profile =
905 (OMX_AUDIO_PARAM_AC3TYPE *)params;
907 if (profile->nPortIndex != kInputPortIndex) {
908 return OMX_ErrorUndefined;
911 CHECK(!isConfigured());
913 mCtx->channels = profile->nChannels;
914 mCtx->sample_rate = profile->nSamplingRate;
918 ALOGV("set OMX_IndexParamAudioFlac, nChannels:%lu, nSampleRate:%lu",
919 profile->nChannels, profile->nSamplingRate);
921 return OMX_ErrorNone;
924 case OMX_IndexParamAudioApe:
926 OMX_AUDIO_PARAM_APETYPE *profile =
927 (OMX_AUDIO_PARAM_APETYPE *)params;
929 if (profile->nPortIndex != kInputPortIndex) {
930 return OMX_ErrorUndefined;
933 CHECK(!isConfigured());
935 mCtx->channels = profile->nChannels;
936 mCtx->sample_rate = profile->nSamplingRate;
938 //ape decoder need bits_per_coded_sample
939 mCtx->bits_per_coded_sample = profile->nBitsPerSample;
943 ALOGV("set OMX_IndexParamAudioApe, nChannels:%lu, "
944 "nSampleRate:%lu, nBitsPerSample:%lu",
945 profile->nChannels, profile->nSamplingRate,
946 profile->nBitsPerSample);
948 return OMX_ErrorNone;
951 case OMX_IndexParamAudioDts:
953 OMX_AUDIO_PARAM_DTSTYPE *profile =
954 (OMX_AUDIO_PARAM_DTSTYPE *)params;
956 if (profile->nPortIndex != kInputPortIndex) {
957 return OMX_ErrorUndefined;
960 CHECK(!isConfigured());
962 mCtx->channels = profile->nChannels;
963 mCtx->sample_rate = profile->nSamplingRate;
967 ALOGV("set OMX_IndexParamAudioDts, nChannels:%lu, nSampleRate:%lu",
968 profile->nChannels, profile->nSamplingRate);
970 return OMX_ErrorNone;
973 case OMX_IndexParamAudioFFmpeg:
975 OMX_AUDIO_PARAM_FFMPEGTYPE *profile =
976 (OMX_AUDIO_PARAM_FFMPEGTYPE *)params;
978 if (profile->nPortIndex != kInputPortIndex) {
979 return OMX_ErrorUndefined;
982 CHECK(!isConfigured());
985 mCtx->codec_id = (enum AVCodecID)profile->eCodecId;
986 mCtx->channels = profile->nChannels;
987 mCtx->bit_rate = profile->nBitRate;
988 mCtx->bits_per_coded_sample = profile->nBitsPerSample;
989 mCtx->sample_rate = profile->nSampleRate;
990 mCtx->block_align = profile->nBlockAlign;
991 mCtx->sample_fmt = (AVSampleFormat)profile->eSampleFormat;
995 ALOGD("set OMX_IndexParamAudioFFmpeg, "
996 "eCodecId:%ld(%s), nChannels:%lu, nBitRate:%lu, "
997 "nBitsPerSample:%lu, nSampleRate:%lu, "
998 "nBlockAlign:%lu, eSampleFormat:%lu(%s)",
999 profile->eCodecId, avcodec_get_name(mCtx->codec_id),
1000 profile->nChannels, profile->nBitRate,
1001 profile->nBitsPerSample, profile->nSampleRate,
1002 profile->nBlockAlign, profile->eSampleFormat,
1003 av_get_sample_fmt_name(mCtx->sample_fmt));
1004 return OMX_ErrorNone;
1009 return SimpleSoftOMXComponent::internalSetParameter(index, params);
1013 int32_t SoftFFmpegAudio::handleExtradata() {
1014 List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex);
1015 BufferInfo *inInfo = *inQueue.begin();
1016 OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;
1018 ALOGI("got extradata, ignore: %d, size: %lu",
1019 mIgnoreExtradata, inHeader->nFilledLen);
1020 hexdump(inHeader->pBuffer + inHeader->nOffset, inHeader->nFilledLen);
1022 if (mIgnoreExtradata) {
1023 ALOGI("got extradata, size: %lu, but ignore it", inHeader->nFilledLen);
1025 if (!mExtradataReady) {
1026 int orig_extradata_size = mCtx->extradata_size;
1027 mCtx->extradata_size += inHeader->nFilledLen;
1028 mCtx->extradata = (uint8_t *)av_realloc(mCtx->extradata,
1029 mCtx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
1030 if (!mCtx->extradata) {
1031 ALOGE("ffmpeg audio decoder failed to alloc extradata memory.");
1035 memcpy(mCtx->extradata + orig_extradata_size,
1036 inHeader->pBuffer + inHeader->nOffset, inHeader->nFilledLen);
1037 memset(mCtx->extradata + mCtx->extradata_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
1041 inInfo->mOwnedByUs = false;
1042 inQueue.erase(inQueue.begin());
1044 notifyEmptyBufferDone(inHeader);
1050 int32_t SoftFFmpegAudio::openDecoder() {
1051 if (mCodecAlreadyOpened) {
1055 if (!mExtradataReady && !mIgnoreExtradata) {
1056 ALOGI("extradata is ready, size: %d", mCtx->extradata_size);
1057 hexdump(mCtx->extradata, mCtx->extradata_size);
1058 mExtradataReady = true;
1062 mCtx->codec = avcodec_find_decoder(mCtx->codec_id);
1064 ALOGE("ffmpeg audio decoder failed to find codec");
1065 return ERR_CODEC_NOT_FOUND;
1068 CHECK(isConfigured());
1070 setDefaultCtx(mCtx, mCtx->codec);
1072 ALOGD("begin to open ffmpeg audio decoder(%s), mCtx sample_rate: %d, "
1073 "channels: %d, , sample_fmt: %s",
1074 avcodec_get_name(mCtx->codec_id),
1075 mCtx->sample_rate, mCtx->channels,
1076 av_get_sample_fmt_name(mCtx->sample_fmt));
1078 int err = avcodec_open2(mCtx, mCtx->codec, NULL);
1080 ALOGE("ffmpeg audio decoder failed to initialize.(%s)", av_err2str(err));
1081 return ERR_DECODER_OPEN_FAILED;
1083 mCodecAlreadyOpened = true;
1085 ALOGD("open ffmpeg audio decoder(%s) success, mCtx sample_rate: %d, "
1086 "channels: %d, sample_fmt: %s",
1087 avcodec_get_name(mCtx->codec_id),
1088 mCtx->sample_rate, mCtx->channels,
1089 av_get_sample_fmt_name(mCtx->sample_fmt));
1091 mFrame = avcodec_alloc_frame();
1093 ALOGE("oom for video frame");
1100 void SoftFFmpegAudio::updateTimeStamp(OMX_BUFFERHEADERTYPE *inHeader) {
1101 CHECK_EQ(mInputBufferSize, 0);
1103 //XXX reset to AV_NOPTS_VALUE if the pts is invalid
1104 if (inHeader->nTimeStamp == SF_NOPTS_VALUE) {
1105 inHeader->nTimeStamp = AV_NOPTS_VALUE;
1108 //update the audio clock if the pts is valid
1109 if (inHeader->nTimeStamp != AV_NOPTS_VALUE) {
1110 mAudioClock = inHeader->nTimeStamp;
1114 void SoftFFmpegAudio::initPacket(AVPacket *pkt,
1115 OMX_BUFFERHEADERTYPE *inHeader) {
1116 memset(pkt, 0, sizeof(AVPacket));
1117 av_init_packet(pkt);
1120 pkt->data = (uint8_t *)inHeader->pBuffer + inHeader->nOffset;
1121 pkt->size = inHeader->nFilledLen;
1122 pkt->pts = inHeader->nTimeStamp; //ingore it, we will compute it
1126 pkt->pts = AV_NOPTS_VALUE;
1130 if (pkt->pts != AV_NOPTS_VALUE)
1132 ALOGV("pkt size:%d, pts:%lld", pkt->size, pkt->pts);
1134 ALOGV("pkt size:%d, pts:N/A", pkt->size);
1139 int32_t SoftFFmpegAudio::decodeAudio() {
1142 int32_t ret = ERR_OK;
1143 int32_t inputBufferUsedLength = 0;
1144 bool is_flush = (mEOSStatus != INPUT_DATA_AVAILABLE);
1145 List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex);
1146 BufferInfo *inInfo = NULL;
1147 OMX_BUFFERHEADERTYPE *inHeader = NULL;
1149 CHECK_EQ(mResampledDataSize, 0);
1152 inInfo = *inQueue.begin();
1153 CHECK(inInfo != NULL);
1154 inHeader = inInfo->mHeader;
1156 if (mInputBufferSize == 0) {
1157 updateTimeStamp(inHeader);
1158 mInputBufferSize = inHeader->nFilledLen;
1163 initPacket(&pkt, inHeader);
1164 av_frame_unref(mFrame);
1165 avcodec_get_frame_defaults(mFrame);
1167 len = avcodec_decode_audio4(mCtx, mFrame, &gotFrm, &pkt);
1168 //a negative error code is returned if an error occurred during decoding
1170 ALOGW("ffmpeg audio decoder err, we skip the frame and play silence instead");
1171 mResampledData = mSilenceBuffer;
1172 mResampledDataSize = kOutputBufferSize;
1176 ALOGV("ffmpeg audio decoder, consume pkt len: %d", len);
1179 ALOGI("ffmpeg audio decoder failed to get frame.");
1180 //stop sending empty packets if the decoder is finished
1181 if (is_flush && mCtx->codec->capabilities & CODEC_CAP_DELAY) {
1187 ret = resampleAudio();
1193 //if error, we skip the frame
1194 inputBufferUsedLength = mInputBufferSize;
1196 inputBufferUsedLength = len;
1199 CHECK_GE(inHeader->nFilledLen, inputBufferUsedLength);
1200 inHeader->nOffset += inputBufferUsedLength;
1201 inHeader->nFilledLen -= inputBufferUsedLength;
1202 mInputBufferSize -= inputBufferUsedLength;
1204 if (inHeader->nFilledLen == 0) {
1205 CHECK_EQ(mInputBufferSize, 0);
1206 inQueue.erase(inQueue.begin());
1207 inInfo->mOwnedByUs = false;
1208 notifyEmptyBufferDone(inHeader);
1215 int32_t SoftFFmpegAudio::resampleAudio() {
1217 int64_t channelLayout = 0;
1218 size_t dataSize = 0;
1220 dataSize = av_samples_get_buffer_size(NULL, av_frame_get_channels(mFrame),
1221 mFrame->nb_samples, (enum AVSampleFormat)mFrame->format, 1);
1224 ALOGV("ffmpeg audio decoder, nb_samples:%d, get buffer size:%d",
1225 mFrame->nb_samples, dataSize);
1228 channels = av_get_channel_layout_nb_channels(mFrame->channel_layout);
1230 (mFrame->channel_layout && av_frame_get_channels(mFrame) == channels) ?
1231 mFrame->channel_layout : av_get_default_channel_layout(av_frame_get_channels(mFrame));
1233 if (mFrame->format != mAudioSrcFmt
1234 || channelLayout != mAudioSrcChannelLayout
1235 || mFrame->sample_rate != mAudioSrcFreq) {
1239 mSwrCtx = swr_alloc_set_opts(NULL,
1240 mAudioTgtChannelLayout, mAudioTgtFmt, mAudioTgtFreq,
1241 channelLayout, (enum AVSampleFormat)mFrame->format, mFrame->sample_rate,
1243 if (!mSwrCtx || swr_init(mSwrCtx) < 0) {
1244 ALOGE("Cannot create sample rate converter for conversion "
1245 "of %d Hz %s %d channels to %d Hz %s %d channels!",
1246 mFrame->sample_rate,
1247 av_get_sample_fmt_name((enum AVSampleFormat)mFrame->format),
1248 av_frame_get_channels(mFrame),
1250 av_get_sample_fmt_name(mAudioTgtFmt),
1252 return ERR_SWR_INIT_FAILED;
1255 char src_layout_name[1024] = {0};
1256 char tgt_layout_name[1024] = {0};
1257 av_get_channel_layout_string(src_layout_name, sizeof(src_layout_name),
1258 mCtx->channels, channelLayout);
1259 av_get_channel_layout_string(tgt_layout_name, sizeof(tgt_layout_name),
1260 mAudioTgtChannels, mAudioTgtChannelLayout);
1261 ALOGI("Create sample rate converter for conversion "
1262 "of %d Hz %s %d channels(%s) "
1263 "to %d Hz %s %d channels(%s)!",
1264 mFrame->sample_rate,
1265 av_get_sample_fmt_name((enum AVSampleFormat)mFrame->format),
1266 av_frame_get_channels(mFrame),
1269 av_get_sample_fmt_name(mAudioTgtFmt),
1273 mAudioSrcChannelLayout = channelLayout;
1274 mAudioSrcChannels = av_frame_get_channels(mFrame);
1275 mAudioSrcFreq = mFrame->sample_rate;
1276 mAudioSrcFmt = (enum AVSampleFormat)mFrame->format;
1280 const uint8_t **in = (const uint8_t **)mFrame->extended_data;
1281 uint8_t *out[] = {mAudioBuffer};
1282 int out_count = sizeof(mAudioBuffer) / mAudioTgtChannels / av_get_bytes_per_sample(mAudioTgtFmt);
1283 int out_size = av_samples_get_buffer_size(NULL, mAudioTgtChannels, out_count, mAudioTgtFmt, 0);
1286 ALOGE("av_samples_get_buffer_size() failed");
1287 return ERR_INVALID_PARAM;
1290 len2 = swr_convert(mSwrCtx, out, out_count, in, mFrame->nb_samples);
1292 ALOGE("audio_resample() failed");
1293 return ERR_RESAMPLE_FAILED;
1295 if (len2 == out_count) {
1296 ALOGE("warning: audio buffer is probably too small");
1299 mResampledData = mAudioBuffer;
1300 mResampledDataSize = len2 * mAudioTgtChannels * av_get_bytes_per_sample(mAudioTgtFmt);
1303 ALOGV("ffmpeg audio decoder(resample), mFrame->nb_samples:%d, len2:%d, mResampledDataSize:%d, "
1304 "src channel:%u, src fmt:%s, tgt channel:%u, tgt fmt:%s",
1305 mFrame->nb_samples, len2, mResampledDataSize,
1306 av_frame_get_channels(mFrame),
1307 av_get_sample_fmt_name((enum AVSampleFormat)mFrame->format),
1309 av_get_sample_fmt_name(mAudioTgtFmt));
1312 mResampledData = mFrame->data[0];
1313 mResampledDataSize = dataSize;
1316 ALOGV("ffmpeg audio decoder(no resample),"
1317 "nb_samples(before resample):%d, mResampledDataSize:%d",
1318 mFrame->nb_samples, mResampledDataSize);
1325 void SoftFFmpegAudio::drainOneOutputBuffer() {
1326 List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);
1327 BufferInfo *outInfo = *outQueue.begin();
1328 CHECK(outInfo != NULL);
1329 OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader;
1331 CHECK_GT(mResampledDataSize, 0);
1333 size_t copy = mResampledDataSize;
1334 if (mResampledDataSize > kOutputBufferSize) {
1335 copy = kOutputBufferSize;
1338 outHeader->nOffset = 0;
1339 outHeader->nFilledLen = copy;
1340 outHeader->nTimeStamp = mAudioClock;
1341 memcpy(outHeader->pBuffer, mResampledData, copy);
1342 outHeader->nFlags = 0;
1344 //update mResampledSize
1345 mResampledData += copy;
1346 mResampledDataSize -= copy;
1349 size_t frames = copy / (av_get_bytes_per_sample(mAudioTgtFmt) * mAudioTgtChannels);
1350 mAudioClock += (frames * 1000000ll) / mAudioTgtFreq;
1353 ALOGV("ffmpeg audio decoder, fill out buffer, copy:%u, pts: %lld",
1354 copy, outHeader->nTimeStamp);
1357 outQueue.erase(outQueue.begin());
1358 outInfo->mOwnedByUs = false;
1359 notifyFillBufferDone(outHeader);
1362 void SoftFFmpegAudio::drainEOSOutputBuffer() {
1363 List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);
1364 BufferInfo *outInfo = *outQueue.begin();
1365 CHECK(outInfo != NULL);
1366 OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader;
1368 CHECK_EQ(mResampledDataSize, 0);
1370 ALOGD("ffmpeg audio decoder fill eos outbuf");
1372 outHeader->nTimeStamp = 0;
1373 outHeader->nFilledLen = 0;
1374 outHeader->nFlags = OMX_BUFFERFLAG_EOS;
1376 outQueue.erase(outQueue.begin());
1377 outInfo->mOwnedByUs = false;
1378 notifyFillBufferDone(outHeader);
1380 mEOSStatus = OUTPUT_FRAMES_FLUSHED;
1383 void SoftFFmpegAudio::drainAllOutputBuffers() {
1384 List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);
1386 if (!mCodecAlreadyOpened) {
1387 drainEOSOutputBuffer();
1388 mEOSStatus = OUTPUT_FRAMES_FLUSHED;
1392 if(!(mCtx->codec->capabilities & CODEC_CAP_DELAY)) {
1393 drainEOSOutputBuffer();
1394 mEOSStatus = OUTPUT_FRAMES_FLUSHED;
1398 while (!outQueue.empty()) {
1399 if (mResampledDataSize == 0) {
1400 int32_t err = decodeAudio();
1402 notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
1403 mSignalledError = true;
1405 } else if (err == ERR_FLUSHED) {
1406 drainEOSOutputBuffer();
1409 CHECK_EQ(err, ERR_OK);
1413 if (mResampledDataSize > 0) {
1414 drainOneOutputBuffer();
1419 void SoftFFmpegAudio::onQueueFilled(OMX_U32 portIndex) {
1420 BufferInfo *inInfo = NULL;
1421 OMX_BUFFERHEADERTYPE *inHeader = NULL;
1423 if (mSignalledError || mOutputPortSettingsChange != NONE) {
1427 if (mEOSStatus == OUTPUT_FRAMES_FLUSHED) {
1431 List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex);
1432 List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);
1434 while (((mEOSStatus != INPUT_DATA_AVAILABLE) || !inQueue.empty())
1435 && !outQueue.empty()) {
1437 if (mEOSStatus == INPUT_EOS_SEEN) {
1438 drainAllOutputBuffers();
1442 inInfo = *inQueue.begin();
1443 inHeader = inInfo->mHeader;
1445 if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) {
1446 ALOGD("ffmpeg audio decoder empty eos inbuf");
1447 inQueue.erase(inQueue.begin());
1448 inInfo->mOwnedByUs = false;
1449 notifyEmptyBufferDone(inHeader);
1450 mEOSStatus = INPUT_EOS_SEEN;
1454 if (inHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG) {
1455 if (handleExtradata() != ERR_OK) {
1456 notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
1457 mSignalledError = true;
1463 if (!mCodecAlreadyOpened) {
1464 if (openDecoder() != ERR_OK) {
1465 notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
1466 mSignalledError = true;
1471 if (mResampledDataSize == 0) {
1472 int32_t err = decodeAudio();
1474 notify(OMX_EventError, OMX_ErrorUndefined, 0, NULL);
1475 mSignalledError = true;
1477 } else if (err == ERR_NO_FRM) {
1478 CHECK_EQ(mResampledDataSize, 0);
1481 CHECK_EQ(err, ERR_OK);
1485 if (mResampledDataSize > 0) {
1486 drainOneOutputBuffer();
1491 void SoftFFmpegAudio::onPortFlushCompleted(OMX_U32 portIndex) {
1492 ALOGV("ffmpeg audio decoder flush port(%lu)", portIndex);
1493 if (portIndex == kInputPortIndex) {
1495 //Make sure that the next buffer output does not still
1496 //depend on fragments from the last one decoded.
1497 avcodec_flush_buffers(mCtx);
1501 mInputBufferSize = 0;
1502 mResampledDataSize = 0;
1503 mResampledData = NULL;
1504 mEOSStatus = INPUT_DATA_AVAILABLE;
1508 void SoftFFmpegAudio::onPortEnableCompleted(OMX_U32 portIndex, bool enabled) {
1509 if (portIndex != kOutputPortIndex) {
1513 switch (mOutputPortSettingsChange) {
1517 case AWAITING_DISABLED:
1520 mOutputPortSettingsChange = AWAITING_ENABLED;
1526 CHECK_EQ((int)mOutputPortSettingsChange, (int)AWAITING_ENABLED);
1528 mOutputPortSettingsChange = NONE;
1534 } // namespace android
1536 android::SoftOMXComponent *createSoftOMXComponent(
1537 const char *name, const OMX_CALLBACKTYPE *callbacks,
1538 OMX_PTR appData, OMX_COMPONENTTYPE **component) {
1539 return new android::SoftFFmpegAudio(name, callbacks, appData, component);