mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 11:15:34 +00:00
Bug 1332585 - Protect TrackEncoder members from races. r=jesup
mCanceled is one member which is protected only in a couple of places. I hit a MOZ_CRASH without this in a gtest, but I'm not sure if we haven't seen it in release by chance or by design. MozReview-Commit-ID: 61KpjaBDyhB --HG-- extra : rebase_source : 4ab032ee2963cd7e94d19b8428e6405ffa59332e extra : source : 06b2f8307ad0c96197e75d2e147e660d8085afc7
This commit is contained in:
parent
2bca25c1da
commit
94d46cd57d
@ -57,6 +57,8 @@ AudioTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
if (mCanceled) {
|
||||
return;
|
||||
}
|
||||
@ -109,13 +111,14 @@ AudioTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
|
||||
void
|
||||
AudioTrackEncoder::NotifyEndOfStream()
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
// If source audio track is completely silent till the end of encoding,
|
||||
// initialize the encoder with default channel counts and sampling rate.
|
||||
if (!mCanceled && !mInitialized) {
|
||||
Init(DEFAULT_CHANNELS, DEFAULT_SAMPLING_RATE);
|
||||
}
|
||||
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
mEndOfStream = true;
|
||||
mReentrantMonitor.NotifyAll();
|
||||
}
|
||||
@ -195,6 +198,8 @@ AudioTrackEncoder::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) cons
|
||||
void
|
||||
VideoTrackEncoder::Init(const VideoSegment& aSegment)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
if (mInitialized) {
|
||||
return;
|
||||
}
|
||||
@ -227,12 +232,13 @@ VideoTrackEncoder::Init(const VideoSegment& aSegment)
|
||||
NotifyEndOfStream();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
VideoTrackEncoder::SetCurrentFrames(const VideoSegment& aSegment)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
if (mCanceled) {
|
||||
return;
|
||||
}
|
||||
@ -248,6 +254,8 @@ VideoTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
|
||||
uint32_t aTrackEvents,
|
||||
const MediaSegment& aQueuedMedia)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
if (mCanceled) {
|
||||
return;
|
||||
}
|
||||
@ -390,6 +398,8 @@ VideoTrackEncoder::AppendVideoSegment(const VideoSegment& aSegment)
|
||||
void
|
||||
VideoTrackEncoder::NotifyEndOfStream()
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
// If source video track is muted till the end of encoding, initialize the
|
||||
// encoder with default frame width, frame height, and track rate.
|
||||
if (!mCanceled && !mInitialized) {
|
||||
@ -397,8 +407,6 @@ VideoTrackEncoder::NotifyEndOfStream()
|
||||
DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_HEIGHT);
|
||||
}
|
||||
|
||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||
|
||||
if (mEndOfStream) {
|
||||
// We have already been notified.
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user