mmserv/radioutility/radioserver/Server/Src/RadioServer.cpp
changeset 12 5a06f39ad45b
parent 0 71ca22bcf22a
child 14 80975da52420
equal deleted inserted replaced
0:71ca22bcf22a 12:5a06f39ad45b
    18 
    18 
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include    <mmf/common/mmfstandardcustomcommands.h>
    21 #include    <mmf/common/mmfstandardcustomcommands.h>
    22 #include    <centralrepository.h>
    22 #include    <centralrepository.h>
    23 #include    <coreapplicationuissdkcrkeys.h>
    23 #include    <CoreApplicationUIsSDKCRKeys.h>
    24 #include    <audiopreference.h>
    24 #include    <AudioPreference.h>
    25 
    25 
    26 #include    "RadioServer.h"
    26 #include    "RadioServer.h"
    27 #include    "RadioServerSession.h"
    27 #include    "RadioServerSession.h"
    28 #include    "RadioServerShutdown.h"
    28 #include    "RadioServerShutdown.h"
    29 #include    "RadioServerSettings.h"
    29 #include    "RadioServerSettings.h"
    30 #include    "RadioServerFmTuner.h"
    30 #include    "RadioServerFMTuner.h"
    31 #include    "RadioDebug.h"
    31 #include    "RadioDebug.h"
    32 
    32 
    33 // CONSTANTS
    33 // CONSTANTS
    34 const TInt KFMDefaultFreq           = 87500000; // 87.5 MHz
    34 const TInt KFMDefaultFreq           = 87500000; // 87.5 MHz
    35 const TInt KJapaneseFMDefaultFreq   = 76000000; // 76.0 MHz
    35 const TInt KJapaneseFMDefaultFreq   = 76000000; // 76.0 MHz
    68         iSyncRequestQue(_FOFF( TRadioMessageRequestData, iLink )),
    68         iSyncRequestQue(_FOFF( TRadioMessageRequestData, iLink )),
    69         iSyncRequest(NULL),
    69         iSyncRequest(NULL),
    70         iMaxSigStrength(0),
    70         iMaxSigStrength(0),
    71         iEnableTunerInOffline(EFalse),
    71         iEnableTunerInOffline(EFalse),
    72         iSquelch(EFalse),
    72         iSquelch(EFalse),
    73         iPreEmpted(EFalse)
    73         iPreEmpted(EFalse),
       
    74         iSchedulerWait( NULL )
    74     {
    75     {
    75     }
    76     }
    76 
    77 
    77 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    78 // CRadioServer::ConstructL
    79 // CRadioServer::ConstructL
   125     iShutdownTimer->Start();
   126     iShutdownTimer->Start();
   126 #ifdef RD_TSP_CLIENT_MAPPER
   127 #ifdef RD_TSP_CLIENT_MAPPER
   127     iMapper = CTspClientMapper::NewL();
   128     iMapper = CTspClientMapper::NewL();
   128     iTspState = CTspClientMapper::ERegisteredClients;
   129     iTspState = CTspClientMapper::ERegisteredClients;
   129 #endif // RD_TSP_CLIENT_MAPPER
   130 #endif // RD_TSP_CLIENT_MAPPER
       
   131     
       
   132     iSchedulerWait  = new (ELeave) CActiveSchedulerWait;
   130 
   133 
   131     RADIO_RDEBUG(_L("[RADIO-SVR] ConstructL() - End"));
   134     RADIO_RDEBUG(_L("[RADIO-SVR] ConstructL() - End"));
   132     }
   135     }
   133 
   136 
   134 // -----------------------------------------------------------------------------
   137 // -----------------------------------------------------------------------------
   164     delete iDevSound;
   167     delete iDevSound;
   165     delete iSettings;
   168     delete iSettings;
   166     delete iTunerControl;
   169     delete iTunerControl;
   167     delete iTunerControlObserver;
   170     delete iTunerControlObserver;
   168     delete iAsyncRequest;
   171     delete iAsyncRequest;
       
   172     delete iSchedulerWait;
   169 
   173 
   170     ClearQueue();
   174     ClearQueue();
   171     iRdsNotifyClientIdArray.Close();
   175     iRdsNotifyClientIdArray.Close();
   172 
   176 
   173 #ifdef RD_TSP_CLIENT_MAPPER
   177 #ifdef RD_TSP_CLIENT_MAPPER
   617                 // Make sure a new session hasn't been started while TunerOff was being processed
   621                 // Make sure a new session hasn't been started while TunerOff was being processed
   618                 iShutdownTimer->Start();
   622                 iShutdownTimer->Start();
   619                 }
   623                 }
   620             break;
   624             break;
   621         case EStateTunerOff:
   625         case EStateTunerOff:
       
   626             if( iSchedulerWait->IsStarted() )
       
   627                 {
       
   628                 // let the PlayError() continue after this callback
       
   629                 iSchedulerWait->AsyncStop();
       
   630                 }
   622             if ( iAsyncRequest && iAsyncRequest->iType == ERadioServSetFrequencyRange )
   631             if ( iAsyncRequest && iAsyncRequest->iType == ERadioServSetFrequencyRange )
   623                 {
   632                 {
   624                 if ( aError == KErrNone )
   633                 if ( aError == KErrNone )
   625                     {
   634                     {
   626                     RADIO_RDEBUG(_L("[RADIO-SVR] TunerOffComplete() - Tuner ON"));
   635                     RADIO_RDEBUG(_L("[RADIO-SVR] TunerOffComplete() - Tuner ON"));
   635                     iTunerControl->TunerOn(freqRange, freq);
   644                     iTunerControl->TunerOn(freqRange, freq);
   636                     }
   645                     }
   637                 else
   646                 else
   638                     {
   647                     {
   639                     CompleteAsyncRequest(aError);
   648                     CompleteAsyncRequest(aError);
       
   649                     }
       
   650                 }
       
   651             else
       
   652                 {
       
   653                 if( aError == KRadioServErrDuplicateRequest )
       
   654                     {
       
   655                     // tuner off and duplicate request going on, trace it out
       
   656                     RADIO_RDEBUG(_L("[RADIO-SVR] TunerOffComplete() - EStateTunerOff - KRadioServErrDuplicateRequest"));
   640                     }
   657                     }
   641                 }
   658                 }
   642             break;
   659             break;
   643         default:
   660         default:
   644             // should never happen
   661             // should never happen
  1385                 {
  1402                 {
  1386                 // Restore the last volume
  1403                 // Restore the last volume
  1387                 iDevSound->SetVolume(iSettings->Volume());
  1404                 iDevSound->SetVolume(iSettings->Volume());
  1388                 iSquelch = EFalse;
  1405                 iSquelch = EFalse;
  1389                 }
  1406                 }
  1390             CompleteAsyncRequest(KRadioServErrTuning);
  1407             // do not yet complete async request with KRadioServErrTuning
  1391             }
  1408             }
  1392 
  1409 
  1393         // We are being pre-empted by another application with higher priority.
  1410         // We are being pre-empted by another application with higher priority.
  1394         // Turn the tuner off also to prevent interference + power saving.
  1411         // Turn the tuner off also to prevent interference + power saving.
  1395         iState = EStateTunerOff;
  1412         iState = EStateTunerOff;
  1396         iPreEmpted = ETrue;
  1413         iPreEmpted = ETrue;
  1397         iSettings->SetRadioOff(aError);
  1414         iSettings->SetRadioOff(aError);
  1398         iTunerControl->TunerOff();
  1415         iTunerControl->TunerOff();		//The adaptation is expected to call TunerOffComplete() upon completion
       
  1416         // wait for TunerOffComplete callback
       
  1417         iSchedulerWait->Start();
  1399         SetTspTargetClient( ERsPlayerIdle );
  1418         SetTspTargetClient( ERsPlayerIdle );
       
  1419         
       
  1420         if ( iAsyncRequest && ( (iAsyncRequest->iType == ERadioServStationSeek) ||
       
  1421                                 (iAsyncRequest->iType == ERadioServStationSeekByPTY) ||
       
  1422                                 (iAsyncRequest->iType == ERadioServStationSeekByTA) ||
       
  1423                                 (iAsyncRequest->iType == ERadioServStationSeekByTP) ) )
       
  1424             {
       
  1425             CompleteAsyncRequest(KRadioServErrTuning);
       
  1426             }
  1400         }
  1427         }
  1401     }
  1428     }
  1402 
  1429 
  1403 // -----------------------------------------------------------------------------
  1430 // -----------------------------------------------------------------------------
  1404 // CRadioServer::BufferToBeEmptied (From MDevSoundObserver)
  1431 // CRadioServer::BufferToBeEmptied (From MDevSoundObserver)
  1899         {
  1926         {
  1900         if ( aIfOnlyPrimaryClient && (iSessionCountPrimary > 1) )
  1927         if ( aIfOnlyPrimaryClient && (iSessionCountPrimary > 1) )
  1901             {
  1928             {
  1902             // Client has requested stop only if the requesting client is the only primary client.
  1929             // Client has requested stop only if the requesting client is the only primary client.
  1903             // There are other clients, so don't stop the audio in this case.
  1930             // There are other clients, so don't stop the audio in this case.
       
  1931             CompleteAsyncRequest(KErrNone);         //the request needs to be completed though 
  1904             return;
  1932             return;
  1905             }
  1933             }
  1906         iState = EStateTunerOn;
  1934         iState = EStateTunerOn;
  1907         // Stop ongoing playback. This is synchronous function.
  1935         // Stop ongoing playback. This is synchronous function.
  1908         iDevSound->Stop();
  1936         iDevSound->Stop();