2012-12-06 03:01:58 +00:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "AudioChannelServiceChild.h"
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
|
|
|
#include "mozilla/Services.h"
|
|
|
|
#include "mozilla/StaticPtr.h"
|
|
|
|
#include "mozilla/unused.h"
|
|
|
|
#include "mozilla/Util.h"
|
|
|
|
|
|
|
|
#include "mozilla/dom/ContentChild.h"
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
|
|
|
StaticRefPtr<AudioChannelServiceChild> gAudioChannelServiceChild;
|
|
|
|
|
|
|
|
// static
|
|
|
|
AudioChannelService*
|
|
|
|
AudioChannelServiceChild::GetAudioChannelService()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
// If we already exist, exit early
|
|
|
|
if (gAudioChannelServiceChild) {
|
|
|
|
return gAudioChannelServiceChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create new instance, register, return
|
|
|
|
nsRefPtr<AudioChannelServiceChild> service = new AudioChannelServiceChild();
|
|
|
|
NS_ENSURE_TRUE(service, nullptr);
|
|
|
|
|
|
|
|
gAudioChannelServiceChild = service;
|
|
|
|
return gAudioChannelServiceChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AudioChannelServiceChild::Shutdown()
|
|
|
|
{
|
|
|
|
if (gAudioChannelServiceChild) {
|
|
|
|
delete gAudioChannelServiceChild;
|
|
|
|
gAudioChannelServiceChild = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioChannelServiceChild::AudioChannelServiceChild()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioChannelServiceChild::~AudioChannelServiceChild()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
AudioChannelServiceChild::GetMuted(AudioChannelType aType, bool aMozHidden)
|
|
|
|
{
|
|
|
|
ContentChild *cc = ContentChild::GetSingleton();
|
|
|
|
bool muted = false;
|
|
|
|
|
|
|
|
if (cc) {
|
|
|
|
cc->SendAudioChannelGetMuted(aType, aMozHidden, &muted);
|
|
|
|
}
|
|
|
|
|
|
|
|
return muted;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-12-06 15:25:18 +00:00
|
|
|
AudioChannelServiceChild::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
|
2012-12-06 03:01:58 +00:00
|
|
|
AudioChannelType aType)
|
|
|
|
{
|
2012-12-06 15:25:18 +00:00
|
|
|
AudioChannelService::RegisterAudioChannelAgent(aAgent, aType);
|
2012-12-06 03:01:58 +00:00
|
|
|
|
|
|
|
ContentChild *cc = ContentChild::GetSingleton();
|
|
|
|
if (cc) {
|
|
|
|
cc->SendAudioChannelRegisterType(aType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-12-06 15:25:18 +00:00
|
|
|
AudioChannelServiceChild::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent)
|
2012-12-06 03:01:58 +00:00
|
|
|
{
|
|
|
|
AudioChannelType type;
|
2012-12-06 15:25:18 +00:00
|
|
|
if (!mAgents.Get(aAgent, &type)) {
|
2012-12-06 03:01:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-12-06 15:25:18 +00:00
|
|
|
AudioChannelService::UnregisterAudioChannelAgent(aAgent);
|
2012-12-06 03:01:58 +00:00
|
|
|
|
|
|
|
ContentChild *cc = ContentChild::GetSingleton();
|
|
|
|
if (cc) {
|
|
|
|
cc->SendAudioChannelUnregisterType(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|