Skip to content

Commit

Permalink
mpg123: Be more strict about accepting unknown content as MP3.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlindgren90 committed Mar 9, 2015
1 parent ba1ac05 commit b31fce4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/mpg123/mpg123.cc
Expand Up @@ -126,7 +126,7 @@ struct DecodeState
{
mpg123_handle * dec = nullptr;

bool init (const char * filename, VFSFile & file, bool quiet, bool stream);
bool init (const char * filename, VFSFile & file, bool probing, bool stream);

~DecodeState()
{ mpg123_delete (dec); }
Expand All @@ -138,13 +138,17 @@ struct DecodeState
float buf[4096];
};

bool DecodeState::init (const char * filename, VFSFile & file, bool quiet, bool stream)
bool DecodeState::init (const char * filename, VFSFile & file, bool probing, bool stream)
{
dec = mpg123_new (nullptr, nullptr);
mpg123_param (dec, MPG123_ADD_FLAGS, DECODE_OPTIONS, 0);
mpg123_replace_reader_handle (dec, replace_read,
stream ? replace_lseek_dummy : replace_lseek, nullptr);

/* be strict about junk data in file during content probe */
if (probing)
mpg123_param (dec, MPG123_RESYNC_LIMIT, 0, 0);

mpg123_format_none (dec);

for (int rate : {8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000})
Expand Down Expand Up @@ -175,7 +179,7 @@ bool DecodeState::init (const char * filename, VFSFile & file, bool quiet, bool
}

err:
if (quiet)
if (probing)
AUDDBG ("mpg123 error in %s: %s\n", filename, mpg123_strerror (dec));
else
AUDERR ("mpg123 error in %s: %s\n", filename, mpg123_strerror (dec));
Expand Down Expand Up @@ -209,12 +213,6 @@ static StringBuf make_format_string (const mpg123_frameinfo * info)

bool MPG123Plugin::is_our_file (const char * filename, VFSFile & file)
{
/* MPG123 likes to grab WMA streams, so blacklist anything that starts with
* mms://. If there are mms:// streams out there carrying MP3, they will
* just have to play in ffaudio. --jlindgren */
if (! strncmp (filename, "mms://", 6))
return false;

bool stream = (file.fsize () < 0);

/* Some MP3s begin with enormous ID3 tags, which fill up the whole probe
Expand Down

0 comments on commit b31fce4

Please sign in to comment.