diff src/recpt1.c @ 149:a9f60d56d673

Fix DLNA problem
author Naoya OYAMA <naoya.oyama@gmail.com>
date Sat, 25 Aug 2012 11:10:24 +0900
parents 066f33b2213a
children f7f594bf4e98
line wrap: on
line diff
--- a/src/recpt1.c	Wed Aug 22 22:06:09 2012 +0900
+++ b/src/recpt1.c	Sat Aug 25 11:10:24 2012 +0900
@@ -523,7 +523,8 @@
         /*
          * DLNA $B$G$N(BSID$BJQ99$N<BAu<B83(B
          */
-        if ( use_dlna && buf.size > 0 ) {
+        if ( use_dlna && buf.size > 0 &&
+             strcmp("all", ut->request_channel)) {
             if ( use_splitter ) {
                 new_sid = atoi(ut->request_channel);
                 if ( old_sid != new_sid ) {
@@ -537,6 +538,25 @@
                     split_select_finish = TSS_ERROR;
                     free(qbuf);
                     qbuf = NULL;
+
+                    pthread_mutex_lock(&data->stream_queue->mutex);
+                    while(1) {
+                         STREAM_QUEUE_T *p_queue = data->stream_queue;
+                         if (p_queue->num_used == 0)
+                             break;
+                         free(p_queue->buffer[p_queue->out]->data);
+                         p_queue->buffer[p_queue->out]->data = NULL;
+                         free(p_queue->buffer[p_queue->out]);
+                         p_queue->buffer[p_queue->out] = NULL;
+                         p_queue->out++;
+                         p_queue->out %= p_queue->size;
+
+                         /* update counters */
+                         p_queue->num_avail++;
+                         p_queue->num_used--;
+                    }
+                    pthread_mutex_unlock(&data->stream_queue->mutex);
+                    fprintf (stderr, "reader_func() free stream queue finish.\n");
                     time(&split_start_time);
                     continue;
                 }