Bug 1534313 - Remove direct calls to GetDeviceCollection method. r=padenot

Differential Revision: https://phabricator.services.mozilla.com/D22988

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alex Chronopoulos 2019-03-19 10:40:12 +00:00
Родитель 026c81cfc9
Коммит eb84b032d9
2 изменённых файлов: 14 добавлений и 14 удалений

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

@ -28,7 +28,7 @@
#include "mozilla/layers/APZCCallbackHelper.h"
#include "ClientLayerManager.h"
#include "nsQueryObject.h"
#include "CubebUtils.h"
#include "CubebDeviceEnumerator.h"
#include "nsIScrollableFrame.h"
@ -2149,10 +2149,14 @@ nsDOMWindowUtils::AudioDevices(uint16_t aSide, nsIArray** aDevices) {
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<CubebDeviceEnumerator> enumerator = Enumerator::GetInstance();
nsTArray<RefPtr<AudioDeviceInfo>> collection;
CubebUtils::GetDeviceCollection(collection, aSide == AUDIO_INPUT
? CubebUtils::Side::Input
: CubebUtils::Side::Output);
if (aSide == AUDIO_INPUT) {
enumerator->EnumerateAudioInputDevices(collection);
} else {
enumerator->EnumerateAudioOutputDevices(collection);
}
for (auto device : collection) {
devices->AppendElement(device);
}

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

@ -11,7 +11,7 @@
#include "mozilla/SharedThreadPool.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/Unused.h"
#include "CubebUtils.h"
#include "CubebDeviceEnumerator.h"
#include "Tracing.h"
#ifdef MOZ_WEBRTC
@ -578,15 +578,11 @@ bool AudioCallbackDriver::Init() {
char* forcedOutputDeviceName = CubebUtils::GetForcedOutputDevice();
if (forcedOutputDeviceName) {
nsTArray<RefPtr<AudioDeviceInfo>> deviceInfos;
GetDeviceCollection(deviceInfos, CubebUtils::Output);
for (const auto& device : deviceInfos) {
const nsString& name = device->Name();
if (name.Equals(NS_ConvertUTF8toUTF16(forcedOutputDeviceName))) {
if (device->DeviceID()) {
forcedOutputDeviceId = device->DeviceID();
}
}
RefPtr<CubebDeviceEnumerator> enumerator = Enumerator::GetInstance();
RefPtr<AudioDeviceInfo> device = enumerator->DeviceInfoFromName(
NS_ConvertUTF8toUTF16(forcedOutputDeviceName), EnumeratorSide::OUTPUT);
if (device->DeviceID()) {
forcedOutputDeviceId = device->DeviceID();
}
}