Verified Commit 6fc3660a authored by Karl Tomlinson's avatar Karl Tomlinson Committed by Pier Angelo Vendrame
Browse files

Bug 1988931 use GetInstanceIfExists() from MediaTrackGraphImpl::GetInstance() a=dmeehan DONTBUILD

parent 4236d923
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -3566,11 +3566,10 @@ MediaTrackGraphImpl* MediaTrackGraphImpl::GetInstance(
  MOZ_ASSERT(aGraphDriverRequested != OFFLINE_THREAD_DRIVER,
             "Use CreateNonRealtimeInstance() for offline graphs");

  GraphHashSet* graphs = Graphs();
  GraphHashSet::AddPtr addPtr =
      graphs->lookupForAdd({aWindowID, aSampleRate, aPrimaryOutputDeviceID});
  if (addPtr) {  // graph already exists
    return *addPtr;
  MediaTrackGraphImpl* graph =
      GetInstanceIfExists(aWindowID, aSampleRate, aPrimaryOutputDeviceID);
  if (graph) {  // graph already exists
    return graph;
  }

  GraphRunType runType = DIRECT_DRIVER;
@@ -3581,10 +3580,11 @@ MediaTrackGraphImpl* MediaTrackGraphImpl::GetInstance(
  // In a real time graph, the number of output channels is determined by
  // the underlying number of channel of the default audio output device.
  uint32_t channelCount = CubebUtils::MaxNumberOfChannels();
  MediaTrackGraphImpl* graph = new MediaTrackGraphImpl(
      aWindowID, aSampleRate, aPrimaryOutputDeviceID, aMainThread);
  graph = new MediaTrackGraphImpl(aWindowID, aSampleRate,
                                  aPrimaryOutputDeviceID, aMainThread);
  graph->Init(aGraphDriverRequested, runType, channelCount);
  MOZ_ALWAYS_TRUE(graphs->add(addPtr, graph));
  MOZ_ALWAYS_TRUE(Graphs()->putNew(
      {aWindowID, aSampleRate, aPrimaryOutputDeviceID}, graph));

  LOG(LogLevel::Debug, ("Starting up MediaTrackGraph %p for window 0x%" PRIx64,
                        graph, aWindowID));