Changeset 2504


Ignore:
Timestamp:
Mar 11, 2009 2:52:10 PM (12 years ago)
Author:
nanang
Message:

Fixed Symbian APS auddev that Stop() should wait until initialization completed (if initialization is on progress).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/symb_aps_dev.cpp

    r2502 r2504  
    360360    { 
    361361        STATE_NULL, 
     362        STATE_INITIALIZING, 
    362363        STATE_READY, 
    363         STATE_STREAMING 
     364        STATE_STREAMING, 
     365        STATE_PENDING_STOP 
    364366    }; 
    365367 
     
    482484        iWriteCommQ.Close(); 
    483485    } 
     486     
     487    TRACE_((THIS_FILE, "Sound device destroyed")); 
    484488} 
    485489 
    486490TInt CPjAudioEngine::InitPlayL() 
    487491{ 
    488     if (state_ == STATE_STREAMING || state_ == STATE_READY) 
    489         return 0; 
    490  
    491492    TInt err = iSession.InitializePlayer(iPlaySettings); 
    492493    if (err != KErrNone) { 
     
    518519TInt CPjAudioEngine::InitRecL() 
    519520{ 
    520     if (state_ == STATE_STREAMING || state_ == STATE_READY) 
    521         return 0; 
    522  
    523521    // Initialize input stream device 
    524522    TInt err = iSession.InitializeRecorder(iRecSettings); 
     
    558556        return StartStreamL(); 
    559557 
     558    PJ_ASSERT_RETURN(state_ == STATE_NULL, PJMEDIA_EAUD_INVOP); 
     559     
    560560    // Even if only capturer are opened, playback thread of APS Server need 
    561561    // to be run(?). Since some messages will be delivered via play comm queue. 
     562    state_ = STATE_INITIALIZING; 
     563 
    562564    return InitPlayL(); 
    563565} 
     
    569571        state_ = STATE_READY; 
    570572        TRACE_((THIS_FILE, "Sound device stopped")); 
     573    } else if (state_ == STATE_INITIALIZING) { 
     574        // Initialization is on progress, so let's set the state to  
     575        // STATE_PENDING_STOP to prevent it starting the stream. 
     576        state_ = STATE_PENDING_STOP; 
     577         
     578        // Then wait until initialization done. 
     579        while (state_ != STATE_READY) 
     580            pj_symbianos_poll(-1, 100); 
    571581    } 
    572582} 
     
    596606TInt CPjAudioEngine::StartStreamL() 
    597607{ 
    598     if (state_ == STATE_STREAMING) 
    599         return 0; 
    600  
     608    pj_assert(state_==STATE_READY || state_==STATE_INITIALIZING);  
     609     
    601610    iSession.SetCng(setting_.cng); 
    602611    iSession.SetVadMode(setting_.vad); 
     
    619628 
    620629    state_ = STATE_STREAMING; 
     630     
    621631    return 0; 
    622632} 
     
    626636    TRACE_((THIS_FILE, "Recorder initialized, err=%d", aStatus)); 
    627637 
    628     state_ = STATE_READY; 
    629638    if (aStatus == KErrNone) { 
    630         StartStreamL(); 
     639        // Don't start the stream since Stop() has been requested.  
     640        if (state_ != STATE_PENDING_STOP) { 
     641            StartStreamL(); 
     642        } else { 
     643            state_ = STATE_READY; 
     644        } 
    631645    } 
    632646} 
     
    638652    if (aStatus == KErrNone) { 
    639653        if (parentStrm_->param.dir == PJMEDIA_DIR_PLAYBACK) { 
    640             state_ = STATE_READY; 
    641             // Only playback, start directly 
    642             StartStreamL(); 
     654            // Don't start the stream since Stop() has been requested. 
     655            if (state_ != STATE_PENDING_STOP) { 
     656                StartStreamL(); 
     657            } else { 
     658                state_ = STATE_READY; 
     659            } 
    643660        } else 
    644661            InitRecL(); 
Note: See TracChangeset for help on using the changeset viewer.