diff src/recpt1.c @ 146:066f33b2213a

EXPERIMENTAL: Select a particular program from multi-channel.
author Naoya OYAMA <naoya.oyama@gmail.com>
date Tue, 21 Aug 2012 04:21:11 +0900
parents bf96eac4dbb1
children a9f60d56d673
line wrap: on
line diff
--- a/src/recpt1.c	Thu Aug 16 21:57:34 2012 +0900
+++ b/src/recpt1.c	Tue Aug 21 04:21:11 2012 +0900
@@ -50,6 +50,7 @@
 
 /* globals */
 boolean f_exit = FALSE;
+extern struct ushare_t *ut;
 
 /* prototypes */
 int tune(char *channel, thread_data *tdata, char *device);
@@ -414,6 +415,10 @@
     ARIB_STD_B25_BUFFER sbuf, dbuf, buf;
     int code;
     int split_select_finish = TSS_ERROR;
+    int old_sid = 0, new_sid = 0;
+    time_t split_start_time;
+
+    time(&split_start_time);
 
     buf.size = 0;
     buf.data = NULL;
@@ -453,7 +458,6 @@
                 buf = dbuf;
         }
 
-
         if(use_splitter) {
             splitbuf.size = 0;
             if(splitbuf.buffer_length < buf.size && buf.size > 0) {
@@ -482,7 +486,8 @@
                          */
                         time_t cur_time;
                         time(&cur_time);
-                        if(cur_time - data->start_time > 4) {
+                        if(cur_time - split_start_time > 4) {
+                            fprintf(stderr, "split_select cur_time out.\n");
                             use_splitter = FALSE;
                             goto fin;
                         }
@@ -515,8 +520,27 @@
          *      2.2.3 tdata->stream_queue $B$K(B 2.2.1 $B$N%]%$%s%?$r(B enqueue() $B$9$k(B
          *        2.2.3.1 enqueue() $B$O(B tdata->stream_queue->mutex $B$r(B lock/unlock $B$7$F=q$-9~$_;~$NF1;~99?7$rKI;_$7$F$$$k(B
          */
-        //fprintf (stderr, "reader_func() buf.size[%d]\n", buf.size);
+        /*
+         * DLNA $B$G$N(BSID$BJQ99$N<BAu<B83(B
+         */
         if ( use_dlna && buf.size > 0 ) {
+            if ( use_splitter ) {
+                new_sid = atoi(ut->request_channel);
+                if ( old_sid != new_sid ) {
+                    old_sid = new_sid;
+                    split_shutdown(splitter);
+                    splitter = split_startup(ut->request_channel, NULL, NULL);
+                    if ( splitter == NULL ) {
+                        fprintf (stderr, "reader_func() splitter RESTART FAILED.\n", old_sid, new_sid);
+                        use_splitter = FALSE;
+                    }
+                    split_select_finish = TSS_ERROR;
+                    free(qbuf);
+                    qbuf = NULL;
+                    time(&split_start_time);
+                    continue;
+                }
+            }
             do {
                 eqbuf = malloc(sizeof(ARIB_STD_B25_BUFFER));
                 if ( eqbuf == NULL ) {