gst_plugins_symbian/gst/devsound/devsoundsinkwrapper.cpp
branchRCL_3
changeset 29 567bb019e3e3
parent 2 5505e8908944
child 30 7e817e7e631c
equal deleted inserted replaced
6:9b2c3c7a1a9c 29:567bb019e3e3
    40     iG711DecoderIntfc = NULL;
    40     iG711DecoderIntfc = NULL;
    41     iG729DecoderIntfc = NULL;
    41     iG729DecoderIntfc = NULL;
    42     iIlbcDecoderIntfc = NULL;
    42     iIlbcDecoderIntfc = NULL;
    43     iCallbackError = KErrNone;
    43     iCallbackError = KErrNone;
    44     iAudioOutput = NULL;
    44     iAudioOutput = NULL;
       
    45     iIsBufferToBeFilledDone = TRUE;
    45     }
    46     }
    46 
    47 
    47 /*********************************************************/
    48 /*********************************************************/
    48 void DevSoundWrapper::InitializeComplete(TInt aError)
    49 void DevSoundWrapper::InitializeComplete(TInt aError)
    49     {
    50     {
    76 
    77 
    77     if (aBuffer)
    78     if (aBuffer)
    78         {
    79         {
    79         User::RequestComplete(stat, KErrNone);
    80         User::RequestComplete(stat, KErrNone);
    80         iCallbackError = KErrNone;
    81         iCallbackError = KErrNone;
       
    82         iIsBufferToBeFilledDone = FALSE;
    81         }
    83         }
    82     else
    84     else
    83         {
    85         {
    84         User::RequestComplete(stat, KErrNotFound);
    86         User::RequestComplete(stat, KErrNotFound);
    85         iCallbackError = KErrNotFound;
    87         iCallbackError = KErrNotFound;
    91 /***********************************************************/
    93 /***********************************************************/
    92 void DevSoundWrapper::PlayError(TInt aError)
    94 void DevSoundWrapper::PlayError(TInt aError)
    93     {
    95     {
    94     TRequestStatus* stat = &(AL->iStatus);
    96     TRequestStatus* stat = &(AL->iStatus);
    95     User::RequestComplete(stat, aError);
    97     User::RequestComplete(stat, aError);
    96     iCallbackError = aError;
    98     iCallbackError = 0;
    97     }
    99     }
    98 /*******************************************************/
   100 /*******************************************************/
    99 void DevSoundWrapper::BufferToBeEmptied(CMMFBuffer* /*aBuffer*/)
   101 void DevSoundWrapper::BufferToBeEmptied(CMMFBuffer* /*aBuffer*/)
   100     {
   102     {
   101 
   103 
   242     return ret;
   244     return ret;
   243     }
   245     }
   244 
   246 
   245 /************************************************************/
   247 /************************************************************/
   246 
   248 
       
   249 int pause_devsound(GstDevsoundSink *ds)
       
   250     {
       
   251     TRACE_PRN_FN_ENT;
       
   252     DevSoundWrapper* handle = (DevSoundWrapper*) ds->handle;
       
   253     if(handle->dev_sound->IsResumeSupported())
       
   254         {
       
   255         handle->dev_sound->Pause();
       
   256         }
       
   257     else
       
   258         {
       
   259         handle->iSamplesPlayed = handle->dev_sound->SamplesPlayed();
       
   260         handle->dev_sound->Stop();
       
   261         }
       
   262     TRACE_PRN_FN_EXT;
       
   263     return 0;
       
   264     }
       
   265 
       
   266 int resume_devsound(GstDevsoundSink *ds)
       
   267     {
       
   268     TRACE_PRN_FN_ENT;
       
   269     DevSoundWrapper* handle = (DevSoundWrapper*) ds->handle;
       
   270     if(handle->dev_sound->IsResumeSupported())
       
   271         {
       
   272         handle->dev_sound->Resume();
       
   273         }
       
   274     else
       
   275         {
       
   276         playinit(handle);
       
   277         initproperties(ds);
       
   278         }
       
   279     TRACE_PRN_FN_EXT;
       
   280     return 0;
       
   281     }
       
   282 
       
   283 
   247 int close_devsound(GstDevsoundSink *ds)
   284 int close_devsound(GstDevsoundSink *ds)
   248     {
   285     {
   249     TRACE_PRN_FN_ENT;
   286     TRACE_PRN_FN_ENT;
       
   287     CMMFDevSound    *dev_sound = 0;
       
   288     dev_sound = (STATIC_CAST(DevSoundWrapper*, ds->handle))->dev_sound;
       
   289     dev_sound->Stop();
       
   290     delete dev_sound;
   250 
   291 
   251     g_list_foreach(ds->fmt, (GFunc) g_free, NULL);
   292     g_list_foreach(ds->fmt, (GFunc) g_free, NULL);
   252     g_list_free(ds->fmt);
   293     g_list_free(ds->fmt);
   253     ds->fmt = NULL;
   294     ds->fmt = NULL;
   254     delete ds->handle;
   295     delete ds->handle;
   558 
   599 
   559 int get_ds_cb_error(DevSoundWrapper *handle)
   600 int get_ds_cb_error(DevSoundWrapper *handle)
   560     {
   601     {
   561     return handle->iCallbackError;
   602     return handle->iCallbackError;
   562     }
   603     }
       
   604 
       
   605 #ifdef AV_SYNC
       
   606 gboolean  is_timeplayed_supported(DevSoundWrapper *handle)
       
   607     {
       
   608     gboolean retVal = FALSE;
       
   609     if (handle->dev_sound && (handle->dev_sound)->IsGetTimePlayedSupported())
       
   610         {
       
   611         retVal = TRUE;
       
   612         }
       
   613     return retVal;
       
   614     }
       
   615 #endif /*AV_SYNC*/
       
   616 
   563 /*******************************************************************/
   617 /*******************************************************************/
   564 
   618 
   565 int playinit(DevSoundWrapper *handle)
   619 int playinit(DevSoundWrapper *handle)
   566     {
   620     {
   567     TRACE_PRN_FN_ENT;
   621     TRACE_PRN_FN_ENT;
   568 
   622     handle->iCallbackError = KErrNone;
   569     ((handle)->AL)->InitialiseActiveListener();
   623     if( handle->iIsBufferToBeFilledDone )
   570     handle->eosReceived = false;
   624     {
   571 
   625         ((handle)->AL)->InitialiseActiveListener();
       
   626         handle->eosReceived = false;
       
   627     
   572         TRAP(handle->iCallbackError,(handle->dev_sound)->PlayInitL());
   628         TRAP(handle->iCallbackError,(handle->dev_sound)->PlayInitL());
   573     if (handle->iCallbackError == KErrNone)
   629         if (handle->iCallbackError == KErrNone)
   574         {
   630             {
   575         ((handle)->AL)->StartActiveScheduler();
   631             ((handle)->AL)->StartActiveScheduler();
   576         }
   632             }    
       
   633     }
       
   634 
   577 
   635 
   578     TRACE_PRN_IF_ERR(handle->iCallbackError);
   636     TRACE_PRN_IF_ERR(handle->iCallbackError);
   579     TRACE_PRN_FN_EXT;
   637     TRACE_PRN_FN_EXT;
   580     return handle->iCallbackError;
   638     return handle->iCallbackError;
   581     }
   639     }
   629     (handle->AL)->InitialiseActiveListener();
   687     (handle->AL)->InitialiseActiveListener();
   630 
   688 
   631     (handle->dev_sound)->PlayData();
   689     (handle->dev_sound)->PlayData();
   632 
   690 
   633     ((handle)->AL)->StartActiveScheduler();
   691     ((handle)->AL)->StartActiveScheduler();
   634 
   692     handle->iIsBufferToBeFilledDone = TRUE;
   635     TRACE_PRN_FN_EXT;
   693     TRACE_PRN_FN_EXT;
   636     return KErrNone;
   694     return KErrNone;
   637     }
   695     }
   638 
   696 
   639 /*********************************************************************/
   697 /*********************************************************************/
   713 /*********************************************************/
   771 /*********************************************************/
   714 void populateproperties(GstDevsoundSink *ds)
   772 void populateproperties(GstDevsoundSink *ds)
   715     {
   773     {
   716     TRACE_PRN_FN_ENT;
   774     TRACE_PRN_FN_ENT;
   717     DevSoundWrapper* dsPtr = STATIC_CAST(DevSoundWrapper*, ds->handle);
   775     DevSoundWrapper* dsPtr = STATIC_CAST(DevSoundWrapper*, ds->handle);
   718     ds->samplesplayed = (dsPtr->dev_sound)->SamplesPlayed();
   776 #ifdef AV_SYNC
       
   777     if (dsPtr->dev_sound->IsGetTimePlayedSupported())
       
   778         {
       
   779         TTimeIntervalMicroSeconds timePlayedInMS = 0;
       
   780         (dsPtr->dev_sound)->GetTimePlayed(timePlayedInMS);
       
   781         /* store value in nano seconds */
       
   782         ds->time_or_samples_played = timePlayedInMS.Int64() * 1000;
       
   783         }
       
   784     else
       
   785         {
       
   786         ds->time_or_samples_played += (dsPtr->dev_sound)->SamplesPlayed();
       
   787         }
       
   788 #endif /*AV_SYNC*/
   719     get_outputdevice(dsPtr,&ds->output);
   789     get_outputdevice(dsPtr,&ds->output);
   720     TRACE_PRN_FN_EXT;
   790     TRACE_PRN_FN_EXT;
   721     }
   791     }
   722 
   792 
   723 void initproperties(GstDevsoundSink* ds)
   793 void initproperties(GstDevsoundSink* ds)
   724     {
   794     {
   725     TRACE_PRN_FN_ENT;
   795     TRACE_PRN_FN_ENT;
   726     DevSoundWrapper* dsPtr=  STATIC_CAST(DevSoundWrapper*, ds->handle);
   796     DevSoundWrapper* dsPtr=  STATIC_CAST(DevSoundWrapper*, ds->handle);
   727     ds->maxvolume     = (dsPtr->dev_sound)->MaxVolume();
   797     ds->maxvolume     = (dsPtr->dev_sound)->MaxVolume();
   728     ds->volume        = (dsPtr->dev_sound)->Volume();
   798     ds->volume        = (dsPtr->dev_sound)->Volume();    
   729     framemode_rqrd_for_ec(dsPtr,&ds->framemodereq);   
       
   730     get_cng(dsPtr,&ds->g711cng);
       
   731     get_ilbccng(dsPtr,&ds->ilbccng);
       
   732     TRACE_PRN_FN_EXT;    
   799     TRACE_PRN_FN_EXT;    
   733     }
   800     }