khronosfws/openmax_al/src/mmf_adaptation/xarecorditfadaptationmmf.c
changeset 25 6f7ceef7b1d1
parent 19 4a629bc82c5e
child 33 5e8b14bae8c3
--- a/khronosfws/openmax_al/src/mmf_adaptation/xarecorditfadaptationmmf.c	Fri May 28 19:26:28 2010 -0500
+++ b/khronosfws/openmax_al/src/mmf_adaptation/xarecorditfadaptationmmf.c	Fri Jun 11 19:59:23 2010 -0500
@@ -1,19 +1,19 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: 
+ *
+ */
 
 #include "xamediarecorderadaptctxmmf.h"
 #include "xarecorditfadaptationmmf.h"
@@ -28,88 +28,92 @@
  * XAuint32 state - Record state to be set
  * @return XAresult ret - Success value
  */
-XAresult XARecordItfAdaptMMF_SetRecordState(XAAdaptationMMFCtx *bCtx, XAuint32 state)
-{
+XAresult XARecordItfAdaptMMF_SetRecordState(XAAdaptationMMFCtx *bCtx,
+        XAuint32 state)
+    {
     XAresult ret = XA_RESULT_SUCCESS;
     int mmfretCode;
-    XAAdaptEvent stalledevent = {XA_RECORDITFEVENTS, XA_RECORDEVENT_HEADSTALLED, 0, NULL};
+    XAAdaptEvent stalledevent =
+        {
+        XA_RECORDITFEVENTS, XA_RECORDEVENT_HEADSTALLED, 0, NULL
+        };
     XAMediaRecorderAdaptationMMFCtx* mCtx = NULL;
     DEBUG_API_A1("->XARecordItfAdaptMMF_SetRecordState %s",RECORDSTATENAME(state));
-    if(!bCtx)
-    {
-        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
-        DEBUG_API("<-XARecordItfAdaptMMF_SetRecordState");
+    if (!bCtx)
+        {
+        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XARecordItfAdaptMMF_SetRecordState");
         return XA_RESULT_PARAMETER_INVALID;
-    }
+        }
 
     mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx;
 
     mCtx->isRecord = XA_BOOLEAN_TRUE;
 
-    switch ( state )
-    {
+    switch (state)
+        {
         case XA_RECORDSTATE_STOPPED:
-        {
-            mmfretCode= mmf_stop_recording(mCtx->mmfContext, TRUE);
-            if(mmfretCode != XA_RESULT_SUCCESS)
+            {
+            mmfretCode = mmf_stop_recording(mCtx->mmfContext, TRUE);
+            if (mmfretCode != XA_RESULT_SUCCESS)
                 {
                 ret = XA_RESULT_PARAMETER_INVALID;
                 }
             break;
-        }
+            }
         case XA_RECORDSTATE_PAUSED:
-        {
-            mmfretCode = mmf_stop_recording(mCtx->mmfContext,FALSE);
-            if(mmfretCode != XA_RESULT_SUCCESS)
+            {
+            mmfretCode = mmf_stop_recording(mCtx->mmfContext, FALSE);
+            if (mmfretCode != XA_RESULT_SUCCESS)
                 {
                 ret = XA_RESULT_PARAMETER_INVALID;
                 }
             else
                 {
-                XAAdaptationBase_SendAdaptEvents(&bCtx->baseObj, &stalledevent );
+                XAAdaptationBase_SendAdaptEvents(&bCtx->baseObj,
+                        &stalledevent);
                 }
             break;
-        }
+            }
         case XA_RECORDSTATE_RECORDING:
-        {
+            {
             mmfretCode = mmf_start_recording(mCtx->mmfContext);
-            if(mmfretCode != XA_RESULT_SUCCESS)
+            if (mmfretCode != XA_RESULT_SUCCESS)
                 {
                 ret = XA_RESULT_PARAMETER_INVALID;
                 }
             break;
-        }
+            }
         default:
-            DEBUG_ERR("Unhandled state");
+            DEBUG_ERR("Unhandled state")
+            ;
             ret = XA_RESULT_PARAMETER_INVALID;
             break;
-    }
+        }
 
-    if( ret == XA_RESULT_SUCCESS )
-    {
+    if (ret == XA_RESULT_SUCCESS)
+        {
         mCtx->xaRecordState = state;
-    }
-
+        }
 
     DEBUG_API("<-XARecordItfAdaptMMF_SetRecordState %d");
     return ret;
-}
+    }
 
 /*
  * XAresult XARecordItfAdapt_GetRecordState(XAAdaptationBaseCtx *bCtx, XAuint32 *state)
  * Description: Return record state
  */
-XAresult XARecordItfAdaptMMF_GetRecordState(XAAdaptationMMFCtx *bCtx, XAuint32 *state)
-{
+XAresult XARecordItfAdaptMMF_GetRecordState(XAAdaptationMMFCtx *bCtx,
+        XAuint32 *state)
+    {
     XAMediaRecorderAdaptationMMFCtx* mCtx = NULL;
     DEBUG_API("->XARecordItfAdaptMMF_GetRecordState");
 
-    if(!bCtx)
-    {
-        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
-        DEBUG_API("<-XARecordItfAdaptMMF_GetRecordState");
+    if (!bCtx)
+        {
+        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XARecordItfAdaptMMF_GetRecordState");
         return XA_RESULT_PARAMETER_INVALID;
-    }
+        }
 
     mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx;
 
@@ -117,7 +121,7 @@
 
     DEBUG_API("<-XARecordItfAdaptMMF_GetRecordState");
     return XA_RESULT_SUCCESS;
-}
+    }
 
 /*
  * XAresult XARecordItfAdapt_GetPosition(XAAdaptationBaseCtx *ctx, AdaptationContextIDS ctxIDs, XAmillisecond *pMsec)
@@ -125,28 +129,29 @@
  * XAmillisecond *pMsec - Pointer where to store current position in stream.
  * @return XAresult ret - Success value
  */
-XAresult XARecordItfAdaptMMF_GetPosition(XAAdaptationMMFCtx *bCtx, XAmillisecond *pMsec)
-{
+XAresult XARecordItfAdaptMMF_GetPosition(XAAdaptationMMFCtx *bCtx,
+        XAmillisecond *pMsec)
+    {
     XAresult ret = XA_RESULT_SUCCESS;
     XAuint64 position;
     XAMediaRecorderAdaptationMMFCtx* mCtx = NULL;
     DEBUG_API("->XARecordItfAdaptMMF_GetPosition");
 
-    if(!bCtx)
-    {
-        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
-        DEBUG_API("<-XARecordItfAdaptMMF_GetPosition");
+    if (!bCtx)
+        {
+        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XARecordItfAdaptMMF_GetPosition");
         /* invalid parameter */
-        return XA_RESULT_PARAMETER_INVALID;
-    }
+        ret = XA_RESULT_PARAMETER_INVALID;
+        return ret;
+        }
     mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx;
-    mmf_get_record_position(mCtx->mmfContext, &position);
-    
-    *pMsec =  (XAmillisecond)position;
-    
+    ret = mmf_get_record_position(mCtx->mmfContext, &position);
+
+    *pMsec = (XAmillisecond) position;
+
     DEBUG_API("<-XARecordItfAdaptMMF_GetPosition");
     return ret;
-}
+    }
 
 /*
  * gboolean XARecordItfAdapt_PositionUpdate(gpointer ctx)
@@ -155,79 +160,84 @@
  * @return false to stop periodic calls
  */
 gboolean XARecordItfAdaptMMF_PositionUpdate(gpointer ctx, XAuint64 position)
-{
+    {
     XAAdaptationMMFCtx *bCtx = (XAAdaptationMMFCtx*) ctx;
-    XAMediaRecorderAdaptationMMFCtx* mCtx = (XAMediaRecorderAdaptationMMFCtx*) ctx;
-    XAAdaptEvent event = {XA_RECORDITFEVENTS, XA_ADAPT_POSITION_UPDATE_EVT, 1, NULL};
+    XAMediaRecorderAdaptationMMFCtx* mCtx =
+            (XAMediaRecorderAdaptationMMFCtx*) ctx;
+    XAAdaptEvent event =
+        {
+        XA_RECORDITFEVENTS, XA_ADAPT_POSITION_UPDATE_EVT, 1, NULL
+        };
     DEBUG_API("->XARecordItfAdapt_PositionUpdate");
 
-    if( mCtx && mCtx->trackpositionenabled )
-    {
+    if (mCtx && mCtx->trackpositionenabled)
+        {
         XAmillisecond posInMsec = 0;
-        {
-            XARecordItfAdaptMMF_GetPosition(bCtx , &posInMsec);
+            {
+            XARecordItfAdaptMMF_GetPosition(bCtx, &posInMsec);
             event.data = &posInMsec;
             DEBUG_API_A1("XARecordItfAdapt_PositionUpdate: pos %lu ms", posInMsec);
-            XAAdaptationBase_SendAdaptEvents(&bCtx->baseObj, &event );
+            XAAdaptationBase_SendAdaptEvents(&bCtx->baseObj, &event);
+            }DEBUG_API_A1("<-XARecordItfAdapt_PositionUpdate: %d", mCtx->runpositiontimer);
+        return (mCtx->runpositiontimer);
         }
-    DEBUG_API_A1("<-XARecordItfAdapt_PositionUpdate: %d", mCtx->runpositiontimer);
-    return( mCtx->runpositiontimer );
-    }
     /* return false to stop timer */
     return FALSE;
-}
+    }
 
 /*
  * XAresult XARecordItfAdapt_EnablePositionTracking
  * Enable/disable periodic position tracking callbacks
  */
-XAresult XARecordItfAdaptMMF_EnablePositionTracking(XAAdaptationMMFCtx *bCtx, XAboolean enable)
-{
-    XAMediaRecorderAdaptationMMFCtx* mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx;
+XAresult XARecordItfAdaptMMF_EnablePositionTracking(XAAdaptationMMFCtx *bCtx,
+        XAboolean enable)
+    {
+    XAMediaRecorderAdaptationMMFCtx* mCtx =
+            (XAMediaRecorderAdaptationMMFCtx*) bCtx;
     DEBUG_API_A1("->XARecordItfAdapt_EnablePositionTracking (enable: %lu)", enable);
 
-    if(!bCtx || bCtx->baseObj.ctxId != XAMediaRecorderAdaptation)
-    {
-        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
-        DEBUG_API("<-XARecordItfAdapt_EnablePositionTracking");
+    if (!bCtx || bCtx->baseObj.ctxId != XAMediaRecorderAdaptation)
+        {
+        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XARecordItfAdapt_EnablePositionTracking");
         /* invalid parameter */
         return XA_RESULT_PARAMETER_INVALID;
-    }
-
+        }
 
     /* create a timer to track position of playback */
-    if(enable && !(mCtx->trackpositionenabled))
-    {
+    if (enable && !(mCtx->trackpositionenabled))
+        {
         mCtx->trackpositionenabled = XA_BOOLEAN_TRUE;
         //mCtx->positionCb = &XARecordItfAdaptMMF_PositionUpdate;
 
-    }
+        }
     else if (!enable && (mCtx->trackpositionenabled))
-    {
+        {
         mCtx->trackpositionenabled = XA_BOOLEAN_FALSE;
-        if(mCtx->runpositiontimer > 0)
-        {
-            mCtx->runpositiontimer=0;
+        if (mCtx->runpositiontimer > 0)
+            {
+            mCtx->runpositiontimer = 0;
+            }
         }
-    }
 
     DEBUG_API("<-XARecordItfAdapt_EnablePositionTracking");
     return XA_RESULT_SUCCESS;
-}
+    }
 
-XAresult XARecordItfAdaptMMF_SetPositionUpdatePeriod(XAAdaptationMMFCtx *bCtx, XAmillisecond pMsec)
+XAresult XARecordItfAdaptMMF_SetPositionUpdatePeriod(
+        XAAdaptationMMFCtx *bCtx, XAmillisecond pMsec)
     {
-    XAMediaRecorderAdaptationMMFCtx* mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx;
+    XAresult ret = XA_RESULT_SUCCESS;
+    XAMediaRecorderAdaptationMMFCtx* mCtx =
+            (XAMediaRecorderAdaptationMMFCtx*) bCtx;
     DEBUG_API_A1("->XARecordItfAdaptMMF_SetPositionUpdatePeriod (pMsec: %lu)", pMsec);
 
-    if(!bCtx || bCtx->baseObj.ctxId != XAMediaRecorderAdaptation)
+    if (!bCtx || bCtx->baseObj.ctxId != XAMediaRecorderAdaptation)
         {
-            DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
-            DEBUG_API("<-XARecordItfAdapt_EnablePositionTracking");
-            /* invalid parameter */
-            return XA_RESULT_PARAMETER_INVALID;
+        DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XARecordItfAdapt_EnablePositionTracking");
+        /* invalid parameter */
+        return XA_RESULT_PARAMETER_INVALID;
         }
-        
-    mmf_set_record_position_update_period(mCtx->mmfContext, pMsec);
-    return XA_RESULT_SUCCESS;
+
+    ret = mmf_set_record_position_update_period(mCtx->mmfContext, pMsec);
+    return ret;
     }