changeset 149:a9f60d56d673

Fix DLNA problem
author Naoya OYAMA <naoya.oyama@gmail.com>
date Sat, 25 Aug 2012 11:10:24 +0900
parents da6ea0ef68ff
children 036ae90f1b01
files src/http.c src/recpt1.c src/tssplitter_lite.c
diffstat 3 files changed, 38 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/http.c	Wed Aug 22 22:06:09 2012 +0900
+++ b/src/http.c	Sat Aug 25 11:10:24 2012 +0900
@@ -590,8 +590,6 @@
                 pthread_mutex_unlock(&p_queue->mutex);
                 destroy_stream_queue(p_queue);
                 tdata->streamer->stream_session[id]->p_queue = NULL;
-                strcpy(ut->request_channel, "all");
-                ut->nr_channel = 0;
             }
             break;
         default:
--- 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;
                 }
--- a/src/tssplitter_lite.c	Wed Aug 22 22:06:09 2012 +0900
+++ b/src/tssplitter_lite.c	Sat Aug 25 11:10:24 2012 +0900
@@ -742,22 +742,24 @@
 			 * ushare 側(TV表示上)には channel_name を表示させる
 			 * TODO 局名も含めて入れたいなぁ
 			 */
+			if(!strcmp("all", sp->sid_list[0])) {
 #define CHANNEL_NAME_LENGTH (64)
-			ut->channel_name[ut->nr_channel] = malloc(CHANNEL_NAME_LENGTH);
-			if(!ut->channel_name[ut->nr_channel])
-				return TSS_NULL;
-			snprintf(ut->channel_name[ut->nr_channel],
-					CHANNEL_NAME_LENGTH,
-					"%d.ts",
-					avail_sids[k]);
-			ut->location_name[ut->nr_channel] = malloc(CHANNEL_NAME_LENGTH);
-			if(!ut->location_name[ut->nr_channel])
-				return TSS_NULL;
-			snprintf(ut->location_name[ut->nr_channel],
-					CHANNEL_NAME_LENGTH,
-					VIRTUAL_DIR "/%d.ts",
-					avail_sids[k]);
-			ut->nr_channel += 1;
+				ut->channel_name[ut->nr_channel] = malloc(CHANNEL_NAME_LENGTH);
+				if(!ut->channel_name[ut->nr_channel])
+					return TSS_NULL;
+				snprintf(ut->channel_name[ut->nr_channel],
+						CHANNEL_NAME_LENGTH,
+						"%d.ts",
+						avail_sids[k]);
+				ut->location_name[ut->nr_channel] = malloc(CHANNEL_NAME_LENGTH);
+				if(!ut->location_name[ut->nr_channel])
+					return TSS_NULL;
+				snprintf(ut->location_name[ut->nr_channel],
+						CHANNEL_NAME_LENGTH,
+						VIRTUAL_DIR "/%d.ts",
+						avail_sids[k]);
+				ut->nr_channel += 1;
+			}
 		}
 		// metadata list を作り直す
 		free_metadata_list(ut);