khronosfws/openmax_al/src/adaptation/xavolumeitfadaptation.c
changeset 12 5a06f39ad45b
equal deleted inserted replaced
0:71ca22bcf22a 12:5a06f39ad45b
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include <gst.h>
       
    19 #include <mixer.h>
       
    20 #include "XAAdaptation.h"
       
    21 #include "XAVolumeItfAdaptation.h"
       
    22 #include "XAMediaPlayerAdaptCtx.h"
       
    23 #include "XAStaticCapsAdaptation.h"
       
    24 #include "XAOutputMixAdaptCtx.h"
       
    25 #include "XAMediaRecorderAdaptCtx.h"
       
    26 
       
    27 /*
       
    28  * XAresult XAVolumeItfAdapt_FlushBin(XAAdaptationBaseCtx *ctx)
       
    29  */
       
    30 XAresult XAVolumeItfAdapt_FlushBin(XAAdaptationBaseCtx *ctx)
       
    31 {
       
    32     DEBUG_API("->XAVolumeItfAdapt_FlushBin");
       
    33     if(!ctx || ( ctx->ctxId != XAMediaPlayerAdaptation ))
       
    34     {
       
    35         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
    36         /* invalid parameter */
       
    37         return XA_RESULT_PARAMETER_INVALID;
       
    38     }
       
    39     if (GST_STATE(ctx->bin) != GST_STATE_PLAYING)
       
    40     {
       
    41         gint64 position = 0;
       
    42         GstFormat format = GST_FORMAT_TIME;
       
    43 
       
    44         gst_element_query_position( GST_ELEMENT(ctx->bin), &format, &position  ) ;
       
    45 
       
    46         XAAdaptationBase_PrepareAsyncWait(ctx);
       
    47         /* in effect seeks to current position and flushing the buffer, due to
       
    48          * gstreamer implementation actual position might change, if stopped, seek to beginning
       
    49          */
       
    50         if(!gst_element_seek( ctx->bin, ((XAMediaPlayerAdaptationCtx*)ctx)->playrate, GST_FORMAT_TIME,
       
    51                             GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE,
       
    52                             GST_SEEK_TYPE_SET, position,
       
    53                             GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
       
    54         {
       
    55             DEBUG_ERR("WARN: gst reports seek not handled");
       
    56         }
       
    57         /* flushed seeks always asynchronous */
       
    58         XAAdaptationBase_StartAsyncWait(ctx);
       
    59         DEBUG_INFO("Bin flushed.");
       
    60         ctx->waitingasyncop = XA_BOOLEAN_FALSE;
       
    61     }
       
    62     DEBUG_API("<-XAVolumeItfAdapt_FlushBin");
       
    63     return XA_RESULT_SUCCESS;
       
    64 }
       
    65 
       
    66 /*
       
    67  * XAresult XAVolumeItfAdapt_SetVolumeLevel(void *ctx, AdaptationContextIDS ctx->ctxId,
       
    68  *                                          XAmillibel level)
       
    69  * @param void *ctx - Adaptation context, this will be casted to correct type regarding to contextID
       
    70  * XAmillibel level - Requested volume level, in between XA_MILLIBEL_MIN and XA_MILLIBEL_MAX
       
    71  * @return XAresult ret - Success value
       
    72  */
       
    73 XAresult XAVolumeItfAdapt_SetVolumeLevel(XAAdaptationBaseCtx *ctx, XAmillibel level)
       
    74 {
       
    75     GstElement *vol=NULL, *audiopp=NULL;
       
    76     gdouble gstVolume = 0;
       
    77     XAmillibel tempVolumeLevel = 0;
       
    78     XAresult res = XA_RESULT_SUCCESS;
       
    79 
       
    80     DEBUG_API_A1("->XAVolumeItfAdapt_SetVolumeLevel (level %d)", level);
       
    81     if(!ctx || ( ctx->ctxId != XAMediaPlayerAdaptation &&
       
    82                  ctx->ctxId != XAMediaRecorderAdaptation &&
       
    83                  ctx->ctxId != XAOutputMixAdaptation) )
       
    84     {
       
    85         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
    86         DEBUG_API("<-XAVolumeItfAdapt_SetVolumeLevel");
       
    87         /* invalid parameter */
       
    88         return XA_RESULT_PARAMETER_INVALID;
       
    89     }
       
    90 
       
    91     if( level <= MIN_SUPPORT_VOLUME_LEVEL )
       
    92     {
       
    93         tempVolumeLevel = MIN_SUPPORT_VOLUME_LEVEL;
       
    94     }
       
    95     else if( level >= MAX_SUPPORT_VOLUME_LEVEL )
       
    96     {
       
    97         tempVolumeLevel = MAX_SUPPORT_VOLUME_LEVEL;
       
    98     }
       
    99     else
       
   100     {
       
   101         tempVolumeLevel = level;
       
   102     }
       
   103     gstVolume = ( ( (gdouble)(VOLUME_LEVEL_RATIO + tempVolumeLevel)/ VOLUME_LEVEL_RATIO) );
       
   104 
       
   105     if ( ctx->ctxId == XAMediaPlayerAdaptation )
       
   106     {
       
   107         XAMediaPlayerAdaptationCtx* context = (XAMediaPlayerAdaptationCtx*) ctx;
       
   108         audiopp = gst_bin_get_by_name( GST_BIN(context->baseObj.bin), "audiopp" );
       
   109         if(audiopp)
       
   110         {
       
   111             vol = gst_bin_get_by_name( GST_BIN(audiopp), "pp_vol" );
       
   112         }
       
   113         if(vol)
       
   114         {
       
   115             DEBUG_INFO_A1("Setting gst level to %f",gstVolume);
       
   116             g_object_set( G_OBJECT(vol), "volume", (gdouble)gstVolume, NULL );
       
   117 
       
   118             XAVolumeItfAdapt_FlushBin(ctx);
       
   119         }
       
   120         else
       
   121         {
       
   122             DEBUG_ERR("Could not find gst volume controller element!!");
       
   123         }
       
   124     }
       
   125     else if ( ctx->ctxId == XAMediaRecorderAdaptation )
       
   126     {
       
   127         XAMediaRecorderAdaptationCtx* context = (XAMediaRecorderAdaptationCtx*) ctx;
       
   128         audiopp = gst_bin_get_by_name( GST_BIN(context->baseObj.bin), "audiopp" );
       
   129         if(audiopp)
       
   130         {
       
   131             vol = gst_bin_get_by_name( GST_BIN(audiopp), "pp_vol" );
       
   132         }
       
   133         if(vol)
       
   134         {
       
   135             DEBUG_INFO_A1("Setting gst level to %f",gstVolume);
       
   136             g_object_set( G_OBJECT(vol), "volume", (gdouble)gstVolume, NULL );
       
   137         }
       
   138         else
       
   139         {
       
   140             DEBUG_ERR("Could not find gst volume controller element!!");
       
   141         }
       
   142     }
       
   143     else if (ctx->ctxId == XAOutputMixAdaptation )
       
   144     {
       
   145         XAOutputMixAdaptationCtx* context = (XAOutputMixAdaptationCtx*) ctx;
       
   146         guint iterator = 0;
       
   147         for ( iterator = 0; iterator < context->connectedObjects->len; iterator++ )
       
   148         {
       
   149             GstBin* basebin = NULL;
       
   150             XAAdaptationBaseCtx* bCtx = g_array_index(context->connectedObjects,XAOMixAdaptConnObj,iterator).ctx;
       
   151             if(!bCtx)
       
   152             {
       
   153                 DEBUG_ERR_A1("Context in connected objects array (index %u) is NULL!", iterator);
       
   154                 DEBUG_API("<-XAVolumeItfAdapt_SetVolumeLevel");
       
   155                 return XA_RESULT_INTERNAL_ERROR;
       
   156             }
       
   157 
       
   158             basebin = GST_BIN(bCtx->bin);
       
   159             if(!basebin)
       
   160             {
       
   161                 DEBUG_ERR_A1("Bin in connected objects context (index %u) is NULL!", iterator);
       
   162                 DEBUG_API("<-XAVolumeItfAdapt_SetVolumeLevel");
       
   163                 return XA_RESULT_INTERNAL_ERROR;
       
   164             }
       
   165 
       
   166             audiopp = gst_bin_get_by_name( basebin, "audiopp" );
       
   167             if(audiopp)
       
   168             {
       
   169                 vol = gst_bin_get_by_name( GST_BIN(audiopp), "pp_vol" );
       
   170             }
       
   171             if(vol)
       
   172             {
       
   173                 DEBUG_INFO_A1("Setting gst level to %f",gstVolume);
       
   174                 g_object_set( G_OBJECT(vol), "volume", (gdouble)gstVolume, NULL );
       
   175 
       
   176                 XAVolumeItfAdapt_FlushBin(bCtx);
       
   177             }
       
   178             else
       
   179             {
       
   180                 DEBUG_ERR_A1("Could not find gst volume controller for player %u!!", iterator);
       
   181             }
       
   182         }
       
   183     }
       
   184     DEBUG_API("<-XAVolumeItfAdapt_SetVolumeLevel");
       
   185     return res;
       
   186 }
       
   187 
       
   188 /*
       
   189  * XAresult XAVolumeItfAdapt_GetMaxVolumeLevel(void *ctx, AdaptationContextIDS ctx->ctxId,
       
   190                                             XAmillibel *pMaxLevel)
       
   191  * @param void *ctx - Adaptation context, this will be casted to correct type regarding to contextID value given as 2nd parameter
       
   192  * @param AdaptationContextIDS ctx->ctxId - Type specifier for context, this will be used to cast ctx pointer to correct type.
       
   193  * XAmillibel *pMaxLevel - Maximum volume level
       
   194  * @return XAresult ret - Success value
       
   195  */
       
   196 XAresult XAVolumeItfAdapt_GetMaxVolumeLevel(XAAdaptationBaseCtx *ctx, XAmillibel *pMaxLevel)
       
   197 {
       
   198     DEBUG_API("->XAVolumeItfAdapt_GetMaxVolumeLevel");
       
   199 
       
   200     if(!ctx || ( ctx->ctxId != XAMediaPlayerAdaptation &&
       
   201                  ctx->ctxId != XAMediaRecorderAdaptation &&
       
   202                  ctx->ctxId != XAOutputMixAdaptation) )
       
   203     {
       
   204         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   205         DEBUG_API("<-XAVolumeItfAdapt_GetMaxVolumeLevel");
       
   206         /* invalid parameter */
       
   207         return XA_RESULT_PARAMETER_INVALID;
       
   208     }
       
   209 
       
   210     *pMaxLevel = MAX_SUPPORT_VOLUME_LEVEL;
       
   211 
       
   212     DEBUG_API("<-XAVolumeItfAdapt_GetMaxVolumeLevel");
       
   213 
       
   214     return XA_RESULT_SUCCESS;
       
   215 }
       
   216 
       
   217 /*
       
   218  * XAresult XAVolumeItfAdapt_SetMute(void *ctx, AdaptationContextIDS ctx->ctxId, XAboolean mute)
       
   219  * @param void *ctx - Adaptation context, this will be casted to correct type regarding to contextID value given as 2nd parameter
       
   220  * @param AdaptationContextIDS ctx->ctxId - Type specifier for context, this will be used to cast ctx pointer to correct type.
       
   221  * @param XAboolean mute - status of mute value
       
   222  * @return XAresult ret - Success value
       
   223  */
       
   224 XAresult XAVolumeItfAdapt_SetMute(XAAdaptationBaseCtx *ctx, XAboolean mute)
       
   225 {
       
   226     GstElement *vol=NULL, *audiopp=NULL;
       
   227     gboolean gmute = 0;
       
   228 
       
   229     DEBUG_API("->XAVolumeItfAdapt_SetMute");
       
   230     if(!ctx || ( ctx->ctxId != XAMediaPlayerAdaptation &&
       
   231                  ctx->ctxId != XAMediaRecorderAdaptation &&
       
   232                  ctx->ctxId != XAOutputMixAdaptation ) )
       
   233     {
       
   234         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   235         DEBUG_API("<-XAVolumeItfAdapt_SetMute");
       
   236         /* invalid parameter */
       
   237         return XA_RESULT_PARAMETER_INVALID;
       
   238     }
       
   239 
       
   240     if ( ctx->ctxId == XAMediaPlayerAdaptation )
       
   241     {
       
   242         XAMediaPlayerAdaptationCtx* context = (XAMediaPlayerAdaptationCtx*) ctx;
       
   243         context->mute = mute;
       
   244         audiopp = gst_bin_get_by_name( GST_BIN(context->baseObj.bin), "audiopp" );
       
   245         if(audiopp)
       
   246         {
       
   247             vol = gst_bin_get_by_name( GST_BIN(audiopp), "pp_vol" );
       
   248         }
       
   249         if(vol)
       
   250         {
       
   251             if ( mute )
       
   252             {
       
   253                 gmute = 1;
       
   254             }
       
   255             else
       
   256             {
       
   257                 gmute = 0;
       
   258             }
       
   259             g_object_set( G_OBJECT(vol), "mute", gmute, NULL );
       
   260         }
       
   261         else
       
   262         {
       
   263             DEBUG_ERR("Could not find gst volume controller element!!");
       
   264         }
       
   265     }
       
   266     else if ( ctx->ctxId == XAMediaRecorderAdaptation )
       
   267     {
       
   268         XAMediaRecorderAdaptationCtx* context = (XAMediaRecorderAdaptationCtx*) ctx;
       
   269         context->mute = mute;
       
   270         audiopp = gst_bin_get_by_name( GST_BIN(context->baseObj.bin), "audiopp" );
       
   271         if(audiopp)
       
   272         {
       
   273             vol = gst_bin_get_by_name( GST_BIN(audiopp), "pp_vol" );
       
   274         }
       
   275         if(vol)
       
   276         {
       
   277             if ( mute )
       
   278             {
       
   279                 gmute = 1;
       
   280             }
       
   281             else
       
   282             {
       
   283                 gmute = 0;
       
   284             }
       
   285             g_object_set( G_OBJECT(vol), "mute", gmute, NULL );
       
   286         }
       
   287         else
       
   288         {
       
   289             DEBUG_ERR("Could not find gst volume controller element!!");
       
   290         }
       
   291     }
       
   292     else if ( ctx->ctxId == XAOutputMixAdaptation )
       
   293     {
       
   294         XAOutputMixAdaptationCtx* context = (XAOutputMixAdaptationCtx*) ctx;
       
   295         guint iterator = 0;
       
   296         context->mute = mute;
       
   297         for ( iterator = 0; iterator < context->connectedObjects->len; iterator++ )
       
   298         {
       
   299             GstBin* basebin = NULL;
       
   300             XAAdaptationBaseCtx* bCtx = g_array_index(context->connectedObjects,XAOMixAdaptConnObj,iterator).ctx;
       
   301             if(!bCtx)
       
   302             {
       
   303                 DEBUG_ERR_A1("Context in connected objects array (index %u) is NULL!", iterator);
       
   304                 DEBUG_API("<-XAVolumeItfAdapt_SetMute");
       
   305                 return XA_RESULT_INTERNAL_ERROR;
       
   306             }
       
   307 
       
   308             basebin = GST_BIN(bCtx->bin);
       
   309             if(!basebin)
       
   310             {
       
   311                 DEBUG_ERR_A1("Bin in connected objects context (index %u) is NULL!", iterator);
       
   312                 DEBUG_API("<-XAVolumeItfAdapt_SetMute");
       
   313                 return XA_RESULT_INTERNAL_ERROR;
       
   314             }
       
   315 
       
   316             audiopp = gst_bin_get_by_name( basebin, "audiopp" );
       
   317             if(audiopp)
       
   318             {
       
   319                 vol = gst_bin_get_by_name( GST_BIN(audiopp), "pp_vol" );
       
   320             }
       
   321             if(vol)
       
   322             {
       
   323                 if ( mute )
       
   324                 {
       
   325                     gmute = 1;
       
   326                 }
       
   327                 else
       
   328                 {
       
   329                     gmute = 0;
       
   330                 }
       
   331                 g_object_set( G_OBJECT(vol), "mute", gmute, NULL );
       
   332             }
       
   333             else
       
   334             {
       
   335                 DEBUG_ERR_A1("Could not find gst volume controller for player %u!!", iterator);
       
   336             }
       
   337         }
       
   338     }
       
   339     DEBUG_API("<-XAVolumeItfAdapt_SetMute");
       
   340     return XA_RESULT_SUCCESS;
       
   341 }
       
   342 
       
   343 /*
       
   344  * XAresult XAVolumeItfAdapt_EnableStereoPosition(XAAdaptationBaseCtx *ctx, XAboolean enable)
       
   345  * @param XAAdaptationBaseCtx *ctx - Adaptation context
       
   346  * @param XAboolean enable - Enable Stereo Position
       
   347  * @return XAresult - Success value
       
   348  */
       
   349 XAresult XAVolumeItfAdapt_EnableStereoPosition(XAAdaptationBaseCtx *ctx, XAboolean enable)
       
   350 {
       
   351     DEBUG_API("->XAVolumeItfAdapt_EnableStereoPosition");
       
   352 
       
   353     if(!ctx || ( ctx->ctxId != XAMediaPlayerAdaptation &&
       
   354                  ctx->ctxId != XAMediaRecorderAdaptation &&
       
   355                  ctx->ctxId != XAOutputMixAdaptation ) )
       
   356     {
       
   357         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   358         DEBUG_API("<-XAVolumeItfAdapt_EnableStereoPosition");
       
   359         /* invalid parameter */
       
   360         return XA_RESULT_PARAMETER_INVALID;
       
   361     }
       
   362 
       
   363     if ( ctx->ctxId == XAMediaPlayerAdaptation  )
       
   364     {
       
   365         XAMediaPlayerAdaptationCtx* context = (XAMediaPlayerAdaptationCtx*) ctx;
       
   366         context->isStereoPosition = enable;
       
   367     }
       
   368     else if ( ctx->ctxId == XAMediaRecorderAdaptation  )
       
   369     {
       
   370         XAMediaRecorderAdaptationCtx* context = (XAMediaRecorderAdaptationCtx*) ctx;
       
   371         context->isStereoPosition = enable;
       
   372     }
       
   373     else if ( ctx->ctxId == XAOutputMixAdaptation  )
       
   374     {
       
   375         XAOutputMixAdaptationCtx* context = (XAOutputMixAdaptationCtx*) ctx;
       
   376         context->isStereoPosition = enable;
       
   377     }
       
   378 
       
   379     DEBUG_API("<-XAVolumeItfAdapt_EnableStereoPosition");
       
   380     return XA_RESULT_SUCCESS;
       
   381 }
       
   382 
       
   383 /*
       
   384  * XAresult XAVolumeItfAdapt_SetStereoPosition(XAAdaptationBaseCtx *ctx, XApermille stereoPosition)
       
   385  * @param XAAdaptationBaseCtx *ctx - Adaptation context
       
   386  * @param XApermille stereoPosition - Stereo Position to be set
       
   387  * @return XAresult - Success value
       
   388  */
       
   389 XAresult XAVolumeItfAdapt_SetStereoPosition(XAAdaptationBaseCtx *ctx,
       
   390                                             XApermille stereoPosition)
       
   391 {
       
   392     GstElement *audiopp = NULL, *pan = NULL;
       
   393     gfloat gstPosition = 0.0;
       
   394 
       
   395     DEBUG_API("->XAVolumeItfAdapt_SetStereoPosition");
       
   396     if(!ctx || ( ctx->ctxId != XAMediaPlayerAdaptation &&
       
   397                  ctx->ctxId != XAMediaRecorderAdaptation &&
       
   398                  ctx->ctxId != XAOutputMixAdaptation) )
       
   399     {
       
   400         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   401         DEBUG_API("<-XAVolumeItfAdapt_SetStereoPosition");
       
   402         return XA_RESULT_PARAMETER_INVALID;
       
   403     }
       
   404 
       
   405     gstPosition = ( (gfloat)stereoPosition / STEREO_POSITION_RATIO );
       
   406 
       
   407     if ( ctx->ctxId == XAMediaPlayerAdaptation  )
       
   408     {
       
   409         XAMediaPlayerAdaptationCtx* context = (XAMediaPlayerAdaptationCtx*) ctx;
       
   410 
       
   411         audiopp = gst_bin_get_by_name( GST_BIN(context->baseObj.bin), "audiopp");
       
   412         if( !audiopp )
       
   413         {
       
   414             DEBUG_ERR("XA_RESULT_INTERNAL_ERROR");
       
   415             DEBUG_API("<-XAVolumeItfAdapt_SetStereoPosition");
       
   416             return XA_RESULT_INTERNAL_ERROR;
       
   417         }
       
   418 
       
   419         pan = gst_bin_get_by_name( GST_BIN(audiopp), "pp_pan" );
       
   420         if( !pan )
       
   421         {
       
   422             DEBUG_ERR("XA_RESULT_INTERNAL_ERROR");
       
   423             DEBUG_API("<-XAVolumeItfAdapt_SetStereoPosition");
       
   424             return XA_RESULT_INTERNAL_ERROR;
       
   425         }
       
   426 
       
   427         g_object_set( G_OBJECT(pan), "panorama", gstPosition, NULL );
       
   428 
       
   429         XAVolumeItfAdapt_FlushBin(ctx);
       
   430     }
       
   431     else if ( ctx->ctxId == XAMediaRecorderAdaptation  )
       
   432     {
       
   433         XAMediaRecorderAdaptationCtx* context = (XAMediaRecorderAdaptationCtx*) ctx;
       
   434 
       
   435         audiopp = gst_bin_get_by_name( GST_BIN(context->baseObj.bin), "audiopp");
       
   436         if( !audiopp )
       
   437         {
       
   438             DEBUG_ERR("XA_RESULT_INTERNAL_ERROR");
       
   439             DEBUG_API("<-XAVolumeItfAdapt_SetStereoPosition");
       
   440             return XA_RESULT_INTERNAL_ERROR;
       
   441         }
       
   442 
       
   443         pan = gst_bin_get_by_name( GST_BIN(audiopp), "pp_pan" );
       
   444         if( !pan )
       
   445         {
       
   446             DEBUG_ERR("XA_RESULT_INTERNAL_ERROR");
       
   447             DEBUG_API("<-XAVolumeItfAdapt_SetStereoPosition");
       
   448             return XA_RESULT_INTERNAL_ERROR;
       
   449         }
       
   450 
       
   451         g_object_set( G_OBJECT(pan), "panorama", gstPosition, NULL );
       
   452     }
       
   453 
       
   454     else if ( ctx->ctxId == XAOutputMixAdaptation )
       
   455     {
       
   456         XAOutputMixAdaptationCtx* context = (XAOutputMixAdaptationCtx*) ctx;
       
   457         guint iterator = 0;
       
   458         for ( iterator = 0; iterator < context->connectedObjects->len; iterator++ )
       
   459         {
       
   460             GstBin* basebin = NULL;
       
   461             XAAdaptationBaseCtx* bCtx = g_array_index(context->connectedObjects,XAOMixAdaptConnObj,iterator).ctx;
       
   462             if(!bCtx)
       
   463             {
       
   464                 DEBUG_ERR_A1("Context in connected objects array (index %u) is NULL!", iterator);
       
   465                 return XA_RESULT_INTERNAL_ERROR;
       
   466             }
       
   467 
       
   468             basebin = GST_BIN(bCtx->bin);
       
   469             if(!basebin)
       
   470             {
       
   471                 DEBUG_ERR_A1("Bin in connected objects context (index %u) is NULL!", iterator);
       
   472                 return XA_RESULT_INTERNAL_ERROR;
       
   473             }
       
   474 
       
   475             audiopp = gst_bin_get_by_name( basebin, "audiopp" );
       
   476             if( !audiopp )
       
   477             {
       
   478                 DEBUG_ERR("XA_RESULT_INTERNAL_ERROR");
       
   479                 DEBUG_API("<-XAVolumeItfAdapt_SetStereoPosition");
       
   480                 return XA_RESULT_INTERNAL_ERROR;
       
   481             }
       
   482             pan = gst_bin_get_by_name( GST_BIN(audiopp), "pp_pan" );
       
   483             if( !pan )
       
   484             {
       
   485                 DEBUG_ERR("XA_RESULT_INTERNAL_ERROR");
       
   486                 DEBUG_API("<-XAVolumeItfAdapt_SetStereoPosition");
       
   487                 return XA_RESULT_INTERNAL_ERROR;
       
   488             }
       
   489             g_object_set( G_OBJECT(pan), "panorama", gstPosition, NULL );
       
   490 
       
   491             XAVolumeItfAdapt_FlushBin(bCtx);
       
   492         }
       
   493     }
       
   494 
       
   495     DEBUG_API("<-XAVolumeItfAdapt_SetStereoPosition");
       
   496     return XA_RESULT_SUCCESS;
       
   497 }
       
   498 
       
   499 /*
       
   500  * XAresult XAVolumeItfAdapt_ThreadEntry(XAAdaptationBaseCtx *adapCtx)
       
   501  * Description: Safety thread entry
       
   502  */
       
   503 XAresult XAVolumeItfAdapt_ThreadEntry(XAAdaptationBaseCtx *adaptCtx)
       
   504 {
       
   505     DEBUG_API("->XAVolumeItfAdapt_ThreadEntry");
       
   506     if((!adaptCtx ) ||( adaptCtx->ctxId != XAMediaPlayerAdaptation &&
       
   507                         adaptCtx->ctxId != XAMediaRecorderAdaptation &&
       
   508                         adaptCtx->ctxId != XAOutputMixAdaptation ))
       
   509     {
       
   510         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   511         DEBUG_API("<-XAVolumeItfAdapt_ThreadEntry");
       
   512         /* invalid parameter */
       
   513         return XA_RESULT_PARAMETER_INVALID;
       
   514 
       
   515     }
       
   516 
       
   517     if ( adaptCtx->ctxId == XAMediaPlayerAdaptation )
       
   518     {
       
   519         XA_IMPL_THREAD_SAFETY_ENTRY(XATSMediaPlayer);
       
   520     }
       
   521     else if( adaptCtx->ctxId == XAMediaRecorderAdaptation )
       
   522     {
       
   523         XA_IMPL_THREAD_SAFETY_ENTRY(XATSMediaRecorder);
       
   524     }
       
   525     else if (adaptCtx->ctxId == XAOutputMixAdaptation )
       
   526     {
       
   527         XA_IMPL_THREAD_SAFETY_ENTRY(XATSOutputMix);
       
   528     }
       
   529 
       
   530     DEBUG_API("<-XAVolumeItfAdapt_ThreadEntry");
       
   531     return XA_RESULT_SUCCESS;
       
   532 }
       
   533 /*
       
   534  * XAresult XAVolumeItfAdapt_ThreadExit(XAAdaptationBaseCtx *adaptCtx)
       
   535  * Description: Safety thread exit
       
   536  */
       
   537 XAresult XAVolumeItfAdapt_ThreadExit(XAAdaptationBaseCtx *adaptCtx)
       
   538 {
       
   539     DEBUG_API("->XAVolumeItfAdapt_ThreadExit");
       
   540     if((!adaptCtx ) ||( adaptCtx->ctxId != XAMediaPlayerAdaptation &&
       
   541                         adaptCtx->ctxId != XAMediaRecorderAdaptation &&
       
   542                         adaptCtx->ctxId != XAOutputMixAdaptation ))
       
   543     {
       
   544         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   545         DEBUG_API("<-XAVolumeItfAdapt_ThreadExit");
       
   546         /* invalid parameter */
       
   547         return XA_RESULT_PARAMETER_INVALID;
       
   548 
       
   549     }
       
   550 
       
   551     if ( adaptCtx->ctxId == XAMediaPlayerAdaptation )
       
   552     {
       
   553         XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaPlayer);
       
   554     }
       
   555     else if( adaptCtx->ctxId == XAMediaRecorderAdaptation )
       
   556     {
       
   557         XA_IMPL_THREAD_SAFETY_EXIT(XATSMediaRecorder);
       
   558     }
       
   559     else if (adaptCtx->ctxId == XAOutputMixAdaptation )
       
   560     {
       
   561         XA_IMPL_THREAD_SAFETY_EXIT(XATSOutputMix);
       
   562     }
       
   563 
       
   564     DEBUG_API("<-XAVolumeItfAdapt_ThreadExit");
       
   565     return XA_RESULT_SUCCESS;
       
   566 }