From: Tsuda Kageyu Date: Tue, 30 Jun 2015 06:59:01 +0000 (+0900) Subject: WAV: Avoid using a magic number. X-Git-Tag: v1.10beta~38^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=801c9db8103aa193e50da4231ca389ecaf5d5502;p=taglib WAV: Avoid using a magic number. --- diff --git a/taglib/riff/wav/wavproperties.cpp b/taglib/riff/wav/wavproperties.cpp index 48f068c7..39f0dddc 100644 --- a/taglib/riff/wav/wavproperties.cpp +++ b/taglib/riff/wav/wavproperties.cpp @@ -29,6 +29,16 @@ using namespace TagLib; +namespace +{ + // Quoted from RFC 2361. + enum WaveFormat + { + FORMAT_UNKNOWN = 0x0000, + FORMAT_PCM = 0x0001 + }; +} + class RIFF::WAV::Properties::PropertiesPrivate { public: @@ -173,7 +183,7 @@ void RIFF::WAV::Properties::read(File *file) } d->format = data.toShort(0, false); - if(d->format != 1 && totalSamples == 0) { + if(d->format != FORMAT_PCM && totalSamples == 0) { debug("RIFF::WAV::Properties::read() - Non-PCM format, but 'fact' chunk not found."); return; } diff --git a/taglib/riff/wav/wavproperties.h b/taglib/riff/wav/wavproperties.h index ab1b9e70..1fd6a136 100644 --- a/taglib/riff/wav/wavproperties.h +++ b/taglib/riff/wav/wavproperties.h @@ -139,9 +139,11 @@ namespace TagLib { /*! * Returns the format ID of the file. - * 0 for unknown, 1 for PCM, 2 for ADPCM, 3 for 32/64-bit IEEE754, and so forth. + * 0 for unknown, 1 for PCM, 2 for ADPCM, 3 for 32/64-bit IEEE754, and + * so forth. * - * \note For further information, refer to RFC 2361. + * \note For further information, refer to the WAVE Form Registration + * Numbers in RFC 2361. */ int format() const;