Changeset 3748 for pjproject


Ignore:
Timestamp:
Sep 9, 2011 9:51:10 AM (13 years ago)
Author:
nanang
Message:

More Symbian MDA fixes (re #1365):

  • Added config setting to control sync/async start. Due to problem with async start: any volume query performed immediately after starting the device will always return zero.
  • Fixed get_default_param() to set the flags to zero (was copied from caps, i.e: input/output volume flags without setting the value).
  • Fixed stream_get_param() to also check the input and output volume level.
Location:
pjproject/branches/1.x/pjmedia
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/1.x/pjmedia/include/pjmedia-audiodev/config.h

    r3553 r3748  
    146146 
    147147/** 
     148 * This setting controls whether the Symbian audio with built-in multimedia 
     149 * framework backend should be started synchronously. Note that synchronous 
     150 * start will block the application/UI, e.g: about 40ms for each direction 
     151 * on N95. While asynchronous start may cause invalid value (always zero) 
     152 * returned in input/output volume query, if the query is performed when 
     153 * the internal start procedure is not completely finished. 
     154 *  
     155 * Default: 1 (yes) 
     156 */ 
     157#ifndef PJMEDIA_AUDIO_DEV_MDA_USE_SYNC_START 
     158#   define PJMEDIA_AUDIO_DEV_MDA_USE_SYNC_START 1 
     159#endif 
     160 
     161 
     162/** 
    148163 * This setting controls whether the Audio Device API should support 
    149164 * device implementation that is based on the old sound device API 
  • pjproject/branches/1.x/pjmedia/src/pjmedia-audiodev/symb_mda_dev.cpp

    r3744 r3748  
    240240    TInt                     lastError_; 
    241241    pj_uint32_t              timeStamp_; 
     242    CActiveSchedulerWait     startAsw_; 
    242243 
    243244    // cache variable 
     
    364365    iInputStream_->Open(&iStreamSettings); 
    365366     
     367#if defined(PJMEDIA_AUDIO_DEV_MDA_USE_SYNC_START) && \ 
     368    PJMEDIA_AUDIO_DEV_MDA_USE_SYNC_START != 0 
     369     
     370    startAsw_.Start(); 
     371     
     372#endif 
     373     
    366374    // Success 
    367375    PJ_LOG(4,(THIS_FILE, "Sound capture started.")); 
     
    387395    } 
    388396     
     397    if (startAsw_.IsStarted()) { 
     398        startAsw_.AsyncStop(); 
     399    } 
     400     
    389401    state_ = STATE_INACTIVE; 
    390402} 
     
    400412void CPjAudioInputEngine::MaiscOpenComplete(TInt aError) 
    401413{ 
     414    if (startAsw_.IsStarted()) { 
     415        startAsw_.AsyncStop(); 
     416    } 
     417     
    402418    lastError_ = aError; 
    403419    if (aError != KErrNone) { 
     
    406422    } 
    407423 
    408     /* Apply output volume setting if specified */ 
     424    /* Apply input volume setting if specified */ 
    409425    if (parentStrm_->param.flags &  
    410426        PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING)  
     
    424440    if (err2) { 
    425441        PJ_LOG(4,(THIS_FILE, "Exception in iInputStream_->ReadL()")); 
    426     } 
     442        lastError_ = err2; 
     443        return; 
     444    } 
     445 
     446    // input stream opened succesfully, set status to Active 
     447    state_ = STATE_ACTIVE; 
    427448} 
    428449 
     
    557578    TInt                     lastError_; 
    558579    unsigned                 timestamp_; 
     580    CActiveSchedulerWait     startAsw_; 
    559581 
    560582    CPjAudioOutputEngine(struct mda_stream *parent_strm, 
     
    648670    lastError_ = KRequestPending; 
    649671    iOutputStream_->Open(&iStreamSettings); 
     672     
     673#if defined(PJMEDIA_AUDIO_DEV_MDA_USE_SYNC_START) && \ 
     674    PJMEDIA_AUDIO_DEV_MDA_USE_SYNC_START != 0 
     675     
     676    startAsw_.Start(); 
     677     
     678#endif 
    650679 
    651680    // Success 
     
    672701    } 
    673702     
     703    if (startAsw_.IsStarted()) { 
     704        startAsw_.AsyncStop(); 
     705    } 
     706     
    674707    state_ = STATE_INACTIVE; 
    675708} 
     
    677710void CPjAudioOutputEngine::MaoscOpenComplete(TInt aError) 
    678711{ 
     712    if (startAsw_.IsStarted()) { 
     713        startAsw_.AsyncStop(); 
     714    } 
     715 
    679716    lastError_ = aError; 
    680717     
    681718    if (aError==KErrNone) { 
    682         // output stream opened succesfully, set status to Active 
    683         state_ = STATE_ACTIVE; 
    684  
    685719        // set stream properties, 16bit 8KHz mono 
    686720        TMdaAudioDataSettings iSettings; 
     
    737771        frame_.Set(frameBuf_, frameBufSize_); 
    738772        iOutputStream_->WriteL(frame_); 
     773 
     774        // output stream opened succesfully, set status to Active 
     775        state_ = STATE_ACTIVE; 
    739776    } else { 
    740777        snd_perror("Error in MaoscOpenComplete()", aError); 
     
    900937    param->samples_per_frame = af->dev_info.default_samples_per_sec * 20 / 1000; 
    901938    param->bits_per_sample = BITS_PER_SAMPLE; 
    902     param->flags = af->dev_info.caps; 
     939    // Don't set the flags without specifying the flags value. 
     940    //param->flags = af->dev_info.caps; 
    903941 
    904942    return PJ_SUCCESS; 
     
    9741012 
    9751013    pj_memcpy(pi, &strm->param, sizeof(*pi)); 
     1014     
     1015    /* Update the output volume setting */ 
     1016    if (stream_get_cap(s, PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING, 
     1017                       &pi->output_vol) == PJ_SUCCESS) 
     1018    { 
     1019        pi->flags |= PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING; 
     1020    } 
     1021     
     1022    /* Update the input volume setting */ 
     1023    if (stream_get_cap(s, PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING, 
     1024                       &pi->input_vol) == PJ_SUCCESS) 
     1025    { 
     1026        pi->flags |= PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING; 
     1027    } 
    9761028     
    9771029    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.