Skip to content

Commit

Permalink
Adjust probing priorities. Large ID3 tags make it impossible to detec…
Browse files Browse the repository at this point in the history
…t content, so assume these files are MP3.
  • Loading branch information
jlindgren90 committed Apr 29, 2013
1 parent 1898898 commit a3230bb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/ffaudio/ffaudio-core.c
Expand Up @@ -690,7 +690,6 @@ AUD_INPUT_PLUGIN
.extensions = ffaudio_fmts,
.update_song_tuple = ffaudio_write_tag,

/* FFMPEG probing takes forever on network files, so try everything else
* first. -jlindgren */
/* lowest priority fallback */
.priority = 10,
)
20 changes: 19 additions & 1 deletion src/mpg123/mpg123.c
Expand Up @@ -101,10 +101,28 @@ static bool_t mpg123_probe_for_fd (const char * fname, VFSFile * file)
if (! strncmp (fname, "mms://", 6))
return FALSE;

bool_t is_streaming = vfs_is_streaming (file);

/* Some MP3s begin with enormous ID3 tags, which fill up the whole probe
* buffer and thus hide any MP3 content. As a workaround, assume that an
* ID3 tag means an MP3 file. --jlindgren */
if (! is_streaming)
{
char id3buf[3];
if (vfs_fread (id3buf, 1, 3, file) != 3)
return FALSE;

if (! memcmp (id3buf, "ID3", 3))
return TRUE;

if (vfs_fseek (file, 0, SEEK_SET) < 0)
return FALSE;
}

mpg123_handle * dec = mpg123_new (NULL, NULL);
mpg123_param (dec, MPG123_ADD_FLAGS, MPG123_QUIET, 0);

if (vfs_is_streaming (file))
if (is_streaming)
mpg123_replace_reader_handle (dec, replace_read, replace_lseek_dummy, NULL);
else
mpg123_replace_reader_handle (dec, replace_read, replace_lseek, NULL);
Expand Down
5 changes: 4 additions & 1 deletion src/sid/xmms-sid.c
Expand Up @@ -431,5 +431,8 @@ AUD_INPUT_PLUGIN
.probe_for_tuple = xs_probe_for_tuple,

.extensions = xs_sid_fmts, /* File ext assist */
.have_subtune = TRUE
.have_subtune = TRUE,

/* medium priority (slow to initialize) */
.priority = 5,
)
3 changes: 3 additions & 0 deletions src/sndfile/plugin.c
Expand Up @@ -442,4 +442,7 @@ AUD_INPUT_PLUGIN
.is_our_file_from_vfs = is_our_file_from_vfs,
.extensions = sndfile_fmts,
.mseek = file_mseek,

/* low priority fallback (but before ffaudio) */
.priority = 9,
)
2 changes: 1 addition & 1 deletion src/vorbis/vorbis.c
Expand Up @@ -586,6 +586,6 @@ AUD_INPUT_PLUGIN
.extensions = vorbis_fmts,
.mimes = mimes,

/* Vorbis probing is a bit slow; check for MP3 and AAC first. -jlindgren */
/* medium-high priority (a little slow) */
.priority = 2,
)

0 comments on commit a3230bb

Please sign in to comment.