Bug 1271483 - p5. Remove 'canPlay', can be inferred otherwise - r=cpearce

Instead of having yet-another variable, just infer playability from the lists
of playable&unplayable formats, which we need to look at anyway.

MozReview-Commit-ID: ABc2WtWADzN
This commit is contained in:
Gerald Squelart 2016-05-12 12:49:36 +10:00
Родитель 941f072570
Коммит c89979e5f5
1 изменённых файлов: 26 добавлений и 24 удалений

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

@ -359,7 +359,6 @@ DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
bool canPlay = false;
#if defined(XP_WIN) #if defined(XP_WIN)
bool WMFNeeded = false; bool WMFNeeded = false;
#endif #endif
@ -377,7 +376,6 @@ DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
switch (diag.mDecoderDoctorDiagnostics.Type()) { switch (diag.mDecoderDoctorDiagnostics.Type()) {
case DecoderDoctorDiagnostics::eFormatSupportCheck: case DecoderDoctorDiagnostics::eFormatSupportCheck:
if (diag.mDecoderDoctorDiagnostics.CanPlay()) { if (diag.mDecoderDoctorDiagnostics.CanPlay()) {
canPlay = true;
AppendToStringList(playableFormats, AppendToStringList(playableFormats,
diag.mDecoderDoctorDiagnostics.Format()); diag.mDecoderDoctorDiagnostics.Format());
} else { } else {
@ -418,7 +416,7 @@ DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
} }
} }
// Look at Key System issues first, as they may influence format checks. // Look at Key System issues first, as they take precedence over format checks.
if (!unsupportedKeySystems.IsEmpty() && supportedKeySystems.IsEmpty()) { if (!unsupportedKeySystems.IsEmpty() && supportedKeySystems.IsEmpty()) {
// No supported key systems! // No supported key systems!
switch (lastKeySystemIssue) { switch (lastKeySystemIssue) {
@ -436,32 +434,36 @@ DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
} }
} }
if (!canPlay && !unplayableFormats.IsEmpty()) { // Next, check playability of requested formats.
if (!unplayableFormats.IsEmpty()) {
// Some requested formats cannot be played.
if (playableFormats.IsEmpty()) {
// No requested formats can be played. See if we can help the user...
#if defined(XP_WIN) #if defined(XP_WIN)
if (WMFNeeded) { if (WMFNeeded) {
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - formats: %s -> Cannot play media because WMF was not found", DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - formats: %s -> Cannot play media because WMF was not found",
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get()); this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found, ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
"MediaWMFNeeded", unplayableFormats); "MediaWMFNeeded", unplayableFormats);
return; return;
} }
#endif #endif
#if defined(MOZ_FFMPEG) #if defined(MOZ_FFMPEG)
if (FFMpegNeeded) { if (FFMpegNeeded) {
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because platform decoder was not found", DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because platform decoder was not found",
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get()); this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found, ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
"MediaPlatformDecoderNotFound", unplayableFormats); "MediaPlatformDecoderNotFound", unplayableFormats);
return;
}
#endif
DD_WARN("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Cannot play media, unplayable formats: %s",
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
ReportAnalysis(dom::DecoderDoctorNotificationType::Cannot_play,
"MediaCannotPlayNoDecoders", unplayableFormats);
return; return;
} }
#endif
DD_WARN("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Cannot play media, unplayable formats: %s",
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
ReportAnalysis(dom::DecoderDoctorNotificationType::Cannot_play,
"MediaCannotPlayNoDecoders", unplayableFormats);
return;
}
if (!unplayableFormats.IsEmpty()) {
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Can play media, but no decoders for some requested formats: %s", DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Can play media, but no decoders for some requested formats: %s",
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get()); this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
if (Preferences::GetBool("media.decoder-doctor.verbose", false)) { if (Preferences::GetBool("media.decoder-doctor.verbose", false)) {