Closed Bug 1706524 Opened 3 years ago Closed 3 years ago

Track AudioDeviceID in AudioInputTrack

Categories

(Core :: Audio/Video: MediaStreamGraph, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: chunmin, Assigned: chunmin)

References

Details

Attachments

(1 file, 1 obsolete file)

Now the AudioDeviceID is tracked by MediaEngineWebRTCMicrophoneSource.mDeviceInfo.DeviceID() so AudioInputTrack has no idea of what device is closed when it's destroyed. In this situation, we search the paired device for the AudioDeviceID's mInputListener, in MediaTrackGraphImpl, to get the information.

We could track the AudioDeviceID directly when AudioInputTrack::OpenAudioInput is called and use this AudioDeviceID whenever AudioInputTrack::CloseAudioInput is called. Then MediaTrackGraphImpl has no need to do the search.

This gives two benefits:

  1. I am going to remove mInputDeviceUsers and skip tracking AudioDataListener in MediaTrackGraphImpl in bug 1702646. This makes things easier.
  2. The time complexity to get the device that will be closed, in MediaTrackGraphImpl::CloseAudioInputImpl, is reduced from O(MN) to O(1), where N is the number of listeners in device D and M is the number of devices in MediaTrackGraphImpl. Since we only support one device at a time currently so the actual time complexity is O(N).

This patch adds an AudioDeviceID member in AudioInputTrack. This
aims to simplify AudioInputTrack::CloseAudioInput.

Before this patch, the AudioDeviceID is tracked by
MediaEngineWebRTCMicrophoneSource only instead so AudioInputTrack
has no idea of what device it pairs with. One main drawback is that
MediaTrackGraphImpl needs to search all the AudioDataListener
inside it to infer what device is closed when
AudioInputTrack::Destroy() is called, since AudioInputTrack
doesn't know what is its paired device, which gives an O(N) time
complexity, where N is the number of AudioDataListener in
MediaTrackGraphImpl

A simple way to reduce the time complexity from O(N) to O(1) is to track
the paired device when AudioInputTrack::OpenAudioInput is called. This
also enables the possibility to remove mInputDeviceUsers in Bug
1702646.

This patch adds an AudioDeviceID member in AudioInputTrack. This
aims to simplify AudioInputTrack::CloseAudioInput.

Before this patch, the AudioDeviceID is tracked by
MediaEngineWebRTCMicrophoneSource only instead so AudioInputTrack
has no idea of what device it pairs with. One main drawback is that
MediaTrackGraphImpl needs to search all the AudioDataListener
inside it to infer what device is closed when
AudioInputTrack::Destroy() is called, since AudioInputTrack
doesn't know what is its paired device, which gives an O(N) time
complexity, where N is the number of AudioDataListener in
MediaTrackGraphImpl

A simple way to reduce the time complexity from O(N) to O(1) is to track
the paired device when AudioInputTrack::OpenAudioInput is called. This
also enables the possibility to remove mInputDeviceUsers in Bug
1702646.

Attachment #9217559 - Attachment is obsolete: true
See Also: → 1707785
Pushed by cchang@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/595892080fa3
Track AudioDeviceID in AudioInputTrack r=padenot
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 90 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: