Bug 1267637: P1. Consider invalid an AudioData with more than 8 audio channels. r=gerald

Add AudioConfig::IsValid() method

--HG--
extra : rebase_source : 80f7dd62b3b5971a0710c0c3bbf40735a4095fbf
This commit is contained in:
Jean-Yves Avenard 2016-04-27 17:34:41 +10:00
parent 9b75326cc2
commit 25410f2b25

View File

@ -34,6 +34,9 @@ public:
nsCString mValue;
};
// Maximum channel number we can currently handle (7.1)
#define MAX_AUDIO_CHANNELS 8
class TrackInfo {
public:
enum TrackType {
@ -304,7 +307,7 @@ public:
bool IsValid() const override
{
return mChannels > 0 && mRate > 0;
return mChannels > 0 && mChannels <= MAX_AUDIO_CHANNELS && mRate > 0;
}
AudioInfo* GetAsAudioInfo() override
@ -516,9 +519,6 @@ public:
const nsCString& mMimeType;
};
// Maximum channel number we can currently handle (7.1)
#define MAX_AUDIO_CHANNELS 8
class AudioConfig {
public:
enum Channel {
@ -658,6 +658,11 @@ public:
return !(*this == aOther);
}
bool IsValid() const
{
return mChannelLayout.IsValid() && Format() != FORMAT_NONE && Rate() > 0;
}
static const char* FormatToString(SampleFormat aFormat);
static uint32_t SampleSize(SampleFormat aFormat);
static uint32_t FormatToBits(SampleFormat aFormat);