khronosfws/openmax_al/src/mmf_adaptation/cmmfradiobackendengine.cpp
branchRCL_3
changeset 45 095bea5f582e
equal deleted inserted replaced
41:a36789189b53 45:095bea5f582e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cmmfradiobackendengine.h"
       
    19 
       
    20 extern "C" {
       
    21 #include "xaradioitfadaptation.h"
       
    22 #include "xanokiavolumeextitfadaptationmmf.h"
       
    23 #include "xanokialinearvolumeitfadaptationmmf.h"
       
    24 #include "xaplayitfadaptationmmf.h"
       
    25 }
       
    26 
       
    27 CMMFRadioBackendEngine *CMMFRadioBackendEngine::s_instance = 0;
       
    28 
       
    29 CMMFRadioBackendEngine* CMMFRadioBackendEngine::Instance()
       
    30 {
       
    31     if (!s_instance)
       
    32     {
       
    33         s_instance = new CMMFRadioBackendEngine();
       
    34         if (s_instance)
       
    35         {
       
    36             s_instance->ConstructL();
       
    37         }
       
    38     }
       
    39     return s_instance;
       
    40 }
       
    41 
       
    42 void CMMFRadioBackendEngine::DeleteInstance()
       
    43 {
       
    44     if (iFmTunerUtility)
       
    45   {
       
    46     iFmTunerUtility->Close();
       
    47     iFmTunerUtility = NULL;
       
    48   }
       
    49   if (iRadioPlayerUtility)
       
    50   {
       
    51     iRadioPlayerUtility->Close();
       
    52     iRadioPlayerUtility = NULL;
       
    53   }
       
    54 
       
    55   if (iRadioUtility)
       
    56   {
       
    57         delete iRadioUtility;
       
    58         iRadioUtility = NULL;
       
    59     }
       
    60 
       
    61 }
       
    62 
       
    63 CMMFRadioBackendEngine::~CMMFRadioBackendEngine()
       
    64 {
       
    65 }
       
    66 
       
    67 CMMFRadioBackendEngine::CMMFRadioBackendEngine()
       
    68 {
       
    69 
       
    70 }
       
    71 
       
    72 void CMMFRadioBackendEngine::ConstructL()
       
    73 {
       
    74     iRadioUtility = CRadioUtility::NewL( ETrue );
       
    75     if (iRadioUtility)
       
    76     {
       
    77         iFmTunerUtility = &iRadioUtility->RadioFmTunerUtilityL( *this );
       
    78     }
       
    79     if (iFmTunerUtility)
       
    80     {
       
    81         iFmTunerUtility->EnableTunerInOfflineMode( ETrue );
       
    82         iFmTunerUtility->RequestTunerControl();
       
    83     }
       
    84   if (iRadioUtility)
       
    85   {
       
    86         iRadioPlayerUtility = &iRadioUtility->RadioPlayerUtilityL( *this );
       
    87     }
       
    88 
       
    89     SetForceMonoFlag();
       
    90     iDefaultFrequency = RADIO_DEFAULT_FREQ;
       
    91     iDefaultFreqRange = (TFmRadioFrequencyRange)RADIO_DEFAULT_FREQ_RANGE;
       
    92     iDefaultMinFreq = RADIO_DEFAULT_MIN_FREQ;
       
    93     iDefaultMaxFreq = RADIO_DEFAULT_MAX_FREQ;
       
    94 
       
    95 }
       
    96 void CMMFRadioBackendEngine::StationSeek(XAboolean aUpwards)
       
    97 {
       
    98     if (iFmTunerUtility)
       
    99     {
       
   100     iFmTunerUtility->StationSeek(aUpwards);
       
   101     }
       
   102 }
       
   103 
       
   104 void CMMFRadioBackendEngine::SetFrequency(TInt aFreq)
       
   105 {
       
   106   DEBUG_API_A1("CMMFRadioBackendEngine::SetFrequency: %d", aFreq);
       
   107 
       
   108     if (iFmTunerUtility)
       
   109     {
       
   110     iFmTunerUtility->SetFrequency(aFreq);
       
   111     }
       
   112 }
       
   113 
       
   114 TInt CMMFRadioBackendEngine::GetFrequency(TInt& aFreq)
       
   115 {
       
   116   DEBUG_API("CMMFRadioBackendEngine::GetFrequency");
       
   117     TInt ret = KErrNotFound;
       
   118     if (iFmTunerUtility)
       
   119     {
       
   120     ret = iFmTunerUtility->GetFrequency(aFreq);
       
   121     if (ret != KErrNone)
       
   122     {
       
   123         aFreq = iDefaultFrequency;
       
   124         ret = KErrNone;
       
   125     }
       
   126     }
       
   127   DEBUG_API_A1("CMMFRadioBackendEngine::GetFrequency RET: %d", ret);
       
   128 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetFrequency RET: %d"), ret);
       
   129     return ret;
       
   130 }
       
   131 
       
   132 TInt CMMFRadioBackendEngine::GetSignalStrength(TInt& aSignalStrength)
       
   133 {
       
   134     TInt ret = KErrNotFound;
       
   135     if (iFmTunerUtility)
       
   136     {
       
   137     ret = iFmTunerUtility->GetSignalStrength(aSignalStrength);
       
   138     }
       
   139   DEBUG_API_A1("CMMFRadioBackendEngine::GetSignalStrength RET: %d", ret);
       
   140 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetSignalStrength RET: %d"), ret);
       
   141     return ret;
       
   142 }
       
   143 
       
   144 void CMMFRadioBackendEngine::CancelSetFrequency()
       
   145 {
       
   146     if (iFmTunerUtility)
       
   147     {
       
   148         iFmTunerUtility->CancelSetFrequency();
       
   149     }
       
   150 }
       
   151 
       
   152 void CMMFRadioBackendEngine::CancelStationSeek()
       
   153 {
       
   154     if (iFmTunerUtility)
       
   155     {
       
   156         iFmTunerUtility->CancelStationSeek();
       
   157     }
       
   158 }
       
   159 
       
   160 void CMMFRadioBackendEngine::SetFreqRange(TFmRadioFrequencyRange aRange)
       
   161 {
       
   162     if (iFmTunerUtility)
       
   163     {
       
   164         iFmTunerUtility->SetFrequencyRange(aRange);
       
   165     }
       
   166 }
       
   167 
       
   168 TInt CMMFRadioBackendEngine::GetFreqRange(TFmRadioFrequencyRange& aRange)
       
   169 {
       
   170     TInt ret = KErrNotFound;
       
   171     TInt minFreq;
       
   172     TInt maxFreq;
       
   173 
       
   174     if (iFmTunerUtility)
       
   175     {
       
   176         ret = iFmTunerUtility->GetFrequencyRange((TFmRadioFrequencyRange&)aRange, (TInt&)minFreq, (TInt&)maxFreq);
       
   177         if (ret != KErrNone)
       
   178         {
       
   179             minFreq = iDefaultMinFreq;
       
   180             maxFreq = iDefaultMaxFreq;
       
   181             aRange = iDefaultFreqRange;
       
   182             ret = KErrNone;
       
   183         }
       
   184     }
       
   185   DEBUG_API_A1("CMMFRadioBackendEngine::GetFreqRange RET: %d", ret);
       
   186 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetFreqRange RET: %d"), ret);
       
   187   return ret;
       
   188 }
       
   189 
       
   190 TInt CMMFRadioBackendEngine::GetFreqRangeProperties(TFmRadioFrequencyRange& aRange, TInt& aMinFreq, TInt& aMaxFreq)
       
   191 {
       
   192     TInt ret = KErrNotFound;
       
   193 
       
   194     if (iFmTunerUtility)
       
   195     {
       
   196         ret = iFmTunerUtility->GetFrequencyRange((TFmRadioFrequencyRange&)aRange, (TInt&)aMinFreq, (TInt&)aMaxFreq);
       
   197         if (ret != KErrNone)
       
   198         {
       
   199             aRange = iDefaultFreqRange;
       
   200             aMinFreq = iDefaultMinFreq;
       
   201             aMaxFreq = iDefaultMaxFreq;
       
   202             ret = KErrNone;
       
   203         }
       
   204     }
       
   205   DEBUG_API_A1("CMMFRadioBackendEngine::GetFreqRangeProperties RET: %d", ret);
       
   206 //  RDebug::Print(_L("CMMFRadioBackendEngine::GetFreqRangeProperties RET: %d"), ret);
       
   207   return ret;
       
   208 }
       
   209 TInt CMMFRadioBackendEngine::GetMaxVolume(TInt& aMaxVol)
       
   210 {
       
   211     TInt ret = KErrNotFound;
       
   212 
       
   213     if (iRadioPlayerUtility)
       
   214     {
       
   215         ret = iRadioPlayerUtility->GetMaxVolume(aMaxVol);
       
   216     }
       
   217   return ret;
       
   218 }
       
   219 
       
   220 TInt CMMFRadioBackendEngine::SetVolume(TInt aVol)
       
   221 {
       
   222     TInt ret = KErrNotFound;
       
   223 
       
   224     if (iRadioPlayerUtility)
       
   225     {
       
   226         ret = iRadioPlayerUtility->SetVolume(aVol);
       
   227     }
       
   228   return ret;
       
   229 }
       
   230 
       
   231 TInt CMMFRadioBackendEngine::SetMute(XAboolean aMute)
       
   232 {
       
   233     TInt ret = KErrNotFound;
       
   234 
       
   235     if (iRadioPlayerUtility)
       
   236     {
       
   237         ret = iRadioPlayerUtility->Mute(aMute);
       
   238     }
       
   239   return ret;
       
   240 }
       
   241 
       
   242 TInt CMMFRadioBackendEngine::GetVolume(TInt& aVol)
       
   243 {
       
   244     TInt ret = KErrNotFound;
       
   245 
       
   246     if (iRadioPlayerUtility)
       
   247     {
       
   248         ret = iRadioPlayerUtility->GetVolume(aVol);
       
   249     }
       
   250   return ret;
       
   251 }
       
   252 
       
   253 TInt CMMFRadioBackendEngine::GetForcedMonoReception(XAuint32& aForcedMono)
       
   254 {
       
   255     TInt ret = KErrNotFound;
       
   256     TBool forceMono(EFalse);
       
   257 
       
   258     if (iFmTunerUtility)
       
   259     {
       
   260         ret = iFmTunerUtility->GetForcedMonoReception(forceMono);
       
   261         if (ret == KErrNotReady)
       
   262         {
       
   263             aForcedMono = XA_STEREOMODE_AUTO; // Radio Utility Default value
       
   264             return KErrNone;
       
   265         }
       
   266     }
       
   267 
       
   268 
       
   269     if (forceMono)
       
   270     {
       
   271         aForcedMono = XA_STEREOMODE_MONO;
       
   272     }
       
   273     else
       
   274     {
       
   275         if (iForceStereo)
       
   276             aForcedMono = XA_STEREOMODE_STEREO;
       
   277         else
       
   278             aForcedMono = XA_STEREOMODE_AUTO;
       
   279     }
       
   280   return ret;
       
   281 }
       
   282 
       
   283 void CMMFRadioBackendEngine::PlayRadio()
       
   284 {
       
   285     if (iRadioPlayerUtility)
       
   286     {
       
   287         iRadioPlayerUtility->Play();
       
   288     }
       
   289 }
       
   290 
       
   291 void CMMFRadioBackendEngine::StopRadio()
       
   292 {
       
   293     if (iRadioPlayerUtility)
       
   294     {
       
   295         iRadioPlayerUtility->Stop();
       
   296     }
       
   297 }
       
   298 
       
   299 TInt CMMFRadioBackendEngine::ForceMonoReception(XAuint32 aForcedMono)
       
   300 {
       
   301     TInt ret = KErrNotFound;
       
   302     XAuint32 currentMode;
       
   303 
       
   304     ret = GetForcedMonoReception(currentMode);
       
   305     if (ret != XA_RESULT_SUCCESS)
       
   306         return ret;
       
   307 
       
   308     if (iFmTunerUtility)
       
   309     {
       
   310         if (aForcedMono == XA_STEREOMODE_MONO)
       
   311         {
       
   312             iForceStereo = EFalse;
       
   313             ret = iFmTunerUtility->ForceMonoReception(ETrue);
       
   314         }
       
   315         else if (aForcedMono == XA_STEREOMODE_STEREO)
       
   316         {
       
   317             iForceStereo = ETrue;
       
   318             if (currentMode == XA_STEREOMODE_AUTO) // Transition from Auto to Stereo doesn't require Utility call:
       
   319             {
       
   320                 MrftoForcedMonoChange(ETrue);
       
   321             }
       
   322             else
       
   323             {
       
   324                 ret = iFmTunerUtility->ForceMonoReception(EFalse);
       
   325             }
       
   326         }
       
   327         else // (aForcedMono == XA_STEREOMODE_AUTO)
       
   328         {
       
   329             iForceStereo = EFalse;
       
   330             if (currentMode == XA_STEREOMODE_STEREO) // Transition from Stereo to Auto doesn't require Utility call:
       
   331             {
       
   332                 MrftoForcedMonoChange(EFalse);
       
   333             }
       
   334             else
       
   335             {
       
   336                 ret = iFmTunerUtility->ForceMonoReception(EFalse);
       
   337             }
       
   338         }
       
   339     }
       
   340   DEBUG_API_A1("CMMFRadioBackendEngine::ForceMonoReception RET: %d", ret);
       
   341  // RDebug::Print(_L("CMMFRadioBackendEngine::ForceMonoReception RET: %d"), ret);
       
   342   return ret;
       
   343 }
       
   344 
       
   345 XAresult CMMFRadioBackendEngine::SetForceMonoFlag()
       
   346 {
       
   347     TInt ret = KErrNotFound;
       
   348     TBool forceMono(EFalse);
       
   349 
       
   350     if (iFmTunerUtility)
       
   351     {
       
   352         ret = iFmTunerUtility->GetForcedMonoReception(forceMono);
       
   353         if (ret == KErrNotReady)
       
   354         {
       
   355             // For Radio Utility Default value = XA_STEREOMODE_STEREO
       
   356             iForceStereo = ETrue;
       
   357             return KErrNone;
       
   358         }
       
   359 
       
   360     }
       
   361 
       
   362     if (forceMono == XA_STEREOMODE_MONO)
       
   363     {
       
   364         iForceStereo = EFalse;
       
   365     }
       
   366     else
       
   367     {
       
   368         iForceStereo = ETrue;
       
   369     }
       
   370   return ret;
       
   371 }
       
   372 XAresult CMMFRadioBackendEngine::SetRadioAdaptContext(void * adaptcontext)
       
   373 {
       
   374     iRadioAdaptContext = adaptcontext;
       
   375     return XA_RESULT_SUCCESS;
       
   376 }
       
   377 
       
   378 XAresult CMMFRadioBackendEngine::SetPlayerAdaptContext(void * adaptcontext)
       
   379 {
       
   380     iPlayerAdaptContext = adaptcontext;
       
   381     return XA_RESULT_SUCCESS;
       
   382 }
       
   383 
       
   384 XAresult TranslateError(TInt error)
       
   385     {
       
   386     XAresult status(XA_RESULT_SUCCESS);
       
   387     switch(error)
       
   388         {
       
   389         case KErrNone:
       
   390             status = XA_RESULT_SUCCESS;
       
   391             break;
       
   392         // to do: investigate and add other possible errors:
       
   393 
       
   394        /* case XA_RESULT_PRECONDITIONS_VIOLATED:
       
   395 
       
   396             break;
       
   397         case XA_RESULT_PARAMETER_INVALID:
       
   398 
       
   399             break;
       
   400         case XA_RESULT_MEMORY_FAILURE:
       
   401 
       
   402             break;
       
   403         case XA_RESULT_RESOURCE_ERROR:
       
   404 
       
   405             break;
       
   406         case XA_RESULT_RESOURCE_LOST:
       
   407 
       
   408             break;
       
   409         case XA_RESULT_IO_ERROR:
       
   410 
       
   411             break;
       
   412         case XA_RESULT_BUFFER_INSUFFICIENT:
       
   413 
       
   414             break;
       
   415         case XA_RESULT_CONTENT_CORRUPTED:
       
   416 
       
   417             break;
       
   418         case XA_RESULT_CONTENT_UNSUPPORTED:
       
   419 
       
   420             break;
       
   421         case XA_RESULT_CONTENT_NOT_FOUND:
       
   422 
       
   423             break;
       
   424         case XA_RESULT_PERMISSION_DENIED:
       
   425 
       
   426             break;
       
   427         case XA_RESULT_FEATURE_UNSUPPORTED:
       
   428 
       
   429             break;
       
   430         case XA_RESULT_INTERNAL_ERROR:
       
   431 
       
   432             break;
       
   433         case XA_RESULT_UNKNOWN_ERROR:
       
   434 
       
   435             break;
       
   436         case XA_RESULT_OPERATION_ABORTED:
       
   437 
       
   438             break;
       
   439         case XA_RESULT_CONTROL_LOST:
       
   440 
       
   441             break;
       
   442             */
       
   443         default:
       
   444             break;
       
   445         } // end switch
       
   446     return status;
       
   447     }
       
   448 // -----------------------------------------------------------------------------
       
   449 // CMMFRadioBackendEngine::MrpeoPresetChanged
       
   450 // Observer for Presets
       
   451 // -----------------------------------------------------------------------------
       
   452 void CMMFRadioBackendEngine::MrpeoPresetChanged(
       
   453     TPresetChangeEvent /*aChange*/,
       
   454     TInt /*aIndex*/ )
       
   455 {
       
   456 
       
   457 }
       
   458 
       
   459 // ----------------------------------------------------
       
   460 // CMMFRadioBackendEngine::MrftoSquelchChange
       
   461 //
       
   462 // ----------------------------------------------------
       
   463 //
       
   464 void CMMFRadioBackendEngine::MrftoSquelchChange(
       
   465     TBool /*aSquelch*/ )
       
   466 {
       
   467 
       
   468 }
       
   469 
       
   470 // ----------------------------------------------------
       
   471 // CMMFRadioBackendEngine::MrftoForcedMonoChanged
       
   472 // Called when a client enables/disabled forced mono reception
       
   473 // ----------------------------------------------------
       
   474 //
       
   475 void CMMFRadioBackendEngine::MrftoForcedMonoChange(
       
   476     TBool aForcedMono )
       
   477 {
       
   478   DEBUG_API_A1("CMMFRadioBackendEngine::MrftoForcedMonoChange: aForcedMono =  %d", aForcedMono);
       
   479 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoForcedMonoChange: aForcedMono = %d"), aForcedMono);
       
   480     XARadioItfAdapt_StereoStatusChange((XAAdaptationBaseCtx*)iRadioAdaptContext, aForcedMono);
       
   481 }
       
   482 
       
   483  // ----------------------------------------------------
       
   484 // CMMFRadioBackendEngine::MrftoFrequencyChange
       
   485 // Called when the tuned frequency changes
       
   486 // ----------------------------------------------------
       
   487 //
       
   488 void CMMFRadioBackendEngine::MrftoFrequencyChange(
       
   489     TInt aNewFrequency)
       
   490 {
       
   491     DEBUG_API_A1("CMMFRadioBackendEngine::MrftoFrequencyChange: aNewFrequency =  %d", aNewFrequency);
       
   492  // RDebug::Print(_L("CMMFRadioBackendEngine::MrftoFrequencyChange aNewFrequency = %d"), aNewFrequency);
       
   493     XARadioItfAdapt_FrequencyChange((XAAdaptationBaseCtx*)iRadioAdaptContext, aNewFrequency);
       
   494 }
       
   495 
       
   496 // ----------------------------------------------------
       
   497 // CMMFRadioBackendEngine::MrftoFrequencyRangeChange
       
   498 //
       
   499 // ----------------------------------------------------
       
   500 //
       
   501 void CMMFRadioBackendEngine::MrftoFrequencyRangeChange(
       
   502     TFmRadioFrequencyRange aNewRange )
       
   503 {
       
   504     DEBUG_API_A1("CMMFRadioBackendEngine::MrftoFrequencyRangeChange: aNewRange =  %d", aNewRange);
       
   505 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoFrequencyRangeChange: aNewRange = %d"), aNewRange);
       
   506     XARadioItfAdapt_FrequencyRangeChange((XAAdaptationBaseCtx*)iRadioAdaptContext, aNewRange);
       
   507 }
       
   508 
       
   509 // ----------------------------------------------------
       
   510 // CMMFRadioBackendEngine::MrftoOfflineModeStatusChange
       
   511 // Called when offline mode status changes
       
   512 // ----------------------------------------------------
       
   513 //
       
   514 void CMMFRadioBackendEngine::MrftoOfflineModeStatusChange(
       
   515     TBool /*aOfflineMode*/ )
       
   516 {
       
   517 
       
   518 }
       
   519 
       
   520 // ----------------------------------------------------
       
   521 // CMMFRadioBackendEngine::MrftoAntennaStatusChange
       
   522 // Called when antenna status changes.
       
   523 // ----------------------------------------------------
       
   524 //
       
   525 void CMMFRadioBackendEngine::MrftoAntennaStatusChange(
       
   526     TBool /*aAttached*/ )
       
   527 {
       
   528 
       
   529 }
       
   530 
       
   531 // ----------------------------------------------------
       
   532 // CMMFRadioBackendEngine::MrftoFmTransmitterStatusChange
       
   533 // The FM tuner is turned off when FM transmitter is on.
       
   534 // ----------------------------------------------------
       
   535 //
       
   536 void CMMFRadioBackendEngine::MrftoFmTransmitterStatusChange(
       
   537     TBool /*aActive*/ )
       
   538 {
       
   539 
       
   540 }
       
   541 
       
   542 // ----------------------------------------------------
       
   543 // CMMFRadioBackendEngine::MrftoStationSeekComplete
       
   544 //
       
   545 // ----------------------------------------------------
       
   546 //
       
   547 void CMMFRadioBackendEngine::MrftoStationSeekComplete(
       
   548     TInt aError,
       
   549     TInt aFrequency )
       
   550 {
       
   551     XARadioItfAdapt_SeekComplete((XAAdaptationBaseCtx*)iRadioAdaptContext, aError, aFrequency);
       
   552 }
       
   553 
       
   554 // ----------------------------------------------------
       
   555 // CMMFRadioBackendEngine::MrftoSetFrequencyComplete
       
   556 // ----------------------------------------------------
       
   557 //
       
   558 void CMMFRadioBackendEngine::MrftoSetFrequencyComplete(
       
   559     TInt aError )
       
   560 {
       
   561     DEBUG_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyComplete: aError =  %d", aError);
       
   562 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoFrrequencyComplete: aError = %d"), aError);
       
   563     TInt freq = 0;
       
   564   if (!aError)
       
   565     {
       
   566         iFmTunerUtility->GetFrequency(freq);
       
   567     }
       
   568     DEBUG_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyComplete: new freq is: %d", freq);
       
   569 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoSetFrequencyComplete: new freq is: %d"), freq);
       
   570     XARadioItfAdapt_SetFrequencyComplete((XAAdaptationBaseCtx*)iRadioAdaptContext, aError, freq);
       
   571 }
       
   572 
       
   573 // ----------------------------------------------------
       
   574 // CMMFRadioBackendEngine::MrftoSetFrequencyRangeComplete
       
   575 //
       
   576 // ----------------------------------------------------
       
   577 //
       
   578 void CMMFRadioBackendEngine::MrftoSetFrequencyRangeComplete(
       
   579     TInt aError )
       
   580 {
       
   581     DEBUG_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyRangeComplete: aError =  %d", aError);
       
   582 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoSetFrequencyRangeComplete: aError = %d"), aError);
       
   583     XARadioItfAdapt_SetFrequencyRangeComplete((XAAdaptationBaseCtx*)iRadioAdaptContext, aError);
       
   584 }
       
   585 
       
   586 // ----------------------------------------------------
       
   587 // CMMFRadioBackendEngine::MrftoRequestTunerControlComplete
       
   588 // ----------------------------------------------------
       
   589 //
       
   590 void CMMFRadioBackendEngine::MrftoRequestTunerControlComplete(
       
   591     TInt aError)
       
   592 {
       
   593 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrftoRequestTunerControlComplete: aError = %d"), aError);
       
   594 }
       
   595 
       
   596 // ----------------------------------------------------
       
   597 // CMMFRadioBackendEngine::MrpoBalanceChange
       
   598 //
       
   599 // ----------------------------------------------------
       
   600 //
       
   601 void CMMFRadioBackendEngine::MrpoBalanceChange(
       
   602     TInt /*aLeftPercentage*/,
       
   603     TInt /*aRightPercentage*/ )
       
   604 {
       
   605 
       
   606 }
       
   607 
       
   608 // ----------------------------------------------------
       
   609 // CMMFRadioBackendEngine::MrpoMuteChange
       
   610 //
       
   611 // ----------------------------------------------------
       
   612 //
       
   613 void CMMFRadioBackendEngine::MrpoMuteChange(
       
   614     TBool aMute )
       
   615 {
       
   616     XANokiaVolumeExtItfAdapt_MuteChange((XAAdaptationBaseCtx*)iPlayerAdaptContext, aMute);
       
   617 }
       
   618 
       
   619 // ----------------------------------------------------
       
   620 // CMMFRadioBackendEngine::MrpoVolumeChange
       
   621 //
       
   622 // ----------------------------------------------------
       
   623 //
       
   624 void CMMFRadioBackendEngine::MrpoVolumeChange(
       
   625     TInt aVolume )
       
   626 {
       
   627     XANokiaLinearVolumeItfAdapt_VolumeChange((XAAdaptationBaseCtx*)iPlayerAdaptContext, aVolume);
       
   628 }
       
   629 
       
   630 // ----------------------------------------------------
       
   631 // CMMFRadioBackendEngine::MrpoStateChange This is Tuner State
       
   632 // Called when the state of the tuner changes
       
   633 // ----------------------------------------------------
       
   634 //
       
   635 void CMMFRadioBackendEngine::MrpoStateChange(
       
   636     TPlayerState aState,
       
   637     TInt aError )
       
   638 {
       
   639     if ( aError )
       
   640     {
       
   641         DEBUG_API_A1("CMMFRadioBackendEngine::MrpoStateChange: aError =  %d", aError);
       
   642  //     RDebug::Print(_L("CMMFRadioBackendEngine::MrpoStateChange: aError = %d"), aError);
       
   643     }
       
   644 
       
   645     DEBUG_API_A1("CMMFRadioBackendEngine::MrpoStateChange: new state =  %d", aState);
       
   646 //  RDebug::Print(_L("CMMFRadioBackendEngine::MrpoStateChange: new state = %d"), aState);
       
   647 
       
   648     if ( aState == ERadioPlayerPlaying )
       
   649     {
       
   650     XAPlayItfAdaptMMF_StateChange((XAAdaptationBaseCtx*)iPlayerAdaptContext, ETrue);
       
   651     }
       
   652     else  // ERadioPlayerIdle
       
   653     {
       
   654     XAPlayItfAdaptMMF_StateChange((XAAdaptationBaseCtx*)iPlayerAdaptContext, EFalse);
       
   655     }
       
   656 }
       
   657 
       
   658 extern "C" {
       
   659 
       
   660     void* cmmfradiobackendengine_init()
       
   661     {
       
   662         return CMMFRadioBackendEngine::Instance();
       
   663     }
       
   664 
       
   665     void cmmfradiobackendengine_delete(void* context)
       
   666     {
       
   667         ((CMMFRadioBackendEngine*)(context))->DeleteInstance();
       
   668     }
       
   669 
       
   670     void  set_frequency(void* context, XAuint32 freq)
       
   671     {
       
   672         ((CMMFRadioBackendEngine*)(context))->SetFrequency((TInt)freq);
       
   673     }
       
   674 
       
   675     XAresult  get_frequency(void* context, XAuint32* freq)
       
   676     {
       
   677         return ((CMMFRadioBackendEngine*)(context))->GetFrequency((TInt&)*freq);
       
   678     }
       
   679 
       
   680     XAresult  get_signal_strength(void* context, XAuint32* signalStrength)
       
   681     {
       
   682         return ((CMMFRadioBackendEngine*)(context))->GetSignalStrength((TInt&)*signalStrength);
       
   683     }
       
   684 
       
   685     void station_seek(void* context, XAboolean upwards)
       
   686     {
       
   687         ((CMMFRadioBackendEngine*)(context))->StationSeek(upwards);
       
   688     }
       
   689 
       
   690     void cancel_set_frequency(void* context)
       
   691     {
       
   692         ((CMMFRadioBackendEngine*)(context))->CancelSetFrequency();
       
   693     }
       
   694 
       
   695     void cancel_station_seek(void* context)
       
   696     {
       
   697         ((CMMFRadioBackendEngine*)(context))->CancelStationSeek();
       
   698     }
       
   699 
       
   700     void set_freq_range(void* context, XAuint8 range)
       
   701     {
       
   702         ((CMMFRadioBackendEngine*)(context))->SetFreqRange((TFmRadioFrequencyRange)range);
       
   703     }
       
   704 
       
   705     XAresult  get_freq_range(void* context, XAuint8* range)
       
   706     {
       
   707         return ((CMMFRadioBackendEngine*)(context))->GetFreqRange((TFmRadioFrequencyRange&)*range);
       
   708     }
       
   709 
       
   710     XAresult  get_freq_range_properties(void* context, XAuint8 aRange, XAuint32* aMinFreq, XAuint32* aMaxFreq)
       
   711     {
       
   712         return ((CMMFRadioBackendEngine*)(context))->GetFreqRangeProperties((TFmRadioFrequencyRange&) aRange, (TInt&) *aMinFreq, (TInt&) *aMaxFreq);
       
   713     }
       
   714 
       
   715     XAresult  get_max_volume(void* context, XAmillibel* maxVol)
       
   716     {
       
   717         return  ((CMMFRadioBackendEngine*)(context))->GetMaxVolume((TInt&)*maxVol);
       
   718     }
       
   719 
       
   720     XAresult  set_volume(void* context, XAuint32 vol)
       
   721     {
       
   722         return ((CMMFRadioBackendEngine*)(context))->SetVolume((TInt)vol);
       
   723     }
       
   724 
       
   725     XAresult  get_volume(void* context, XAuint32* vol)
       
   726     {
       
   727         return ((CMMFRadioBackendEngine*)(context))->GetVolume((TInt&)*vol);
       
   728     }
       
   729 
       
   730     XAresult  set_mute(void* context, XAboolean mute)
       
   731     {
       
   732         return ((CMMFRadioBackendEngine*)(context))->SetMute(mute);
       
   733     }
       
   734 
       
   735     XAresult  get_stereo_mode(void* context, XAuint32* mode)
       
   736     {
       
   737         return ((CMMFRadioBackendEngine*)(context))->GetForcedMonoReception(*mode);
       
   738     }
       
   739 
       
   740     XAresult  set_stereo_mode(void* context, XAuint32 mode)
       
   741     {
       
   742         return ((CMMFRadioBackendEngine*)(context))->ForceMonoReception(mode);
       
   743     }
       
   744 
       
   745     void play_radio(void* context)
       
   746     {
       
   747         ((CMMFRadioBackendEngine*)(context))->PlayRadio();
       
   748     }
       
   749 
       
   750     void stop_radio(void* context)
       
   751     {
       
   752         ((CMMFRadioBackendEngine*)(context))->StopRadio();
       
   753     }
       
   754 
       
   755     XAresult mmf_set_radio_adapt_context(void * context, void * adaptcontext)
       
   756     {
       
   757         return ((CMMFRadioBackendEngine*)(context))->SetRadioAdaptContext(adaptcontext);
       
   758     }
       
   759 
       
   760     XAresult mmf_set_player_adapt_context(void * context, void * adaptcontext)
       
   761     {
       
   762         return ((CMMFRadioBackendEngine*)(context))->SetPlayerAdaptContext(adaptcontext);
       
   763     }
       
   764 }