comparison src/flac112/plugin.c @ 524:bb7312f3ec1a trunk

[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
author giacomo
date Mon, 22 Jan 2007 13:35:34 -0800
parents 2d3fad6a3842
children 914c96de3244
comparison
equal deleted inserted replaced
523:221086196f89 524:bb7312f3ec1a
401 decoder_ = 0; 401 decoder_ = 0;
402 } 402 }
403 403
404 void FLAC_XMMS__get_song_info(char *filename, char **title, int *length_in_msec) 404 void FLAC_XMMS__get_song_info(char *filename, char **title, int *length_in_msec)
405 { 405 {
406 /* NOTE vfs is not yet used here, so only try 406 FLAC__StreamMetadata streaminfo;
407
408 /* NOTE vfs is not used here, so only try
407 to pick tags if you can do it with flac library stdio */ 409 to pick tags if you can do it with flac library stdio */
408 if ( strncmp(filename,"/",1) ) 410 if ( strncmp(filename,"/",1) )
409 { 411 {
410 FLAC__StreamMetadata streaminfo; 412 *title = g_strdup(filename);
411 if(!FLAC__metadata_get_streaminfo(filename, &streaminfo)) { 413 *length_in_msec = -1;
412 /* @@@ how to report the error? */ 414 return;
413 if(title) { 415 }
414 if (source_to_decoder_type (filename) == DECODER_FILE) { 416
415 static const char *errtitle = "Invalid FLAC File: "; 417 if(!FLAC__metadata_get_streaminfo(filename, &streaminfo)) {
416 *title = g_malloc(strlen(errtitle) + 1 + strlen(filename) + 1 + 1); 418 /* @@@ how to report the error? */
417 sprintf(*title, "%s\"%s\"", errtitle, filename); 419 if(title) {
418 } else { 420 if (source_to_decoder_type (filename) == DECODER_FILE) {
419 *title = NULL; 421 static const char *errtitle = "Invalid FLAC File: ";
420 } 422 *title = g_malloc(strlen(errtitle) + 1 + strlen(filename) + 1 + 1);
423 sprintf(*title, "%s\"%s\"", errtitle, filename);
424 } else {
425 *title = NULL;
421 } 426 }
422 if(length_in_msec)
423 *length_in_msec = -1;
424 return;
425 }
426
427 if(title) {
428 *title = flac_format_song_title(filename);
429 } 427 }
430 if(length_in_msec) 428 if(length_in_msec)
431 *length_in_msec = (unsigned)((double)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5); 429 *length_in_msec = -1;
432 } 430 return;
431 }
432
433 if(title) {
434 *title = flac_format_song_title(filename);
435 }
436 if(length_in_msec)
437 *length_in_msec = (unsigned)((double)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5);
433 } 438 }
434 439
435 /*********************************************************************** 440 /***********************************************************************
436 * local routines 441 * local routines
437 **********************************************************************/ 442 **********************************************************************/