diff -r a493a607b5bf -r eabc8c503852 khronosfws/openmax_al/src/mmf_adaptation/xamediarecorderadaptctxmmf.c --- a/khronosfws/openmax_al/src/mmf_adaptation/xamediarecorderadaptctxmmf.c Fri Sep 03 19:34:12 2010 -0500 +++ b/khronosfws/openmax_al/src/mmf_adaptation/xamediarecorderadaptctxmmf.c Tue Sep 21 11:38:43 2010 -0500 @@ -16,7 +16,6 @@ */ #include -#include #include "xamediarecorderadaptctxmmf.h" #include "xaadaptationmmf.h" #include "cmmfbackendengine.h" @@ -39,60 +38,56 @@ pSelf = (XAMediaRecorderAdaptationMMFCtx*) calloc(1, sizeof(XAMediaRecorderAdaptationMMFCtx)); - if (pSelf) - { - if (XAAdaptationBaseMMF_Init(&(pSelf->baseObj), - XAMediaRecorderAdaptation) != XA_RESULT_SUCCESS) - { - DEBUG_ERR("Failed to init base context!!!"); - free(pSelf); - pSelf = NULL; - } - else - { - pSelf->xaAudioSource = pAudioSrc; - pSelf->xaVideoSource = pImageVideoSrc; - pSelf->xaSink = pDataSnk; - pSelf->xaRecordState = XA_RECORDSTATE_STOPPED; - pSelf->curMirror = XA_VIDEOMIRROR_NONE; - pSelf->curRotation = 0; - pSelf->recModes = recModes; - pSelf->isRecord = XA_BOOLEAN_FALSE; - - /* defaults from API spec */ - pSelf->imageEncSettings.width = 640; - pSelf->imageEncSettings.height = 480; - pSelf->imageEncSettings.compressionLevel = 0; - pSelf->imageEncSettings.encoderId = XA_IMAGECODEC_JPEG; - pSelf->imageEncSettings.colorFormat = XA_COLORFORMAT_UNUSED; - /* no specified defaults for rest, determined later from container type */ - pSelf->videoEncSettings.encoderId = XA_ADAPTID_UNINITED; - pSelf->videoEncSettings.width = 640; - pSelf->videoEncSettings.height = 480; - pSelf->videoEncSettings.frameRate = 15; - pSelf->audioEncSettings.encoderId = XA_ADAPTID_UNINITED; - pSelf->audioEncSettings.channelsIn = 2; - pSelf->audioEncSettings.channelsOut = 2; - pSelf->audioEncSettings.bitsPerSample = 8; - pSelf->audioEncSettings.bitRate = 128; - pSelf->audioEncSettings.sampleRate = 44100; - } - } - else + if (!pSelf) { DEBUG_ERR("Failed to create XAMediaRecorderAdaptationMMFCtx !!!"); + DEBUG_API("<-XAMediaRecorderAdaptMMF_Create"); + return NULL; + } + + if (XAAdaptationBaseMMF_Init(&(pSelf->baseObj), + XAMediaRecorderAdaptation) != XA_RESULT_SUCCESS) + { + free(pSelf); + DEBUG_ERR("Failed to init base context!!!"); + DEBUG_API("<-XAMediaRecorderAdaptMMF_Create"); return NULL; } - if (pSelf) + pSelf->xaAudioSource = pAudioSrc; + pSelf->xaVideoSource = pImageVideoSrc; + pSelf->xaSink = pDataSnk; + pSelf->xaRecordState = XA_RECORDSTATE_STOPPED; + pSelf->curMirror = XA_VIDEOMIRROR_NONE; + pSelf->curRotation = 0; + pSelf->recModes = recModes; + pSelf->isRecord = XA_BOOLEAN_FALSE; + + /* defaults from API spec */ + pSelf->imageEncSettings.width = 640; + pSelf->imageEncSettings.height = 480; + pSelf->imageEncSettings.compressionLevel = 0; + pSelf->imageEncSettings.encoderId = XA_IMAGECODEC_JPEG; + pSelf->imageEncSettings.colorFormat = XA_COLORFORMAT_UNUSED; + /* no specified defaults for rest, determined later from container type */ + pSelf->videoEncSettings.encoderId = XA_ADAPTID_UNINITED; + pSelf->videoEncSettings.width = 640; + pSelf->videoEncSettings.height = 480; + pSelf->videoEncSettings.frameRate = 15; + pSelf->audioEncSettings.encoderId = XA_ADAPTID_UNINITED; + pSelf->audioEncSettings.channelsIn = 2; + pSelf->audioEncSettings.channelsOut = 2; + pSelf->audioEncSettings.bitsPerSample = 8; + pSelf->audioEncSettings.bitRate = 128; + pSelf->audioEncSettings.sampleRate = 44100; + + res = mmf_backend_engine_init(&(pSelf->mmfContext)); + if (!(pSelf->mmfContext) || (res != XA_RESULT_SUCCESS)) { - res = mmf_backend_engine_init(&(pSelf->mmfContext)); - if (!(pSelf->mmfContext) || (res != XA_RESULT_SUCCESS)) - { - DEBUG_ERR("Failed to init mmf context!!!"); - free(pSelf); - pSelf = NULL; - } + free(pSelf); + DEBUG_ERR("Failed to init mmf context!!!"); + DEBUG_API("<-XAMediaRecorderAdaptMMF_Create"); + return NULL; } DEBUG_API("<-XAMediaRecorderAdaptMMF_Create"); @@ -116,6 +111,8 @@ if(!bCtx) { ret = XA_RESULT_PARAMETER_INVALID; + DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); + DEBUG_API("<-XAMediaRecorderAdapt_PostInit"); return ret; } @@ -126,12 +123,20 @@ tempFormat = (XADataFormat_MIME*) (pSelf->xaSink->pFormat); ret = mmf_set_recorder_uri(pSelf->mmfContext, (char *) (tempUri->URI), tempFormat->containerType); - if(ret == XA_RESULT_SUCCESS) + if (ret != XA_RESULT_SUCCESS) { - ret = mmf_set_adapt_context(pSelf->mmfContext, &(pSelf->baseObj)); + DEBUG_ERR("Failed to set recorder uri on mmf!!!"); + DEBUG_API("<-XAMediaRecorderAdapt_PostInit"); + return ret; + } + ret = mmf_set_adapt_context(pSelf->mmfContext, &(pSelf->baseObj)); + if (ret != XA_RESULT_SUCCESS) + { + DEBUG_ERR("Failed to set adapt context on mmf!!!"); + DEBUG_API("<-XAMediaRecorderAdapt_PostInit"); + return ret; } } - DEBUG_API("<-XAMediaRecorderAdapt_PostInit"); return ret; }