зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1624322 - Add a method to get the default device for a side in CubebDeviceEnumerator. r=achronop
Differential Revision: https://phabricator.services.mozilla.com/D68083 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f052193d19
Коммит
98e5745c85
|
@ -243,9 +243,9 @@ already_AddRefed<AudioDeviceInfo> CubebDeviceEnumerator::DeviceInfoFromID(
|
|||
if (mInputDevices.IsEmpty() || mManualInputInvalidation) {
|
||||
EnumerateAudioDevices(Side::INPUT);
|
||||
}
|
||||
for (uint32_t i = 0; i < mInputDevices.Length(); i++) {
|
||||
if (mInputDevices[i]->DeviceID() == aID) {
|
||||
RefPtr<AudioDeviceInfo> other = mInputDevices[i];
|
||||
for (RefPtr<AudioDeviceInfo>& device : mInputDevices) {
|
||||
if (device->DeviceID() == aID) {
|
||||
RefPtr<AudioDeviceInfo> other = device;
|
||||
return other.forget();
|
||||
}
|
||||
}
|
||||
|
@ -253,9 +253,9 @@ already_AddRefed<AudioDeviceInfo> CubebDeviceEnumerator::DeviceInfoFromID(
|
|||
if (mOutputDevices.IsEmpty() || mManualOutputInvalidation) {
|
||||
EnumerateAudioDevices(Side::OUTPUT);
|
||||
}
|
||||
for (uint32_t i = 0; i < mOutputDevices.Length(); i++) {
|
||||
if (mOutputDevices[i]->DeviceID() == aID) {
|
||||
RefPtr<AudioDeviceInfo> other = mOutputDevices[i];
|
||||
for (RefPtr<AudioDeviceInfo>& device : mOutputDevices) {
|
||||
if (device->DeviceID() == aID) {
|
||||
RefPtr<AudioDeviceInfo> other = device;
|
||||
return other.forget();
|
||||
}
|
||||
}
|
||||
|
@ -283,9 +283,30 @@ already_AddRefed<AudioDeviceInfo> CubebDeviceEnumerator::DeviceInfoFromName(
|
|||
if (devices.IsEmpty() || manualInvalidation) {
|
||||
EnumerateAudioDevices(aSide);
|
||||
}
|
||||
for (uint32_t i = 0; i < devices.Length(); i++) {
|
||||
if (devices[i]->Name().Equals(aName)) {
|
||||
RefPtr<AudioDeviceInfo> other = devices[i];
|
||||
for (RefPtr<AudioDeviceInfo>& device : devices) {
|
||||
if (device->Name().Equals(aName)) {
|
||||
RefPtr<AudioDeviceInfo> other = device;
|
||||
return other.forget();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<AudioDeviceInfo> CubebDeviceEnumerator::DefaultDevice(Side aSide) {
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
nsTArray<RefPtr<AudioDeviceInfo>>& devices =
|
||||
(aSide == Side::INPUT) ? mInputDevices : mOutputDevices;
|
||||
bool manualInvalidation = (aSide == Side::INPUT) ? mManualInputInvalidation
|
||||
: mManualOutputInvalidation;
|
||||
|
||||
if (devices.IsEmpty() || manualInvalidation) {
|
||||
EnumerateAudioDevices(aSide);
|
||||
}
|
||||
for (RefPtr<AudioDeviceInfo>& device : devices) {
|
||||
if (device->Preferred()) {
|
||||
RefPtr<AudioDeviceInfo> other = device;
|
||||
return other.forget();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,9 @@ class CubebDeviceEnumerator final {
|
|||
return mOnOutputDeviceListChange;
|
||||
}
|
||||
|
||||
// Return the default device for a particular side.
|
||||
RefPtr<AudioDeviceInfo> DefaultDevice(Side aSide);
|
||||
|
||||
private:
|
||||
CubebDeviceEnumerator();
|
||||
~CubebDeviceEnumerator();
|
||||
|
|
Загрузка…
Ссылка в новой задаче