mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1860954 add a conversion operator from MediaTrackGraphImpl to Lookup for HashSet.lookup(*graph) r=pehrsons
Differential Revision: https://phabricator.services.mozilla.com/D191920
This commit is contained in:
parent
6431e9277a
commit
241af1cdbc
@ -117,12 +117,12 @@ void DeviceInputTrackManager::Remove(DeviceInputTrack* aTrack) {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
/**
|
||||
* A hash table containing the graph instances, one per Window ID,
|
||||
* sample rate, and device ID combination.
|
||||
*/
|
||||
struct GraphLookup final {
|
||||
|
||||
struct MediaTrackGraphImpl::Lookup final {
|
||||
HashNumber Hash() const {
|
||||
return HashGeneric(mWindowID, mSampleRate, mOutputDeviceID);
|
||||
}
|
||||
@ -131,8 +131,14 @@ struct GraphLookup final {
|
||||
const CubebUtils::AudioDeviceID mOutputDeviceID;
|
||||
};
|
||||
|
||||
// Implicit to support GraphHashSet.lookup(*graph).
|
||||
MOZ_IMPLICIT MediaTrackGraphImpl::operator MediaTrackGraphImpl::Lookup() const {
|
||||
return {mWindowID, mSampleRate, mOutputDeviceID};
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct GraphHasher { // for HashSet
|
||||
using Lookup = const GraphLookup;
|
||||
using Lookup = const MediaTrackGraphImpl::Lookup;
|
||||
|
||||
static HashNumber hash(const Lookup& aLookup) { return aLookup.Hash(); }
|
||||
|
||||
@ -3600,8 +3606,7 @@ void MediaTrackGraph::AddTrack(MediaTrack* aTrack) {
|
||||
MediaTrackGraphImpl* graph = static_cast<MediaTrackGraphImpl*>(this);
|
||||
#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
if (graph->mRealtime) {
|
||||
GraphHashSet::Ptr p = Graphs()->lookup(
|
||||
{graph->mWindowID, GraphRate(), graph->mOutputDeviceID});
|
||||
GraphHashSet::Ptr p = Graphs()->lookup(*graph);
|
||||
MOZ_DIAGNOSTIC_ASSERT(p, "Graph must not be shutting down");
|
||||
}
|
||||
#endif
|
||||
@ -3621,8 +3626,7 @@ void MediaTrackGraphImpl::RemoveTrack(MediaTrack* aTrack) {
|
||||
if (mRealtime) {
|
||||
// Find the graph in the hash table and remove it.
|
||||
GraphHashSet* graphs = Graphs();
|
||||
GraphHashSet::Ptr p =
|
||||
graphs->lookup({mWindowID, mSampleRate, mOutputDeviceID});
|
||||
GraphHashSet::Ptr p = graphs->lookup(*this);
|
||||
MOZ_ASSERT(*p == this);
|
||||
graphs->remove(p);
|
||||
|
||||
|
@ -142,6 +142,9 @@ class MediaTrackGraphImpl : public MediaTrackGraph,
|
||||
static MediaTrackGraphImpl* GetInstanceIfExists(
|
||||
uint64_t aWindowID, TrackRate aSampleRate,
|
||||
CubebUtils::AudioDeviceID aOutputDeviceID);
|
||||
// For GraphHashSet:
|
||||
struct Lookup;
|
||||
operator Lookup() const;
|
||||
|
||||
// Intended only for assertions, either on graph thread or not running (in
|
||||
// which case we must be on the main thread).
|
||||
|
Loading…
Reference in New Issue
Block a user