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,
|
uint32_t aTrackEvents,
|
||||||
const MediaSegment& aQueuedMedia)
|
const MediaSegment& aQueuedMedia)
|
||||||
{
|
{
|
||||||
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||||
|
|
||||||
if (mCanceled) {
|
if (mCanceled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,13 +111,14 @@ AudioTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
|
|||||||
void
|
void
|
||||||
AudioTrackEncoder::NotifyEndOfStream()
|
AudioTrackEncoder::NotifyEndOfStream()
|
||||||
{
|
{
|
||||||
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||||
|
|
||||||
// If source audio track is completely silent till the end of encoding,
|
// If source audio track is completely silent till the end of encoding,
|
||||||
// initialize the encoder with default channel counts and sampling rate.
|
// initialize the encoder with default channel counts and sampling rate.
|
||||||
if (!mCanceled && !mInitialized) {
|
if (!mCanceled && !mInitialized) {
|
||||||
Init(DEFAULT_CHANNELS, DEFAULT_SAMPLING_RATE);
|
Init(DEFAULT_CHANNELS, DEFAULT_SAMPLING_RATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
|
||||||
mEndOfStream = true;
|
mEndOfStream = true;
|
||||||
mReentrantMonitor.NotifyAll();
|
mReentrantMonitor.NotifyAll();
|
||||||
}
|
}
|
||||||
@ -195,6 +198,8 @@ AudioTrackEncoder::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) cons
|
|||||||
void
|
void
|
||||||
VideoTrackEncoder::Init(const VideoSegment& aSegment)
|
VideoTrackEncoder::Init(const VideoSegment& aSegment)
|
||||||
{
|
{
|
||||||
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||||
|
|
||||||
if (mInitialized) {
|
if (mInitialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -227,12 +232,13 @@ VideoTrackEncoder::Init(const VideoSegment& aSegment)
|
|||||||
NotifyEndOfStream();
|
NotifyEndOfStream();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VideoTrackEncoder::SetCurrentFrames(const VideoSegment& aSegment)
|
VideoTrackEncoder::SetCurrentFrames(const VideoSegment& aSegment)
|
||||||
{
|
{
|
||||||
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||||
|
|
||||||
if (mCanceled) {
|
if (mCanceled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -248,6 +254,8 @@ VideoTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
|
|||||||
uint32_t aTrackEvents,
|
uint32_t aTrackEvents,
|
||||||
const MediaSegment& aQueuedMedia)
|
const MediaSegment& aQueuedMedia)
|
||||||
{
|
{
|
||||||
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||||
|
|
||||||
if (mCanceled) {
|
if (mCanceled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -390,6 +398,8 @@ VideoTrackEncoder::AppendVideoSegment(const VideoSegment& aSegment)
|
|||||||
void
|
void
|
||||||
VideoTrackEncoder::NotifyEndOfStream()
|
VideoTrackEncoder::NotifyEndOfStream()
|
||||||
{
|
{
|
||||||
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
||||||
|
|
||||||
// If source video track is muted till the end of encoding, initialize the
|
// If source video track is muted till the end of encoding, initialize the
|
||||||
// encoder with default frame width, frame height, and track rate.
|
// encoder with default frame width, frame height, and track rate.
|
||||||
if (!mCanceled && !mInitialized) {
|
if (!mCanceled && !mInitialized) {
|
||||||
@ -397,8 +407,6 @@ VideoTrackEncoder::NotifyEndOfStream()
|
|||||||
DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_HEIGHT);
|
DEFAULT_FRAME_WIDTH, DEFAULT_FRAME_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
|
||||||
|
|
||||||
if (mEndOfStream) {
|
if (mEndOfStream) {
|
||||||
// We have already been notified.
|
// We have already been notified.
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user