[xiph-cvs] cvs commit: icecast/src admin.c format_mp3.c format_mp3.h

Michael Smith msmith at xiph.org
Mon Feb 9 19:50:40 PST 2004



msmith      04/02/09 22:50:40

  Modified:    src      admin.c format_mp3.c format_mp3.h
  Log:
  Fire off stats event for metadata updates when we get metadata inline.
  This fixes stats.xml listings for mp3 slave relays with metadata.
  We get rid of 'metadata_raw', since we now have to format out that stuff anyway.

Revision  Changes    Path
1.22      +0 -1      icecast/src/admin.c

Index: admin.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/admin.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- admin.c	3 Feb 2004 00:48:02 -0000	1.21
+++ admin.c	10 Feb 2004 03:50:39 -0000	1.22
@@ -659,7 +659,6 @@
     free(state->metadata);
     state->metadata = strdup(value);
     state->metadata_age++;
-    state->metadata_raw = 0;
     thread_mutex_unlock(&(state->lock));
 
     DEBUG2("Metadata on mountpoint %s changed to \"%s\"", 

<p><p>1.29      +27 -32    icecast/src/format_mp3.c

Index: format_mp3.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format_mp3.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- format_mp3.c	3 Feb 2004 00:29:36 -0000	1.28
+++ format_mp3.c	10 Feb 2004 03:50:39 -0000	1.29
@@ -106,7 +106,6 @@
 static int send_metadata(client_t *client, mp3_client_data *client_state,
         mp3_state *source_state)
 {
-    int free_meta = 0;
     int len_byte;
     int len;
     int ret = -1;
@@ -122,32 +121,18 @@
         if (source_state->metadata == NULL)
             break; /* Shouldn't be possible */
 
-        if (source_state->metadata_raw)
+        fullmetadata_size = strlen (source_state->metadata) + sizeof (meta_fmt);
+
+        if (fullmetadata_size > 4080)
         {
-            fullmetadata_size = strlen (source_state->metadata);
-            fullmetadata = source_state->metadata;
-            if (fullmetadata_size > 4080)
-            {
-                fullmetadata_size = 4080;
-            }
+            fullmetadata_size = 4080;
         }
-        else
-        {
-            fullmetadata_size = strlen (source_state->metadata) + 
-                sizeof (meta_fmt);
+        fullmetadata = malloc (fullmetadata_size);
+        if (fullmetadata == NULL)
+            break;
 
-            if (fullmetadata_size > 4080)
-            {
-                fullmetadata_size = 4080;
-            }
-            fullmetadata = malloc (fullmetadata_size);
-            if (fullmetadata == NULL)
-                break;
-
-            fullmetadata_size = snprintf (fullmetadata, fullmetadata_size,
-                    "StreamTitle='%.*s';", fullmetadata_size-(sizeof (meta_fmt)-1), source_state->metadata); 
-            free_meta = 1;
-        }
+        fullmetadata_size = snprintf (fullmetadata, fullmetadata_size,
+                "StreamTitle='%.*s';", fullmetadata_size-(sizeof (meta_fmt)-1), source_state->metadata); 
 
         source_age = source_state->metadata_age;
 
@@ -184,15 +169,13 @@
             client_state->metadata_offset = 0;
         }
         free (buf);
-        if (free_meta)
-            free (fullmetadata);
+        free (fullmetadata);
         return ret;
 
     } while (0);
 
     thread_mutex_unlock(&(source_state->lock));
-    if (free_meta)
-        free (fullmetadata);
+    free (fullmetadata);
     return -1;
 }
 
@@ -339,10 +322,24 @@
                     {
                         thread_mutex_lock(&(state->lock));
                         free(state->metadata);
-                        state->metadata = state->metadata_buffer;
+                        /* Now, reformat state->metadata_buffer to strip off
+                           StreamTitle=' and the closing '; (but only if there's
+                           enough data for it to be correctly formatted) */
+                        if(state->metadata_length >= 15) {
+                            state->metadata = malloc(state->metadata_length -
+                                    15 + 1);
+                            memcpy(state->metadata, 
+                                    state->metadata_buffer + 13, 
+                                    state->metadata_length - 15);
+                            state->metadata[state->metadata_length - 2] = 0;
+                            free(state->metadata_buffer);
+                        }
+                        else
+                            state->metadata = state->metadata_buffer;
+
+                        stats_event(self->mount, "title", state->metadata);
                         state->metadata_buffer = NULL;
                         state->metadata_age++;
-                        state->metadata_raw = 1;
                         thread_mutex_unlock(&(state->lock));
                     }
 
@@ -393,8 +390,6 @@
 static void format_mp3_send_headers(format_plugin_t *self,
         source_t *source, client_t *client)
 {
-    http_var_t *var;
-    avl_node *node;
     int bytes;
     mp3_client_data *mp3data = client->format_data;
     

<p><p>1.7       +0 -1      icecast/src/format_mp3.h

Index: format_mp3.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format_mp3.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- format_mp3.h	29 Jan 2004 01:02:06 -0000	1.6
+++ format_mp3.h	10 Feb 2004 03:50:39 -0000	1.7
@@ -21,7 +21,6 @@
 typedef struct {
     char *metadata;
     int metadata_age;
-    int metadata_raw;
     mutex_t lock;
 
     /* These are for inline metadata */

<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