зеркало из https://github.com/mozilla/gecko-dev.git
Bug 828828: Use monitor around all accesses to stream array r=derf
This commit is contained in:
Родитель
ed3782edfb
Коммит
95409d3f0a
|
@ -139,6 +139,10 @@ private:
|
|||
TrackID mTrackID;
|
||||
TrackTicks mLastEndTime;
|
||||
|
||||
// mMonitor protects mImage access/changes, and transitions of mState
|
||||
// from kStarted to kStopped (which are combined with EndTrack() and
|
||||
// image changes). Note that mSources is not accessed from other threads
|
||||
// for video and is not protected.
|
||||
mozilla::ReentrantMonitor mMonitor; // Monitor for processing WebRTC frames.
|
||||
nsTArray<SourceMediaStream *> mSources; // When this goes empty, we shut down HW
|
||||
|
||||
|
@ -215,6 +219,9 @@ private:
|
|||
webrtc::VoEExternalMedia* mVoERender;
|
||||
webrtc::VoENetwork* mVoENetwork;
|
||||
|
||||
// mMonitor protects mSources[] access/changes, and transitions of mState
|
||||
// from kStarted to kStopped (which are combined with EndTrack()).
|
||||
// mSources[] is accessed from webrtc threads.
|
||||
mozilla::ReentrantMonitor mMonitor;
|
||||
nsTArray<SourceMediaStream *> mSources; // When this goes empty, we shut down HW
|
||||
|
||||
|
|
|
@ -89,7 +89,10 @@ MediaEngineWebRTCAudioSource::Start(SourceMediaStream* aStream, TrackID aID)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mSources.AppendElement(aStream);
|
||||
{
|
||||
ReentrantMonitorAutoEnter enter(mMonitor);
|
||||
mSources.AppendElement(aStream);
|
||||
}
|
||||
|
||||
AudioSegment* segment = new AudioSegment();
|
||||
segment->Init(CHANNELS);
|
||||
|
@ -119,22 +122,23 @@ MediaEngineWebRTCAudioSource::Start(SourceMediaStream* aStream, TrackID aID)
|
|||
nsresult
|
||||
MediaEngineWebRTCAudioSource::Stop(SourceMediaStream *aSource, TrackID aID)
|
||||
{
|
||||
if (!mSources.RemoveElement(aSource)) {
|
||||
// Already stopped - this is allowed
|
||||
return NS_OK;
|
||||
}
|
||||
if (!mSources.IsEmpty()) {
|
||||
return NS_OK;
|
||||
}
|
||||
if (mState != kStarted) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!mVoEBase) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
{
|
||||
ReentrantMonitorAutoEnter enter(mMonitor);
|
||||
|
||||
if (!mSources.RemoveElement(aSource)) {
|
||||
// Already stopped - this is allowed
|
||||
return NS_OK;
|
||||
}
|
||||
if (!mSources.IsEmpty()) {
|
||||
return NS_OK;
|
||||
}
|
||||
if (mState != kStarted) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!mVoEBase) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mState = kStopped;
|
||||
aSource->EndTrack(aID);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче