diff src/flac112/plugin.c @ 522:2d3fad6a3842 trunk

[svn] - flac 112 plugin: do not try to pick tuple from file if file is not accessible via stdio (and stop crashing when such attempts are done); TODO: pick tags from flac via vfs
author giacomo
date Mon, 22 Jan 2007 12:32:00 -0800
parents 8f1785471613
children bb7312f3ec1a
line wrap: on
line diff
--- a/src/flac112/plugin.c	Mon Jan 22 12:21:31 2007 -0800
+++ b/src/flac112/plugin.c	Mon Jan 22 12:32:00 2007 -0800
@@ -403,32 +403,33 @@
 
 void FLAC_XMMS__get_song_info(char *filename, char **title, int *length_in_msec)
 {
-	FLAC__StreamMetadata streaminfo;
+	/* NOTE vfs is not yet used here, so only try
+	   to pick tags if you can do it with flac library stdio */
+	if ( strncmp(filename,"/",1) )
+	{
+		FLAC__StreamMetadata streaminfo;
+		if(!FLAC__metadata_get_streaminfo(filename, &streaminfo)) {
+			/* @@@ how to report the error? */
+			if(title) {
+				if (source_to_decoder_type (filename) == DECODER_FILE) {
+					static const char *errtitle = "Invalid FLAC File: ";
+					*title = g_malloc(strlen(errtitle) + 1 + strlen(filename) + 1 + 1);
+					sprintf(*title, "%s\"%s\"", errtitle, filename);
+				} else {
+					*title = NULL;
+				}
+			}
+			if(length_in_msec)
+				*length_in_msec = -1;
+			return;
+		}
 
-	if(0 == filename)
-		filename = "";
-
-	if(!FLAC__metadata_get_streaminfo(filename, &streaminfo)) {
-		/* @@@ how to report the error? */
 		if(title) {
-			if (source_to_decoder_type (filename) == DECODER_FILE) {
-				static const char *errtitle = "Invalid FLAC File: ";
-				*title = g_malloc(strlen(errtitle) + 1 + strlen(filename) + 1 + 1);
-				sprintf(*title, "%s\"%s\"", errtitle, filename);
-			} else {
-				*title = NULL;
-			}
+			*title = flac_format_song_title(filename);
 		}
 		if(length_in_msec)
-			*length_in_msec = -1;
-		return;
+			*length_in_msec = (unsigned)((double)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5);
 	}
-
-	if(title) {
-		*title = flac_format_song_title(filename);
-	}
-	if(length_in_msec)
-		*length_in_msec = (unsigned)((double)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5);
 }
 
 /***********************************************************************