Skip to content

Commit

Permalink
Bug 1860954 store window ID on graph r=padenot
Browse files Browse the repository at this point in the history
This will be used for naming audio output streams.

Depends on D191828

Differential Revision: https://phabricator.services.mozilla.com/D191830
  • Loading branch information
karlt committed Oct 25, 2023
1 parent b730e4d commit 2cc42dc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
14 changes: 8 additions & 6 deletions dom/media/MediaTrackGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3189,7 +3189,7 @@ void ProcessedMediaTrack::DestroyImpl() {

MediaTrackGraphImpl::MediaTrackGraphImpl(
GraphDriverType aDriverRequested, GraphRunType aRunTypeRequested,
TrackRate aSampleRate, uint32_t aChannelCount,
uint64_t aWindowID, TrackRate aSampleRate, uint32_t aChannelCount,
CubebUtils::AudioDeviceID aOutputDeviceID,
nsISerialEventTarget* aMainThread)
: MediaTrackGraph(aSampleRate),
Expand All @@ -3201,6 +3201,7 @@ MediaTrackGraphImpl::MediaTrackGraphImpl(
,
mEndTime(aDriverRequested == OFFLINE_THREAD_DRIVER ? 0 : GRAPH_TIME_MAX),
mPortCount(0),
mWindowID(aWindowID),
mOutputDeviceID(aOutputDeviceID),
mMonitor("MediaTrackGraphImpl"),
mLifecycleState(LIFECYCLE_THREAD_NOT_STARTED),
Expand Down Expand Up @@ -3326,8 +3327,9 @@ MediaTrackGraphImpl* MediaTrackGraphImpl::GetInstance(
// capped to 8.
uint32_t channelCount =
std::min<uint32_t>(8, CubebUtils::MaxNumberOfChannels());
graph = new MediaTrackGraphImpl(aGraphDriverRequested, runType, aSampleRate,
channelCount, aOutputDeviceID, aMainThread);
graph = new MediaTrackGraphImpl(aGraphDriverRequested, runType, aWindowID,
aSampleRate, channelCount, aOutputDeviceID,
aMainThread);
GraphKey key(aWindowID, aSampleRate, aOutputDeviceID);
gGraphs.InsertOrUpdate(key, graph);

Expand Down Expand Up @@ -3360,9 +3362,9 @@ MediaTrackGraph* MediaTrackGraph::CreateNonRealtimeInstance(
nsISerialEventTarget* mainThread = GetMainThreadSerialEventTarget();
// Offline graphs have 0 output channel count: they write the output to a
// buffer, not an audio output track.
MediaTrackGraphImpl* graph =
new MediaTrackGraphImpl(OFFLINE_THREAD_DRIVER, DIRECT_DRIVER, aSampleRate,
0, DEFAULT_OUTPUT_DEVICE, mainThread);
MediaTrackGraphImpl* graph = new MediaTrackGraphImpl(
OFFLINE_THREAD_DRIVER, DIRECT_DRIVER, 0, aSampleRate, 0,
DEFAULT_OUTPUT_DEVICE, mainThread);

LOG(LogLevel::Debug, ("Starting up Offline MediaTrackGraph %p", graph));

Expand Down
10 changes: 8 additions & 2 deletions dom/media/MediaTrackGraphImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
*/
explicit MediaTrackGraphImpl(GraphDriverType aGraphDriverRequested,
GraphRunType aRunTypeRequested,
TrackRate aSampleRate, uint32_t aChannelCount,
uint64_t aWindowID, TrackRate aSampleRate,
uint32_t aChannelCount,
CubebUtils::AudioDeviceID aOutputDeviceID,
nsISerialEventTarget* aMainThread);
static MediaTrackGraphImpl* GetInstance(
Expand Down Expand Up @@ -732,13 +733,18 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
*/
nsTArray<nsCOMPtr<nsIRunnable>> mPendingUpdateRunnables;

/**
* The ID of the inner Window which uses this graph, or zero for offline
* graphs.
*/
const uint64_t mWindowID;
/**
* Devices to use for cubeb output, or nullptr for default device.
* A MediaTrackGraph always has an output (even if silent).
*
* All mOutputDeviceID access is on the graph thread.
*/
CubebUtils::AudioDeviceID mOutputDeviceID;
const CubebUtils::AudioDeviceID mOutputDeviceID;

/**
* List of resume operations waiting for a switch to an AudioCallbackDriver.
Expand Down
2 changes: 1 addition & 1 deletion dom/media/gtest/TestAudioDecoderInputTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ constexpr uint32_t kChannels = 2;
class MockTestGraph : public MediaTrackGraphImpl {
public:
MockTestGraph(TrackRate aRate, uint32_t aChannels)
: MediaTrackGraphImpl(OFFLINE_THREAD_DRIVER, DIRECT_DRIVER, aRate,
: MediaTrackGraphImpl(OFFLINE_THREAD_DRIVER, DIRECT_DRIVER, 0, aRate,
aChannels, nullptr, NS_GetCurrentThread()) {
ON_CALL(*this, OnGraphThread).WillByDefault(Return(true));
// We have to call `Destroy()` manually in order to break the reference.
Expand Down
2 changes: 1 addition & 1 deletion dom/media/gtest/TestAudioInputProcessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using testing::Return;
class MockGraph : public MediaTrackGraphImpl {
public:
MockGraph(TrackRate aRate, uint32_t aChannels)
: MediaTrackGraphImpl(OFFLINE_THREAD_DRIVER, DIRECT_DRIVER, aRate,
: MediaTrackGraphImpl(OFFLINE_THREAD_DRIVER, DIRECT_DRIVER, 0, aRate,
aChannels, nullptr, AbstractThread::MainThread()) {
ON_CALL(*this, OnGraphThread).WillByDefault(Return(true));
// Remove this graph's driver since it holds a ref. If no AppendMessage
Expand Down
2 changes: 1 addition & 1 deletion dom/media/gtest/TestDeviceInputTrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace {
class MockGraphImpl : public MediaTrackGraphImpl {
public:
MockGraphImpl(TrackRate aRate, uint32_t aChannels)
: MediaTrackGraphImpl(OFFLINE_THREAD_DRIVER, DIRECT_DRIVER, aRate,
: MediaTrackGraphImpl(OFFLINE_THREAD_DRIVER, DIRECT_DRIVER, 0, aRate,
aChannels, nullptr, NS_GetCurrentThread()) {
ON_CALL(*this, OnGraphThread).WillByDefault(Return(true));
// We have to call `Destroy()` manually in order to break the reference.
Expand Down

0 comments on commit 2cc42dc

Please sign in to comment.