mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-30 13:45:27 +00:00
116 lines
3.2 KiB
C++
116 lines
3.2 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* 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 "FMRadioParent.h"
|
|
#include "mozilla/unused.h"
|
|
#include "mozilla/dom/ContentParent.h"
|
|
#include "FMRadioRequestParent.h"
|
|
#include "FMRadioService.h"
|
|
|
|
BEGIN_FMRADIO_NAMESPACE
|
|
|
|
FMRadioParent::FMRadioParent()
|
|
{
|
|
MOZ_COUNT_CTOR(FMRadioParent);
|
|
|
|
IFMRadioService::Singleton()->AddObserver(this);
|
|
}
|
|
|
|
FMRadioParent::~FMRadioParent()
|
|
{
|
|
MOZ_COUNT_DTOR(FMRadioParent);
|
|
|
|
IFMRadioService::Singleton()->RemoveObserver(this);
|
|
}
|
|
|
|
void
|
|
FMRadioParent::ActorDestroy(ActorDestroyReason aWhy)
|
|
{
|
|
// Implement me! Bug 1005146
|
|
}
|
|
|
|
bool
|
|
FMRadioParent::RecvGetStatusInfo(StatusInfo* aStatusInfo)
|
|
{
|
|
aStatusInfo->enabled() = IFMRadioService::Singleton()->IsEnabled();
|
|
aStatusInfo->frequency() = IFMRadioService::Singleton()->GetFrequency();
|
|
aStatusInfo->upperBound() =
|
|
IFMRadioService::Singleton()->GetFrequencyUpperBound();
|
|
aStatusInfo->lowerBound() =
|
|
IFMRadioService::Singleton()->GetFrequencyLowerBound();
|
|
aStatusInfo->channelWidth() =
|
|
IFMRadioService::Singleton()->GetChannelWidth();
|
|
return true;
|
|
}
|
|
|
|
PFMRadioRequestParent*
|
|
FMRadioParent::AllocPFMRadioRequestParent(const FMRadioRequestArgs& aArgs)
|
|
{
|
|
nsRefPtr<FMRadioRequestParent> requestParent = new FMRadioRequestParent();
|
|
|
|
switch (aArgs.type()) {
|
|
case FMRadioRequestArgs::TEnableRequestArgs:
|
|
IFMRadioService::Singleton()->Enable(
|
|
aArgs.get_EnableRequestArgs().frequency(), requestParent);
|
|
break;
|
|
case FMRadioRequestArgs::TDisableRequestArgs:
|
|
IFMRadioService::Singleton()->Disable(requestParent);
|
|
break;
|
|
case FMRadioRequestArgs::TSetFrequencyRequestArgs:
|
|
IFMRadioService::Singleton()->SetFrequency(
|
|
aArgs.get_SetFrequencyRequestArgs().frequency(), requestParent);
|
|
break;
|
|
case FMRadioRequestArgs::TSeekRequestArgs:
|
|
IFMRadioService::Singleton()->Seek(
|
|
aArgs.get_SeekRequestArgs().direction(), requestParent);
|
|
break;
|
|
case FMRadioRequestArgs::TCancelSeekRequestArgs:
|
|
IFMRadioService::Singleton()->CancelSeek(requestParent);
|
|
break;
|
|
default:
|
|
MOZ_CRASH();
|
|
}
|
|
|
|
// Balanced in DeallocPFMRadioRequestParent
|
|
return requestParent.forget().take();
|
|
}
|
|
|
|
bool
|
|
FMRadioParent::DeallocPFMRadioRequestParent(PFMRadioRequestParent* aActor)
|
|
{
|
|
FMRadioRequestParent* parent = static_cast<FMRadioRequestParent*>(aActor);
|
|
NS_RELEASE(parent);
|
|
return true;
|
|
}
|
|
|
|
void
|
|
FMRadioParent::Notify(const FMRadioEventType& aType)
|
|
{
|
|
switch (aType) {
|
|
case FrequencyChanged:
|
|
unused << SendNotifyFrequencyChanged(
|
|
IFMRadioService::Singleton()->GetFrequency());
|
|
break;
|
|
case EnabledChanged:
|
|
unused << SendNotifyEnabledChanged(
|
|
IFMRadioService::Singleton()->IsEnabled(),
|
|
IFMRadioService::Singleton()->GetFrequency());
|
|
break;
|
|
default:
|
|
NS_RUNTIMEABORT("not reached");
|
|
break;
|
|
}
|
|
}
|
|
|
|
bool
|
|
FMRadioParent::RecvEnableAudio(const bool& aAudioEnabled)
|
|
{
|
|
IFMRadioService::Singleton()->EnableAudio(aAudioEnabled);
|
|
return true;
|
|
}
|
|
|
|
END_FMRADIO_NAMESPACE
|
|
|