[xiph-cvs] cvs commit: ices/src in_vorbis.c metadata.c metadata.h stream.c

Brendan brendan at xiph.org
Thu Jun 19 20:28:25 PDT 2003



brendan     03/06/19 23:28:25

  Modified:    .        BUGS
               src      in_vorbis.c metadata.c metadata.h stream.c
  Log:
  Update metadata on successful reconnect

Revision  Changes    Path
1.7       +2 -1      ices/BUGS

Index: BUGS
===================================================================
RCS file: /cvs/ice/ices/BUGS,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -p -u -r1.6 -r1.7
--- BUGS	13 Mar 2003 23:29:11 -0000	1.6
+++ BUGS	20 Jun 2003 03:28:25 -0000	1.7
@@ -1,2 +1,3 @@
 * Handles error conditions poorly.
-* Doesn't update metadata on server on reconnect until next track.
\ No newline at end of file
+
+$Id: BUGS,v 1.7 2003/06/20 03:28:25 brendan Exp $
\ No newline at end of file

<p><p>1.9       +1 -1      ices/src/in_vorbis.c

Index: in_vorbis.c
===================================================================
RCS file: /cvs/ice/ices/src/in_vorbis.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -p -u -r1.8 -r1.9
--- in_vorbis.c	24 Mar 2003 04:16:15 -0000	1.8
+++ in_vorbis.c	20 Jun 2003 03:28:25 -0000	1.9
@@ -1,7 +1,7 @@
 /* in_vorbis.c
  * Plugin to read vorbis files as PCM
  *
- * Copyright (c) 2001-3 Brendan Cully
+ * Copyright (c) 2001-3 Brendan Cully <brendan at xiph.org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License

<p><p>1.12      +26 -16    ices/src/metadata.c

Index: metadata.c
===================================================================
RCS file: /cvs/ice/ices/src/metadata.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -p -u -r1.11 -r1.12
--- metadata.c	17 Mar 2003 04:43:09 -0000	1.11
+++ metadata.c	20 Jun 2003 03:28:25 -0000	1.12
@@ -1,5 +1,5 @@
 /* metadata.c
- * Copyright (c) 2001-3 Brendan Cully
+ * Copyright (c) 2001-3 Brendan Cully <brendan at xiph.org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -19,17 +19,18 @@
 
 #include "definitions.h"
 
-#define INITDELAY 1000000
+#define INITDELAY 500000
 
 extern ices_config_t ices_config;
 
 static char* Artist = NULL;
 static char* Title = NULL;
+static char* Filename = NULL;
 
 /* Private function declarations */
 static char* metadata_clean_filename (const char* path, char* buf,
                                       size_t len);
-static void metadata_update (input_stream_t* source, int delay);
+static void metadata_update (int delay);
 
 /* Global function definitions */
 
@@ -56,34 +57,43 @@ ices_metadata_set (const char* artist, c
     Title = ices_util_strdup (title);
 }
 
+void
+ices_metadata_set_file (const char* filename)
+{
+  char buf[1024];
+
+  ices_util_free (Filename);
+  Filename = NULL;
+
+  if (filename && *filename) {
+    metadata_clean_filename (filename, buf, sizeof (buf));
+    Filename = ices_util_strdup (buf);
+  }
+}
+
 /* Update metadata on server via fork.
- * It also does the job of cleaning up the song title to something the
- * world likes.
- * Note that the very first metadata update is delayed, because if we
- * try to update our new info to the server and the server has not yet
- * accepted us as a source, the information is lost. */
+ * Note that the very first metadata update after connection is delayed,
+ * because if we try to update our new info to the server and the server has
+ * not yet accepted us as a source, the information is lost. */
 void
-ices_metadata_update (input_stream_t* source)
+ices_metadata_update (int delay)
 {
-  static int delay = INITDELAY;
   pid_t child;
 
   if (delay)
-    ices_log_debug ("Initially delaying metadata update...");
+    ices_log_debug ("Delaying metadata update...");
 
   if ((child = fork()) == 0) {
-    metadata_update (source, delay);
+    metadata_update (delay ? INITDELAY : 0);
     _exit (0);
   }
 
   if (child == -1)
     ices_log_debug ("Metadata update failed: fork");
-
-  delay = 0;
 }
 
 static void
-metadata_update (input_stream_t* source, int delay)
+metadata_update (int delay)
 {
   ices_stream_t* stream;
   shout_metadata_t* metadata;
@@ -102,7 +112,7 @@ metadata_update (input_stream_t* source,
       else
         snprintf (song, sizeof (song), "%s", Title);
     } else
-      metadata_clean_filename (source->path, song, sizeof (song));
+      snprintf (song, sizeof (song), "%s", Filename);
     
     value = song;
   } else

<p><p>1.4       +3 -2      ices/src/metadata.h

Index: metadata.h
===================================================================
RCS file: /cvs/ice/ices/src/metadata.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -p -u -r1.3 -r1.4
--- metadata.h	18 Apr 2002 02:10:37 -0000	1.3
+++ metadata.h	20 Jun 2003 03:28:25 -0000	1.4
@@ -1,5 +1,5 @@
 /* metadata.h
- * Copyright (c) 2001-2 Brendan Cully
+ * Copyright (c) 2001-3 Brendan Cully <brendan at xiph.org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -20,4 +20,5 @@
 /* Public function declarations */
 void ices_metadata_get (char* artist, size_t alen, char* title, size_t tlen);
 void ices_metadata_set (const char* artist, const char* title);
-void ices_metadata_update (input_stream_t* source);
+void ices_metadata_set_file (const char* filename);
+void ices_metadata_update (int delay);

<p><p>1.55      +22 -23    ices/src/stream.c

Index: stream.c
===================================================================
RCS file: /cvs/ice/ices/src/stream.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -p -u -r1.54 -r1.55
--- stream.c	19 Jun 2003 22:17:27 -0000	1.54
+++ stream.c	20 Jun 2003 03:28:25 -0000	1.55
@@ -69,12 +69,7 @@ ices_stream_loop (ices_config_t* config)
   ices_stream_t* stream;
   int rc;
 
-  for (stream = config->streams; stream; stream = stream->next)
-    stream_connect (stream);
-
   while (1) {
-    ices_metadata_set (NULL, NULL);
-
     source.path = ices_playlist_get_next ();
 
     ices_cue_set_lineno (ices_playlist_get_current_lineno ());
@@ -90,6 +85,9 @@ ices_stream_loop (ices_config_t* config)
       ices_setup_shutdown ();
     }
 
+    ices_metadata_set (NULL, NULL);
+    ices_metadata_set_file (source.path);
+
     /* This stops ices from entering a loop with 10-20 lines of output per
          second. Usually caused by a playlist handler that produces only
          invalid file names. */
@@ -114,7 +112,7 @@ ices_stream_loop (ices_config_t* config)
           ices_util_free (source.path);
           consecutive_errors++;
           continue;
-	    }
+	}
 
     rc = stream_send (config, &source);
     source.close (&source);
@@ -191,7 +189,7 @@ stream_send (ices_config_t* config, inpu
   
   ices_log ("Playing %s", source->path);
 
-  ices_metadata_update (source);
+  ices_metadata_update (0);
 
   finish_send = 0;
   while (! finish_send) {
@@ -363,26 +361,27 @@ stream_open_source (input_stream_t* sour
 static int
 stream_send_data (ices_stream_t* stream, unsigned char* buf, size_t len)
 {
-  int rc = -1;
+  if (shout_get_connected (stream->conn) != SHOUTERR_CONNECTED) {
+    stream_connect (stream);
+    if (shout_get_connected (stream->conn) == SHOUTERR_CONNECTED)
+      ices_metadata_update (1);
+    else
+      return -1;
+  }
 
-  if (shout_get_connected (stream->conn) != SHOUTERR_CONNECTED)
-    rc = stream_connect (stream);
+  shout_sync(stream->conn);
+  if (shout_send (stream->conn, buf, len) == SHOUTERR_SUCCESS) {
+    stream->errs = 0;
 
-  if (shout_get_connected (stream->conn) == SHOUTERR_CONNECTED) {
-    shout_sync(stream->conn);
-    if (shout_send (stream->conn, buf, len) == SHOUTERR_SUCCESS) {
-      stream->errs = 0;
-      rc = 0;
-    } else {
-      ices_log_error ("Libshout reported send error, disconnecting: %s",
-		      shout_get_error (stream->conn));
-      shout_close (stream->conn);
-      stream->errs++;
-      rc = -1;
-    }
+    return 0;
   }
 
-  return rc;
+  ices_log_error ("Libshout reported send error, disconnecting: %s",
+		  shout_get_error (stream->conn));
+  shout_close (stream->conn);
+  stream->errs++;
+
+  return -1;
 }
 
 static int

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list