Bug 1797020 - Add an API to determine if there are any midi devices. r=gsvelto

Differential Revision: https://phabricator.services.mozilla.com/D160974
This commit is contained in:
Bobby Holley 2022-11-02 17:35:51 +00:00
Родитель e9b58109c1
Коммит e8d791fac7
4 изменённых файлов: 17 добавлений и 0 удалений

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

@ -97,6 +97,9 @@ class MIDIPlatformService {
// before/at now, and schedules MIDI Port connection closing.
void Close(MIDIPortParent* aPort);
// Returns whether there are currently any MIDI devices.
bool HasDevice() { return !mPortInfo.IsEmpty(); }
protected:
MIDIPlatformService();
virtual ~MIDIPlatformService();

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

@ -1259,6 +1259,16 @@ bool BackgroundParentImpl::DeallocPMIDIManagerParent(
return true;
}
mozilla::ipc::IPCResult BackgroundParentImpl::RecvHasMIDIDevice(
HasMIDIDeviceResolver&& aResolver) {
AssertIsInMainOrSocketProcess();
AssertIsOnBackgroundThread();
bool hasDevice = MIDIPlatformService::Get()->HasDevice();
aResolver(hasDevice);
return IPC_OK();
}
mozilla::dom::PClientManagerParent*
BackgroundParentImpl::AllocPClientManagerParent() {
return mozilla::dom::AllocClientManagerParent();

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

@ -347,6 +347,9 @@ class BackgroundParentImpl : public PBackgroundParent {
bool DeallocPMIDIManagerParent(PMIDIManagerParent* aActor) override;
mozilla::ipc::IPCResult RecvHasMIDIDevice(
HasMIDIDeviceResolver&& aResolver) override;
mozilla::ipc::IPCResult RecvStorageActivity(
const PrincipalInfo& aPrincipalInfo) override;

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

@ -254,6 +254,7 @@ parent:
async PMIDIManager();
async PMIDIPort(MIDIPortInfo portInfo, bool sysexEnabled);
async HasMIDIDevice() returns (bool hasDevice);
// This method is used to propagate storage activities from the child actor
// to the parent actor. See StorageActivityService.