Bug 1311876: P3. Provide more details when audio decoder errors. r=gerald

MozReview-Commit-ID: Dbh2Cvyq1NH

--HG--
extra : rebase_source : 6fa83589965db1f63c80c18bb6c94b896c1b894b
This commit is contained in:
Jean-Yves Avenard 2016-10-26 11:34:46 +11:00
Родитель 83df18207f
Коммит a4f3312d22
2 изменённых файлов: 28 добавлений и 19 удалений

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

@ -209,12 +209,11 @@ AppleATDecoder::SubmitSample(MediaRawData* aSample)
return; return;
} }
nsresult rv = NS_OK; MediaResult rv = NS_OK;
if (!mConverter) { if (!mConverter) {
rv = SetupDecoder(aSample); rv = SetupDecoder(aSample);
if (rv != NS_OK && rv != NS_ERROR_NOT_INITIALIZED) { if (rv != NS_OK && rv != NS_ERROR_NOT_INITIALIZED) {
mCallback->Error( mCallback->Error(rv);
MediaResult(rv, RESULT_DETAIL("Unable to create decoder")));
return; return;
} }
} }
@ -226,8 +225,7 @@ AppleATDecoder::SubmitSample(MediaRawData* aSample)
rv = DecodeSample(mQueuedSamples[i]); rv = DecodeSample(mQueuedSamples[i]);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
mErrored = true; mErrored = true;
mCallback->Error(MediaResult( mCallback->Error(rv);
rv, RESULT_DETAIL("Unable to decode sample %lld", aSample->mTime)));
return; return;
} }
} }
@ -236,7 +234,7 @@ AppleATDecoder::SubmitSample(MediaRawData* aSample)
mCallback->InputExhausted(); mCallback->InputExhausted();
} }
nsresult MediaResult
AppleATDecoder::DecodeSample(MediaRawData* aSample) AppleATDecoder::DecodeSample(MediaRawData* aSample)
{ {
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn()); MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
@ -283,8 +281,10 @@ AppleATDecoder::DecodeSample(MediaRawData* aSample)
packets.get()); packets.get());
if (rv && rv != kNoMoreDataErr) { if (rv && rv != kNoMoreDataErr) {
LOG("Error decoding audio stream: %d\n", rv); LOG("Error decoding audio sample: %d\n", rv);
return NS_ERROR_DOM_MEDIA_DECODE_ERR; return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
RESULT_DETAIL("Error decoding audio sample: %d @ %lld",
rv, aSample->mTime));
} }
if (numFrames) { if (numFrames) {
@ -305,7 +305,11 @@ AppleATDecoder::DecodeSample(MediaRawData* aSample)
media::TimeUnit duration = FramesToTimeUnit(numFrames, rate); media::TimeUnit duration = FramesToTimeUnit(numFrames, rate);
if (!duration.IsValid()) { if (!duration.IsValid()) {
NS_WARNING("Invalid count of accumulated audio samples"); NS_WARNING("Invalid count of accumulated audio samples");
return NS_ERROR_DOM_MEDIA_OVERFLOW_ERR; return MediaResult(
NS_ERROR_DOM_MEDIA_OVERFLOW_ERR,
RESULT_DETAIL(
"Invalid count of accumulated audio samples: num:%llu rate:%d",
uint64_t(numFrames), rate));
} }
#ifdef LOG_SAMPLE_DECODE #ifdef LOG_SAMPLE_DECODE
@ -322,7 +326,8 @@ AppleATDecoder::DecodeSample(MediaRawData* aSample)
AudioConfig in(*mChannelLayout.get(), rate); AudioConfig in(*mChannelLayout.get(), rate);
AudioConfig out(channels, rate); AudioConfig out(channels, rate);
if (!in.IsValid() || !out.IsValid()) { if (!in.IsValid() || !out.IsValid()) {
return NS_ERROR_DOM_MEDIA_DECODE_ERR; return MediaResult(NS_ERROR_DOM_MEDIA_DECODE_ERR,
RESULT_DETAIL("Invalid audio config"));
} }
mAudioConverter = MakeUnique<AudioConverter>(in, out); mAudioConverter = MakeUnique<AudioConverter>(in, out);
} }
@ -342,7 +347,7 @@ AppleATDecoder::DecodeSample(MediaRawData* aSample)
return NS_OK; return NS_OK;
} }
nsresult MediaResult
AppleATDecoder::GetInputAudioDescription(AudioStreamBasicDescription& aDesc, AppleATDecoder::GetInputAudioDescription(AudioStreamBasicDescription& aDesc,
const nsTArray<uint8_t>& aExtraData) const nsTArray<uint8_t>& aExtraData)
{ {
@ -373,7 +378,9 @@ AppleATDecoder::GetInputAudioDescription(AudioStreamBasicDescription& aDesc,
&inputFormatSize, &inputFormatSize,
&aDesc); &aDesc);
if (NS_WARN_IF(rv)) { if (NS_WARN_IF(rv)) {
return NS_ERROR_FAILURE; return MediaResult(
NS_ERROR_FAILURE,
RESULT_DETAIL("Unable to get format info:%lld", int64_t(rv)));
} }
// If any of the methods below fail, we will return the default format as // If any of the methods below fail, we will return the default format as
@ -549,7 +556,7 @@ AppleATDecoder::SetupChannelLayout()
return NS_OK; return NS_OK;
} }
nsresult MediaResult
AppleATDecoder::SetupDecoder(MediaRawData* aSample) AppleATDecoder::SetupDecoder(MediaRawData* aSample)
{ {
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn()); MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
@ -574,7 +581,7 @@ AppleATDecoder::SetupDecoder(MediaRawData* aSample)
AudioStreamBasicDescription inputFormat; AudioStreamBasicDescription inputFormat;
PodZero(&inputFormat); PodZero(&inputFormat);
nsresult rv = MediaResult rv =
GetInputAudioDescription(inputFormat, GetInputAudioDescription(inputFormat,
mMagicCookie.Length() ? mMagicCookie.Length() ?
mMagicCookie : *mConfig.mExtraData); mMagicCookie : *mConfig.mExtraData);
@ -606,7 +613,9 @@ AppleATDecoder::SetupDecoder(MediaRawData* aSample)
if (status) { if (status) {
LOG("Error %d constructing AudioConverter", status); LOG("Error %d constructing AudioConverter", status);
mConverter = nullptr; mConverter = nullptr;
return NS_ERROR_FAILURE; return MediaResult(
NS_ERROR_FAILURE,
RESULT_DETAIL("Error constructing AudioConverter:%lld", int64_t(status)));
} }
if (NS_FAILED(SetupChannelLayout())) { if (NS_FAILED(SetupChannelLayout())) {

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

@ -61,12 +61,12 @@ private:
void ProcessFlush(); void ProcessFlush();
void ProcessShutdown(); void ProcessShutdown();
void SubmitSample(MediaRawData* aSample); void SubmitSample(MediaRawData* aSample);
nsresult DecodeSample(MediaRawData* aSample); MediaResult DecodeSample(MediaRawData* aSample);
nsresult GetInputAudioDescription(AudioStreamBasicDescription& aDesc, MediaResult GetInputAudioDescription(AudioStreamBasicDescription& aDesc,
const nsTArray<uint8_t>& aExtraData); const nsTArray<uint8_t>& aExtraData);
// Setup AudioConverter once all information required has been gathered. // Setup AudioConverter once all information required has been gathered.
// Will return NS_ERROR_NOT_INITIALIZED if more data is required. // Will return NS_ERROR_NOT_INITIALIZED if more data is required.
nsresult SetupDecoder(MediaRawData* aSample); MediaResult SetupDecoder(MediaRawData* aSample);
nsresult GetImplicitAACMagicCookie(const MediaRawData* aSample); nsresult GetImplicitAACMagicCookie(const MediaRawData* aSample);
nsresult SetupChannelLayout(); nsresult SetupChannelLayout();
uint32_t mParsedFramesForAACMagicCookie; uint32_t mParsedFramesForAACMagicCookie;