radioengine/engine/src/cradiordsreceiver.cpp
branchGCC_SURGE
changeset 37 451b2e1545b2
parent 14 63aabac4416d
parent 28 075425b8d9a4
equal deleted inserted replaced
26:6bcf277166c1 37:451b2e1545b2
    28 // ---------------------------------------------------------------------------
    28 // ---------------------------------------------------------------------------
    29 //
    29 //
    30 CRadioRdsReceiver::CRadioRdsReceiver( MRadioEngineSettings& aSettings )
    30 CRadioRdsReceiver::CRadioRdsReceiver( MRadioEngineSettings& aSettings )
    31     : CRadioRdsReceiverBase( aSettings )
    31     : CRadioRdsReceiverBase( aSettings )
    32     {
    32     {
       
    33     LEVEL3( LOG_METHOD_AUTO );
    33     }
    34     }
    34 
    35 
    35 // ---------------------------------------------------------------------------
    36 // ---------------------------------------------------------------------------
    36 //
    37 //
    37 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
    38 //
    39 //
    39 void CRadioRdsReceiver::ConstructL()
    40 void CRadioRdsReceiver::ConstructL()
    40     {
    41     {
       
    42     LEVEL3( LOG_METHOD_AUTO );
    41     BaseConstructL();
    43     BaseConstructL();
    42     }
    44     }
    43 
    45 
    44 // ---------------------------------------------------------------------------
    46 // ---------------------------------------------------------------------------
    45 //
    47 //
    46 // ---------------------------------------------------------------------------
    48 // ---------------------------------------------------------------------------
    47 //
    49 //
    48 CRadioRdsReceiver* CRadioRdsReceiver::NewL( MRadioEngineSettings& aSettings )
    50 CRadioRdsReceiver* CRadioRdsReceiver::NewL( MRadioEngineSettings& aSettings )
    49     {
    51     {
       
    52     LEVEL3( LOG_METHOD_AUTO );
    50     CRadioRdsReceiver* self = new ( ELeave ) CRadioRdsReceiver( aSettings );
    53     CRadioRdsReceiver* self = new ( ELeave ) CRadioRdsReceiver( aSettings );
    51     CleanupStack::PushL( self );
    54     CleanupStack::PushL( self );
    52     self->ConstructL();
    55     self->ConstructL();
    53     CleanupStack::Pop( self );
    56     CleanupStack::Pop( self );
    54     return self;
    57     return self;
    58 //
    61 //
    59 // ---------------------------------------------------------------------------
    62 // ---------------------------------------------------------------------------
    60 //
    63 //
    61 CRadioRdsReceiver::~CRadioRdsReceiver()
    64 CRadioRdsReceiver::~CRadioRdsReceiver()
    62     {
    65     {
       
    66     LEVEL3( LOG_METHOD_AUTO );
    63     if ( iRdsUtility )
    67     if ( iRdsUtility )
    64         {
    68         {
    65         iRdsUtility->Close();
    69         iRdsUtility->Close();
    66         }
    70         }
    67     }
    71     }
    68 
    72 
    69 // ---------------------------------------------------------------------------
    73 // ---------------------------------------------------------------------------
    70 //
    74 //
    71 // ---------------------------------------------------------------------------
    75 // ---------------------------------------------------------------------------
    72 //
    76 //
    73 void CRadioRdsReceiver::InitL( CRadioUtility& aRadioUtility, CRadioPubSub* aPubSub )
    77 void CRadioRdsReceiver::InitL( CRadioUtility& aRadioUtility )
    74     {
    78     {
    75     LOG_METHOD_AUTO;
    79     LOG_METHOD_AUTO;
    76     iPubSub = aPubSub;
       
    77 
    80 
    78     iRdsUtility = &aRadioUtility.RadioRdsUtilityL( *this );
    81     iRdsUtility = &aRadioUtility.RadioRdsUtilityL( *this );
    79 
    82 
    80     LogReceiverCapabilities();
    83     LogReceiverCapabilities();
    81 
    84 
    82     SetAutomaticSwitchingL( iSettings.RdsAfSearchEnabled() );
    85     SetAutomaticSwitchingL( EFalse );
    83     }
    86     }
    84 
    87 
    85 // ---------------------------------------------------------------------------
    88 // ---------------------------------------------------------------------------
    86 //
    89 //
    87 // ---------------------------------------------------------------------------
    90 // ---------------------------------------------------------------------------
    88 //
    91 //
    89 void CRadioRdsReceiver::SetAutomaticSwitchingL( TBool aEnable )
    92 void CRadioRdsReceiver::SetAutomaticSwitchingL( TBool aEnable )
    90     {
    93     {
       
    94     LEVEL3( LOG_METHOD_AUTO );
    91     if ( iRdsUtility )
    95     if ( iRdsUtility )
    92         {
    96         {
    93         User::LeaveIfError( iRdsUtility->SetAutomaticSwitching( aEnable ) );
    97         User::LeaveIfError( iRdsUtility->SetAutomaticSwitching( aEnable ) );
    94         }
    98         }
    95 
    99 
   101 //
   105 //
   102 // ---------------------------------------------------------------------------
   106 // ---------------------------------------------------------------------------
   103 //
   107 //
   104 void CRadioRdsReceiver::StartReceiver()
   108 void CRadioRdsReceiver::StartReceiver()
   105     {
   109     {
       
   110     LOG_METHOD_AUTO;
   106     // Request to be notified of almost all RDS data.
   111     // Request to be notified of almost all RDS data.
   107     // Unwanted RDS values:
   112     // Unwanted RDS values:
   108     //    ERdsClockTime
   113     //    ERdsClockTime
   109     //    ERdsTrafficProgramme
   114     //    ERdsTrafficProgramme
   110     //    ERdsTrafficAnnouncement
   115     //    ERdsTrafficAnnouncement
   117                             ERdsRadioTextPlus;
   122                             ERdsRadioTextPlus;
   118 
   123 
   119     rdsData.iAdditionalFunctions1 = 0;
   124     rdsData.iAdditionalFunctions1 = 0;
   120     rdsData.iAdditionalFunctions2 = 0;
   125     rdsData.iAdditionalFunctions2 = 0;
   121 
   126 
   122     LOG_ASSERT( iRdsUtility, LOG( "CRadioRdsReceiver::StartReceiverL. Error: RDS utility not created!" ) );
   127     LOG_ASSERT( iRdsUtility, LOG( "Error: RDS utility not created!" ) );
   123     if ( iRdsUtility && !iStarted )
   128     if ( iRdsUtility && !iStarted )
   124         {
   129         {
   125         TInt err = iRdsUtility->NotifyRdsDataChange( rdsData );
   130         TInt err = iRdsUtility->NotifyRdsDataChange( rdsData );
   126         if ( !err )
   131         if ( !err )
   127             {
   132             {
   128             // Avoid further calls
   133             // Avoid further calls
   129             iStarted = ETrue;
   134             iStarted = ETrue;
   130             LOG( "CRadioRdsReceiver::StartReceiverL: Requested RDS notifications from receiver." );
   135             LOG( "Requested RDS notifications from receiver." );
   131             }
   136             }
   132         else
   137         else
   133             {
   138             {
   134             LOG_FORMAT( "CRadioRdsReceiver::StartReceiverL. Failed to request RDS data with err %d", err );
   139             LOG_FORMAT( "Failed to request RDS data with err %d", err );
   135             }
   140             }
   136         }
   141         }
   137     }
   142     }
   138 
   143 
   139 // ---------------------------------------------------------------------------
   144 // ---------------------------------------------------------------------------
   140 //
   145 //
   141 // ---------------------------------------------------------------------------
   146 // ---------------------------------------------------------------------------
   142 //
   147 //
   143 void CRadioRdsReceiver::StopReceiver()
   148 void CRadioRdsReceiver::StopReceiver()
   144     {
   149     {
   145     LOG( "CRadioRdsReceiver::StopReceiver" );
   150     LOG_METHOD_AUTO;
   146 
   151 
   147     if ( iRdsUtility )
   152     if ( iRdsUtility )
   148         {
   153         {
   149         iRdsUtility->CancelNotifyRdsDataChange();
   154         iRdsUtility->CancelNotifyRdsDataChange();
   150         }
   155         }
   155 // Logs the RDS receiver capabilities if logging is enabled
   160 // Logs the RDS receiver capabilities if logging is enabled
   156 // ---------------------------------------------------------------------------
   161 // ---------------------------------------------------------------------------
   157 //
   162 //
   158 void CRadioRdsReceiver::LogReceiverCapabilities()
   163 void CRadioRdsReceiver::LogReceiverCapabilities()
   159     {
   164     {
       
   165     LEVEL3( LOG_METHOD_AUTO );
   160 #ifdef LOGGING_ENABLED
   166 #ifdef LOGGING_ENABLED
   161     // Log the RDS utility capabilities
   167     // Log the RDS utility capabilities
   162     if ( iRdsUtility )
   168     if ( iRdsUtility )
   163         {
   169         {
   164         TRdsCapabilities caps;
   170         TRdsCapabilities caps;
   203                 }
   209                 }
   204             if ( caps.iRdsFunctions & ERdsTrafficAnnouncement == ERdsTrafficAnnouncement )
   210             if ( caps.iRdsFunctions & ERdsTrafficAnnouncement == ERdsTrafficAnnouncement )
   205                 {
   211                 {
   206                 capsBuf.Append( _L("TrafficAnnouncement ") );
   212                 capsBuf.Append( _L("TrafficAnnouncement ") );
   207                 }
   213                 }
   208             LOG_FORMAT( "CRadioRdsReceiver::LogReceiverCapabilities. RDS receiver capabilities: %S", &capsBuf );
   214             LOG_FORMAT( "RDS receiver capabilities: %S", &capsBuf );
   209             LOG_FORMAT( "CRadioRdsReceiver::LogReceiverCapabilities. Functions: %d, AdditionalFunctions1: %d, iAdditionalFunctions2: %d",
   215             LOG_FORMAT( "Functions: %d, AdditionalFunctions1: %d, iAdditionalFunctions2: %d",
   210                     caps.iRdsFunctions, caps.iAdditionalFunctions1, caps.iAdditionalFunctions2 );
   216                     caps.iRdsFunctions, caps.iAdditionalFunctions1, caps.iAdditionalFunctions2 );
   211             }
   217             }
   212         else
   218         else
   213             {
   219             {
   214             LOG_FORMAT( "CRadioRdsReceiver::LogReceiverCapabilities: Failed to get RDS utility capabilities: err %d", err );
   220             LOG_FORMAT( "Failed to get RDS utility capabilities: err %d", err );
   215             }
   221             }
   216         }
   222         }
   217 #endif // LOGGING_ENABLED
   223 #endif // LOGGING_ENABLED
   218     }
   224     }