123 aFreq = iDefaultFrequency; |
124 aFreq = iDefaultFrequency; |
124 ret = KErrNone; |
125 ret = KErrNone; |
125 } |
126 } |
126 } |
127 } |
127 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::GetFrequency RET: %d", ret); |
128 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::GetFrequency RET: %d", ret); |
128 return ret; |
129 return TranslateError(ret); |
129 } |
130 } |
130 |
131 |
131 TInt CMMFRadioBackendEngine::GetSignalStrength(TInt& aSignalStrength) |
132 XAresult CMMFRadioBackendEngine::GetSignalStrength(TInt& aSignalStrength) |
132 { |
133 { |
133 TInt ret = KErrNotFound; |
134 TInt ret = KErrNotFound; |
134 if (iFmTunerUtility) |
135 if (iFmTunerUtility) |
135 { |
136 { |
136 ret = iFmTunerUtility->GetSignalStrength(aSignalStrength); |
137 ret = iFmTunerUtility->GetSignalStrength(aSignalStrength); |
137 } |
138 } |
138 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::GetSignalStrength RET: %d", ret); |
139 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::GetSignalStrength RET: %d", ret); |
139 // RDebug::Print(_L("CMMFRadioBackendEngine::GetSignalStrength RET: %d"), ret); |
140 return TranslateError(ret); |
140 return ret; |
|
141 } |
141 } |
142 |
142 |
143 void CMMFRadioBackendEngine::CancelSetFrequency() |
143 void CMMFRadioBackendEngine::CancelSetFrequency() |
144 { |
144 { |
145 if (iFmTunerUtility) |
145 if (iFmTunerUtility) |
179 maxFreq = iDefaultMaxFreq; |
179 maxFreq = iDefaultMaxFreq; |
180 aRange = iDefaultFreqRange; |
180 aRange = iDefaultFreqRange; |
181 ret = KErrNone; |
181 ret = KErrNone; |
182 } |
182 } |
183 } |
183 } |
184 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::GetFreqRange RET: %d", ret); |
184 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::GetFreqRange RET: %d", ret); |
185 return ret; |
185 return TranslateError(ret); |
186 } |
186 } |
187 |
187 |
188 TInt CMMFRadioBackendEngine::GetFreqRangeProperties(TFmRadioFrequencyRange& aRange, TInt& aMinFreq, TInt& aMaxFreq) |
188 XAresult CMMFRadioBackendEngine::GetFreqRangeProperties(TFmRadioFrequencyRange& aRange, TInt& aMinFreq, TInt& aMaxFreq) |
189 { |
189 { |
190 TInt ret = KErrNotFound; |
190 TInt ret = KErrNotFound; |
191 if (iFmTunerUtility) |
191 if (iFmTunerUtility) |
192 { |
192 { |
193 ret = iFmTunerUtility->GetFrequencyRange((TFmRadioFrequencyRange&)aRange, (TInt&)aMinFreq, (TInt&)aMaxFreq); |
193 ret = iFmTunerUtility->GetFrequencyRange((TFmRadioFrequencyRange&)aRange, (TInt&)aMinFreq, (TInt&)aMaxFreq); |
197 aMinFreq = iDefaultMinFreq; |
197 aMinFreq = iDefaultMinFreq; |
198 aMaxFreq = iDefaultMaxFreq; |
198 aMaxFreq = iDefaultMaxFreq; |
199 ret = KErrNone; |
199 ret = KErrNone; |
200 } |
200 } |
201 } |
201 } |
202 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::GetFreqRangeProperties RET: %d", ret); |
202 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::GetFreqRangeProperties RET: %d", ret); |
203 return ret; |
203 return TranslateError(ret); |
204 } |
204 } |
205 TInt CMMFRadioBackendEngine::GetMaxVolume(TInt& aMaxVol) |
205 |
206 { |
206 XAresult CMMFRadioBackendEngine::SetVolume(TInt aVol) |
207 TInt ret = KErrNotFound; |
|
208 if (iRadioPlayerUtility) |
|
209 { |
|
210 ret = iRadioPlayerUtility->GetMaxVolume(aMaxVol); |
|
211 } |
|
212 return ret; |
|
213 } |
|
214 |
|
215 TInt CMMFRadioBackendEngine::SetVolume(TInt aVol) |
|
216 { |
207 { |
217 TInt ret = KErrNotFound; |
208 TInt ret = KErrNotFound; |
218 if (iRadioPlayerUtility) |
209 if (iRadioPlayerUtility) |
219 { |
210 { |
220 ret = iRadioPlayerUtility->SetVolume(aVol); |
211 ret = iRadioPlayerUtility->SetVolume(aVol); |
221 } |
212 } |
222 return ret; |
213 return TranslateError(ret); |
223 } |
214 } |
224 |
215 |
225 TInt CMMFRadioBackendEngine::SetMute(TBool aMute) |
216 XAresult CMMFRadioBackendEngine::SetMute(TBool aMute) |
226 { |
217 { |
227 TInt ret = KErrNotFound; |
218 TInt ret = KErrNotFound; |
228 if (iRadioPlayerUtility) |
219 if (iRadioPlayerUtility) |
229 { |
220 { |
230 ret = iRadioPlayerUtility->Mute(aMute); |
221 ret = iRadioPlayerUtility->Mute(aMute); |
231 } |
222 } |
232 return ret; |
223 return TranslateError(ret); |
233 } |
224 } |
234 |
225 |
235 TInt CMMFRadioBackendEngine::GetVolume(TInt& aVol) |
226 XAresult CMMFRadioBackendEngine::GetVolume(TInt& aVol) |
236 { |
227 { |
237 TInt ret = KErrNotFound; |
228 TInt ret = KErrNotFound; |
238 if (iRadioPlayerUtility) |
229 if (iRadioPlayerUtility) |
239 { |
230 { |
240 ret = iRadioPlayerUtility->GetVolume(aVol); |
231 ret = iRadioPlayerUtility->GetVolume(aVol); |
241 } |
232 } |
242 return ret; |
233 return TranslateError(ret); |
243 } |
234 } |
244 |
235 |
245 TInt CMMFRadioBackendEngine::GetForcedMonoReception(TUint& aForcedMono) |
236 XAresult CMMFRadioBackendEngine::GetForcedMonoReception(TUint& aForcedMono) |
246 { |
237 { |
247 TInt ret = KErrNotFound; |
238 TInt ret = KErrNotFound; |
248 TBool forceMono(EFalse); |
239 TBool forceMono = XA_BOOLEAN_FALSE; |
249 |
240 |
250 if (iFmTunerUtility) |
241 if (iFmTunerUtility) |
251 { |
242 { |
252 ret = iFmTunerUtility->GetForcedMonoReception(forceMono); |
243 ret = iFmTunerUtility->GetForcedMonoReception(forceMono); |
253 if (ret == KErrNotReady) |
244 if (ret == KErrNotReady) |
254 { |
245 { |
255 aForcedMono = XA_STEREOMODE_AUTO; // Radio Utility Default value |
246 aForcedMono = XA_STEREOMODE_AUTO; // Radio Utility Default value |
256 return KErrNone; |
247 return TranslateError(KErrNone); |
257 } |
248 } |
258 } |
249 } |
259 |
250 |
260 if (forceMono) |
251 if (forceMono) |
261 { |
252 { |
285 { |
276 { |
286 iRadioPlayerUtility->Stop(); |
277 iRadioPlayerUtility->Stop(); |
287 } |
278 } |
288 } |
279 } |
289 |
280 |
290 TInt CMMFRadioBackendEngine::ForceMonoReception(TUint aForcedMono) |
281 XAresult CMMFRadioBackendEngine::ForceMonoReception(TUint aForcedMono) |
291 { |
282 { |
292 TInt ret = KErrNotFound; |
283 TInt ret = KErrNotFound; |
293 TUint currentMode; |
284 TUint currentMode; |
294 |
285 |
295 ret = GetForcedMonoReception(currentMode); |
286 ret = GetForcedMonoReception(currentMode); |
296 if (ret != XA_RESULT_SUCCESS) |
287 if (ret != XA_RESULT_SUCCESS) |
297 return ret; |
288 return TranslateError(ret); |
298 |
289 |
299 if (iFmTunerUtility) |
290 if (iFmTunerUtility) |
300 { |
291 { |
301 if (aForcedMono == XA_STEREOMODE_MONO) |
292 if (aForcedMono == XA_STEREOMODE_MONO) |
302 { |
293 { |
326 { |
317 { |
327 ret = iFmTunerUtility->ForceMonoReception(EFalse); |
318 ret = iFmTunerUtility->ForceMonoReception(EFalse); |
328 } |
319 } |
329 } |
320 } |
330 } |
321 } |
331 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::ForceMonoReception RET: %d", ret); |
322 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::ForceMonoReception RET: %d", ret); |
332 return ret; |
323 return TranslateError(ret); |
333 } |
324 } |
334 |
325 |
335 XAresult CMMFRadioBackendEngine::SetForceMonoFlag() |
326 XAresult CMMFRadioBackendEngine::SetForceMonoFlag() |
336 { |
327 { |
337 TInt ret = KErrNotFound; |
328 TInt ret = KErrNotFound; |
338 TBool forceMono; |
329 TBool forceMono = XA_BOOLEAN_FALSE; |
339 |
330 |
340 if (iFmTunerUtility) |
331 if (iFmTunerUtility) |
341 { |
332 { |
342 ret = iFmTunerUtility->GetForcedMonoReception(forceMono); |
333 ret = iFmTunerUtility->GetForcedMonoReception(forceMono); |
343 if (ret == KErrNotReady) |
334 if (ret == KErrNotReady) |
344 { |
335 { |
345 // For Radio Utility Default value = XA_STEREOMODE_STEREO |
336 // For Radio Utility Default value = XA_STEREOMODE_STEREO |
346 iForceStereo = ETrue; |
337 iForceStereo = ETrue; |
347 return KErrNone; |
338 return TranslateError(KErrNone); |
348 } |
339 } |
349 } |
340 } |
350 if (forceMono == XA_STEREOMODE_MONO) |
341 if (!forceMono) |
351 { |
342 { |
352 iForceStereo = EFalse; |
343 iForceStereo = EFalse; |
353 } |
344 } |
354 else |
345 else |
355 { |
346 { |
356 iForceStereo = ETrue; |
347 iForceStereo = ETrue; |
357 } |
348 } |
358 return ret; |
349 return TranslateError(ret); |
359 } |
350 } |
360 |
351 |
361 TInt CMMFRadioBackendEngine::GetSquelch(TBool& aSquelch) |
352 XAresult CMMFRadioBackendEngine::GetSquelch(TBool& aSquelch) |
362 { |
353 { |
363 TInt ret = KErrNotFound; |
354 TInt ret = KErrNotFound; |
364 if (iFmTunerUtility) |
355 if (iFmTunerUtility) |
365 { |
356 { |
366 ret = iFmTunerUtility->GetSquelch(aSquelch); |
357 ret = iFmTunerUtility->GetSquelch(aSquelch); |
367 } |
358 } |
368 return ret; |
359 return TranslateError(ret); |
369 } |
360 } |
370 |
361 |
371 TInt CMMFRadioBackendEngine::SetSquelch(TBool aSquelch) |
362 XAresult CMMFRadioBackendEngine::SetSquelch(TBool aSquelch) |
372 { |
363 { |
373 TInt ret = KErrNotFound; |
364 TInt ret = KErrNotFound; |
374 if (iFmTunerUtility) |
365 if (iFmTunerUtility) |
375 { |
366 { |
376 ret = iFmTunerUtility->SetSquelch(aSquelch); |
367 ret = iFmTunerUtility->SetSquelch(aSquelch); |
377 } |
368 } |
378 return ret; |
369 return TranslateError(ret); |
379 } |
370 } |
380 |
371 |
381 void CMMFRadioBackendEngine::SetAdaptContext(void * adaptcontext) |
372 void CMMFRadioBackendEngine::SetAdaptContext(void * adaptcontext) |
382 { |
373 { |
383 iAdaptContext = (XAAdaptationBaseCtx*)adaptcontext; |
374 iAdaptContext = (XAAdaptationBaseCtx*)adaptcontext; |
384 } |
375 } |
385 |
376 |
386 XAresult TranslateError(TInt error) |
377 XAresult CMMFRadioBackendEngine::TranslateError(TInt error) |
387 { |
378 { |
388 XAresult status(XA_RESULT_SUCCESS); |
379 XAresult status(XA_RESULT_SUCCESS); |
389 switch(error) |
380 switch(error) |
390 { |
381 { |
391 case KErrNone: |
382 case KErrNone: |
392 status = XA_RESULT_SUCCESS; |
383 status = XA_RESULT_SUCCESS; |
|
384 break; |
|
385 case KErrNotFound: |
|
386 status = XA_RESULT_MEMORY_FAILURE; |
393 break; |
387 break; |
394 // to do: investigate and add other possible errors: |
388 // to do: investigate and add other possible errors: |
395 |
389 |
396 /* case XA_RESULT_PRECONDITIONS_VIOLATED: |
390 /* case XA_RESULT_PRECONDITIONS_VIOLATED: |
397 |
391 |
398 break; |
392 break; |
399 case XA_RESULT_PARAMETER_INVALID: |
393 case XA_RESULT_PARAMETER_INVALID: |
400 |
394 |
401 break; |
395 break; |
402 case XA_RESULT_MEMORY_FAILURE: |
396 |
403 |
|
404 break; |
|
405 case XA_RESULT_RESOURCE_ERROR: |
397 case XA_RESULT_RESOURCE_ERROR: |
406 |
398 |
407 break; |
399 break; |
408 case XA_RESULT_RESOURCE_LOST: |
400 case XA_RESULT_RESOURCE_LOST: |
409 |
401 |
500 // ---------------------------------------------------- |
491 // ---------------------------------------------------- |
501 // |
492 // |
502 void CMMFRadioBackendEngine::MrftoFrequencyRangeChange( |
493 void CMMFRadioBackendEngine::MrftoFrequencyRangeChange( |
503 TFmRadioFrequencyRange aNewRange ) |
494 TFmRadioFrequencyRange aNewRange ) |
504 { |
495 { |
505 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoFrequencyRangeChange: aNewRange = %d", aNewRange); |
496 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoFrequencyRangeChange: aNewRange = %d", aNewRange); |
506 XARadioItfAdapt_FrequencyRangeChange((XAAdaptationBaseCtx*)iAdaptContext, aNewRange); |
497 XARadioItfAdapt_FrequencyRangeChange((XAAdaptationBaseCtx*)iAdaptContext, aNewRange); |
507 } |
498 } |
508 |
499 |
509 // ---------------------------------------------------- |
500 // ---------------------------------------------------- |
510 // CMMFRadioBackendEngine::MrftoOfflineModeStatusChange |
501 // CMMFRadioBackendEngine::MrftoOfflineModeStatusChange |
557 // |
548 // |
558 void CMMFRadioBackendEngine::MrftoSetFrequencyComplete( |
549 void CMMFRadioBackendEngine::MrftoSetFrequencyComplete( |
559 TInt aError ) |
550 TInt aError ) |
560 { |
551 { |
561 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyComplete: aError = %d", aError); |
552 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyComplete: aError = %d", aError); |
562 // RDebug::Print(_L("CMMFRadioBackendEngine::MrftoFrrequencyComplete: aError = %d"), aError); |
|
563 TInt freq = 0; |
553 TInt freq = 0; |
564 if (!aError) |
554 if (aError == KErrNone) |
565 { |
555 { |
566 iFmTunerUtility->GetFrequency(freq); |
556 iFmTunerUtility->GetFrequency(freq); |
567 } |
557 } |
568 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyComplete: new freq is: %d", freq); |
558 // DEBUG_CPP_API_A1("CMMFRadioBackendEngine::MrftoSetFrequencyComplete: new freq is: %d", freq); |
569 XARadioItfAdapt_SetFrequencyComplete((XAAdaptationBaseCtx*)iAdaptContext, aError, freq); |
559 XARadioItfAdapt_SetFrequencyComplete((XAAdaptationBaseCtx*)iAdaptContext, aError, freq); |
710 XAresult get_freq_range_properties(void* pContext, XAuint8 aRange, XAuint32* pMinFreq, XAuint32* pMaxFreq) |
701 XAresult get_freq_range_properties(void* pContext, XAuint8 aRange, XAuint32* pMinFreq, XAuint32* pMaxFreq) |
711 { |
702 { |
712 return ((CMMFRadioBackendEngine*)(pContext))->GetFreqRangeProperties((TFmRadioFrequencyRange&) aRange, (TInt&) *pMinFreq, (TInt&) *pMaxFreq); |
703 return ((CMMFRadioBackendEngine*)(pContext))->GetFreqRangeProperties((TFmRadioFrequencyRange&) aRange, (TInt&) *pMinFreq, (TInt&) *pMaxFreq); |
713 } |
704 } |
714 |
705 |
715 XAresult get_max_volume(void* pContext, XAmillibel* pMaxVol) |
|
716 { |
|
717 return ((CMMFRadioBackendEngine*)(pContext))->GetMaxVolume((TInt&)*pMaxVol); |
|
718 } |
|
719 |
|
720 XAresult set_volume(void* pContext, void* pAdaptcontext, XAuint32 vol) |
706 XAresult set_volume(void* pContext, void* pAdaptcontext, XAuint32 vol) |
721 { |
707 { |
722 ((CMMFRadioBackendEngine*)(pContext))->SetAdaptContext(pAdaptcontext); |
708 ((CMMFRadioBackendEngine*)(pContext))->SetAdaptContext(pAdaptcontext); |
723 return ((CMMFRadioBackendEngine*)(pContext))->SetVolume((TInt)vol); |
709 return ((CMMFRadioBackendEngine*)(pContext))->SetVolume((TInt)vol); |
724 } |
710 } |