Mercurial > pt1.oyama
comparison src/recpt1.c @ 164:7d8a5bb874ad
EXPERIMENTAL: Change phisical channel by mq_recv().
KNOWN ISSUE: Cannnot split BS-TBS(BS1_1).
enable compile recpt1ctl.
SID can specified by recpt1ctl.
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Mon, 01 Oct 2012 21:52:05 +0900 |
parents | 57eae2aec60d |
children | 726fe10d9e4a |
comparison
equal
deleted
inserted
replaced
163:57eae2aec60d | 164:7d8a5bb874ad |
---|---|
34 #include <sys/msg.h> | 34 #include <sys/msg.h> |
35 #include "pt1_dev.h" | 35 #include "pt1_dev.h" |
36 #include "tssplitter_lite.h" | 36 #include "tssplitter_lite.h" |
37 #include "ushare.h" | 37 #include "ushare.h" |
38 #include "trace.h" | 38 #include "trace.h" |
39 #include "pt1_common.h" | |
39 | 40 |
40 /* maximum write length at once */ | 41 /* maximum write length at once */ |
41 #define SIZE_CHANK 1316 | 42 #define SIZE_CHANK 1316 |
42 | 43 |
43 /* ipc message size */ | |
44 #define MSGSZ 255 | |
45 | |
46 #define ISDB_T_NODE_LIMIT 24 // 32:ARIB limit 24:program maximum | 44 #define ISDB_T_NODE_LIMIT 24 // 32:ARIB limit 24:program maximum |
47 #define ISDB_T_SLOT_LIMIT 8 | 45 #define ISDB_T_SLOT_LIMIT 8 |
48 | |
49 typedef struct pt1_msgbuf { | |
50 long mtype; | |
51 char mtext[MSGSZ]; | |
52 } pt1_message_buf; | |
53 | 46 |
54 /* globals */ | 47 /* globals */ |
55 boolean f_exit = FALSE; | 48 boolean f_exit = FALSE; |
56 struct channel_info_list *channel_list = NULL; | 49 struct channel_info_list *channel_list = NULL; |
57 extern struct ushare_t *ut; | 50 extern struct ushare_t *ut; |
165 void * | 158 void * |
166 mq_recv(void *t) | 159 mq_recv(void *t) |
167 { | 160 { |
168 thread_data *tdata = (thread_data *)t; | 161 thread_data *tdata = (thread_data *)t; |
169 pt1_message_buf rbuf; | 162 pt1_message_buf rbuf; |
170 char channel[16]; | 163 static char channel[16]; |
171 int ch = 0, recsec = 0, time_to_add = 0; | 164 static char sid_list[16]; |
165 int recsec = 0, time_to_add = 0; | |
166 int current_type; | |
167 splitter *splitter = tdata->splitter; | |
168 boolean use_splitter = splitter ? TRUE : FALSE; | |
169 boolean use_dlna = tdata->streamer ? TRUE : FALSE; | |
170 ISDB_T_FREQ_CONV_TABLE *table = NULL; | |
172 | 171 |
173 while(1) { | 172 while(1) { |
174 if(msgrcv(tdata->msqid, &rbuf, MSGSZ, 1, 0) < 0) { | 173 if(msgrcv(tdata->msqid, &rbuf, MSGSZ, 1, 0) < 0) { |
175 return NULL; | 174 return NULL; |
176 } | 175 } |
177 | 176 |
178 sscanf(rbuf.mtext, "ch=%s t=%d e=%d", channel, &recsec, &time_to_add); | 177 sscanf(rbuf.mtext, "ch=%s t=%d e=%d i=%s", channel, &recsec, &time_to_add, sid_list); |
179 ch = atoi(channel); | 178 |
180 // fprintf(stderr, "ch=%d time=%d extend=%d\n", ch, recsec, time_to_add); | 179 if ((strcmp(channel, "")) && strcmp(tdata->ch, channel)) { |
181 | |
182 if(ch && tdata->ch != ch) { | |
183 #if 0 | 180 #if 0 |
184 /* re-initialize decoder */ | 181 /* re-initialize decoder */ |
185 if(tdata->decoder) { | 182 if(tdata->decoder) { |
186 // b25_finish(tdata->decoder); | 183 // b25_finish(tdata->decoder); |
187 b25_shutdown(tdata->decoder); | 184 b25_shutdown(tdata->decoder); |
190 fprintf(stderr, "Cannot start b25 decoder\n"); | 187 fprintf(stderr, "Cannot start b25 decoder\n"); |
191 fprintf(stderr, "Fall back to encrypted recording\n"); | 188 fprintf(stderr, "Fall back to encrypted recording\n"); |
192 } | 189 } |
193 } | 190 } |
194 #endif | 191 #endif |
195 int current_type = tdata->table->type; | 192 current_type = tdata->table->type; |
196 ISDB_T_FREQ_CONV_TABLE *table = searchrecoff(channel); | 193 table = searchrecoff(channel); |
197 if (table == NULL) { | 194 if (table == NULL) { |
198 fprintf(stderr, "Invalid Channel: %s\n", channel); | 195 fprintf(stderr, "Invalid Channel: %s\n", channel); |
199 goto CHECK_TIME_TO_ADD; | 196 goto CHECK_TIME_TO_ADD; |
200 } | 197 } |
201 tdata->table = table; | 198 tdata->table = table; |
205 | 202 |
206 /* wait for remainder */ | 203 /* wait for remainder */ |
207 while(tdata->queue->num_used > 0) { | 204 while(tdata->queue->num_used > 0) { |
208 usleep(10000); | 205 usleep(10000); |
209 } | 206 } |
210 | 207 } |
208 if (use_splitter && | |
209 (strcmp(tdata->sid_list, sid_list) || | |
210 strcmp(tdata->ch, channel))) { | |
211 // $BJ*M}%A%c%s%M%kJQ99;~$K$O(B splitter $B$O6/@)E*$K:F5/F0$5$;$k(B | |
212 pthread_mutex_lock(&tdata->splitter_mutex); | |
213 split_shutdown(splitter); | |
214 splitter = split_startup(sid_list, NULL, NULL); | |
215 if (splitter->sid_list == NULL) { | |
216 fprintf (stderr, "reader_func() splitter RESTART FAILED.\n"); | |
217 tdata->splitter = NULL; | |
218 pthread_mutex_unlock(&tdata->splitter_mutex); | |
219 continue; | |
220 } | |
221 if (tdata->streamer) { | |
222 pthread_mutex_lock(&tdata->stream_queue->mutex); | |
223 while(1) { | |
224 STREAM_QUEUE_T *p_queue = tdata->stream_queue; | |
225 if (p_queue->num_used == 0) | |
226 break; | |
227 free(p_queue->buffer[p_queue->out]->data); | |
228 p_queue->buffer[p_queue->out]->data = NULL; | |
229 free(p_queue->buffer[p_queue->out]); | |
230 p_queue->buffer[p_queue->out] = NULL; | |
231 p_queue->out++; | |
232 p_queue->out %= p_queue->size; | |
233 | |
234 /* update counters */ | |
235 p_queue->num_avail++; | |
236 p_queue->num_used--; | |
237 } | |
238 pthread_mutex_unlock(&tdata->stream_queue->mutex); | |
239 } | |
240 tdata->table = table; | |
241 tdata->splitter = splitter; | |
242 time(&splitter->split_start_time); | |
243 strncpy(tdata->sid_list, sid_list, sizeof(tdata->sid_list)); | |
244 pthread_mutex_unlock(&tdata->splitter_mutex); | |
245 } | |
246 | |
247 if (strcmp(tdata->ch, channel)) { | |
211 if (tdata->table->type != current_type) { | 248 if (tdata->table->type != current_type) { |
212 /* re-open device */ | 249 /* re-open device */ |
213 if(close_tuner(tdata) != 0) | 250 if(close_tuner(tdata) != 0) |
214 return NULL; | 251 return NULL; |
215 | 252 |
216 tune(channel, tdata, NULL); | 253 tune(channel, tdata, NULL); |
217 } else { | 254 } else { |
218 /* SET_CHANNEL only */ | 255 /* SET_CHANNEL only */ |
219 const FREQUENCY freq = { | 256 const FREQUENCY freq = { |
220 .frequencyno = tdata->table->set_freq, | 257 .frequencyno = tdata->table->set_freq, |
221 .slot = tdata->table->add_freq, | 258 .slot = tdata->table->add_freq, |
222 }; | 259 }; |
223 if(ioctl(tdata->tfd, SET_CHANNEL, &freq) < 0) { | 260 if(ioctl(tdata->tfd, SET_CHANNEL, &freq) < 0) { |
224 fprintf(stderr, "Cannot tune to the specified channel\n"); | 261 fprintf(stderr, "Cannot tune to the specified channel\n"); |
225 tdata->ch = 0; | 262 tdata->ch[0] = '\0'; |
226 goto CHECK_TIME_TO_ADD; | 263 goto CHECK_TIME_TO_ADD; |
227 } | 264 } |
228 tdata->ch = ch; | |
229 calc_cn(tdata->tfd, tdata->table->type); | 265 calc_cn(tdata->tfd, tdata->table->type); |
230 } | 266 } |
231 /* restart recording */ | 267 /* restart recording */ |
232 if(ioctl(tdata->tfd, START_REC, 0) < 0) { | 268 if(ioctl(tdata->tfd, START_REC, 0) < 0) { |
233 fprintf(stderr, "Tuner cannot start recording\n"); | 269 fprintf(stderr, "Tuner cannot start recording\n"); |
234 return NULL; | 270 return NULL; |
235 } | 271 } |
272 strncpy(tdata->ch, channel, sizeof(tdata->ch)); | |
236 } | 273 } |
237 | 274 |
238 CHECK_TIME_TO_ADD: | 275 CHECK_TIME_TO_ADD: |
239 if(time_to_add) { | 276 if(time_to_add) { |
240 tdata->recsec += time_to_add; | 277 tdata->recsec += time_to_add; |
250 else { | 287 else { |
251 tdata->recsec = recsec; | 288 tdata->recsec = recsec; |
252 fprintf(stderr, "Total recording time = %d sec\n", recsec); | 289 fprintf(stderr, "Total recording time = %d sec\n", recsec); |
253 } | 290 } |
254 } | 291 } |
255 | |
256 if(f_exit) | 292 if(f_exit) |
257 return NULL; | 293 return NULL; |
258 } | 294 } |
259 } | 295 } |
260 | 296 |
550 reader_func(void *p) | 586 reader_func(void *p) |
551 { | 587 { |
552 thread_data *data = (thread_data *)p; | 588 thread_data *data = (thread_data *)p; |
553 QUEUE_T *p_queue = data->queue; | 589 QUEUE_T *p_queue = data->queue; |
554 decoder *dec = data->decoder; | 590 decoder *dec = data->decoder; |
555 splitter *splitter = data->splitter; | |
556 int wfd = data->wfd; | 591 int wfd = data->wfd; |
557 boolean use_b25 = dec ? TRUE : FALSE; | 592 boolean use_b25 = dec ? TRUE : FALSE; |
558 boolean use_udp = data->sock_data ? TRUE : FALSE; | 593 boolean use_udp = data->sock_data ? TRUE : FALSE; |
559 boolean fileless = FALSE; | 594 boolean fileless = FALSE; |
560 boolean use_splitter = splitter ? TRUE : FALSE; | 595 boolean use_splitter = data->splitter ? TRUE : FALSE; |
561 boolean use_dlna = data->streamer ? TRUE : FALSE; | 596 boolean use_dlna = data->streamer ? TRUE : FALSE; |
562 int sfd = -1; | 597 int sfd = -1; |
563 pthread_t signal_thread = data->signal_thread; | 598 pthread_t signal_thread = data->signal_thread; |
564 struct sockaddr_in *addr = NULL; | 599 struct sockaddr_in *addr = NULL; |
565 BUFSZ *qbuf; | 600 BUFSZ *qbuf; |
566 ARIB_STD_B25_BUFFER *eqbuf; | 601 ARIB_STD_B25_BUFFER *eqbuf; |
567 splitbuf_t splitbuf; | 602 splitbuf_t splitbuf; |
568 ARIB_STD_B25_BUFFER sbuf, dbuf, buf; | 603 ARIB_STD_B25_BUFFER sbuf, dbuf, buf; |
569 int code; | 604 int code; |
570 int split_select_finish = TSS_ERROR; | 605 pt1_message_buf mbuf; |
571 int old_sid = 0, new_sid = 0; | 606 int msqid; |
572 char *old_tp = NULL, *new_tp = NULL; | 607 int msgflg = IPC_CREAT | 0666; |
573 time_t split_start_time; | 608 |
574 | 609 if (use_splitter) |
575 time(&split_start_time); | 610 time(&data->splitter->split_start_time); |
576 | 611 |
577 buf.size = 0; | 612 buf.size = 0; |
578 buf.data = NULL; | 613 buf.data = NULL; |
579 splitbuf.size = 0; | 614 splitbuf.size = 0; |
580 splitbuf.buffer_length = 0; | 615 splitbuf.buffer_length = 0; |
611 else | 646 else |
612 buf = dbuf; | 647 buf = dbuf; |
613 } | 648 } |
614 | 649 |
615 if(use_splitter) { | 650 if(use_splitter) { |
651 pthread_mutex_lock(&data->splitter_mutex); | |
616 splitbuf.size = 0; | 652 splitbuf.size = 0; |
617 if(splitbuf.buffer_length < buf.size && buf.size > 0) { | 653 if(splitbuf.buffer_length < buf.size && buf.size > 0) { |
618 splitbuf.buffer = realloc(splitbuf.buffer, buf.size); | 654 splitbuf.buffer = realloc(splitbuf.buffer, buf.size); |
619 if(NULL == splitbuf.buffer) { | 655 if(NULL == splitbuf.buffer) { |
620 fprintf(stderr, "splitbuf.buffer realloc failed\n"); | 656 fprintf(stderr, "splitbuf.buffer realloc failed\n"); |
624 splitbuf.buffer_length = buf.size; | 660 splitbuf.buffer_length = buf.size; |
625 } | 661 } |
626 | 662 |
627 while(buf.size) { | 663 while(buf.size) { |
628 /* $BJ,N%BP>](BPID$B$NCj=P(B */ | 664 /* $BJ,N%BP>](BPID$B$NCj=P(B */ |
629 if(split_select_finish != TSS_SUCCESS) { | 665 if(data->splitter->split_select_finish != TSS_SUCCESS) { |
630 split_select_finish = split_select(splitter, &buf); | 666 data->splitter->split_select_finish = split_select(data->splitter, &buf); |
631 if(split_select_finish == TSS_NULL) { | 667 if(data->splitter->split_select_finish == TSS_NULL) { |
632 /* malloc$B%(%i!<H/@8(B */ | 668 /* malloc$B%(%i!<H/@8(B */ |
633 fprintf(stderr, "split_select malloc failed\n"); | 669 fprintf(stderr, "split_select malloc failed\n"); |
634 use_splitter = FALSE; | 670 use_splitter = FALSE; |
635 goto fin; | 671 goto fin; |
636 } | 672 } |
637 else if(split_select_finish != TSS_SUCCESS) { | 673 else if(data->splitter->split_select_finish != TSS_SUCCESS) { |
638 /* $BJ,N%BP>](BPID$B$,40A4$KCj=P$G$-$k$^$G=PNO$7$J$$(B | 674 /* $BJ,N%BP>](BPID$B$,40A4$KCj=P$G$-$k$^$G=PNO$7$J$$(B |
639 * 1$BICDxEYM>M5$r8+$k$H$$$$$+$b(B | 675 * 1$BICDxEYM>M5$r8+$k$H$$$$$+$b(B |
640 */ | 676 */ |
641 time_t cur_time; | 677 time_t cur_time; |
642 time(&cur_time); | 678 time(&cur_time); |
643 if(cur_time - split_start_time > 4) { | 679 if(cur_time - data->splitter->split_start_time > 4) { |
644 fprintf(stderr, "split_select cur_time out.\n"); | 680 fprintf(stderr, "split_select cur_time out.\n"); |
645 use_splitter = FALSE; | 681 use_splitter = FALSE; |
646 goto fin; | 682 goto fin; |
647 } | 683 } |
648 break; | 684 break; |
649 } | 685 } |
650 } | 686 } |
651 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */ | 687 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */ |
652 code = split_ts(splitter, &buf, &splitbuf); | 688 code = split_ts(data->splitter, &buf, &splitbuf); |
653 if(code != TSS_SUCCESS) { | 689 if(code != TSS_SUCCESS) { |
654 fprintf(stderr, "split_ts failed\n"); | 690 fprintf(stderr, "split_ts failed\n"); |
655 break; | 691 break; |
656 } | 692 } |
657 | 693 |
659 } /* while */ | 695 } /* while */ |
660 | 696 |
661 buf.size = splitbuf.size; | 697 buf.size = splitbuf.size; |
662 buf.data = splitbuf.buffer; | 698 buf.data = splitbuf.buffer; |
663 fin: | 699 fin: |
664 ; | 700 pthread_mutex_unlock(&data->splitter_mutex); |
665 } /* if */ | 701 } /* if */ |
666 | 702 |
667 /* | 703 /* |
668 * 2. reader_func$B2~B$E@(B | 704 * 2. reader_func$B2~B$E@(B |
669 * 2.1 tdata->p_queue $B$+$i(B dequeue() $B$7$F%9%H%j!<%`$J%G!<%?$r<hF@$9$k(B | 705 * 2.1 tdata->p_queue $B$+$i(B dequeue() $B$7$F%9%H%j!<%`$J%G!<%?$r<hF@$9$k(B |
676 */ | 712 */ |
677 /* | 713 /* |
678 * DLNA $B$G$NJ*M}%A%c%s%M%k!&(BSID$BJQ99$N<BAu<B83(B | 714 * DLNA $B$G$NJ*M}%A%c%s%M%k!&(BSID$BJQ99$N<BAu<B83(B |
679 */ | 715 */ |
680 if ( use_dlna && buf.size > 0 ) { | 716 if ( use_dlna && buf.size > 0 ) { |
681 if ( use_splitter ) { | 717 if (use_splitter && (ut->tp) && (ut->sid)) { |
682 if (ut->tp) { | 718 if (strcmp(data->ch, ut->tp) || |
683 if (!old_tp) | 719 strcmp(data->sid_list, ut->sid)) { |
684 old_tp = "0"; | 720 if ((msqid = msgget((key_t)getpid(), msgflg)) < 0) { |
685 new_tp = ut->tp; | 721 // $B%(%i!<;~$O%A%c%s%M%kJQ99%j%/%(%9%H$O$J$+$C$?$3$H$K$9$k(B |
686 } | 722 // $B$J$`$J$`(B |
687 if (ut->sid) | 723 fprintf(stderr, "msgget error.\n"); |
688 new_sid = atoi(ut->sid); | 724 ut->tp = data->ch; |
689 if ((new_tp) && (old_tp)) | 725 free(qbuf); |
690 if (strcmp(old_tp, new_tp)) { | 726 qbuf = NULL; |
691 int current_type = data->table->type; | 727 ut->sid = data->sid_list; |
692 ISDB_T_FREQ_CONV_TABLE *table = searchrecoff(new_tp); | 728 continue; |
693 if (table == NULL) { | |
694 fprintf(stderr, "Invalid Channel: %s\n", new_tp); | |
695 break; | |
696 } | |
697 data->table = table; | |
698 old_tp = new_tp; | |
699 | |
700 /* stop stream */ | |
701 ioctl(data->tfd, STOP_REC, 0); | |
702 pthread_mutex_lock(&data->queue->mutex); | |
703 while(data->queue->num_used > 0) { | |
704 while(1) { | |
705 QUEUE_T *p_queue = data->queue; | |
706 if (p_queue->num_used == 0) | |
707 break; | |
708 free(p_queue->buffer[p_queue->out]); | |
709 p_queue->buffer[p_queue->out] = NULL; | |
710 p_queue->out++; | |
711 p_queue->out %= p_queue->size; | |
712 | |
713 /* update counters */ | |
714 p_queue->num_avail++; | |
715 p_queue->num_used--; | |
716 } | |
717 } | |
718 pthread_mutex_unlock(&data->queue->mutex); | |
719 if (data->table->type != current_type) { | |
720 /* re-open device */ | |
721 if(close_tuner(data) != 0) | |
722 break; | |
723 tune(new_tp, data, NULL); | |
724 } else { | |
725 /* SET_CHANNEL only */ | |
726 const FREQUENCY freq = { | |
727 .frequencyno = data->table->set_freq, | |
728 .slot = data->table->add_freq, | |
729 }; | |
730 if(ioctl(data->tfd, SET_CHANNEL, &freq) < 0) { | |
731 fprintf(stderr, "Cannot tune to the specified channel\n"); | |
732 data->ch = 0; | |
733 break; | |
734 } | |
735 data->ch = atoi(new_tp); | |
736 calc_cn(data->tfd, data->table->type); | |
737 } | |
738 if(ioctl(data->tfd, START_REC, 0) < 0) { | |
739 // $B$3$3$N07$$$I$3$m$,LB$&$H$3$m!#(Bexit $B$7$F$b$$$$5$$,$9$k(B | |
740 fprintf(stderr, "Tuner cannot start recording\n"); | |
741 break; | |
742 } | |
743 time(&split_start_time); | |
744 } | 729 } |
745 if ( old_sid != new_sid ) { | 730 |
746 old_sid = new_sid; | 731 mbuf.mtype = 1; |
747 split_shutdown(splitter); | 732 snprintf(mbuf.mtext, sizeof(mbuf.mtext), |
748 splitter = split_startup(ut->sid, NULL, NULL); | 733 "ch=%s t=%d e=%d i=%s", |
749 if ( splitter == NULL ) { | 734 ut->tp, 0, 0, ut->sid); |
750 fprintf (stderr, "reader_func() splitter RESTART FAILED.\n"); | 735 if (msgsnd(msqid, &mbuf, strlen(mbuf.mtext)+1, IPC_NOWAIT) < 0) { |
751 use_splitter = FALSE; | 736 // $B%(%i!<;~$O%A%c%s%M%kJQ99%j%/%(%9%H$O$J$+$C$?$3$H$K$9$k(B |
737 // $B$J$`$J$`(B | |
738 fprintf(stderr, "msgsend error.\n"); | |
739 ut->tp = data->ch; | |
740 ut->sid = data->sid_list; | |
741 free(qbuf); | |
742 qbuf = NULL; | |
743 continue; | |
752 } | 744 } |
753 split_select_finish = TSS_ERROR; | |
754 free(qbuf); | 745 free(qbuf); |
755 qbuf = NULL; | 746 qbuf = NULL; |
756 | |
757 pthread_mutex_lock(&data->stream_queue->mutex); | |
758 while(1) { | |
759 STREAM_QUEUE_T *p_queue = data->stream_queue; | |
760 if (p_queue->num_used == 0) | |
761 break; | |
762 free(p_queue->buffer[p_queue->out]->data); | |
763 p_queue->buffer[p_queue->out]->data = NULL; | |
764 free(p_queue->buffer[p_queue->out]); | |
765 p_queue->buffer[p_queue->out] = NULL; | |
766 p_queue->out++; | |
767 p_queue->out %= p_queue->size; | |
768 | |
769 /* update counters */ | |
770 p_queue->num_avail++; | |
771 p_queue->num_used--; | |
772 } | |
773 pthread_mutex_unlock(&data->stream_queue->mutex); | |
774 time(&split_start_time); | |
775 continue; | 747 continue; |
776 } | 748 } |
777 } | 749 } |
778 do { | 750 do { |
779 eqbuf = malloc(sizeof(ARIB_STD_B25_BUFFER)); | 751 eqbuf = malloc(sizeof(ARIB_STD_B25_BUFFER)); |
849 buf = dbuf; | 821 buf = dbuf; |
850 } | 822 } |
851 | 823 |
852 if(use_splitter) { | 824 if(use_splitter) { |
853 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */ | 825 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */ |
854 code = split_ts(splitter, &buf, &splitbuf); | 826 code = split_ts(data->splitter, &buf, &splitbuf); |
855 if(code != TSS_SUCCESS) { | 827 if(code != TSS_SUCCESS) { |
856 break; | 828 break; |
857 } | 829 } |
858 | 830 |
859 buf.data = splitbuf.buffer; | 831 buf.data = splitbuf.buffer; |
1240 close(tdata->tfd); | 1212 close(tdata->tfd); |
1241 fprintf(stderr, "Cannot tune to the specified channel: %s\n", device); | 1213 fprintf(stderr, "Cannot tune to the specified channel: %s\n", device); |
1242 return 1; | 1214 return 1; |
1243 } | 1215 } |
1244 else { | 1216 else { |
1245 tdata->ch = atoi(channel); | 1217 strncpy(tdata->ch, channel, sizeof(tdata->ch)); |
1246 } | 1218 } |
1247 } | 1219 } |
1248 else { | 1220 else { |
1249 /* case 2: loop around available devices */ | 1221 /* case 2: loop around available devices */ |
1250 if(tdata->table->type == CHTYPE_SATELLITE) { | 1222 if(tdata->table->type == CHTYPE_SATELLITE) { |
1282 if(tdata->tfd < 0) { | 1254 if(tdata->tfd < 0) { |
1283 fprintf(stderr, "Cannot tune to the specified channel\n"); | 1255 fprintf(stderr, "Cannot tune to the specified channel\n"); |
1284 return 1; | 1256 return 1; |
1285 } | 1257 } |
1286 else { | 1258 else { |
1287 tdata->ch = atoi(channel); | 1259 strncpy(tdata->ch, channel, sizeof(tdata->ch)); |
1288 } | 1260 } |
1289 } | 1261 } |
1290 | 1262 |
1291 /* show signal strength */ | 1263 /* show signal strength */ |
1292 calc_cn(tdata->tfd, tdata->table->type); | 1264 calc_cn(tdata->tfd, tdata->table->type); |
1599 splitter = split_startup(sid_list, es_name_prefix, start_time); | 1571 splitter = split_startup(sid_list, es_name_prefix, start_time); |
1600 if(splitter->sid_list == NULL) { | 1572 if(splitter->sid_list == NULL) { |
1601 fprintf(stderr, "Cannot start TS splitter\n"); | 1573 fprintf(stderr, "Cannot start TS splitter\n"); |
1602 return 1; | 1574 return 1; |
1603 } | 1575 } |
1576 strncpy(tdata.sid_list, sid_list, sizeof(tdata.sid_list)); | |
1604 } | 1577 } |
1605 | 1578 |
1606 /* initialize DLNA */ | 1579 /* initialize DLNA */ |
1607 if(use_dlna) { | 1580 if(use_dlna) { |
1608 do { | 1581 do { |
1619 break; | 1592 break; |
1620 } | 1593 } |
1621 tdata.streamer->stream_nr = 0; | 1594 tdata.streamer->stream_nr = 0; |
1622 tdata.streamer->stream_session[0] = NULL; | 1595 tdata.streamer->stream_session[0] = NULL; |
1623 pthread_mutex_init(&tdata.streamer->mutex, NULL); | 1596 pthread_mutex_init(&tdata.streamer->mutex, NULL); |
1597 pthread_mutex_init(&tdata.splitter_mutex, NULL); | |
1624 | 1598 |
1625 pthread_create(&stream_thread, NULL, stream_func, &tdata); | 1599 pthread_create(&stream_thread, NULL, stream_func, &tdata); |
1626 pthread_create(&dlna_thread, NULL, dlna_startup, NULL); | 1600 pthread_create(&dlna_thread, NULL, dlna_startup, NULL); |
1627 } while(0); | 1601 } while(0); |
1628 } | 1602 } |