Mercurial > audlegacy-plugins
diff src/madplug/plugin.c @ 773:22c82f3c0411 trunk
[svn] - reduce connection latency to http stream.
- remove unnecessary functions.
- remove redundant dialog which had been shown when madplug failed to open audio output.
- some cleanups.
| author | yaz |
|---|---|
| date | Fri, 02 Mar 2007 20:28:55 -0800 |
| parents | 1d3f70ac6b31 |
| children | 6f519e34ddf0 |
line wrap: on
line diff
--- a/src/madplug/plugin.c Fri Mar 02 20:17:50 2007 -0800 +++ b/src/madplug/plugin.c Fri Mar 02 20:28:55 2007 -0800 @@ -386,14 +386,8 @@ #endif /* DEBUG */ if (input_init(&myinfo, url) == FALSE) { +#ifdef DEBUG g_message("error initialising input"); - return; - } - - // don't try to get from stopped stream. - if(myinfo.remote && (!myinfo.playback || !myinfo.playback->playing)){ -#ifdef DEBUG - g_message("get_song_info: remote and not playing."); #endif return; } @@ -486,7 +480,6 @@ { TitleInput *tuple = NULL; gchar *string = NULL; - VFSFile *file; struct id3_file *id3file = NULL; struct id3_tag *tag = NULL; @@ -527,7 +520,7 @@ tuple->length = -1; tuple->mtime = 0; // this indicates streaming #ifdef DEBUG - g_message("get_song_tuple remote: tuple"); + g_message("get_song_tuple: remote: tuple"); #endif return tuple; } @@ -537,147 +530,95 @@ return NULL; } - if ((file = vfs_fopen(filename, "rb")) != NULL) { - - tuple = bmp_title_input_new(); - id3file = id3_file_open(filename, ID3_FILE_MODE_READONLY); - - if (id3file) { - tag = id3_file_tag(id3file); - - if (tag) { - tuple->performer = - input_id3_get_string(tag, ID3_FRAME_ARTIST); - tuple->album_name = - input_id3_get_string(tag, ID3_FRAME_ALBUM); - tuple->track_name = - input_id3_get_string(tag, ID3_FRAME_TITLE); + tuple = bmp_title_input_new(); - // year - string = NULL; - string = input_id3_get_string(tag, ID3_FRAME_YEAR); //TDRC - if (!string) - string = input_id3_get_string(tag, "TYER"); - - if (string) { - tuple->year = atoi(string); - g_free(string); - string = NULL; - } - - tuple->file_name = g_path_get_basename(filename); - tuple->file_path = g_path_get_dirname(filename); - tuple->file_ext = extname(filename); + id3file = id3_file_open(filename, ID3_FILE_MODE_READONLY); + if (id3file) { - // length - tuple->length = -1; - string = input_id3_get_string(tag, "TLEN"); - if (string) { - tuple->length = atoi(string); -#ifdef DEBUG - g_message("get_song_tuple: TLEN = %d", tuple->length); -#endif - g_free(string); - string = NULL; - } - else { - char *dummy = NULL; - int length = 0; - audmad_get_song_info(filename, &dummy, &length); - tuple->length = length; - g_free(dummy); - } + tag = id3_file_tag(id3file); + if (tag) { + tuple->performer = + input_id3_get_string(tag, ID3_FRAME_ARTIST); + tuple->album_name = + input_id3_get_string(tag, ID3_FRAME_ALBUM); + tuple->track_name = + input_id3_get_string(tag, ID3_FRAME_TITLE); - // track number - string = input_id3_get_string(tag, ID3_FRAME_TRACK); - if (string) { - tuple->track_number = atoi(string); - g_free(string); - string = NULL; - } - // genre - tuple->genre = input_id3_get_string(tag, ID3_FRAME_GENRE); -#ifdef DEBUG - g_message("genre = %s", tuple->genre); -#endif - // comment - tuple->comment = - input_id3_get_string(tag, ID3_FRAME_COMMENT); + // year + string = NULL; + string = input_id3_get_string(tag, ID3_FRAME_YEAR); //TDRC + if (!string) + string = input_id3_get_string(tag, "TYER"); + if (string) { + tuple->year = atoi(string); + g_free(string); + string = NULL; } - id3_file_close(id3file); - } - else { // no id3tag + tuple->file_name = g_path_get_basename(filename); tuple->file_path = g_path_get_dirname(filename); tuple->file_ext = extname(filename); + // length - { + tuple->length = -1; + string = input_id3_get_string(tag, "TLEN"); + if (string) { + tuple->length = atoi(string); +#ifdef DEBUG + g_message("get_song_tuple: TLEN = %d", tuple->length); +#endif + g_free(string); + string = NULL; + } + else { char *dummy = NULL; int length = 0; - if(tuple->length == -1) { - audmad_get_song_info(filename, &dummy, &length); - tuple->length = length; - } + audmad_get_song_info(filename, &dummy, &length); + tuple->length = length; g_free(dummy); } + + // track number + string = input_id3_get_string(tag, ID3_FRAME_TRACK); + if (string) { + tuple->track_number = atoi(string); + g_free(string); + string = NULL; + } + // genre + tuple->genre = input_id3_get_string(tag, ID3_FRAME_GENRE); +#ifdef DEBUG + g_message("genre = %s", tuple->genre); +#endif + // comment + tuple->comment = + input_id3_get_string(tag, ID3_FRAME_COMMENT); + } - vfs_fclose(file); + id3_file_close(id3file); + } + else { // no id3tag + tuple->file_name = g_path_get_basename(filename); + tuple->file_path = g_path_get_dirname(filename); + tuple->file_ext = extname(filename); + // length + { + char *dummy = NULL; + int length = 0; + if(tuple->length == -1) { + audmad_get_song_info(filename, &dummy, &length); + tuple->length = length; + } + g_free(dummy); + } } #ifdef DEBUG g_message("e: mad: audmad_get_song_tuple"); #endif return tuple; - } -// probably this function is nolonger needed. -#if 0 -/** - * Retrieve meta-information about URL. - * For local files this means ID3 tag etc. - */ -gboolean mad_get_info(struct mad_info_t * info, gboolean fast_scan) -{ - TitleInput *tuple = NULL; - -#ifdef DEBUG - g_message("f: mad_get_info: %s", info->filename); -#endif - if (info->remote) { - return TRUE; - } - - tuple = audmad_get_song_tuple(info->filename); - - info->title = xmms_get_titlestring(audmad_config.title_override == TRUE ? - audmad_config.id3_format : xmms_get_gentitle_format(), tuple); - - /* scan mp3 file, decoding headers unless fast_scan is set */ - if (scan_file(info, fast_scan) == FALSE) - return FALSE; - - /* reset the input file to the start */ - vfs_rewind(info->infile); - info->offset = 0; - - /* use the filename for the title as a last resort */ - if (!info->title) - { - char *pos = strrchr(info->filename, '/'); - if (pos) - info->title = g_strdup(pos + 1); - else - info->title = g_strdup(info->filename); - } - -#ifdef DEBUG - g_message("e: mad_get_info"); -#endif - return TRUE; -} -#endif - static gchar *fmts[] = { "mp3", "mp2", "mpg", NULL };
