Bug 896980 - Add error handlings if fail to init track encoder or container writer. r=roc

This commit is contained in:
Shelly Lin 2013-08-06 18:53:07 +08:00
Родитель b0cfbd81f2
Коммит c3844b395e
2 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -27,6 +27,10 @@ AudioTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
uint32_t aTrackEvents,
const MediaSegment& aQueuedMedia)
{
if (mCanceled) {
return;
}
AudioSegment* audio = const_cast<AudioSegment*>
(static_cast<const AudioSegment*>(&aQueuedMedia));
@ -40,9 +44,11 @@ AudioTrackEncoder::NotifyQueuedTrackChanges(MediaStreamGraph* aGraph,
// thus the audio encoder is initialized at this time.
if (!chunk.IsNull()) {
nsresult rv = Init(chunk.mChannelData.Length(), aTrackRate);
if (NS_SUCCEEDED(rv)) {
break;
if (NS_FAILED(rv)) {
LOG("[AudioTrackEncoder]: Fail to initialize the encoder!");
NotifyCancel();
}
break;
} else {
mSilentDuration += chunk.mDuration;
}

Просмотреть файл

@ -49,6 +49,11 @@ nsresult
OggWriter::WriteEncodedTrack(const nsTArray<uint8_t>& aBuffer, int aDuration,
uint32_t aFlags)
{
if (!mInitialized) {
LOG("[OggWriter] OggWriter has not initialized!");
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(!ogg_stream_eos(&mOggStreamState),
"No data can be written after eos has marked.");