khronosfws/openmax_al/src/mmf_adaptation/cmmfradiobackendengine.cpp
changeset 52 4ce423f34688
parent 47 c2e43643db4c
child 55 e267340986c9
equal deleted inserted replaced
47:c2e43643db4c 52:4ce423f34688
    17 
    17 
    18 #include "cmmfradiobackendengine.h"
    18 #include "cmmfradiobackendengine.h"
    19 
    19 
    20 extern "C" {
    20 extern "C" {
    21 #include "xaradioitfadaptation.h"
    21 #include "xaradioitfadaptation.h"
    22 #include "xanokiavolumeextitfadaptationmmf.h"
    22 #include "xaadaptationmmf.h"
    23 #include "xanokialinearvolumeitfadaptationmmf.h"
    23 #include "xaadptbasectx.h"
    24 #include "xaplayitfadaptationmmf.h"
       
    25 }
    24 }
    26 
    25 
    27 CMMFRadioBackendEngine *CMMFRadioBackendEngine::s_instance = 0;
    26 CMMFRadioBackendEngine *CMMFRadioBackendEngine::s_instance = 0;
    28 
    27 
    29 CMMFRadioBackendEngine* CMMFRadioBackendEngine::Instance()
    28 CMMFRadioBackendEngine* CMMFRadioBackendEngine::Instance()
    40 }
    39 }
    41 
    40 
    42 void CMMFRadioBackendEngine::DeleteInstance()
    41 void CMMFRadioBackendEngine::DeleteInstance()
    43 {
    42 {
    44     if (iFmTunerUtility)
    43     if (iFmTunerUtility)
    45   {
    44     {
    46     iFmTunerUtility->Close();
    45         iFmTunerUtility->Close();
    47     iFmTunerUtility = NULL;
    46         iFmTunerUtility = NULL;
    48   }
    47     }
    49   if (iRadioPlayerUtility)
    48     if (iRadioPlayerUtility)
    50   {
    49     {
    51     iRadioPlayerUtility->Close();
    50         iRadioPlayerUtility->Close();
    52     iRadioPlayerUtility = NULL;
    51         iRadioPlayerUtility = NULL;
    53   }
    52     }
    54 
    53 
    55   if (iRadioUtility)
    54     if (iRadioUtility)
    56   {
    55     {
    57         delete iRadioUtility;
    56         delete iRadioUtility;
    58         iRadioUtility = NULL;
    57         iRadioUtility = NULL;
    59     }
    58     }
    60 
       
    61 }
    59 }
    62 
    60 
    63 CMMFRadioBackendEngine::~CMMFRadioBackendEngine()
    61 CMMFRadioBackendEngine::~CMMFRadioBackendEngine()
    64 {
    62 {
    65 }
    63 }
    77         iFmTunerUtility = &iRadioUtility->RadioFmTunerUtilityL( *this );
    75         iFmTunerUtility = &iRadioUtility->RadioFmTunerUtilityL( *this );
    78     }
    76     }
    79     if (iFmTunerUtility)
    77     if (iFmTunerUtility)
    80     {
    78     {
    81         iFmTunerUtility->EnableTunerInOfflineMode( ETrue );
    79         iFmTunerUtility->EnableTunerInOfflineMode( ETrue );
    82         iFmTunerUtility->RequestTunerControl();
    80         iFmTunerUtility->RequestTunerControl();  
    83     }
    81     }
    84   if (iRadioUtility)
    82     if (iRadioUtility)
    85   {
    83     {
    86         iRadioPlayerUtility = &iRadioUtility->RadioPlayerUtilityL( *this );
    84         iRadioPlayerUtility = &iRadioUtility->RadioPlayerUtilityL( *this );
    87     }
    85     }
    88 
    86 
    89     SetForceMonoFlag();
    87     SetForceMonoFlag();
    90     iDefaultFrequency = RADIO_DEFAULT_FREQ;
    88     iDefaultFrequency = RADIO_DEFAULT_FREQ;
    91     iDefaultFreqRange = (TFmRadioFrequencyRange)RADIO_DEFAULT_FREQ_RANGE;
    89     iDefaultFreqRange = (TFmRadioFrequencyRange)RADIO_DEFAULT_FREQ_RANGE;
    92     iDefaultMinFreq = RADIO_DEFAULT_MIN_FREQ;
    90     iDefaultMinFreq = RADIO_DEFAULT_MIN_FREQ;
    93     iDefaultMaxFreq = RADIO_DEFAULT_MAX_FREQ;
    91     iDefaultMaxFreq = RADIO_DEFAULT_MAX_FREQ;
    94 
    92 
    95 }
    93     iAdaptContext = (XAAdaptationBaseCtx*)CMMFRadioBackendEngine::Instance();
    96 void CMMFRadioBackendEngine::StationSeek(XAboolean aUpwards)
    94 
    97 {
    95 }
    98     if (iFmTunerUtility)
    96 void CMMFRadioBackendEngine::StationSeek(TBool aUpwards)
    99     {
    97 {
   100     iFmTunerUtility->StationSeek(aUpwards);
    98     if (iFmTunerUtility)
       
    99     {
       
   100         iFmTunerUtility->StationSeek(aUpwards);
   101     }
   101     }
   102 }
   102 }
   103 
   103 
   104 void CMMFRadioBackendEngine::SetFrequency(TInt aFreq)
   104 void CMMFRadioBackendEngine::SetFrequency(TInt aFreq)
   105 {
   105 {
   106   DEBUG_API_A1("CMMFRadioBackendEngine::SetFrequency: %d", aFreq);
   106 //  DEBUG_CPP_API_A1("CMMFRadioBackendEngine::SetFrequency: %d", aFreq);
   107 
   107 
   108     if (iFmTunerUtility)
   108     if (iFmTunerUtility)
   109     {
   109     {
   110     iFmTunerUtility->SetFrequency(aFreq);
   110         iFmTunerUtility->SetFrequency(aFreq);
   111     }
   111     }
   112 }
   112 }
   113 
   113 
   114 TInt CMMFRadioBackendEngine::GetFrequency(TInt& aFreq)
   114 TInt CMMFRadioBackendEngine::GetFrequency(TInt& aFreq)
   115 {
   115 {
   116   DEBUG_API("CMMFRadioBackendEngine::GetFrequency");
   116 //    DEBUG_CPP_API("CMMFRadioBackendEngine::GetFrequency");
   117     TInt ret = KErrNotFound;
   117     TInt ret = KErrNotFound;
   118     if (iFmTunerUtility)
   118     if (iFmTunerUtility)
   119     {
   119     {
   120     ret = iFmTunerUtility->GetFrequency(aFreq);
   120         ret = iFmTunerUtility->GetFrequency(aFreq);
   121     if (ret != KErrNone)
   121         if (ret != KErrNone)
   122     {
   122         {
   123         aFreq = iDefaultFrequency;
   123             aFreq = iDefaultFrequency;
   124         ret = KErrNone;
   124             ret = KErrNone;
   125     }
   125         }
   126     }
   126     }
   127   DEBUG_API_A1("CMMFRadioBackendEngine::GetFrequency RET: %d", ret);
   127 //  DEBUG_CPP_API_A1("CMMFRadioBackendEngine::GetFrequency RET: %d", ret);
   128 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetFrequency RET: %d"), ret);
       
   129     return ret;
   128     return ret;
   130 }
   129 }
   131 
   130 
   132 TInt CMMFRadioBackendEngine::GetSignalStrength(TInt& aSignalStrength)
   131 TInt CMMFRadioBackendEngine::GetSignalStrength(TInt& aSignalStrength)
   133 {
   132 {
   134     TInt ret = KErrNotFound;
   133     TInt ret = KErrNotFound;
   135     if (iFmTunerUtility)
   134     if (iFmTunerUtility)
   136     {
   135     {
   137     ret = iFmTunerUtility->GetSignalStrength(aSignalStrength);
   136         ret = iFmTunerUtility->GetSignalStrength(aSignalStrength);
   138     }
   137     }
   139   DEBUG_API_A1("CMMFRadioBackendEngine::GetSignalStrength RET: %d", ret);
   138 //    DEBUG_CPP_API_A1("CMMFRadioBackendEngine::GetSignalStrength RET: %d", ret);
   140 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetSignalStrength RET: %d"), ret);
   139 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetSignalStrength RET: %d"), ret);
   141     return ret;
   140     return ret;
   142 }
   141 }
   143 
   142 
   144 void CMMFRadioBackendEngine::CancelSetFrequency()
   143 void CMMFRadioBackendEngine::CancelSetFrequency()
   180             maxFreq = iDefaultMaxFreq;
   179             maxFreq = iDefaultMaxFreq;
   181             aRange = iDefaultFreqRange;
   180             aRange = iDefaultFreqRange;
   182             ret = KErrNone;
   181             ret = KErrNone;
   183         }
   182         }
   184     }
   183     }
   185   DEBUG_API_A1("CMMFRadioBackendEngine::GetFreqRange RET: %d", ret);
   184  //   DEBUG_CPP_API_A1("CMMFRadioBackendEngine::GetFreqRange RET: %d", ret);
   186 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetFreqRange RET: %d"), ret);
   185     return ret;
   187   return ret;
       
   188 }
   186 }
   189 
   187 
   190 TInt CMMFRadioBackendEngine::GetFreqRangeProperties(TFmRadioFrequencyRange& aRange, TInt& aMinFreq, TInt& aMaxFreq)
   188 TInt CMMFRadioBackendEngine::GetFreqRangeProperties(TFmRadioFrequencyRange& aRange, TInt& aMinFreq, TInt& aMaxFreq)
   191 {
   189 {
   192     TInt ret = KErrNotFound;
   190     TInt ret = KErrNotFound;
   193 
       
   194     if (iFmTunerUtility)
   191     if (iFmTunerUtility)
   195     {
   192     {
   196         ret = iFmTunerUtility->GetFrequencyRange((TFmRadioFrequencyRange&)aRange, (TInt&)aMinFreq, (TInt&)aMaxFreq);
   193         ret = iFmTunerUtility->GetFrequencyRange((TFmRadioFrequencyRange&)aRange, (TInt&)aMinFreq, (TInt&)aMaxFreq);
   197         if (ret != KErrNone)
   194         if (ret != KErrNone)
   198         {
   195         {
   200             aMinFreq = iDefaultMinFreq;
   197             aMinFreq = iDefaultMinFreq;
   201             aMaxFreq = iDefaultMaxFreq;
   198             aMaxFreq = iDefaultMaxFreq;
   202             ret = KErrNone;
   199             ret = KErrNone;
   203         }
   200         }
   204     }
   201     }
   205   DEBUG_API_A1("CMMFRadioBackendEngine::GetFreqRangeProperties RET: %d", ret);
   202 //    DEBUG_CPP_API_A1("CMMFRadioBackendEngine::GetFreqRangeProperties RET: %d", ret);
   206 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetFreqRangeProperties RET: %d"), ret);
   203     return ret;
   207   return ret;
       
   208 }
   204 }
   209 TInt CMMFRadioBackendEngine::GetMaxVolume(TInt& aMaxVol)
   205 TInt CMMFRadioBackendEngine::GetMaxVolume(TInt& aMaxVol)
   210 {
   206 {
   211     TInt ret = KErrNotFound;
   207     TInt ret = KErrNotFound;
   212 
       
   213     if (iRadioPlayerUtility)
   208     if (iRadioPlayerUtility)
   214     {
   209     {
   215         ret = iRadioPlayerUtility->GetMaxVolume(aMaxVol);
   210         ret = iRadioPlayerUtility->GetMaxVolume(aMaxVol);
   216     }
   211     }
   217   return ret;
   212     return ret;
   218 }
   213 }
   219 
   214 
   220 TInt CMMFRadioBackendEngine::SetVolume(TInt aVol)
   215 TInt CMMFRadioBackendEngine::SetVolume(TInt aVol)
   221 {
   216 {
   222     TInt ret = KErrNotFound;
   217     TInt ret = KErrNotFound; 
   223 
       
   224     if (iRadioPlayerUtility)
   218     if (iRadioPlayerUtility)
   225     {
   219     {
   226         ret = iRadioPlayerUtility->SetVolume(aVol);
   220         ret = iRadioPlayerUtility->SetVolume(aVol);
   227     }
   221     }
   228   return ret;
   222     return ret;
   229 }
   223 }
   230 
   224 
   231 TInt CMMFRadioBackendEngine::SetMute(XAboolean aMute)
   225 TInt CMMFRadioBackendEngine::SetMute(TBool aMute)
   232 {
   226 {
   233     TInt ret = KErrNotFound;
   227     TInt ret = KErrNotFound;
   234 
       
   235     if (iRadioPlayerUtility)
   228     if (iRadioPlayerUtility)
   236     {
   229     {
   237         ret = iRadioPlayerUtility->Mute(aMute);
   230         ret = iRadioPlayerUtility->Mute(aMute);
   238     }
   231     }
   239   return ret;
   232     return ret;
   240 }
   233 }
   241 
   234 
   242 TInt CMMFRadioBackendEngine::GetVolume(TInt& aVol)
   235 TInt CMMFRadioBackendEngine::GetVolume(TInt& aVol)
   243 {
   236 {
   244     TInt ret = KErrNotFound;
   237     TInt ret = KErrNotFound;
   245 
       
   246     if (iRadioPlayerUtility)
   238     if (iRadioPlayerUtility)
   247     {
   239     {
   248         ret = iRadioPlayerUtility->GetVolume(aVol);
   240         ret = iRadioPlayerUtility->GetVolume(aVol);
   249     }
   241     }
   250   return ret;
   242     return ret;
   251 }
   243 }
   252 
   244 
   253 TInt CMMFRadioBackendEngine::GetForcedMonoReception(XAuint32& aForcedMono)
   245 TInt CMMFRadioBackendEngine::GetForcedMonoReception(TUint& aForcedMono)
   254 {
   246 {
   255     TInt ret = KErrNotFound;
   247     TInt ret = KErrNotFound;
   256     TBool forceMono(EFalse);
   248     TBool forceMono(EFalse);
   257 
   249 
   258     if (iFmTunerUtility)
   250     if (iFmTunerUtility)
   262         {
   254         {
   263             aForcedMono = XA_STEREOMODE_AUTO; // Radio Utility Default value
   255             aForcedMono = XA_STEREOMODE_AUTO; // Radio Utility Default value
   264             return KErrNone;
   256             return KErrNone;
   265         }
   257         }
   266     }
   258     }
   267 
       
   268 
   259 
   269     if (forceMono)
   260     if (forceMono)
   270     {
   261     {
   271         aForcedMono = XA_STEREOMODE_MONO;
   262         aForcedMono = XA_STEREOMODE_MONO;
   272     }
   263     }
   275         if (iForceStereo)
   266         if (iForceStereo)
   276             aForcedMono = XA_STEREOMODE_STEREO;
   267             aForcedMono = XA_STEREOMODE_STEREO;
   277         else
   268         else
   278             aForcedMono = XA_STEREOMODE_AUTO;
   269             aForcedMono = XA_STEREOMODE_AUTO;
   279     }
   270     }
   280   return ret;
   271     return ret;
   281 }
   272 }
   282 
   273 
   283 void CMMFRadioBackendEngine::PlayRadio()
   274 void CMMFRadioBackendEngine::PlayRadio()
   284 {
   275 {
   285     if (iRadioPlayerUtility)
   276     if (iRadioPlayerUtility)
   294     {
   285     {
   295         iRadioPlayerUtility->Stop();
   286         iRadioPlayerUtility->Stop();
   296     }
   287     }
   297 }
   288 }
   298 
   289 
   299 TInt CMMFRadioBackendEngine::ForceMonoReception(XAuint32 aForcedMono)
   290 TInt CMMFRadioBackendEngine::ForceMonoReception(TUint aForcedMono)
   300 {
   291 {
   301     TInt ret = KErrNotFound;
   292     TInt ret = KErrNotFound;
   302     XAuint32 currentMode;
   293     TUint currentMode;
   303 
   294 
   304     ret = GetForcedMonoReception(currentMode);
   295     ret = GetForcedMonoReception(currentMode);
   305     if (ret != XA_RESULT_SUCCESS)
   296     if (ret != XA_RESULT_SUCCESS)
   306         return ret;
   297         return ret;
   307 
   298 
   335             {
   326             {
   336                 ret = iFmTunerUtility->ForceMonoReception(EFalse);
   327                 ret = iFmTunerUtility->ForceMonoReception(EFalse);
   337             }
   328             }
   338         }
   329         }
   339     }
   330     }
   340   DEBUG_API_A1("CMMFRadioBackendEngine::ForceMonoReception RET: %d", ret);
   331  //   DEBUG_CPP_API_A1("CMMFRadioBackendEngine::ForceMonoReception RET: %d", ret);
   341  // RDebug::Print(_L("CMMFRadioBackendEngine::ForceMonoReception RET: %d"), ret);
   332     return ret;
   342   return ret;
   333 }
   343 }
   334 
   344 
   335 XAresult CMMFRadioBackendEngine::SetForceMonoFlag() 
   345 XAresult CMMFRadioBackendEngine::SetForceMonoFlag()
   336 {
   346 {
   337     TInt ret = KErrNotFound;
   347     TInt ret = KErrNotFound;
   338     TBool forceMono;
   348     TBool forceMono(EFalse);
       
   349 
   339 
   350     if (iFmTunerUtility)
   340     if (iFmTunerUtility)
   351     {
   341     {
   352         ret = iFmTunerUtility->GetForcedMonoReception(forceMono);
   342         ret = iFmTunerUtility->GetForcedMonoReception(forceMono);
   353         if (ret == KErrNotReady)
   343         if (ret == KErrNotReady)
   354         {
   344         {
   355             // For Radio Utility Default value = XA_STEREOMODE_STEREO
   345             // For Radio Utility Default value = XA_STEREOMODE_STEREO
   356             iForceStereo = ETrue;
   346             iForceStereo = ETrue;
   357             return KErrNone;
   347             return KErrNone;
   358         }
   348         }
   359 
   349     }
   360     }
       
   361 
       
   362     if (forceMono == XA_STEREOMODE_MONO)
   350     if (forceMono == XA_STEREOMODE_MONO)
   363     {
   351     {
   364         iForceStereo = EFalse;
   352         iForceStereo = EFalse;
   365     }
   353     }
   366     else
   354     else
   367     {
   355     {
   368         iForceStereo = ETrue;
   356         iForceStereo = ETrue;
   369     }
   357     }
   370   return ret;
   358   return ret;
   371 }
   359 }
   372 XAresult CMMFRadioBackendEngine::SetRadioAdaptContext(void * adaptcontext)
   360 
   373 {
   361 TInt CMMFRadioBackendEngine::GetSquelch(TBool& aSquelch)
   374     iRadioAdaptContext = adaptcontext;
   362 {
   375     return XA_RESULT_SUCCESS;
   363     TInt ret = KErrNotFound;
   376 }
   364     if (iFmTunerUtility)
   377 
   365     {
   378 XAresult CMMFRadioBackendEngine::SetPlayerAdaptContext(void * adaptcontext)
   366         ret = iFmTunerUtility->GetSquelch(aSquelch);
   379 {
   367     }
   380     iPlayerAdaptContext = adaptcontext;
   368     return ret;
   381     return XA_RESULT_SUCCESS;
   369 }
       
   370 
       
   371 TInt CMMFRadioBackendEngine::SetSquelch(TBool aSquelch)
       
   372 {
       
   373     TInt ret = KErrNotFound;
       
   374     if (iFmTunerUtility)
       
   375     {
       
   376         ret = iFmTunerUtility->SetSquelch(aSquelch);
       
   377     }
       
   378     return ret;
       
   379 }
       
   380 
       
   381 void CMMFRadioBackendEngine::SetAdaptContext(void * adaptcontext)
       
   382 {
       
   383     iAdaptContext = (XAAdaptationBaseCtx*)adaptcontext;
   382 }
   384 }
   383 
   385 
   384 XAresult TranslateError(TInt error)
   386 XAresult TranslateError(TInt error)
   385     {
   387     {
   386     XAresult status(XA_RESULT_SUCCESS);
   388     XAresult status(XA_RESULT_SUCCESS);
   388         {
   390         {
   389         case KErrNone:
   391         case KErrNone:
   390             status = XA_RESULT_SUCCESS;
   392             status = XA_RESULT_SUCCESS;
   391             break;
   393             break;
   392         // to do: investigate and add other possible errors:
   394         // to do: investigate and add other possible errors:
   393 
   395             
   394        /* case XA_RESULT_PRECONDITIONS_VIOLATED:
   396        /* case XA_RESULT_PRECONDITIONS_VIOLATED:
   395 
   397  
   396             break;
   398             break;
   397         case XA_RESULT_PARAMETER_INVALID:
   399         case XA_RESULT_PARAMETER_INVALID:
   398 
   400 
   399             break;
   401             break;
   400         case XA_RESULT_MEMORY_FAILURE:
   402         case XA_RESULT_MEMORY_FAILURE:
   402             break;
   404             break;
   403         case XA_RESULT_RESOURCE_ERROR:
   405         case XA_RESULT_RESOURCE_ERROR:
   404 
   406 
   405             break;
   407             break;
   406         case XA_RESULT_RESOURCE_LOST:
   408         case XA_RESULT_RESOURCE_LOST:
   407 
   409  
   408             break;
   410             break;
   409         case XA_RESULT_IO_ERROR:
   411         case XA_RESULT_IO_ERROR:
   410 
   412 
   411             break;
   413             break;
   412         case XA_RESULT_BUFFER_INSUFFICIENT:
   414         case XA_RESULT_BUFFER_INSUFFICIENT:
   414             break;
   416             break;
   415         case XA_RESULT_CONTENT_CORRUPTED:
   417         case XA_RESULT_CONTENT_CORRUPTED:
   416 
   418 
   417             break;
   419             break;
   418         case XA_RESULT_CONTENT_UNSUPPORTED:
   420         case XA_RESULT_CONTENT_UNSUPPORTED:
   419 
   421  
   420             break;
   422             break;
   421         case XA_RESULT_CONTENT_NOT_FOUND:
   423         case XA_RESULT_CONTENT_NOT_FOUND:
   422 
   424 
   423             break;
   425             break;
   424         case XA_RESULT_PERMISSION_DENIED:
   426         case XA_RESULT_PERMISSION_DENIED:
   439         case XA_RESULT_CONTROL_LOST:
   441         case XA_RESULT_CONTROL_LOST:
   440 
   442 
   441             break;
   443             break;
   442             */
   444             */
   443         default:
   445         default:
   444             break;
   446         	break;
   445         } // end switch
   447         } // end switch
   446     return status;
   448     return status;
   447     }
   449     }
   448 // -----------------------------------------------------------------------------
   450 // -----------------------------------------------------------------------------
   449 // CMMFRadioBackendEngine::MrpeoPresetChanged
   451 // CMMFRadioBackendEngine::MrpeoPresetChanged
   460 // CMMFRadioBackendEngine::MrftoSquelchChange
   462 // CMMFRadioBackendEngine::MrftoSquelchChange
   461 //
   463 //
   462 // ----------------------------------------------------
   464 // ----------------------------------------------------
   463 //
   465 //
   464 void CMMFRadioBackendEngine::MrftoSquelchChange(
   466 void CMMFRadioBackendEngine::MrftoSquelchChange(
   465     TBool /*aSquelch*/ )
   467     TBool aSquelch)
   466 {
   468 {
   467 
   469 //    DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoSquelchChange: aSquelch =  %d", aSquelch);
       
   470 // Currently, Openmaxal doesn't have event defined to handle this callback
   468 }
   471 }
   469 
   472 
   470 // ----------------------------------------------------
   473 // ----------------------------------------------------
   471 // CMMFRadioBackendEngine::MrftoForcedMonoChanged
   474 // CMMFRadioBackendEngine::MrftoForcedMonoChanged
   472 // Called when a client enables/disabled forced mono reception
   475 // Called when a client enables/disabled forced mono reception
   473 // ----------------------------------------------------
   476 // ----------------------------------------------------
   474 //
   477 //
   475 void CMMFRadioBackendEngine::MrftoForcedMonoChange(
   478 void CMMFRadioBackendEngine::MrftoForcedMonoChange(
   476     TBool aForcedMono )
   479     TBool aForcedMono )
   477 {
   480 {
   478   DEBUG_API_A1("CMMFRadioBackendEngine::MrftoForcedMonoChange: aForcedMono =  %d", aForcedMono);
   481 //    DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoForcedMonoChange: aForcedMono =  %d", aForcedMono);
   479 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoForcedMonoChange: aForcedMono = %d"), aForcedMono);
   482     XARadioItfAdapt_StereoStatusChange((XAAdaptationBaseCtx*)iAdaptContext, aForcedMono);
   480     XARadioItfAdapt_StereoStatusChange((XAAdaptationBaseCtx*)iRadioAdaptContext, aForcedMono);
       
   481 }
   483 }
   482 
   484 
   483  // ----------------------------------------------------
   485  // ----------------------------------------------------
   484 // CMMFRadioBackendEngine::MrftoFrequencyChange
   486 // CMMFRadioBackendEngine::MrftoFrequencyChange
   485 // Called when the tuned frequency changes
   487 // Called when the tuned frequency changes
   486 // ----------------------------------------------------
   488 // ----------------------------------------------------
   487 //
   489 //
   488 void CMMFRadioBackendEngine::MrftoFrequencyChange(
   490 void CMMFRadioBackendEngine::MrftoFrequencyChange(
   489     TInt aNewFrequency)
   491     TInt aNewFrequency)
   490 {
   492 {
   491     DEBUG_API_A1("CMMFRadioBackendEngine::MrftoFrequencyChange: aNewFrequency =  %d", aNewFrequency);
   493 //    DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoFrequencyChange: aNewFrequency =  %d", aNewFrequency);
   492  // RDebug::Print(_L("CMMFRadioBackendEngine::MrftoFrequencyChange aNewFrequency = %d"), aNewFrequency);
   494     XARadioItfAdapt_FrequencyChange((XAAdaptationBaseCtx*)iAdaptContext, aNewFrequency);
   493     XARadioItfAdapt_FrequencyChange((XAAdaptationBaseCtx*)iRadioAdaptContext, aNewFrequency);
       
   494 }
   495 }
   495 
   496 
   496 // ----------------------------------------------------
   497 // ----------------------------------------------------
   497 // CMMFRadioBackendEngine::MrftoFrequencyRangeChange
   498 // CMMFRadioBackendEngine::MrftoFrequencyRangeChange
   498 //
   499 //
   499 // ----------------------------------------------------
   500 // ----------------------------------------------------
   500 //
   501 //
   501 void CMMFRadioBackendEngine::MrftoFrequencyRangeChange(
   502 void CMMFRadioBackendEngine::MrftoFrequencyRangeChange(
   502     TFmRadioFrequencyRange aNewRange )
   503     TFmRadioFrequencyRange aNewRange )
   503 {
   504 {
   504     DEBUG_API_A1("CMMFRadioBackendEngine::MrftoFrequencyRangeChange: aNewRange =  %d", aNewRange);
   505  //   DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoFrequencyRangeChange: aNewRange =  %d", aNewRange);
   505 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoFrequencyRangeChange: aNewRange = %d"), aNewRange);
   506     XARadioItfAdapt_FrequencyRangeChange((XAAdaptationBaseCtx*)iAdaptContext, aNewRange);
   506     XARadioItfAdapt_FrequencyRangeChange((XAAdaptationBaseCtx*)iRadioAdaptContext, aNewRange);
       
   507 }
   507 }
   508 
   508 
   509 // ----------------------------------------------------
   509 // ----------------------------------------------------
   510 // CMMFRadioBackendEngine::MrftoOfflineModeStatusChange
   510 // CMMFRadioBackendEngine::MrftoOfflineModeStatusChange
   511 // Called when offline mode status changes
   511 // Called when offline mode status changes
   546 //
   546 //
   547 void CMMFRadioBackendEngine::MrftoStationSeekComplete(
   547 void CMMFRadioBackendEngine::MrftoStationSeekComplete(
   548     TInt aError,
   548     TInt aError,
   549     TInt aFrequency )
   549     TInt aFrequency )
   550 {
   550 {
   551     XARadioItfAdapt_SeekComplete((XAAdaptationBaseCtx*)iRadioAdaptContext, aError, aFrequency);
   551     XARadioItfAdapt_SeekComplete((XAAdaptationBaseCtx*)iAdaptContext, aError, aFrequency);
   552 }
   552 }
   553 
   553  
   554 // ----------------------------------------------------
   554 // ----------------------------------------------------
   555 // CMMFRadioBackendEngine::MrftoSetFrequencyComplete
   555 // CMMFRadioBackendEngine::MrftoSetFrequencyComplete
   556 // ----------------------------------------------------
   556 // ----------------------------------------------------
   557 //
   557 //
   558 void CMMFRadioBackendEngine::MrftoSetFrequencyComplete(
   558 void CMMFRadioBackendEngine::MrftoSetFrequencyComplete(
   559     TInt aError )
   559     TInt aError )
   560 {
   560 {
   561     DEBUG_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyComplete: aError =  %d", aError);
   561 //    DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyComplete: aError =  %d", aError);
   562 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoFrrequencyComplete: aError = %d"), aError);
   562 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoFrrequencyComplete: aError = %d"), aError);
   563     TInt freq = 0;
   563     TInt freq = 0;
   564   if (!aError)
   564     if (!aError)
   565     {
   565     {
   566         iFmTunerUtility->GetFrequency(freq);
   566         iFmTunerUtility->GetFrequency(freq);
   567     }
   567     }
   568     DEBUG_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyComplete: new freq is: %d", freq);
   568 //    DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyComplete: new freq is: %d", freq);
   569 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoSetFrequencyComplete: new freq is: %d"), freq);
   569     XARadioItfAdapt_SetFrequencyComplete((XAAdaptationBaseCtx*)iAdaptContext, aError, freq);
   570     XARadioItfAdapt_SetFrequencyComplete((XAAdaptationBaseCtx*)iRadioAdaptContext, aError, freq);
       
   571 }
   570 }
   572 
   571 
   573 // ----------------------------------------------------
   572 // ----------------------------------------------------
   574 // CMMFRadioBackendEngine::MrftoSetFrequencyRangeComplete
   573 // CMMFRadioBackendEngine::MrftoSetFrequencyRangeComplete
   575 //
   574 //
   576 // ----------------------------------------------------
   575 // ----------------------------------------------------
   577 //
   576 //
   578 void CMMFRadioBackendEngine::MrftoSetFrequencyRangeComplete(
   577 void CMMFRadioBackendEngine::MrftoSetFrequencyRangeComplete(
   579     TInt aError )
   578     TInt aError )
   580 {
   579 {
   581     DEBUG_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyRangeComplete: aError =  %d", aError);
   580 //    DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyRangeComplete: aError =  %d", aError);
   582 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoSetFrequencyRangeComplete: aError = %d"), aError);
   581     XARadioItfAdapt_SetFrequencyRangeComplete((XAAdaptationBaseCtx*)iAdaptContext, aError);
   583     XARadioItfAdapt_SetFrequencyRangeComplete((XAAdaptationBaseCtx*)iRadioAdaptContext, aError);
       
   584 }
   582 }
   585 
   583 
   586 // ----------------------------------------------------
   584 // ----------------------------------------------------
   587 // CMMFRadioBackendEngine::MrftoRequestTunerControlComplete
   585 // CMMFRadioBackendEngine::MrftoRequestTunerControlComplete
   588 // ----------------------------------------------------
   586 // ----------------------------------------------------
   589 //
   587 //
   590 void CMMFRadioBackendEngine::MrftoRequestTunerControlComplete(
   588 void CMMFRadioBackendEngine::MrftoRequestTunerControlComplete(
   591     TInt aError)
   589     TInt aError)
   592 {
   590 {
   593 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoRequestTunerControlComplete: aError = %d"), aError);
   591 
   594 }
   592 }
   595 
   593 
   596 // ----------------------------------------------------
   594 // ----------------------------------------------------
   597 // CMMFRadioBackendEngine::MrpoBalanceChange
   595 // CMMFRadioBackendEngine::MrpoBalanceChange
   598 //
   596 //
   611 // ----------------------------------------------------
   609 // ----------------------------------------------------
   612 //
   610 //
   613 void CMMFRadioBackendEngine::MrpoMuteChange(
   611 void CMMFRadioBackendEngine::MrpoMuteChange(
   614     TBool aMute )
   612     TBool aMute )
   615 {
   613 {
   616     XANokiaVolumeExtItfAdapt_MuteChange((XAAdaptationBaseCtx*)iPlayerAdaptContext, aMute);
   614     XARadioItfAdapt_MuteChange((XAAdaptationBaseCtx*)iAdaptContext, aMute);
   617 }
   615 }
   618 
   616 
   619 // ----------------------------------------------------
   617 // ----------------------------------------------------
   620 // CMMFRadioBackendEngine::MrpoVolumeChange
   618 // CMMFRadioBackendEngine::MrpoVolumeChange
   621 //
   619 //
   622 // ----------------------------------------------------
   620 // ----------------------------------------------------
   623 //
   621 //
   624 void CMMFRadioBackendEngine::MrpoVolumeChange(
   622 void CMMFRadioBackendEngine::MrpoVolumeChange(
   625     TInt aVolume )
   623     TInt aVolume )
   626 {
   624 {
   627     XANokiaLinearVolumeItfAdapt_VolumeChange((XAAdaptationBaseCtx*)iPlayerAdaptContext, aVolume);
   625     XARadioItfAdapt_VolumeChange((XAAdaptationBaseCtx*)iAdaptContext, aVolume);
   628 }
   626 }
   629 
   627 
   630 // ----------------------------------------------------
   628 // ----------------------------------------------------
   631 // CMMFRadioBackendEngine::MrpoStateChange This is Tuner State
   629 // CMMFRadioBackendEngine::MrpoStateChange This is Tuner State
   632 // Called when the state of the tuner changes
   630 // Called when the state of the tuner changes
   634 //
   632 //
   635 void CMMFRadioBackendEngine::MrpoStateChange(
   633 void CMMFRadioBackendEngine::MrpoStateChange(
   636     TPlayerState aState,
   634     TPlayerState aState,
   637     TInt aError )
   635     TInt aError )
   638 {
   636 {
   639     if ( aError )
   637 //    if ( aError )
   640     {
   638 //    {
   641         DEBUG_API_A1("CMMFRadioBackendEngine::MrpoStateChange: aError =  %d", aError);
   639  //       DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrpoStateChange: aError =  %d", aError);
   642  //     RDebug::Print(_L("CMMFRadioBackendEngine::MrpoStateChange: aError = %d"), aError);
   640 //    }
   643     }
   641 
   644 
   642 //    DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrpoStateChange: new state =  %d", aState);
   645     DEBUG_API_A1("CMMFRadioBackendEngine::MrpoStateChange: new state =  %d", aState);
       
   646 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrpoStateChange: new state = %d"), aState);
       
   647 
   643 
   648     if ( aState == ERadioPlayerPlaying )
   644     if ( aState == ERadioPlayerPlaying )
   649     {
   645     {
   650     XAPlayItfAdaptMMF_StateChange((XAAdaptationBaseCtx*)iPlayerAdaptContext, ETrue);
   646         XARadioItfAdapt_StateChange((XAAdaptationBaseCtx*)iAdaptContext, ETrue);
   651     }
   647     }  
   652     else  // ERadioPlayerIdle
   648     else  // ERadioPlayerIdle
   653     {
   649     {
   654     XAPlayItfAdaptMMF_StateChange((XAAdaptationBaseCtx*)iPlayerAdaptContext, EFalse);
   650         XARadioItfAdapt_StateChange((XAAdaptationBaseCtx*)iAdaptContext, EFalse);
   655     }
   651     }
       
   652 
   656 }
   653 }
   657 
   654 
   658 extern "C" {
   655 extern "C" {
   659 
   656 
   660     void* cmmfradiobackendengine_init()
   657     void* cmmfradiobackendengine_init()
   661     {
   658     {
   662         return CMMFRadioBackendEngine::Instance();
   659     return CMMFRadioBackendEngine::Instance();
   663     }
   660     }
   664 
   661 
   665     void cmmfradiobackendengine_delete(void* context)
   662     void cmmfradiobackendengine_delete(void* pContext)
   666     {
   663     { 
   667         ((CMMFRadioBackendEngine*)(context))->DeleteInstance();
   664         ((CMMFRadioBackendEngine*)(pContext))->DeleteInstance();
   668     }
   665     }
   669 
   666 
   670     void  set_frequency(void* context, XAuint32 freq)
   667     void  set_frequency(void* pContext, void* pAdaptcontext, XAuint32 freq)
   671     {
   668     {
   672         ((CMMFRadioBackendEngine*)(context))->SetFrequency((TInt)freq);
   669         ((CMMFRadioBackendEngine*)(pContext))->SetAdaptContext(pAdaptcontext);
   673     }
   670         ((CMMFRadioBackendEngine*)(pContext))->SetFrequency((TInt)freq);
   674 
   671     }
   675     XAresult  get_frequency(void* context, XAuint32* freq)
   672 
   676     {
   673     XAresult  get_frequency(void* pContext, XAuint32* pFreq)
   677         return ((CMMFRadioBackendEngine*)(context))->GetFrequency((TInt&)*freq);
   674     {
   678     }
   675         return ((CMMFRadioBackendEngine*)(pContext))->GetFrequency((TInt&)*pFreq);
   679 
   676     }
   680     XAresult  get_signal_strength(void* context, XAuint32* signalStrength)
   677 
   681     {
   678     XAresult  get_signal_strength(void* pContext, XAuint32* pSignalStrength)
   682         return ((CMMFRadioBackendEngine*)(context))->GetSignalStrength((TInt&)*signalStrength);
   679     {
   683     }
   680         return ((CMMFRadioBackendEngine*)(pContext))->GetSignalStrength((TInt&)*pSignalStrength);
   684 
   681     }
   685     void station_seek(void* context, XAboolean upwards)
   682 
   686     {
   683     void station_seek(void* pContext, XAboolean upwards)
   687         ((CMMFRadioBackendEngine*)(context))->StationSeek(upwards);
   684     {
   688     }
   685         ((CMMFRadioBackendEngine*)(pContext))->StationSeek(upwards);
   689 
   686     }
   690     void cancel_set_frequency(void* context)
   687 
   691     {
   688     void cancel_set_frequency(void* pContext, void* pAdaptcontext)
   692         ((CMMFRadioBackendEngine*)(context))->CancelSetFrequency();
   689     {
   693     }
   690         ((CMMFRadioBackendEngine*)(pContext))->SetAdaptContext(pAdaptcontext);
   694 
   691         ((CMMFRadioBackendEngine*)(pContext))->CancelSetFrequency();
   695     void cancel_station_seek(void* context)
   692     }
   696     {
   693 
   697         ((CMMFRadioBackendEngine*)(context))->CancelStationSeek();
   694     void cancel_station_seek(void* pContext)
   698     }
   695     {
   699 
   696         ((CMMFRadioBackendEngine*)(pContext))->CancelStationSeek();
   700     void set_freq_range(void* context, XAuint8 range)
   697     }
   701     {
   698 
   702         ((CMMFRadioBackendEngine*)(context))->SetFreqRange((TFmRadioFrequencyRange)range);
   699     void set_freq_range(void* pContext, void* pAdaptcontext, XAuint8 range)
   703     }
   700     {
   704 
   701         ((CMMFRadioBackendEngine*)(pContext))->SetAdaptContext(pAdaptcontext);
   705     XAresult  get_freq_range(void* context, XAuint8* range)
   702         ((CMMFRadioBackendEngine*)(pContext))->SetFreqRange((TFmRadioFrequencyRange)range);
   706     {
   703     }
   707         return ((CMMFRadioBackendEngine*)(context))->GetFreqRange((TFmRadioFrequencyRange&)*range);
   704 
   708     }
   705     XAresult  get_freq_range(void* pContext, XAuint8* pRange)
   709 
   706     {
   710     XAresult  get_freq_range_properties(void* context, XAuint8 aRange, XAuint32* aMinFreq, XAuint32* aMaxFreq)
   707         return ((CMMFRadioBackendEngine*)(pContext))->GetFreqRange((TFmRadioFrequencyRange&)*pRange);
   711     {
   708     }
   712         return ((CMMFRadioBackendEngine*)(context))->GetFreqRangeProperties((TFmRadioFrequencyRange&) aRange, (TInt&) *aMinFreq, (TInt&) *aMaxFreq);
   709 
   713     }
   710     XAresult  get_freq_range_properties(void* pContext, XAuint8 aRange, XAuint32* pMinFreq, XAuint32* pMaxFreq)
   714 
   711     {
   715     XAresult  get_max_volume(void* context, XAmillibel* maxVol)
   712         return ((CMMFRadioBackendEngine*)(pContext))->GetFreqRangeProperties((TFmRadioFrequencyRange&) aRange, (TInt&) *pMinFreq, (TInt&) *pMaxFreq);
   716     {
   713     }
   717         return  ((CMMFRadioBackendEngine*)(context))->GetMaxVolume((TInt&)*maxVol);
   714 
   718     }
   715     XAresult  get_max_volume(void* pContext, XAmillibel* pMaxVol)
   719 
   716     {
   720     XAresult  set_volume(void* context, XAuint32 vol)
   717         return  ((CMMFRadioBackendEngine*)(pContext))->GetMaxVolume((TInt&)*pMaxVol);
   721     {
   718     }
   722         return ((CMMFRadioBackendEngine*)(context))->SetVolume((TInt)vol);
   719 
   723     }
   720     XAresult  set_volume(void* pContext, void* pAdaptcontext, XAuint32 vol)
   724 
   721     {
   725     XAresult  get_volume(void* context, XAuint32* vol)
   722         ((CMMFRadioBackendEngine*)(pContext))->SetAdaptContext(pAdaptcontext);
   726     {
   723         return ((CMMFRadioBackendEngine*)(pContext))->SetVolume((TInt)vol);
   727         return ((CMMFRadioBackendEngine*)(context))->GetVolume((TInt&)*vol);
   724     }
   728     }
   725 
   729 
   726     XAresult  get_volume(void* pContext, XAuint32* pVol)
   730     XAresult  set_mute(void* context, XAboolean mute)
   727     {
   731     {
   728         return ((CMMFRadioBackendEngine*)(pContext))->GetVolume((TInt&)*pVol);
   732         return ((CMMFRadioBackendEngine*)(context))->SetMute(mute);
   729     }
   733     }
   730 
   734 
   731     XAresult  set_mute(void* pContext, void* pAdaptcontext, XAboolean mute)
   735     XAresult  get_stereo_mode(void* context, XAuint32* mode)
   732     {
   736     {
   733         ((CMMFRadioBackendEngine*)(pContext))->SetAdaptContext(pAdaptcontext);
   737         return ((CMMFRadioBackendEngine*)(context))->GetForcedMonoReception(*mode);
   734         return ((CMMFRadioBackendEngine*)(pContext))->SetMute(mute);
   738     }
   735     }
   739 
   736 
   740     XAresult  set_stereo_mode(void* context, XAuint32 mode)
   737     XAresult  get_stereo_mode(void* pContext, XAuint32* pMode)
   741     {
   738     {
   742         return ((CMMFRadioBackendEngine*)(context))->ForceMonoReception(mode);
   739         return ((CMMFRadioBackendEngine*)(pContext))->GetForcedMonoReception((TUint&)*pMode);
   743     }
   740     }
   744 
   741 
   745     void play_radio(void* context)
   742     XAresult  set_stereo_mode(void* pContext, void* pAdaptcontext, XAuint32 mode)
   746     {
   743     {
   747         ((CMMFRadioBackendEngine*)(context))->PlayRadio();
   744         ((CMMFRadioBackendEngine*)(pContext))->SetAdaptContext(pAdaptcontext);
   748     }
   745         return ((CMMFRadioBackendEngine*)(pContext))->ForceMonoReception(mode);
   749 
   746     }
   750     void stop_radio(void* context)
   747 
   751     {
   748     void play_radio(void* pContext, void* pAdaptcontext)
   752         ((CMMFRadioBackendEngine*)(context))->StopRadio();
   749     {
   753     }
   750         ((CMMFRadioBackendEngine*)(pContext))->SetAdaptContext(pAdaptcontext);
   754 
   751         ((CMMFRadioBackendEngine*)(pContext))->PlayRadio();
   755     XAresult mmf_set_radio_adapt_context(void * context, void * adaptcontext)
   752     }
   756     {
   753 
   757         return ((CMMFRadioBackendEngine*)(context))->SetRadioAdaptContext(adaptcontext);
   754     void stop_radio(void* pContext, void* pAdaptcontext)
   758     }
   755     {
   759 
   756         ((CMMFRadioBackendEngine*)(pContext))->SetAdaptContext(pAdaptcontext);
   760     XAresult mmf_set_player_adapt_context(void * context, void * adaptcontext)
   757         ((CMMFRadioBackendEngine*)(pContext))->StopRadio();
   761     {
   758     }
   762         return ((CMMFRadioBackendEngine*)(context))->SetPlayerAdaptContext(adaptcontext);
   759     void get_squelch(void* pContext, XAboolean* pSquelch)
   763     }
   760     {
   764 }
   761         ((CMMFRadioBackendEngine*)(pContext))->GetSquelch((TBool&)*pSquelch);
       
   762     }
       
   763     void set_squelch(void* pContext, void* pAdaptcontext, XAboolean squelch)
       
   764     {
       
   765         ((CMMFRadioBackendEngine*)(pContext))->SetAdaptContext(pAdaptcontext);
       
   766         ((CMMFRadioBackendEngine*)(pContext))->SetSquelch((TBool)squelch);
       
   767     }
       
   768 }