diff -r 9b2c3c7a1a9c -r 567bb019e3e3 gst_plugins_symbian/gst/devsound/devsoundsrcwrapper.cpp --- a/gst_plugins_symbian/gst/devsound/devsoundsrcwrapper.cpp Wed Mar 31 22:03:18 2010 +0300 +++ b/gst_plugins_symbian/gst/devsound/devsoundsrcwrapper.cpp Tue Aug 31 15:30:33 2010 +0300 @@ -27,10 +27,11 @@ DevSoundWrapperSrc::DevSoundWrapperSrc() { - init_complete = 0; + //init_complete = 0; dev_sound = NULL; buffersize = 0; dev_count = 0; + speechbitrate = 0; caps.iRate = EMMFSampleRate8000Hz; caps.iEncoding = EMMFSoundEncoding16BitPCM; caps.iChannels = EMMFMono; @@ -48,15 +49,7 @@ TRACE_PRN_FN_ENT; TRequestStatus* stat = &(AL->iStatus); - if (aError == KErrNone) - { - init_complete = 1; - } - else - { - init_complete = 0; - } - + iCallbackError = aError; User::RequestComplete(stat, aError); TRACE_PRN_FN_EXT; } @@ -74,7 +67,7 @@ void DevSoundWrapperSrc::BufferToBeEmptied(CMMFBuffer* aBuffer) { -// TRACE_PRN_FN_ENT; + TRACE_PRN_FN_ENT; buffer = aBuffer; bufferreadpos = 0; @@ -93,7 +86,7 @@ User::RequestComplete(stat, KErrNotFound); iCallbackError = KErrNotFound; } -// TRACE_PRN_FN_EXT; + TRACE_PRN_FN_EXT; } /********************************************************/ @@ -102,6 +95,16 @@ TRACE_PRN_FN_ENT; TRACE_PRN_N1(_L("DevSoundWrapperSrc::RecordError %d"),aError); iCallbackError = aError; + TRequestStatus* stat = &(AL->iStatus); + /// need to check this, error can occure before and after calling + /// the StartActiveScheduler and might and might not be waiting for + /// completing the request + if( AL->IsActive() ) + { + /// need to complete the request for coming out from blocking call. + User::RequestComplete(stat, aError); + iCallbackError = aError; + } TRACE_PRN_FN_EXT; } /**********************************************************/ @@ -176,45 +179,74 @@ int initialize_devsound(GstDevsoundSrc* ds) { TRACE_PRN_FN_ENT; - int ret = 0; DevSoundWrapperSrc* handle = (DevSoundWrapperSrc*) ds->handle; handle->AL->InitialiseActiveListener(); - TRAP(ret, handle->dev_sound->InitializeL(*handle, handle->fourcc, EMMFStateRecording)); + TRAP(handle->iCallbackError, handle->dev_sound->InitializeL(*handle, handle->fourcc, EMMFStateRecording)); - if (ret) + if ( handle->iCallbackError ) { TRACE_PRN_FN_EXT; - return ret; + return handle->iCallbackError; } handle->AL->StartActiveScheduler(); - if (handle->init_complete == 1) + if (KErrNone == handle->iCallbackError ) { TMMFPrioritySettings temp; temp.iPref = (TMdaPriorityPreference) ds->preference; temp.iPriority = ds->priority; handle->dev_sound->SetPrioritySettings(temp); - SetConfigurations(handle); - ret = KErrNone; + handle->iCallbackError = SetConfigurations(handle); + } + + TRACE_PRN_IF_ERR(handle->iCallbackError); + TRACE_PRN_FN_EXT; + return handle->iCallbackError; + } +/*********************************************************/ + +int stop_devsound(GstDevsoundSrc *ds) + { + TRACE_PRN_FN_ENT; + DevSoundWrapperSrc* handle = (DevSoundWrapperSrc*) ds->handle; + handle->dev_sound->Stop(); + TRACE_PRN_FN_EXT; + return 0; + } + +int pause_devsound(GstDevsoundSrc *ds) + { + TRACE_PRN_FN_ENT; + DevSoundWrapperSrc* handle = (DevSoundWrapperSrc*) ds->handle; + handle->dev_sound->Pause(); + TRACE_PRN_FN_EXT; + return 0; + } + +int resume_devsound(GstDevsoundSrc *ds) + { + TRACE_PRN_FN_ENT; + DevSoundWrapperSrc* handle = (DevSoundWrapperSrc*) ds->handle; + if(handle->dev_sound->IsResumeSupported()) + { + handle->iCallbackError = handle->dev_sound->Resume(); } else { - ret = KErrNotFound; + if( KErrNone == recordinit(handle) ) + initproperties(ds); } - - TRACE_PRN_IF_ERR(ret); TRACE_PRN_FN_EXT; - return ret; + return 0; } -/*********************************************************/ int open_device(DevSoundWrapperSrc **handle) { - int retcode = KErrNone; + (*handle)->iCallbackError = KErrNone; TRACE_PRN_FN_ENT; (*handle)->dev_count++; @@ -233,17 +265,26 @@ (*handle)->AL = new CActiveListener; ((*handle)->AL)->asw = new CActiveSchedulerWait(); - TRAP( retcode,(*handle)->dev_sound = CMMFDevSound::NewL() ); + TRAP( (*handle)->iCallbackError,(*handle)->dev_sound = CMMFDevSound::NewL() ); if (!(*handle)->AL || !((*handle)->AL)->asw || !(*handle)->dev_sound || !(*handle)->as) { - retcode = KErrNoMemory; + return KErrNoMemory; } - + + TRAP((*handle)->iCallbackError ,(*handle)->iAudoInputRecord = CAudioInput::NewL(*(*handle)->dev_sound)); + if ( KErrNone == (*handle)->iCallbackError ) + { + RArray inputArray; + inputArray.Append( CAudioInput::EDefaultMic ); + // Set Audio Input + (*handle)->iAudoInputRecord->SetAudioInputL( inputArray.Array( ) ); + inputArray.Close(); + } TRACE_PRN_FN_EXT; - return retcode; + return (*handle)->iCallbackError; } /*********************************************************/ @@ -251,18 +292,27 @@ int close_devsound(GstDevsoundSrc *ds) { TRACE_PRN_FN_ENT; - (STATIC_CAST(DevSoundWrapperSrc*, ds->handle))->dev_sound->Stop(); + CMMFDevSound *dev_sound= 0; + dev_sound = (STATIC_CAST(DevSoundWrapperSrc*, ds->handle))->dev_sound; + dev_sound->Stop(); g_list_foreach(ds->supportedbitrates, (GFunc) g_free, NULL); g_list_free(ds->supportedbitrates); g_list_foreach(ds->fmt, (GFunc) g_free, NULL); g_list_free(ds->fmt); - + ds->fmt = NULL; + delete (STATIC_CAST(DevSoundWrapperSrc*, ds->handle))->iAudoInputRecord; + delete dev_sound; delete ds->handle; TRACE_PRN_FN_EXT; return 0; } /************************************************************/ +void update_devsound_speech_bitrate(DevSoundWrapperSrc *handle, TUint bitrate) + { + handle->speechbitrate = bitrate; + } +/************************************************************/ int SetConfigurations(DevSoundWrapperSrc *handle) { @@ -275,15 +325,7 @@ handle->gain = (handle->dev_sound)->MaxGain(); (handle->dev_sound)->SetGain(handle->gain); handle->caps.iBufferSize = temp_caps.iBufferSize; - - TRAP(ret, (handle->dev_sound)->SetConfigL(handle->caps) ); - if (ret) - { - return ret; - } - - (handle->caps) = (handle->dev_sound)->Config(); - + switch (handle->fourcc) { case KMccFourCCIdG711: @@ -322,13 +364,33 @@ } } + if (ret) + return ret; + if (!handle->iSpeechEncoderConfig && handle->fourcc != KMMFFourCCCodePCM16) { TRAP(ret, handle->iSpeechEncoderConfig = CSpeechEncoderConfig::NewL(*handle->dev_sound)); + if (ret) + return ret; + + if(handle->speechbitrate > 0) + { + ret = set_speech_encoder_bit_rate(handle,handle->speechbitrate); + if(ret) + return ret; + } } + + TRAP(ret, (handle->dev_sound)->SetConfigL(handle->caps) ); + if (ret) + { + return ret; + } + + (handle->caps) = (handle->dev_sound)->Config(); TRACE_PRN_FN_EXT; return ret; @@ -538,11 +600,13 @@ void set_rate(DevSoundWrapperSrc *handle, int rate) { handle->caps.iRate = rate; + TRACE_PRN_N1(_L("set_rate %d"),rate); } /******************************************************************/ void set_channels(DevSoundWrapperSrc *handle, int channels) { handle->caps.iChannels = channels; + TRACE_PRN_N1(_L("set_channels %d"),channels); } /****************************************************************/ void set_encoding(DevSoundWrapperSrc *handle, int encoding) @@ -557,7 +621,10 @@ /*****************************************************************/ void set_fourcc(DevSoundWrapperSrc *handle, int fourcc) { + TRACE_PRN_FN_ENT; handle->fourcc = fourcc; + TRACE_PRN_N1(_L("set_fourcc %d"),fourcc); + TRACE_PRN_FN_EXT; } /*******************************************************************/ @@ -565,27 +632,18 @@ int recordinit(DevSoundWrapperSrc *handle) { TRACE_PRN_FN_ENT; - int ret = 0; ((handle)->AL)->InitialiseActiveListener(); handle->iCallbackError = KErrNone; - TRAP(ret, (handle->dev_sound)->RecordInitL() ); - - if (ret) - { - TRACE_PRN_FN_EXT; - return ret; - } - ((handle)->AL)->StartActiveScheduler(); + TRAP(handle->iCallbackError, (handle->dev_sound)->RecordInitL() ); - if ((handle->iCallbackError) != KErrNone) + if (!handle->iCallbackError) { - TRACE_PRN_FN_EXT; - return (handle->iCallbackError); + ((handle)->AL)->StartActiveScheduler(); } + TRACE_PRN_FN_EXT; - return KErrNone; - + return handle->iCallbackError; } /*******************************************************************/ @@ -606,9 +664,9 @@ int pre_init_setconf(GstDevsoundSrc *ds) { TRACE_PRN_FN_ENT; - int ret = 0; + DevSoundWrapperSrc* dsPtr = STATIC_CAST(DevSoundWrapperSrc*, ds->handle); - + dsPtr->iCallbackError = KErrNone; // NOTE: it is too late for setting prio/pref here if (ds->pending.preferenceupdate == 1 || ds->pending.priorityupdate == 1) { @@ -625,13 +683,13 @@ == 1) { - TRAP( ret, (dsPtr->dev_sound)->SetRecordBalanceL(ds->leftbalance, + TRAP( dsPtr->iCallbackError, (dsPtr->dev_sound)->SetRecordBalanceL(ds->leftbalance, ds->rightbalance) ); ds->pending.leftbalanceupdate = FALSE; ds->pending.rightbalanceupdate = FALSE; } TRACE_PRN_FN_EXT; - return ret; + return dsPtr->iCallbackError; } /*********************************************************/ void getsupporteddatatypes(GstDevsoundSrc *ds) @@ -689,3 +747,10 @@ TRACE_PRN_FN_EXT; } +int call_back_error(DevSoundWrapperSrc* dsPtr) + { + TRACE_PRN_FN_ENT; + return dsPtr->iCallbackError; + TRACE_PRN_FN_EXT; + } +