# HG changeset patch # User Giacomo Lozito # Date 1184535666 -7200 # Node ID b839faa693e23f8b47f43fd39d1b4320f0cedd7c # Parent bcf6dc9564f4c8a2643dc68793383e5bc9d25342 updated amidi-plug to handle URIs in fileinfo and all-over in code diff -r bcf6dc9564f4 -r b839faa693e2 src/amidi-plug/amidi-plug.c --- a/src/amidi-plug/amidi-plug.c Mon Jul 16 00:39:17 2007 +0900 +++ b/src/amidi-plug/amidi-plug.c Sun Jul 15 23:41:06 2007 +0200 @@ -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,10 @@ } -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); + *title = G_PATH_GET_BASENAME(filename_uri); /* 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 +349,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,12 +363,14 @@ } -static void amidiplug_play( InputPlayback * playback) +static void amidiplug_play( InputPlayback * playback ) { - gchar * filename = playback->filename; + gchar * filename_uri = playback->filename; gint port_count = 0; gint au_samplerate = -1, au_bitdepth = -1, au_channels = -1; +g_print("PLAY %s\n", filename_uri ); + if ( backend.gmodule == NULL ) { g_warning( "No sequencer backend selected\n" ); @@ -403,15 +405,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 +422,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,32 +431,32 @@ { 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 */ @@ -462,7 +464,7 @@ DEBUGMSG( "PLAY requested, song length calculated: %i msec\n" , (gint)(midifile.length / 1000) ); /* our length is in microseconds, but the player wants milliseconds */ - amidiplug_ip.set_info( G_PATH_GET_BASENAME(filename) , + amidiplug_ip.set_info( G_PATH_GET_BASENAME(filename_uri) , (gint)(midifile.length / 1000) , au_bitdepth * au_samplerate * au_channels / 8 , au_samplerate , au_channels ); @@ -477,7 +479,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; } } diff -r bcf6dc9564f4 -r b839faa693e2 src/amidi-plug/i_common.h --- a/src/amidi-plug/i_common.h Mon Jul 16 00:39:17 2007 +0900 +++ b/src/amidi-plug/i_common.h Sun Jul 15 23:41:06 2007 +0200 @@ -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) diff -r bcf6dc9564f4 -r b839faa693e2 src/amidi-plug/i_fileinfo.c --- a/src/amidi-plug/i_fileinfo.c Mon Jul 16 00:39:17 2007 +0900 +++ b/src/amidi-plug/i_fileinfo.c Sun Jul 15 23:41:06 2007 +0200 @@ -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 );