Mercurial > audlegacy-plugins
changeset 1281:1d81217767ab
Automated merge with ssh://hg.atheme.org//hg/audacious-plugins
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Mon, 16 Jul 2007 13:17:12 -0500 |
parents | 9de798e20cb3 (current diff) 2ebffac54865 (diff) |
children | ced2aa634901 7184bbd63761 |
files | src/vorbis/fileinfo.c |
diffstat | 27 files changed, 310 insertions(+), 179 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac Mon Jul 16 13:16:56 2007 -0500 +++ b/configure.ac Mon Jul 16 13:17:12 2007 -0500 @@ -206,8 +206,8 @@ case "$target" in *-apple-*) AC_MSG_RESULT([Mac OS X: -fPIC -bundle -fno-common -flat_namespace -undefined suppress, .dylib]) - PICFLAGS="-fPIC -DPIC" - PICLDFLAGS="-fPIC -DPIC -bundle -fno-common -flat_namespace -undefined suppress" + PICFLAGS="-DPIC -fno-common" + PICLDFLAGS="-DPIC -bundle -fno-common -flat_namespace -undefined suppress" LIBLDFLAGS="-dynamiclib" AUDLDFLAGS="" SHARED_SUFFIX=".dylib"
--- a/src/amidi-plug/amidi-plug.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/amidi-plug/amidi-plug.c Mon Jul 16 13:17:12 2007 -0500 @@ -24,7 +24,7 @@ DECLARE_PLUGIN(amidi-plug, NULL, NULL, amidiplug_iplist, NULL, NULL, NULL, NULL); -static gboolean amidiplug_detect_by_content( gchar * filename , VFSFile * fp ) +static gboolean amidiplug_detect_by_content( gchar * filename_uri , VFSFile * fp ) { gchar magic_bytes[4]; gint res = 0; @@ -37,7 +37,7 @@ if ( !strncmp( magic_bytes , "MThd" , 4 ) ) { - DEBUGMSG( "MIDI found, %s is a standard midi file\n" , filename ); + DEBUGMSG( "MIDI found, %s is a standard midi file\n" , filename_uri ); return TRUE; } @@ -53,7 +53,7 @@ if ( !strncmp( magic_bytes , "RMID" , 4 ) ) { - DEBUGMSG( "MIDI found, %s is a riff midi file\n" , filename ); + DEBUGMSG( "MIDI found, %s is a riff midi file\n" , filename_uri ); return TRUE; } } @@ -62,26 +62,26 @@ } -static gint amidiplug_is_our_file( gchar * filename ) +static gint amidiplug_is_our_file( gchar * filename_uri ) { VFSFile * fp; gboolean result = FALSE; - fp = VFS_FOPEN( filename , "rb" ); + fp = VFS_FOPEN( filename_uri , "rb" ); if ( fp == NULL ) return FALSE; - result = amidiplug_detect_by_content( filename , fp ); + result = amidiplug_detect_by_content( filename_uri , fp ); VFS_FCLOSE( fp ); return result; } -static gint amidiplug_is_our_file_from_vfs( gchar *filename , VFSFile *fp ) +static gint amidiplug_is_our_file_from_vfs( gchar *filename_uri , VFSFile *fp ) { - return amidiplug_detect_by_content( filename , fp ); + return amidiplug_detect_by_content( filename_uri , fp ); } @@ -118,9 +118,9 @@ } -static void amidiplug_file_info_box( gchar * filename ) +static void amidiplug_file_info_box( gchar * filename_uri ) { - i_fileinfo_gui( filename ); + i_fileinfo_gui( filename_uri ); } @@ -335,10 +335,13 @@ } -static void amidiplug_get_song_info( gchar * filename , gchar ** title , gint * length ) +static void amidiplug_get_song_info( gchar * filename_uri , gchar ** title , gint * length ) { /* song title, get it from the filename */ - *title = G_PATH_GET_BASENAME(filename); + gchar * filename = g_filename_from_uri( filename_uri , NULL , NULL ); + if ( !filename ) filename = g_strdup( filename_uri ); + *title = G_PATH_GET_BASENAME(filename_uri); + g_free( filename ); /* sure, it's possible to calculate the length of a MIDI file anytime, but the file must be entirely parsed to calculate it; this could @@ -349,7 +352,7 @@ will return 0 if a problem occurs and the length can't be calculated */ midifile_t mf; - if ( i_midi_parse_from_filename( filename , &mf ) ) + if ( i_midi_parse_from_filename( filename_uri , &mf ) ) *length = (gint)(mf.length / 1000); else *length = -1; @@ -363,9 +366,10 @@ } -static void amidiplug_play( InputPlayback * playback) +static void amidiplug_play( InputPlayback * playback ) { - gchar * filename = playback->filename; + gchar * filename_uri = playback->filename; + gchar * filename = NULL; gint port_count = 0; gint au_samplerate = -1, au_bitdepth = -1, au_channels = -1; @@ -403,15 +407,15 @@ return; } - DEBUGMSG( "PLAY requested, opening file: %s\n" , filename ); - midifile.file_pointer = VFS_FOPEN( filename , "rb" ); + DEBUGMSG( "PLAY requested, opening file: %s\n" , filename_uri ); + midifile.file_pointer = VFS_FOPEN( filename_uri , "rb" ); if (!midifile.file_pointer) { - g_warning( "Cannot open %s\n" , filename ); + g_warning( "Cannot open %s\n" , filename_uri ); amidiplug_playing_status = AMIDIPLUG_ERR; return; } - midifile.file_name = filename; + midifile.file_name = filename_uri; switch( i_midi_file_read_id( &midifile ) ) { @@ -420,7 +424,7 @@ DEBUGMSG( "PLAY requested, RIFF chunk found, processing...\n" ); /* read riff chunk */ if ( !i_midi_file_parse_riff( &midifile ) ) - WARNANDBREAKANDPLAYERR( "%s: invalid file format (riff parser)\n" , filename ); + WARNANDBREAKANDPLAYERR( "%s: invalid file format (riff parser)\n" , filename_uri ); /* if that was read correctly, go ahead and read smf data */ } @@ -429,43 +433,47 @@ { DEBUGMSG( "PLAY requested, MThd chunk found, processing...\n" ); if ( !i_midi_file_parse_smf( &midifile , port_count ) ) - WARNANDBREAKANDPLAYERR( "%s: invalid file format (smf parser)\n" , filename ); + WARNANDBREAKANDPLAYERR( "%s: invalid file format (smf parser)\n" , filename_uri ); if ( midifile.time_division < 1 ) - WARNANDBREAKANDPLAYERR( "%s: invalid time division (%i)\n" , filename , midifile.time_division ); + WARNANDBREAKANDPLAYERR( "%s: invalid time division (%i)\n" , filename_uri , midifile.time_division ); DEBUGMSG( "PLAY requested, setting ppq and tempo...\n" ); /* fill midifile.ppq and midifile.tempo using time_division */ if ( !i_midi_setget_tempo( &midifile ) ) - WARNANDBREAKANDPLAYERR( "%s: invalid values while setting ppq and tempo\n" , filename ); + WARNANDBREAKANDPLAYERR( "%s: invalid values while setting ppq and tempo\n" , filename_uri ); DEBUGMSG( "PLAY requested, sequencer start\n" ); /* sequencer start */ - if ( !backend.seq_start( filename ) ) - WARNANDBREAKANDPLAYERR( "%s: problem with seq_start, play aborted\n" , filename ); + if ( !backend.seq_start( filename_uri ) ) + WARNANDBREAKANDPLAYERR( "%s: problem with seq_start, play aborted\n" , filename_uri ); DEBUGMSG( "PLAY requested, sequencer on\n" ); /* sequencer on */ if ( !backend.seq_on() ) - WARNANDBREAKANDPLAYERR( "%s: problem with seq_on, play aborted\n" , filename ); + WARNANDBREAKANDPLAYERR( "%s: problem with seq_on, play aborted\n" , filename_uri ); DEBUGMSG( "PLAY requested, setting sequencer queue tempo...\n" ); /* set sequencer queue tempo using ppq and tempo (call only after i_midi_setget_tempo) */ if ( !backend.seq_queue_tempo( midifile.current_tempo , midifile.ppq ) ) { backend.seq_off(); /* kill the sequencer */ - WARNANDBREAKANDPLAYERR( "%s: ALSA queue problem, play aborted\n" , filename ); + WARNANDBREAKANDPLAYERR( "%s: ALSA queue problem, play aborted\n" , filename_uri ); } /* fill midifile.length, keeping in count tempo-changes */ i_midi_setget_length( &midifile ); DEBUGMSG( "PLAY requested, song length calculated: %i msec\n" , (gint)(midifile.length / 1000) ); + /* our length is in microseconds, but the player wants milliseconds */ + filename = g_filename_from_uri( filename_uri , NULL , NULL ); + if ( !filename ) filename = g_strdup( filename_uri ); amidiplug_ip.set_info( G_PATH_GET_BASENAME(filename) , (gint)(midifile.length / 1000) , au_bitdepth * au_samplerate * au_channels / 8 , au_samplerate , au_channels ); + g_free( filename ); /* play play play! */ DEBUGMSG( "PLAY requested, starting play thread\n" ); @@ -477,7 +485,7 @@ default: { amidiplug_playing_status = AMIDIPLUG_ERR; - g_warning( "%s is not a Standard MIDI File\n" , filename ); + g_warning( "%s is not a Standard MIDI File\n" , filename_uri ); break; } }
--- a/src/amidi-plug/i_common.h Mon Jul 16 13:16:56 2007 -0500 +++ b/src/amidi-plug/i_common.h Mon Jul 16 13:17:12 2007 -0500 @@ -43,7 +43,7 @@ #endif /* DEBUG */ -#define AMIDIPLUG_VERSION "0.7++" +#define AMIDIPLUG_VERSION "0.7p1" #define PLAYER_NAME "Audacious" #define PLAYER_LOCALRCDIR ".audacious" #define G_PATH_GET_BASENAME(x) g_path_get_basename(x)
--- a/src/amidi-plug/i_fileinfo.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/amidi-plug/i_fileinfo.c Mon Jul 16 13:17:12 2007 -0500 @@ -106,7 +106,7 @@ } -void i_fileinfo_gui( gchar * filename ) +void i_fileinfo_gui( gchar * filename_uri ) { static GtkWidget *fileinfowin = NULL; GtkWidget *fileinfowin_vbox, *fileinfowin_columns_hbox; @@ -121,7 +121,7 @@ PangoAttrList *pangoattrlist; PangoAttribute *pangoattr; GString *value_gstring; - gchar *title , *filename_utf8; + gchar *title , *filename, *filename_utf8; gint bpm = 0, wavg_bpm = 0; midifile_t *mf; @@ -131,7 +131,7 @@ mf = g_malloc(sizeof(midifile_t)); /****************** midifile parser ******************/ - if ( !i_midi_parse_from_filename( filename , mf ) ) + if ( !i_midi_parse_from_filename( filename_uri , mf ) ) return; /* midifile is filled with information at this point, bpm information is needed too */ @@ -333,6 +333,9 @@ /* utf8-ize filename and set window title */ + filename = g_filename_from_uri( filename_uri , NULL , NULL ); + if ( !filename ) + filename = g_strdup( filename_uri ); filename_utf8 = g_strdup(g_filename_to_utf8( filename , -1 , NULL , NULL , NULL )); if ( !filename_utf8 ) { @@ -353,6 +356,7 @@ gtk_entry_set_text( GTK_ENTRY(title_name_v_entry) , filename_utf8 ); gtk_editable_set_position( GTK_EDITABLE(title_name_v_entry) , -1 ); g_free(filename_utf8); + g_free(filename); gtk_widget_grab_focus( GTK_WIDGET(footer_bclose) ); gtk_widget_show_all( fileinfowin );
--- a/src/cue/cuesheet.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/cue/cuesheet.c Mon Jul 16 13:17:12 2007 -0500 @@ -351,31 +351,25 @@ extern void playback_stop(void); extern void mainwin_clear_song_info(void); -static gpointer do_stop(gpointer data) +static gboolean do_stop(gpointer data) { -// InputPlayback *playback = (InputPlayback *)data; - Playlist *playlist = playlist_get_active(); #ifdef DEBUG g_print("f: do_stop\n"); #endif + ip_data.stop = TRUE; playback_stop(); ip_data.stop = FALSE; - PLAYLIST_LOCK(playlist->mutex); - gdk_threads_enter(); mainwin_clear_song_info(); - gdk_threads_leave(); - PLAYLIST_UNLOCK(playlist->mutex); #ifdef DEBUG g_print("e: do_stop\n"); #endif - g_thread_exit(NULL); - return NULL; //dummy + return FALSE; //one-shot } -static gpointer do_setpos(gpointer data) +static gboolean do_setpos(gpointer data) { Playlist *playlist = playlist_get_active(); gint pos = playlist_get_position_nolock(playlist); @@ -388,9 +382,16 @@ #ifdef DEBUG g_print("do_setpos: pos = %d\n\n", pos); #endif + /* being done from the main loop thread, does not require locks */ playlist_set_position(playlist, (guint)pos); - g_thread_exit(NULL); - return NULL; //dummy + + /* kick watchdog */ + g_mutex_lock(cue_mutex); + watchdog_state = RUN; + g_mutex_unlock(cue_mutex); + g_cond_signal(cue_cond); + + return FALSE; //one-shot } static void cue_pause(InputPlayback * data, short p) @@ -545,7 +546,7 @@ #ifdef DEBUG g_print("e: watchdog exit\n"); #endif - g_mutex_unlock(cue_mutex); // stop() locks cue_mutex. + g_mutex_unlock(cue_mutex); // stop() will lock cue_mutex. stop(real_ip); // need not to care about real_ip != NULL here. g_thread_exit(NULL); break; @@ -574,7 +575,7 @@ // prev track if (time < cue_tracks[cur_cue_track].index) { - gint incr; + static gint incr = 0; gint oldpos = cur_cue_track; #ifdef DEBUG g_print("i: watchdog prev\n"); @@ -589,14 +590,18 @@ finetune_seek = time; } - exec_thread = g_thread_create(do_setpos, &incr, FALSE, NULL); - g_usleep(TRANSITION_GUARD_TIME); + g_mutex_lock(cue_mutex); + watchdog_state = STOP; + g_mutex_unlock(cue_mutex); + + g_idle_add_full(G_PRIORITY_HIGH , do_setpos, &incr, NULL); + continue; } // next track if (cur_cue_track + 1 < last_cue_track && time > cue_tracks[cur_cue_track + 1].index) { - gint incr; + static gint incr = 0; gint oldpos = cur_cue_track; #ifdef DEBUG g_print("i: watchdog next\n"); @@ -612,12 +617,17 @@ finetune_seek = time; } + g_mutex_lock(cue_mutex); + watchdog_state = STOP; + g_mutex_unlock(cue_mutex); + if(cfg.stopaftersong) { - exec_thread = g_thread_create(do_stop, (void *)real_ip, FALSE, NULL); + g_idle_add_full(G_PRIORITY_HIGH, do_stop, (void *)real_ip, NULL); + continue; } else { - exec_thread = g_thread_create(do_setpos, &incr, FALSE, NULL); - g_usleep(TRANSITION_GUARD_TIME); + g_idle_add_full(G_PRIORITY_HIGH , do_setpos, &incr, NULL); + continue; } } @@ -631,27 +641,32 @@ #ifdef DEBUG g_print("i: watchdog eof reached\n\n"); #endif - + g_mutex_lock(cue_mutex); + watchdog_state = STOP; + g_mutex_unlock(cue_mutex); + if(cfg.repeat) { - gint incr = -pos; - exec_thread = g_thread_create(do_setpos, &incr, FALSE, NULL); - g_usleep(TRANSITION_GUARD_TIME); + static gint incr = 0; + incr = -pos; + g_idle_add_full(G_PRIORITY_HIGH , do_setpos, &incr, NULL); + continue; } else { - exec_thread = g_thread_create(do_stop, (void *)real_ip, FALSE, NULL); - g_usleep(TRANSITION_GUARD_TIME); + g_idle_add_full(G_PRIORITY_HIGH, do_stop, (void *)real_ip, NULL); + continue; } } else { if(cfg.stopaftersong) { - exec_thread = g_thread_create(do_stop, (void *)real_ip, FALSE, NULL); + g_idle_add_full(G_PRIORITY_HIGH, do_stop, (void *)real_ip, NULL); + continue; } #ifdef DEBUG g_print("i: watchdog end of cue, advance in playlist\n\n"); #endif - gint incr = 1; - exec_thread = g_thread_create(do_setpos, &incr, FALSE, NULL); - g_usleep(TRANSITION_GUARD_TIME); + static gint incr = 1; + g_idle_add_full(G_PRIORITY_HIGH , do_setpos, &incr, NULL); + continue; } } }
--- a/src/curl/Makefile Mon Jul 16 13:16:56 2007 -0500 +++ b/src/curl/Makefile Mon Jul 16 13:17:12 2007 -0500 @@ -3,7 +3,7 @@ SUBDIRS = -OBJECTIVE_LIBS = libcurl$(SHARED_SUFFIX) +OBJECTIVE_LIBS = libcurlsrc$(SHARED_SUFFIX) LIBDIR = $(plugindir)/$(TRANSPORT_PLUGIN_DIR)
--- a/src/filewriter/filewriter.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/filewriter/filewriter.c Mon Jul 16 13:17:12 2007 -0500 @@ -254,7 +254,7 @@ else directory = g_strdup(file_path); - temp = g_strdup_printf("%s/%s.%s", + temp = g_strdup_printf("file://%s/%s.%s", directory, filename, fileext_str[fileext]); g_free(directory); g_free(filename);
--- a/src/filewriter/flac.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/filewriter/flac.c Mon Jul 16 13:17:12 2007 -0500 @@ -191,7 +191,7 @@ static gint flac_get_written_time(void) { if (input.frequency && input.channels) - return (gint) ((olen * 1000) / (input.frequency * 2 * input.channels)); + return (gint) ((olen * 1000) / (input.frequency * 2 * input.channels) + offset); return 0; }
--- a/src/filewriter/vorbis.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/filewriter/vorbis.c Mon Jul 16 13:17:12 2007 -0500 @@ -222,7 +222,7 @@ static gint vorbis_get_written_time(void) { if (input.frequency && input.channels) - return (gint) ((olen * 1000) / (input.frequency * 2 * input.channels)); + return (gint) ((olen * 1000) / (input.frequency * 2 * input.channels) + offset); return 0; }
--- a/src/filewriter/wav.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/filewriter/wav.c Mon Jul 16 13:17:12 2007 -0500 @@ -113,6 +113,6 @@ static gint wav_get_written_time(void) { if (header.byte_p_sec != 0) - return (gint) ((written * 1000) / header.byte_p_sec); + return (gint) ((written * 1000) / header.byte_p_sec + offset); return 0; }
--- a/src/flacng/plugin.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/flacng/plugin.c Mon Jul 16 13:17:12 2007 -0500 @@ -57,7 +57,7 @@ flac_get_song_tuple, // get a tuple NULL, NULL, // write a tuple back to a file as a tag -/* flac_is_our_fd */ NULL, // version of is_our_file which is handed an FD + flac_is_our_fd, // version of is_our_file which is handed an FD flac_fmts // vector of fileextensions allowed by the plugin }; @@ -175,7 +175,7 @@ /* --- */ -gboolean flac_is_our_file(gchar* filename) { +gboolean flac_is_our_fd(gchar* filename, VFSFile* fd) { _ENTER; @@ -184,9 +184,9 @@ _LEAVE FALSE; } - _DEBUG("Testing file: %s", filename); + _DEBUG("Testing fd for file: %s", filename); - if (FALSE == read_metadata(filename, test_decoder, test_info)) { + if (FALSE == read_metadata(fd, test_decoder, test_info)) { _DEBUG("File not handled by this plugin!"); _LEAVE FALSE; } @@ -203,13 +203,8 @@ * If we get here, the file is supported by FLAC. * The stream characteristics have been filled in by * the metadata callback. - * We can close the stream now. */ - vfs_fclose(test_info->input_stream); - test_info->input_stream = NULL; - - _DEBUG("Stream encoded at %d Hz, %d bps, %d channels", test_info->stream.samplerate, test_info->stream.bits_per_sample, @@ -235,13 +230,38 @@ _DEBUG("Accepting file %s", filename); - reset_info(test_info); + reset_info(test_info, FALSE); _LEAVE TRUE; } /* --- */ +gboolean flac_is_our_file(gchar* filename) { + + VFSFile* fd; + gboolean ret; + + _ENTER; + + _DEBUG("Testing file: %s", filename); + /* + * Open the file + */ + if (NULL == (fd = vfs_fopen(filename, "rb"))) { + _ERROR("Could not open file for reading! (%s)", filename); + _LEAVE FALSE; + } + + ret = flac_is_our_fd(filename, fd); + + vfs_fclose(fd); + + _LEAVE ret; +} + +/* --- */ + void squeeze_audio(gint32* src, void* dst, guint count, guint src_res, guint dst_res) { /* @@ -530,6 +550,7 @@ void flac_play_file (InputPlayback* input) { + VFSFile* fd; gint l; _ENTER; @@ -545,7 +566,15 @@ input->playing = FALSE; xmms_usleep(20000); - if (FALSE == read_metadata(input->filename, main_decoder, main_info)) { + /* + * Open the file + */ + if (NULL == (fd = vfs_fopen(input->filename, "rb"))) { + _ERROR("Could not open file for reading! (%s)", input->filename); + _LEAVE; + } + + if (FALSE == read_metadata(fd, main_decoder, main_info)) { _ERROR("Could not prepare file for playing!"); _LEAVE; } @@ -634,13 +663,24 @@ void flac_get_song_info(gchar* filename, gchar** title, gint* length) { gint l; + VFSFile* fd; _ENTER; - if (FALSE == read_metadata(filename, test_decoder, test_info)) { + _DEBUG("Testing file: %s", filename); + /* + * Open the file + */ + if (NULL == (fd = vfs_fopen(filename, "rb"))) { + _ERROR("Could not open file for reading! (%s)", filename); + _LEAVE; + } + + if (FALSE == read_metadata(fd, test_decoder, test_info)) { _ERROR("Could not read file info!"); *length = -1; *title = g_strdup(""); + reset_info(test_info, TRUE); _LEAVE; } @@ -658,7 +698,7 @@ *length = l; *title = get_title(filename, test_info); - reset_info(test_info); + reset_info(test_info, TRUE); _LEAVE; } @@ -667,18 +707,29 @@ TitleInput *flac_get_song_tuple(gchar* filename) { + VFSFile *fd; TitleInput *tuple; _ENTER; - if (FALSE == read_metadata(filename, test_decoder, test_info)) { + _DEBUG("Testing file: %s", filename); + /* + * Open the file + */ + if (NULL == (fd = vfs_fopen(filename, "rb"))) { + _ERROR("Could not open file for reading! (%s)", filename); + _LEAVE NULL; + } + + if (FALSE == read_metadata(fd, test_decoder, test_info)) { _ERROR("Could not read metadata tuple for file <%s>", filename); + reset_info(test_info, TRUE); _LEAVE NULL; } tuple = get_tuple(filename, test_info); - reset_info(test_info); + reset_info(test_info, TRUE); _LEAVE tuple; }
--- a/src/flacng/plugin.h Mon Jul 16 13:16:56 2007 -0500 +++ b/src/flacng/plugin.h Mon Jul 16 13:17:12 2007 -0500 @@ -4,6 +4,7 @@ void flac_init(void); void flac_aboutbox(void); gboolean flac_is_our_file(gchar* filename); +gboolean flac_is_our_fd(gchar* filename, VFSFile* fd); void flac_play_file (InputPlayback* input); void flac_stop(InputPlayback* input); void flac_pause(InputPlayback* input, gshort p);
--- a/src/flacng/seekable_stream_callbacks.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/flacng/seekable_stream_callbacks.c Mon Jul 16 13:17:12 2007 -0500 @@ -116,7 +116,7 @@ if (-1 == (position = vfs_ftell(info->input_stream))) { _ERROR("Could not tell current position!"); - return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; + _LEAVE FLAC__STREAM_DECODER_TELL_STATUS_ERROR; } _DEBUG("Current position: %ld", position); @@ -138,6 +138,16 @@ info = (callback_info*) client_data; _DEBUG("Using callback_info %s", info->name); + /* + * If we are testing a stream and use restricted reading, + * return EOF if we have exhausted our alotted reading + * quota + */ + if (0 == info->read_max) { + _DEBUG("read_max exhausted, faking EOF"); + _LEAVE TRUE; + } + eof = vfs_feof(info->input_stream); _LEAVE eof;
--- a/src/flacng/tools.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/flacng/tools.c Mon Jul 16 13:17:12 2007 -0500 @@ -64,7 +64,7 @@ info->replaygain.track_peak = NULL; info->replaygain.album_gain = NULL; info->replaygain.album_peak = NULL; - reset_info(info); + reset_info(info, FALSE); _DEBUG("Playback buffer allocated for %d samples, %d bytes", BUFFER_SIZE_SAMP, BUFFER_SIZE_BYTE); @@ -73,16 +73,17 @@ /* --- */ -void reset_info(callback_info* info) { +void reset_info(callback_info* info, gboolean close_fd) { _ENTER; _DEBUG("Using callback_info %s", info->name); - if (NULL != info->input_stream) { + if (close_fd && (NULL != info->input_stream)) { + _DEBUG("Closing fd"); vfs_fclose(info->input_stream); - info->input_stream = NULL; } + info->input_stream = NULL; // memset(info->output_buffer, 0, BUFFER_SIZE * sizeof(int16_t)); info->stream.samplerate = 0; @@ -172,7 +173,7 @@ /* --- */ -gboolean read_metadata(gchar* filename, FLAC__StreamDecoder* decoder, callback_info* info) { +gboolean read_metadata(VFSFile* fd, FLAC__StreamDecoder* decoder, callback_info* info) { FLAC__StreamDecoderState ret; @@ -180,7 +181,9 @@ _DEBUG("Using callback_info %s", info->name); - _DEBUG("Opening file %s", filename); + reset_info(info, FALSE); + + info->input_stream = fd; /* * Reset the decoder @@ -190,8 +193,6 @@ _LEAVE FALSE; } - reset_info(info); - /* * Just scan the first 8k for the start of metadata */ @@ -205,21 +206,14 @@ info->testing = TRUE; /* - * Open the file - */ - if (NULL == (info->input_stream = vfs_fopen(filename, "rb"))) { - _ERROR("Could not open file for reading! (%s)", filename); - _LEAVE FALSE; - } - - /* * Try to decode the metadata */ if (false == FLAC__stream_decoder_process_until_end_of_metadata(decoder)) { ret = FLAC__stream_decoder_get_state(decoder); _DEBUG("Could not read the metadata: %s(%d)!", FLAC__StreamDecoderStateString[ret], ret); - reset_info(info); + /* Do not close the filehandle, it was passed to us */ + reset_info(info, FALSE); _LEAVE FALSE; }
--- a/src/flacng/tools.h Mon Jul 16 13:16:56 2007 -0500 +++ b/src/flacng/tools.h Mon Jul 16 13:17:12 2007 -0500 @@ -25,10 +25,10 @@ #include "flac_compat.h" callback_info* init_callback_info(gchar* name); -void reset_info(callback_info* info); +void reset_info(callback_info* info, gboolean close_fd); gchar* get_title(const gchar* filename, callback_info* info); TitleInput *get_tuple(const gchar *filename, callback_info* info); void add_comment(callback_info* info, gchar* key, gchar* value); -gboolean read_metadata(gchar* filename, FLAC__StreamDecoder* decoder, callback_info* info); +gboolean read_metadata(VFSFile* fd, FLAC__StreamDecoder* decoder, callback_info* info); #endif
--- a/src/m3u/m3u.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/m3u/m3u.c Mon Jul 16 13:17:12 2007 -0500 @@ -156,13 +156,14 @@ gchar *outstr = NULL; VFSFile *file; Playlist *playlist = playlist_get_active(); - gchar *fn; + gchar *fn = NULL; g_return_if_fail(filename != NULL); g_return_if_fail(playlist != NULL); - file = vfs_fopen(filename, "wb"); - + fn = g_filename_to_uri(filename, NULL, NULL); + file = vfs_fopen(fn ? fn : filename, "wb"); + g_free(fn); fn = NULL; g_return_if_fail(file != NULL); if (cfg.use_pl_metadata) @@ -194,8 +195,7 @@ fn = g_filename_from_uri(entry->filename, NULL, NULL); vfs_fprintf(file, "%s\n", fn ? fn : entry->filename); - if (fn) - g_free(fn); + g_free(fn); fn = NULL; } PLAYLIST_UNLOCK(playlist->mutex);
--- a/src/madplug/fileinfo.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/madplug/fileinfo.c Mon Jul 16 13:17:12 2007 -0500 @@ -590,6 +590,16 @@ } tmp = g_filename_from_uri(fileurl, NULL, NULL); + if (tmp == NULL) + { +#ifdef DEBUG + tmp = str_to_utf8(fileurl); + g_message("f: audmad_get_file_info: %s , g_filename_from_uri failed", tmp); + g_free(tmp); + tmp = NULL; +#endif + return; + } utf_filename = str_to_utf8(tmp); g_free(tmp); tmp = NULL;
--- a/src/madplug/input.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/madplug/input.c Mon Jul 16 13:17:12 2007 -0500 @@ -352,6 +352,7 @@ static void input_read_tag(struct mad_info_t *info) { gchar *string = NULL; + gchar *realfn = NULL; TitleInput *title_input; glong curpos = 0; @@ -425,9 +426,11 @@ g_free(string); string = NULL; } - - title_input->file_name = g_strdup(g_basename(info->filename)); - title_input->file_path = g_path_get_dirname(info->filename); + + realfn = g_filename_from_uri(info->filename, NULL, NULL); + title_input->file_name = g_strdup(g_basename(realfn ? realfn : info->filename)); + title_input->file_path = g_path_get_dirname(realfn ? realfn : info->filename); + g_free(realfn); realfn = NULL; if ((string = strrchr(title_input->file_name, '.'))) { title_input->file_ext = string + 1; *string = '\0'; // make filename end at dot.
--- a/src/madplug/plugin.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/madplug/plugin.c Mon Jul 16 13:17:12 2007 -0500 @@ -601,6 +601,7 @@ { TitleInput *tuple = NULL; gchar *string = NULL; + gchar *realfn = NULL; struct id3_file *id3file = NULL; struct id3_tag *tag = NULL; @@ -635,9 +636,12 @@ g_message("audmad_get_song_tuple: track_name = %s", tuple->track_name); g_message("audmad_get_song_tuple: stream_name = %s", tuple->album_name); #endif - tuple->file_name = g_path_get_basename(filename); - tuple->file_path = g_path_get_dirname(filename); - tuple->file_ext = extname(filename); + realfn = g_filename_from_uri(filename, NULL, NULL); + tuple->file_name = g_path_get_basename(realfn ? realfn : filename); + tuple->file_path = g_path_get_dirname(realfn ? realfn : filename); + tuple->file_ext = extname(realfn ? realfn : filename); + g_free(realfn); realfn = NULL; + tuple->length = -1; tuple->mtime = 0; // this indicates streaming #ifdef DEBUG @@ -676,10 +680,11 @@ 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); + realfn = g_filename_from_uri(filename, NULL, NULL); + tuple->file_name = g_path_get_basename(realfn ? realfn : filename); + tuple->file_path = g_path_get_dirname(realfn ? realfn : filename); + tuple->file_ext = extname(realfn ? realfn : filename); + g_free(realfn); realfn = NULL; // length tuple->length = -1; @@ -720,9 +725,11 @@ 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); + realfn = g_filename_from_uri(filename, NULL, NULL); + tuple->file_name = g_path_get_basename(realfn ? realfn : filename); + tuple->file_path = g_path_get_dirname(realfn ? realfn : filename); + tuple->file_ext = extname(realfn ? realfn : filename); + g_free(realfn); realfn = NULL; // length { char *dummy = NULL;
--- a/src/paranormal/paranormal.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/paranormal/paranormal.c Mon Jul 16 13:17:12 2007 -0500 @@ -13,7 +13,6 @@ #include <gtk/gtk.h> #include <gdk/gdk.h> -#include <gdk/gdkx.h> #include "paranormal.h" #include "actuators.h"
--- a/src/tta/libtta.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/tta/libtta.c Mon Jul 16 13:17:12 2007 -0500 @@ -235,11 +235,17 @@ playback->output->flush (seek_position * SEEK_STEP); seek_position = -1; } + if(!playing) + goto DONE; } playback->output->buffer_free (); playback->output->buffer_free (); - xmms_usleep(10000); + while (playback->output->buffer_playing()) { + xmms_usleep(10000); + if(!playing) + goto DONE; + } } DONE:
--- a/src/vorbis/Makefile Mon Jul 16 13:16:56 2007 -0500 +++ b/src/vorbis/Makefile Mon Jul 16 13:17:12 2007 -0500 @@ -1,7 +1,7 @@ include ../../mk/rules.mk include ../../mk/init.mk -OBJECTIVE_LIBS = libvorbis$(SHARED_SUFFIX) +OBJECTIVE_LIBS = libvorbisplugin$(SHARED_SUFFIX) LIBDIR = $(plugindir)/$(INPUT_PLUGIN_DIR)
--- a/src/vorbis/fileinfo.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/vorbis/fileinfo.c Mon Jul 16 13:17:12 2007 -0500 @@ -1014,8 +1014,12 @@ gtk_entry_set_text(GTK_ENTRY(location_entry), get_comment(comment, "location")); #endif - - filename_utf8 = filename_to_utf8(vte.filename); + { + gchar *realfn = NULL; + realfn = g_filename_from_uri(vte.filename, NULL, NULL); + filename_utf8 = filename_to_utf8(realfn ? realfn : vte.filename); + g_free(realfn); realfn = NULL; + } title = g_strdup_printf(_("%s - Audacious"), g_basename(filename_utf8)); gtk_window_set_title(GTK_WINDOW(window), title);
--- a/src/vorbis/vorbis.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/vorbis/vorbis.c Mon Jul 16 13:17:12 2007 -0500 @@ -751,12 +751,14 @@ { TitleInput *tuple = NULL; vorbis_comment *comment; - + gchar *realfn = NULL; tuple = bmp_title_input_new(); - tuple->file_name = g_path_get_basename(filename); - tuple->file_ext = get_extension(filename); - tuple->file_path = g_path_get_dirname(filename); + realfn = g_filename_from_uri(filename, NULL, NULL); + tuple->file_name = g_path_get_basename(realfn ? realfn : filename); + tuple->file_ext = get_extension(realfn ? realfn : filename); + tuple->file_path = g_path_get_dirname(realfn ? realfn : filename); + g_free(realfn); realfn = NULL; /* Retrieve the length */ if (is_stream == FALSE)
--- a/src/wav/wav-sndfile.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/wav/wav-sndfile.c Mon Jul 16 13:17:12 2007 -0500 @@ -138,11 +138,14 @@ SF_INFO tmp_sfinfo; gchar *filename = g_filename_from_uri(fileuri, NULL, NULL); + if (filename == NULL) + return FALSE; + /* Have to open the file to see if libsndfile can handle it. */ if (! (tmp_sndfile = sf_open (filename, SFM_READ, &tmp_sfinfo))) { g_free(filename); return FALSE; - } + } /* It can so close file and return TRUE. */ sf_close (tmp_sndfile); @@ -230,6 +233,9 @@ int pcmbitwidth; gchar *song_title; + if (filename == NULL) + return; + if (sndfile) return; @@ -310,6 +316,8 @@ get_song_info (char *fileuri, char **title, int *length) { gchar *filename = g_filename_from_uri(fileuri, NULL, NULL); + if (filename == NULL) + return; (*length) = get_song_length(filename); (*title) = get_title(filename); g_free(filename);
--- a/src/wavpack/Makefile Mon Jul 16 13:16:56 2007 -0500 +++ b/src/wavpack/Makefile Mon Jul 16 13:17:12 2007 -0500 @@ -1,7 +1,7 @@ include ../../mk/rules.mk include ../../mk/init.mk -OBJECTIVE_LIBS = libwavpack$(SHARED_SUFFIX) +OBJECTIVE_LIBS = libwavpackplugin$(SHARED_SUFFIX) LIBDIR = $(plugindir)/$(INPUT_PLUGIN_DIR)
--- a/src/xspf/xspf.c Mon Jul 16 13:16:56 2007 -0500 +++ b/src/xspf/xspf.c Mon Jul 16 13:17:12 2007 -0500 @@ -58,6 +58,7 @@ return FALSE; } +#if 0 static gboolean is_remote(gchar *uri) { if(strstr(uri, "file://")) @@ -68,6 +69,7 @@ else return FALSE; } +#endif // this function is taken from libxml2-2.6.27. static xmlChar *audPathToURI(const xmlChar *path) @@ -110,19 +112,16 @@ if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"location")) { gchar *str = (gchar *)xmlNodeGetContent(nptr); - gchar *tmp; + gchar *tmp = NULL; - if(!is_remote(str)) { /* local file */ - tmp = (gchar *)xmlURIUnescapeString(str, -1, NULL); - } - else { /* streaming */ - tmp = g_strdup(str); - } + // tmp is escaped uri or a part of escaped uri. + tmp = g_strdup_printf("%s%s", base ? base : "", str); + location = g_filename_from_uri(tmp, NULL, NULL); + if(!location) // http:// or something. + location = g_strdup(tmp); - location = g_strdup_printf("%s%s", base ? base : "", tmp); - - xmlFree(str); - g_free(tmp); + xmlFree(str); str = NULL; + g_free(tmp); tmp = NULL; } else if(nptr->type == XML_ELEMENT_NODE && !xmlStrcmp(nptr->name, (xmlChar *)"title")) { @@ -196,11 +195,19 @@ } if(location) { + gchar *uri = NULL; tuple->file_name = g_path_get_basename(location); tuple->file_path = g_path_get_dirname(location); +#ifdef DEBUG + printf("xspf: tuple->file_name = %s\n", tuple->file_name); + printf("xspf: tuple->file_path = %s\n", tuple->file_path); +#endif tuple->file_ext = g_strdup(strrchr(location, '.')); // add file to playlist - playlist_load_ins_file_tuple(playlist, location, filename, pos, tuple); + uri = g_filename_to_uri(location, NULL, NULL); + // uri would be NULL if location is already uri. --yaz + playlist_load_ins_file_tuple(playlist, uri ? uri: location, filename, pos, tuple); + g_free(uri); uri = NULL; pos++; } @@ -245,9 +252,12 @@ { xmlDocPtr doc; xmlNode *nptr, *nptr2; + gchar *tmp = NULL; g_return_if_fail(filename != NULL); - +#ifdef DEBUG + printf("playlist_load_xspf: filename = %s\n", filename); +#endif doc = xmlParseFile(filename); if(doc == NULL) return; @@ -261,21 +271,21 @@ && !xmlStrcmp(nptr->name, (xmlChar *)"playlist")) { base = (gchar *)xmlNodeGetBase(doc, nptr); #ifdef DEBUG - printf("load: base = %s\n", base); + printf("playlist_load_xspf: base @1 = %s\n", base); #endif - { - gchar *tmp = xmlURIUnescapeString(base, -1, NULL); - if(tmp) { - g_free(base); - base = tmp; + // if filename is specified as a base, ignore it. + tmp = xmlURIUnescapeString(base, -1, NULL); + if(tmp) { + if(!strcmp(tmp, filename)) { + xmlFree(base); + base = NULL; } + g_free(tmp); + tmp = NULL; } - - if(!strcmp(base, filename)) { // filename is specified as a base URI. ignore. - xmlFree(base); - base = NULL; - } - +#ifdef DEBUG + printf("playlist_load_xspf: base @2 = %s\n", base); +#endif for(nptr2 = nptr->children; nptr2 != NULL; nptr2 = nptr2->next) { if(nptr2->type == XML_ELEMENT_NODE @@ -307,6 +317,9 @@ gint baselen = 0; Playlist *playlist = playlist_get_active(); +#ifdef DEBUG + printf("playlist_save_xspf: filename = %s\n", filename); +#endif xmlFree(base); base = NULL; @@ -320,6 +333,8 @@ xmlSetProp(rootnode, (xmlChar *)"xmlns", (xmlChar *)XSPF_XMLNS); PLAYLIST_LOCK(playlist->mutex); + + /* relative */ if(playlist->attribute & PLAYLIST_USE_RELATIVE) { /* prescan to determine base uri */ for(node = playlist->entries; node != NULL; node = g_list_next(node)) { @@ -328,14 +343,13 @@ gchar *tmp; gint tmplen = 0; - if(!is_uri(entry->filename)) { + if(!is_uri(entry->filename)) { //obsolete gchar *tmp2; tmp2 = g_path_get_dirname(entry->filename); tmp = g_strdup_printf("%s/", tmp2); - g_free(tmp2); - tmp2 = NULL; + g_free(tmp2); tmp2 = NULL; } - else { + else { //uri tmp = g_strdup(entry->filename); } @@ -376,9 +390,11 @@ base = tmp; } } -// xmlNodeSetBase(rootnode, base); // it blindly escapes characters. if(!is_uri(base)) { +#ifdef DEBUG + printf("base is not uri. something is wrong.\n"); +#endif tmp = g_strdup_printf("file://%s", base); xmlSetProp(rootnode, (xmlChar *)"xml:base", (xmlChar *)tmp); g_free(tmp); @@ -389,7 +405,7 @@ } } /* USE_RELATIVE */ - + /* common */ xmlDocSetRootElement(doc, rootnode); tmp = xmlNewNode(NULL, (xmlChar *)"creator"); @@ -413,8 +429,6 @@ tracklist = xmlNewNode(NULL, (xmlChar *)"trackList"); xmlAddChild(rootnode, tracklist); -// PLAYLIST_LOCK(playlist->mutex); - for(node = playlist->entries; node != NULL; node = g_list_next(node)) { PlaylistEntry *entry = PLAYLIST_ENTRY(node->data); xmlNodePtr track, location; @@ -423,31 +437,26 @@ track = xmlNewNode(NULL, (xmlChar *)"track"); location = xmlNewNode(NULL, (xmlChar *)"location"); - if(is_uri(entry->filename)) { /* remote uri */ - gchar *tmp = NULL; + if(is_uri(entry->filename)) { /* uri */ #ifdef DEBUG printf("filename is uri\n"); #endif - tmp = (gchar *)xmlURIEscape((xmlChar *)entry->filename); - filename = g_strdup(entry->filename + baselen); - g_free(tmp); - tmp = NULL; + filename = g_strdup(entry->filename + baselen); // entry->filename is always uri now. } - else { /* local file */ + else { /* local file (obsolete) */ gchar *tmp = (gchar *)audPathToURI((const xmlChar *)entry->filename + baselen); - if(base) { + if(base) { /* relative */ filename = g_strdup_printf("%s", tmp); } else { #ifdef DEBUG - printf("absolule, local\n"); + printf("absolute and local (obsolete)\n"); #endif - filename = g_strdup_printf("file://%s", tmp); + filename = g_filename_to_uri(tmp, NULL, NULL); } - g_free(tmp); - tmp = NULL; - } + g_free(tmp); tmp = NULL; + } /* obsolete */ if(!g_utf8_validate(filename, -1, NULL)) continue;