Bug 836201 - [FM Radio] Music is not playing while FM is playing in background. r=jlebar, a=leo+

This commit is contained in:
Marco Chen 2013-04-15 23:02:12 +08:00
parent 8986e0f4c3
commit 7630cbfa40
2 changed files with 10 additions and 1 deletions

View File

@ -251,14 +251,23 @@ NS_IMETHODIMP FMRadio::CanPlayChanged(bool canPlay)
nsCOMPtr<nsIAudioManager> audioManager =
do_GetService(NS_AUDIOMANAGER_CONTRACTID);
NS_ENSURE_TRUE(audioManager, NS_OK);
bool AudioEnabled;
audioManager->GetFmRadioAudioEnabled(&AudioEnabled);
if (AudioEnabled == canPlay) {
return NS_OK;
}
/* mute fm first, it should be better to stop&resume fm */
if (canPlay) {
audioManager->SetFmRadioAudioEnabled(true);
int32_t volIdx = 0;
// Restore fm volume, that value is sync as music type
audioManager->GetStreamVolumeIndex(nsIAudioManager::STREAM_TYPE_MUSIC, &volIdx);
audioManager->SetStreamVolumeIndex(nsIAudioManager::STREAM_TYPE_FM, volIdx);
} else {
audioManager->SetStreamVolumeIndex(nsIAudioManager::STREAM_TYPE_FM, 0);
audioManager->SetFmRadioAudioEnabled(false);
}
return NS_OK;
}

View File

@ -42,10 +42,10 @@ public:
private:
~FMRadio();
nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
hal::SwitchState mHeadphoneState;
bool mHasInternalAntenna;
bool mHidden;
nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
};
} // namespace fm