# HG changeset patch # User nenolod # Date 1169375718 28800 # Node ID 90e4ac2189fe49054a867b8fc065f520205e096f # Parent f5191cefba2a15e170545884668a78c736930b1e [svn] - newvfs probing support diff -r f5191cefba2a -r 90e4ac2189fe ChangeLog --- a/ChangeLog Sun Jan 21 02:21:50 2007 -0800 +++ b/ChangeLog Sun Jan 21 02:35:18 2007 -0800 @@ -1,3 +1,11 @@ +2007-01-21 10:21:50 +0000 William Pitcock + revision [1034] + - fix weird "(null) (Radioseven - www.radioseven.se)" glitch + + trunk/src/mpg123/mpg123.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + + 2007-01-21 10:18:37 +0000 William Pitcock revision [1032] - use g_new0 diff -r f5191cefba2a -r 90e4ac2189fe src/vorbis/vorbis.c --- a/src/vorbis/vorbis.c Sun Jan 21 02:21:50 2007 -0800 +++ b/src/vorbis/vorbis.c Sun Jan 21 02:35:18 2007 -0800 @@ -61,6 +61,7 @@ static TitleInput *get_song_tuple(gchar *filename); static int vorbis_check_file(char *filename); +static int vorbis_check_fd(char *filename, VFSFile *stream); static void vorbis_play(char *filename); static void vorbis_stop(void); static void vorbis_pause(short p); @@ -118,7 +119,8 @@ get_song_tuple, NULL, NULL, - NULL, + vorbis_check_fd, + vorbis_fmts, }; static OggVorbis_File vf; @@ -150,17 +152,6 @@ char *ext; gint result; - /* is this our http resource? */ - if (strncasecmp(filename, "http://", 7) == 0) { - ext = strrchr(filename, '.'); - if (ext) { - if (!strncasecmp(ext, ".ogg", 4)) { - return TRUE; - } - } - return FALSE; - } - if (!(stream = vfs_fopen(filename, "r"))) { return FALSE; } @@ -225,6 +216,79 @@ break; } + ov_clear(&vfile); /* once the ov_open succeeds, the stream belongs to + vorbisfile.a. ov_clear will fclose it */ + g_mutex_unlock(vf_mutex); + return TRUE; +} + +static int +vorbis_check_fd(char *filename, VFSFile *stream) +{ + OggVorbis_File vfile; /* avoid thread interaction */ + char *ext; + gint result; + + /* + * The open function performs full stream detection and machine + * initialization. If it returns zero, the stream *is* Vorbis and + * we're fully ready to decode. + */ + + /* libvorbisfile isn't thread safe... */ + memset(&vfile, 0, sizeof(vfile)); + g_mutex_lock(vf_mutex); + + result = ov_test_callbacks(stream, &vfile, NULL, 0, vorbis_callbacks); + + switch (result) { + case OV_EREAD: +#ifdef DEBUG + g_message("** vorbis.c: Media read error: %s", filename); +#endif + g_mutex_unlock(vf_mutex); + vfs_fclose(stream); + return FALSE; + break; + case OV_ENOTVORBIS: +#ifdef DEBUG + g_message("** vorbis.c: Not Vorbis data: %s", filename); +#endif + g_mutex_unlock(vf_mutex); + vfs_fclose(stream); + return FALSE; + break; + case OV_EVERSION: +#ifdef DEBUG + g_message("** vorbis.c: Version mismatch: %s", filename); +#endif + g_mutex_unlock(vf_mutex); + vfs_fclose(stream); + return FALSE; + break; + case OV_EBADHEADER: +#ifdef DEBUG + g_message("** vorbis.c: Invalid Vorbis bistream header: %s", + filename); +#endif + g_mutex_unlock(vf_mutex); + vfs_fclose(stream); + return FALSE; + break; + case OV_EFAULT: +#ifdef DEBUG + g_message("** vorbis.c: Internal logic fault while reading %s", + filename); +#endif + g_mutex_unlock(vf_mutex); + vfs_fclose(stream); + return FALSE; + break; + case 0: + break; + default: + break; + } ov_clear(&vfile); /* once the ov_open succeeds, the stream belongs to vorbisfile.a. ov_clear will fclose it */