Skip to content

Commit

Permalink
Bug 1215699. Ensure that AudioGraphDriver uses the MediaStreamGraph's…
Browse files Browse the repository at this point in the history
… AudioChannel. r=padenot
  • Loading branch information
rocallahan committed Oct 23, 2015
1 parent 88eb851 commit 2c08de6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
4 changes: 2 additions & 2 deletions dom/media/GraphDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,11 @@ StreamAndPromiseForOperation::StreamAndPromiseForOperation(MediaStream* aStream,
// MOZ_ASSERT(aPromise);
}

AudioCallbackDriver::AudioCallbackDriver(MediaStreamGraphImpl* aGraphImpl, dom::AudioChannel aChannel)
AudioCallbackDriver::AudioCallbackDriver(MediaStreamGraphImpl* aGraphImpl)
: GraphDriver(aGraphImpl)
, mIterationDurationMS(MEDIA_GRAPH_TARGET_PERIOD_MS)
, mStarted(false)
, mAudioChannel(aChannel)
, mAudioChannel(aGraphImpl->AudioChannel())
, mInCallback(false)
, mPauseRequested(false)
#ifdef XP_MACOSX
Expand Down
3 changes: 1 addition & 2 deletions dom/media/GraphDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ class AudioCallbackDriver : public GraphDriver,
public MixerCallbackReceiver
{
public:
explicit AudioCallbackDriver(MediaStreamGraphImpl* aGraphImpl,
dom::AudioChannel aChannel = dom::AudioChannel::Normal);
explicit AudioCallbackDriver(MediaStreamGraphImpl* aGraphImpl);
virtual ~AudioCallbackDriver();

virtual void Destroy() override;
Expand Down
16 changes: 8 additions & 8 deletions dom/media/MediaStreamGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1409,9 +1409,9 @@ MediaStreamGraphImpl::RunInStableState(bool aSourceIsMSG)

LIFECYCLE_LOG("Disconnecting MediaStreamGraph %p", this);
MediaStreamGraphImpl* graph;
if (gGraphs.Get(mAudioChannel, &graph) && graph == this) {
if (gGraphs.Get(uint32_t(mAudioChannel), &graph) && graph == this) {
// null out gGraph if that's the graph being shut down
gGraphs.Remove(mAudioChannel);
gGraphs.Remove(uint32_t(mAudioChannel));
}
}
} else {
Expand Down Expand Up @@ -1566,8 +1566,8 @@ MediaStreamGraphImpl::AppendMessage(ControlMessage* aMessage)
mLifecycleState >= LIFECYCLE_WAITING_FOR_STREAM_DESTRUCTION) {

MediaStreamGraphImpl* graph;
if (gGraphs.Get(mAudioChannel, &graph) && graph == this) {
gGraphs.Remove(mAudioChannel);
if (gGraphs.Get(uint32_t(mAudioChannel), &graph) && graph == this) {
gGraphs.Remove(uint32_t(mAudioChannel));
}

Destroy();
Expand Down Expand Up @@ -1653,7 +1653,7 @@ MediaStream::SetGraphImpl(MediaStreamGraphImpl* aGraph)
{
MOZ_ASSERT(!mGraph, "Should only be called once");
mGraph = aGraph;
mAudioChannelType = static_cast<AudioChannel>(aGraph->AudioChannel());
mAudioChannelType = aGraph->AudioChannel();
mBuffer.InitGraphRate(aGraph->GraphRate());
}

Expand Down Expand Up @@ -2567,15 +2567,15 @@ MediaStreamGraphImpl::MediaStreamGraphImpl(GraphDriverType aDriverRequested,
#ifdef DEBUG
, mCanRunMessagesSynchronously(false)
#endif
, mAudioChannel(static_cast<uint32_t>(aChannel))
, mAudioChannel(aChannel)
{
if (!gMediaStreamGraphLog) {
gMediaStreamGraphLog = PR_NewLogModule("MediaStreamGraph");
}

if (mRealtime) {
if (aDriverRequested == AUDIO_THREAD_DRIVER) {
AudioCallbackDriver* driver = new AudioCallbackDriver(this, aChannel);
AudioCallbackDriver* driver = new AudioCallbackDriver(this);
mDriver = driver;
mMixer.AddCallback(driver);
} else {
Expand Down Expand Up @@ -3082,7 +3082,7 @@ MediaStreamGraph::IsNonRealtime() const
const MediaStreamGraphImpl* impl = static_cast<const MediaStreamGraphImpl*>(this);
MediaStreamGraphImpl* graph;

return !gGraphs.Get(impl->AudioChannel(), &graph) || graph != impl;
return !gGraphs.Get(uint32_t(impl->AudioChannel()), &graph) || graph != impl;
}

void
Expand Down
6 changes: 2 additions & 4 deletions dom/media/MediaStreamGraphImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ class MediaStreamGraphImpl : public MediaStreamGraph,
RefPtr<AudioOutputObserver> mFarendObserverRef;
#endif

uint32_t AudioChannel() const { return mAudioChannel; }
dom::AudioChannel AudioChannel() const { return mAudioChannel; }

private:
virtual ~MediaStreamGraphImpl();
Expand Down Expand Up @@ -762,9 +762,7 @@ class MediaStreamGraphImpl : public MediaStreamGraph,
bool mCanRunMessagesSynchronously;
#endif

// We use uint32_t instead AudioChannel because this is just used as key for
// the hashtable gGraphs.
uint32_t mAudioChannel;
dom::AudioChannel mAudioChannel;
};

} // namespace mozilla
Expand Down

0 comments on commit 2c08de6

Please sign in to comment.