Bug 818824 - Fire an event when no audio channel is playing now. r=baku, a=blocking-basecamp

This commit is contained in:
Marco Chen 2012-12-07 19:46:18 +08:00
Родитель 60c0188e98
Коммит dab388309c
1 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -122,6 +122,22 @@ AudioChannelService::UnregisterType(AudioChannelType aType)
mChannelCounters[aType]--;
MOZ_ASSERT(mChannelCounters[aType] >= 0);
bool isNoChannelUsed = true;
for (int32_t type = AUDIO_CHANNEL_NORMAL;
type <= AUDIO_CHANNEL_PUBLICNOTIFICATION;
++type) {
if (mChannelCounters[type]) {
isNoChannelUsed = false;
break;
}
}
if (isNoChannelUsed) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
obs->NotifyObservers(nullptr, "audio-channel-changed", NS_LITERAL_STRING("default").get());
return;
}
// In order to avoid race conditions, it's safer to notify any existing
// agent any time a new one is registered.
Notify();