comparison src/amidi-plug/amidi-plug.c @ 1276:504c0dc36c0a

further improvements for amidi-plug with URIs
author Giacomo Lozito <james@develia.org>
date Mon, 16 Jul 2007 00:24:09 +0200
parents b839faa693e2
children 8298974410fe 761e17b23e0c
comparison
equal deleted inserted replaced
1275:b839faa693e2 1276:504c0dc36c0a
336 336
337 337
338 static void amidiplug_get_song_info( gchar * filename_uri , gchar ** title , gint * length ) 338 static void amidiplug_get_song_info( gchar * filename_uri , gchar ** title , gint * length )
339 { 339 {
340 /* song title, get it from the filename */ 340 /* song title, get it from the filename */
341 gchar * filename = g_filename_from_uri( filename_uri , NULL , NULL );
342 if ( !filename ) filename = g_strdup( filename_uri );
341 *title = G_PATH_GET_BASENAME(filename_uri); 343 *title = G_PATH_GET_BASENAME(filename_uri);
344 g_free( filename );
342 345
343 /* sure, it's possible to calculate the length of a MIDI file anytime, 346 /* sure, it's possible to calculate the length of a MIDI file anytime,
344 but the file must be entirely parsed to calculate it; this could 347 but the file must be entirely parsed to calculate it; this could
345 lead to a bit of performance loss, so let the user decide here */ 348 lead to a bit of performance loss, so let the user decide here */
346 if ( amidiplug_cfg_ap.ap_opts_length_precalc ) 349 if ( amidiplug_cfg_ap.ap_opts_length_precalc )
364 367
365 368
366 static void amidiplug_play( InputPlayback * playback ) 369 static void amidiplug_play( InputPlayback * playback )
367 { 370 {
368 gchar * filename_uri = playback->filename; 371 gchar * filename_uri = playback->filename;
372 gchar * filename = NULL;
369 gint port_count = 0; 373 gint port_count = 0;
370 gint au_samplerate = -1, au_bitdepth = -1, au_channels = -1; 374 gint au_samplerate = -1, au_bitdepth = -1, au_channels = -1;
371
372 g_print("PLAY %s\n", filename_uri );
373 375
374 if ( backend.gmodule == NULL ) 376 if ( backend.gmodule == NULL )
375 { 377 {
376 g_warning( "No sequencer backend selected\n" ); 378 g_warning( "No sequencer backend selected\n" );
377 i_message_gui( _("AMIDI-Plug - warning") , 379 i_message_gui( _("AMIDI-Plug - warning") ,
461 463
462 /* fill midifile.length, keeping in count tempo-changes */ 464 /* fill midifile.length, keeping in count tempo-changes */
463 i_midi_setget_length( &midifile ); 465 i_midi_setget_length( &midifile );
464 DEBUGMSG( "PLAY requested, song length calculated: %i msec\n" , (gint)(midifile.length / 1000) ); 466 DEBUGMSG( "PLAY requested, song length calculated: %i msec\n" , (gint)(midifile.length / 1000) );
465 467
468
466 /* our length is in microseconds, but the player wants milliseconds */ 469 /* our length is in microseconds, but the player wants milliseconds */
467 amidiplug_ip.set_info( G_PATH_GET_BASENAME(filename_uri) , 470 filename = g_filename_from_uri( filename_uri , NULL , NULL );
471 if ( !filename ) filename = g_strdup( filename_uri );
472 amidiplug_ip.set_info( G_PATH_GET_BASENAME(filename) ,
468 (gint)(midifile.length / 1000) , 473 (gint)(midifile.length / 1000) ,
469 au_bitdepth * au_samplerate * au_channels / 8 , 474 au_bitdepth * au_samplerate * au_channels / 8 ,
470 au_samplerate , au_channels ); 475 au_samplerate , au_channels );
476 g_free( filename );
471 477
472 /* play play play! */ 478 /* play play play! */
473 DEBUGMSG( "PLAY requested, starting play thread\n" ); 479 DEBUGMSG( "PLAY requested, starting play thread\n" );
474 amidiplug_playing_status = AMIDIPLUG_PLAY; 480 amidiplug_playing_status = AMIDIPLUG_PLAY;
475 pthread_create(&amidiplug_play_thread, NULL, amidiplug_play_loop, playback); 481 pthread_create(&amidiplug_play_thread, NULL, amidiplug_play_loop, playback);