annotate recpt1/recpt1.c @ 140:c9b1d21c5035

separate common function to core library
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 25 Apr 2013 16:06:15 +0900
parents 61ff9cabf962
children 1e7718cc2556
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100
aeba1988234f support macros to specify sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 99
diff changeset
1 /* -*- tab-width: 4; indent-tabs-mode: nil -*- */
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
2 #include <stdio.h>
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
3 #include <fcntl.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
4 #include <sys/types.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
5 #include <sys/stat.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
6 #include <time.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
7 #include <stdlib.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
8 #include <string.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
9 #include <pthread.h>
11
4615eaf04415 support signal strength calculation.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 8
diff changeset
10 #include <math.h>
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
11 #include <unistd.h>
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
12 #include <getopt.h>
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
13 #include <signal.h>
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
14 #include <errno.h>
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
15 #include <sys/time.h>
47
edd904628e2f a bit improved support for time format. now recpt1 recognize string such as 1h05m10s.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 43
diff changeset
16 #include <ctype.h>
61
f1553492e8bb ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 59
diff changeset
17 #include <libgen.h>
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
18
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
19 #include <netdb.h>
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
20 #include <arpa/inet.h>
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
21 #include <netinet/in.h>
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
22
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
23 #include <sys/ipc.h>
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
24 #include <sys/msg.h>
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
25
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
26 #include <sys/ioctl.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
27 #include "pt1_ioctl.h"
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
28
74
b6607f6e2851 good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 67
diff changeset
29 #include "config.h"
b6607f6e2851 good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 67
diff changeset
30 #include "decoder.h"
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
31 #include "recpt1core.h"
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
32 #include "recpt1.h"
61
f1553492e8bb ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 59
diff changeset
33 #include "mkpath.h"
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
34
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
35 #include "tssplitter_lite.h"
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
36
28
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
37 /* maximum write length at once */
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
38 #define SIZE_CHANK 1316
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
39
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
40 /* ipc message size */
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
41 #define MSGSZ 255
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
42
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
43 /* globals */
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
44 extern boolean f_exit;
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
45
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
46
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
47 /* will be ipc message receive thread */
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
48 void *
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
49 mq_recv(void *t)
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
50 {
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
51 thread_data *tdata = (thread_data *)t;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
52 message_buf rbuf;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
53 char channel[16];
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
54 int recsec = 0, time_to_add = 0;
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
55
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
56 while(1) {
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
57 if(msgrcv(tdata->msqid, &rbuf, MSGSZ, 1, 0) < 0) {
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
58 return NULL;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
59 }
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
60
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
61 sscanf(rbuf.mtext, "ch=%s t=%d e=%d", channel, &recsec, &time_to_add);
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
62
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
63 if(strcmp(channel, tdata->table->parm_freq)) {
133
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
64 int current_type = tdata->table->type;
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
65 ISDB_T_FREQ_CONV_TABLE *table = searchrecoff(channel);
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
66 if (table == NULL) {
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
67 fprintf(stderr, "Invalid Channel: %s\n", channel);
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
68 goto CHECK_TIME_TO_ADD;
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
69 }
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
70 tdata->table = table;
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
71
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
72 /* stop stream */
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
73 ioctl(tdata->tfd, STOP_REC, 0);
88
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
74
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
75 /* wait for remainder */
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
76 while(tdata->queue->num_used > 0) {
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
77 usleep(10000);
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
78 }
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
79
133
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
80 if (tdata->table->type != current_type) {
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
81 /* re-open device */
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
82 if(close_tuner(tdata) != 0)
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
83 return NULL;
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
84
133
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
85 tune(channel, tdata, NULL);
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
86 } else {
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
87 /* SET_CHANNEL only */
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
88 const FREQUENCY freq = {
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
89 .frequencyno = tdata->table->set_freq,
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
90 .slot = tdata->table->add_freq,
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
91 };
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
92 if(ioctl(tdata->tfd, SET_CHANNEL, &freq) < 0) {
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
93 fprintf(stderr, "Cannot tune to the specified channel\n");
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
94 goto CHECK_TIME_TO_ADD;
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
95 }
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
96 calc_cn(tdata->tfd, tdata->table->type, FALSE);
133
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
97 }
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
98 /* restart recording */
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
99 if(ioctl(tdata->tfd, START_REC, 0) < 0) {
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
100 fprintf(stderr, "Tuner cannot start recording\n");
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
101 return NULL;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
102 }
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
103 }
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
104
133
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
105 CHECK_TIME_TO_ADD:
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
106 if(time_to_add) {
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
107 tdata->recsec += time_to_add;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
108 fprintf(stderr, "Extended %d sec\n", time_to_add);
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
109 }
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
110
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
111 if(recsec) {
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
112 time_t cur_time;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
113 time(&cur_time);
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
114 if(cur_time - tdata->start_time > recsec) {
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
115 f_exit = TRUE;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
116 }
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
117 else {
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
118 tdata->recsec = recsec;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
119 fprintf(stderr, "Total recording time = %d sec\n", recsec);
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
120 }
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
121 }
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
122
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
123 if(f_exit)
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
124 return NULL;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
125 }
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
126 }
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
127
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
128
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
129 QUEUE_T *
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
130 create_queue(size_t size)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
131 {
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
132 QUEUE_T *p_queue;
127
8e0f7191b92e Imported PID re-acquisition code by Toshiyuki Kawashima
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 125
diff changeset
133 int memsize = sizeof(QUEUE_T) + size * sizeof(BUFSZ*);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
134
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
135 p_queue = (QUEUE_T*)calloc(memsize, sizeof(char));
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
136
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
137 if(p_queue != NULL) {
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
138 p_queue->size = size;
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
139 p_queue->num_avail = size;
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
140 p_queue->num_used = 0;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
141 pthread_mutex_init(&p_queue->mutex, NULL);
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
142 pthread_cond_init(&p_queue->cond_avail, NULL);
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
143 pthread_cond_init(&p_queue->cond_used, NULL);
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
144 }
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
145
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
146 return p_queue;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
147 }
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
148
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
149 void
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
150 destroy_queue(QUEUE_T *p_queue)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
151 {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
152 if(!p_queue)
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
153 return;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
154
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
155 pthread_mutex_destroy(&p_queue->mutex);
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
156 pthread_cond_destroy(&p_queue->cond_avail);
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
157 pthread_cond_destroy(&p_queue->cond_used);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
158 free(p_queue);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
159 }
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
160
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
161 /* enqueue data. this function will block if queue is full. */
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
162 void
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
163 enqueue(QUEUE_T *p_queue, BUFSZ *data)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
164 {
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
165 struct timeval now;
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
166 struct timespec spec;
125
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
167 int retry_count = 0;
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
168
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
169 pthread_mutex_lock(&p_queue->mutex);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
170 /* entered critical section */
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
171
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
172 /* wait while queue is full */
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
173 while(p_queue->num_avail == 0) {
125
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
174
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
175 gettimeofday(&now, NULL);
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
176 spec.tv_sec = now.tv_sec + 1;
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
177 spec.tv_nsec = now.tv_usec * 1000;
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
178
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
179 pthread_cond_timedwait(&p_queue->cond_avail,
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
180 &p_queue->mutex, &spec);
125
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
181 retry_count++;
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
182 if(retry_count > 60) {
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
183 f_exit = TRUE;
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
184 }
25
011cb9337729 - avoid broken lock on exit
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 24
diff changeset
185 if(f_exit) {
011cb9337729 - avoid broken lock on exit
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 24
diff changeset
186 pthread_mutex_unlock(&p_queue->mutex);
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
187 return;
25
011cb9337729 - avoid broken lock on exit
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 24
diff changeset
188 }
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
189 }
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
190
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
191 p_queue->buffer[p_queue->in] = data;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
192
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
193 /* move position marker for input to next position */
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
194 p_queue->in++;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
195 p_queue->in %= p_queue->size;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
196
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
197 /* update counters */
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
198 p_queue->num_avail--;
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
199 p_queue->num_used++;
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
200
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
201 /* leaving critical section */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
202 pthread_mutex_unlock(&p_queue->mutex);
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
203 pthread_cond_signal(&p_queue->cond_used);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
204 }
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
205
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
206 /* dequeue data. this function will block if queue is empty. */
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
207 BUFSZ *
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
208 dequeue(QUEUE_T *p_queue)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
209 {
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
210 struct timeval now;
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
211 struct timespec spec;
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
212 BUFSZ *buffer;
125
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
213 int retry_count = 0;
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
214
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
215 pthread_mutex_lock(&p_queue->mutex);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
216 /* entered the critical section*/
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
217
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
218 /* wait while queue is empty */
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
219 while(p_queue->num_used == 0) {
125
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
220
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
221 gettimeofday(&now, NULL);
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
222 spec.tv_sec = now.tv_sec + 1;
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
223 spec.tv_nsec = now.tv_usec * 1000;
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
224
27
763cf84d2dc7 fixed a bug that waited for wrong cond variable
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 26
diff changeset
225 pthread_cond_timedwait(&p_queue->cond_used,
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
226 &p_queue->mutex, &spec);
125
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
227 retry_count++;
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
228 if(retry_count > 60) {
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
229 f_exit = TRUE;
a910b49dfbee work in progress improvement:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 110
diff changeset
230 }
25
011cb9337729 - avoid broken lock on exit
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 24
diff changeset
231 if(f_exit) {
011cb9337729 - avoid broken lock on exit
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 24
diff changeset
232 pthread_mutex_unlock(&p_queue->mutex);
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
233 return NULL;
25
011cb9337729 - avoid broken lock on exit
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 24
diff changeset
234 }
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
235 }
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
236
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
237 /* take buffer address */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
238 buffer = p_queue->buffer[p_queue->out];
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
239
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
240 /* move position marker for output to next position */
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
241 p_queue->out++;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
242 p_queue->out %= p_queue->size;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
243
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
244 /* update counters */
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
245 p_queue->num_avail++;
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
246 p_queue->num_used--;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
247
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
248 /* leaving the critical section */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
249 pthread_mutex_unlock(&p_queue->mutex);
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
250 pthread_cond_signal(&p_queue->cond_avail);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
251
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
252 return buffer;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
253 }
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
254
6
d898fd27547f cleanups
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 5
diff changeset
255 /* this function will be reader thread */
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
256 void *
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
257 reader_func(void *p)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
258 {
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
259 thread_data *tdata = (thread_data *)p;
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
260 QUEUE_T *p_queue = tdata->queue;
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
261 decoder *dec = tdata->decoder;
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
262 splitter *splitter = tdata->splitter;
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
263 int wfd = tdata->wfd;
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
264 boolean use_b25 = dec ? TRUE : FALSE;
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
265 boolean use_udp = tdata->sock_data ? TRUE : FALSE;
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
266 boolean fileless = FALSE;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
267 boolean use_splitter = splitter ? TRUE : FALSE;
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
268 int sfd = -1;
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
269 pthread_t signal_thread = tdata->signal_thread;
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
270 struct sockaddr_in *addr = NULL;
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
271 BUFSZ *qbuf;
127
8e0f7191b92e Imported PID re-acquisition code by Toshiyuki Kawashima
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 125
diff changeset
272 static splitbuf_t splitbuf;
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
273 ARIB_STD_B25_BUFFER sbuf, dbuf, buf;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
274 int code;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
275 int split_select_finish = TSS_ERROR;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
276
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
277 buf.size = 0;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
278 buf.data = NULL;
139
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
279 splitbuf.buffer_size = 0;
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
280 splitbuf.buffer = NULL;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
281
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
282 if(wfd == -1)
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
283 fileless = TRUE;
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
284
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
285 if(use_udp) {
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
286 sfd = tdata->sock_data->sfd;
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
287 addr = &tdata->sock_data->addr;
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
288 }
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
289
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
290 while(1) {
28
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
291 ssize_t wc = 0;
39
b03685d25fee recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 38
diff changeset
292 int file_err = 0;
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
293 qbuf = dequeue(p_queue);
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
294 /* no entry in the queue */
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
295 if(qbuf == NULL) {
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
296 break;
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
297 }
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
298
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
299 sbuf.data = qbuf->buffer;
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
300 sbuf.size = qbuf->size;
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
301
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
302 buf = sbuf; /* default */
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
303
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
304 if(use_b25) {
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
305 code = b25_decode(dec, &sbuf, &dbuf);
85
28ba9315a30c falls back to encrypted recording when b25_decode fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 84
diff changeset
306 if(code < 0) {
103
387d18563ef8 temporary workaround: disable splitter if decoder is disabled.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 100
diff changeset
307 fprintf(stderr, "b25_decode failed (code=%d). fall back to encrypted recording.\n", code);
387d18563ef8 temporary workaround: disable splitter if decoder is disabled.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 100
diff changeset
308 use_b25 = FALSE;
85
28ba9315a30c falls back to encrypted recording when b25_decode fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 84
diff changeset
309 }
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
310 else
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
311 buf = dbuf;
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
312 }
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
313
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
314
104
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 103
diff changeset
315 if(use_splitter) {
139
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
316 splitbuf.buffer_filled = 0;
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
317
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
318 /* allocate split buffer */
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
319 if(splitbuf.buffer_size < buf.size && buf.size > 0) {
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
320 splitbuf.buffer = realloc(splitbuf.buffer, buf.size);
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
321 if(splitbuf.buffer == NULL) {
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
322 fprintf(stderr, "split buffer allocation failed\n");
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
323 use_splitter = FALSE;
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
324 goto fin;
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
325 }
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
326 }
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
327
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
328 while(buf.size) {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
329 /* $BJ,N%BP>](BPID$B$NCj=P(B */
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
330 if(split_select_finish != TSS_SUCCESS) {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
331 split_select_finish = split_select(splitter, &buf);
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
332 if(split_select_finish == TSS_NULL) {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
333 /* malloc$B%(%i!<H/@8(B */
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
334 fprintf(stderr, "split_select malloc failed\n");
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
335 use_splitter = FALSE;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
336 goto fin;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
337 }
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
338 else if(split_select_finish != TSS_SUCCESS) {
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
339 /* $BJ,N%BP>](BPID$B$,40A4$KCj=P$G$-$k$^$G=PNO$7$J$$(B
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
340 * 1$BICDxEYM>M5$r8+$k$H$$$$$+$b(B
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
341 */
110
d89f0da0a7e4 do not stuck on split_select() more than 4 sec.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 105
diff changeset
342 time_t cur_time;
d89f0da0a7e4 do not stuck on split_select() more than 4 sec.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 105
diff changeset
343 time(&cur_time);
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
344 if(cur_time - tdata->start_time > 4) {
110
d89f0da0a7e4 do not stuck on split_select() more than 4 sec.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 105
diff changeset
345 use_splitter = FALSE;
d89f0da0a7e4 do not stuck on split_select() more than 4 sec.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 105
diff changeset
346 goto fin;
d89f0da0a7e4 do not stuck on split_select() more than 4 sec.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 105
diff changeset
347 }
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
348 break;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
349 }
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
350 }
139
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
351
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
352 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
353 code = split_ts(splitter, &buf, &splitbuf);
127
8e0f7191b92e Imported PID re-acquisition code by Toshiyuki Kawashima
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 125
diff changeset
354 if(code == TSS_NULL) {
8e0f7191b92e Imported PID re-acquisition code by Toshiyuki Kawashima
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 125
diff changeset
355 fprintf(stderr, "PMT reading..\n");
8e0f7191b92e Imported PID re-acquisition code by Toshiyuki Kawashima
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 125
diff changeset
356 }
8e0f7191b92e Imported PID re-acquisition code by Toshiyuki Kawashima
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 125
diff changeset
357 else if(code != TSS_SUCCESS) {
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
358 fprintf(stderr, "split_ts failed\n");
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
359 break;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
360 }
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
361
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
362 break;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
363 } /* while */
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
364
139
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
365 buf.size = splitbuf.buffer_filled;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
366 buf.data = splitbuf.buffer;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
367 fin:
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
368 ;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
369 } /* if */
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
370
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
371
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
372 if(!fileless) {
28
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
373 /* write data to output file */
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
374 int size_remain = buf.size;
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
375 int offset = 0;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
376
28
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
377 while(size_remain > 0) {
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
378 int ws = size_remain < SIZE_CHANK ? size_remain : SIZE_CHANK;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
379
28
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
380 wc = write(wfd, buf.data + offset, ws);
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
381 if(wc < 0) {
39
b03685d25fee recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 38
diff changeset
382 perror("write");
b03685d25fee recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 38
diff changeset
383 file_err = 1;
b03685d25fee recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 38
diff changeset
384 pthread_kill(signal_thread,
b03685d25fee recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 38
diff changeset
385 errno == EPIPE ? SIGPIPE : SIGUSR2);
28
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
386 break;
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
387 }
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
388 size_remain -= wc;
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
389 offset += wc;
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
390 }
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
391 }
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
392
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
393 if(use_udp && sfd != -1) {
28
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
394 /* write data to socket */
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
395 int size_remain = buf.size;
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
396 int offset = 0;
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
397 while(size_remain > 0) {
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
398 int ws = size_remain < SIZE_CHANK ? size_remain : SIZE_CHANK;
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
399 wc = write(sfd, buf.data + offset, ws);
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
400 if(wc < 0) {
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
401 if(errno == EPIPE)
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
402 pthread_kill(signal_thread, SIGPIPE);
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
403 break;
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
404 }
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
405 size_remain -= wc;
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
406 offset += wc;
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
407 }
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
408 }
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
409
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
410 free(qbuf);
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
411 qbuf = NULL;
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
412
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
413 /* normal exit */
84
1b61fd7c6fde should just shutdown when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 81
diff changeset
414 if((f_exit && !p_queue->num_used) || file_err) {
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
415
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
416 buf = sbuf; /* default */
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
417
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
418 if(use_b25) {
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
419 code = b25_finish(dec, &sbuf, &dbuf);
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
420 if(code < 0)
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
421 fprintf(stderr, "b25_finish failed\n");
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
422 else
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
423 buf = dbuf;
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
424 }
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
425
104
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 103
diff changeset
426 if(use_splitter) {
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
427 /* $BJ,N%BP>]0J30$r$U$k$$Mn$H$9(B */
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
428 code = split_ts(splitter, &buf, &splitbuf);
127
8e0f7191b92e Imported PID re-acquisition code by Toshiyuki Kawashima
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 125
diff changeset
429 if(code == TSS_NULL) {
8e0f7191b92e Imported PID re-acquisition code by Toshiyuki Kawashima
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 125
diff changeset
430 split_select_finish = TSS_ERROR;
8e0f7191b92e Imported PID re-acquisition code by Toshiyuki Kawashima
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 125
diff changeset
431 fprintf(stderr, "PMT reading..\n");
8e0f7191b92e Imported PID re-acquisition code by Toshiyuki Kawashima
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 125
diff changeset
432 }
8e0f7191b92e Imported PID re-acquisition code by Toshiyuki Kawashima
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 125
diff changeset
433 else if(code != TSS_SUCCESS) {
8e0f7191b92e Imported PID re-acquisition code by Toshiyuki Kawashima
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 125
diff changeset
434 fprintf(stderr, "split_ts failed\n");
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
435 break;
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
436 }
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
437
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
438 buf.data = splitbuf.buffer;
139
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
439 buf.size = splitbuf.buffer_size;
99
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
440 }
3a3f15b063e1 now recpt1 accepts single sid for terrestrial channels.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 98
diff changeset
441
84
1b61fd7c6fde should just shutdown when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 81
diff changeset
442 if(!fileless && !file_err) {
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
443 wc = write(wfd, buf.data, buf.size);
24
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
444 if(wc < 0) {
39
b03685d25fee recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 38
diff changeset
445 perror("write");
b03685d25fee recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 38
diff changeset
446 file_err = 1;
b03685d25fee recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 38
diff changeset
447 pthread_kill(signal_thread,
b03685d25fee recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 38
diff changeset
448 errno == EPIPE ? SIGPIPE : SIGUSR2);
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
449 }
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
450 }
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
451
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
452 if(use_udp && sfd != -1) {
28
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
453 wc = write(sfd, buf.data, buf.size);
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
454 if(wc < 0) {
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
455 if(errno == EPIPE)
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
456 pthread_kill(signal_thread, SIGPIPE);
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
457 }
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
458 }
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
459
139
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
460 if(use_splitter) {
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
461 free(splitbuf.buffer);
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
462 splitbuf.buffer = NULL;
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
463 splitbuf.buffer_size = 0;
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
464 }
61ff9cabf962 fix for split buffer shortage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 135
diff changeset
465
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
466 break;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
467 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
468 }
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
469
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
470 time_t cur_time;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
471 time(&cur_time);
81
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
472 fprintf(stderr, "Recorded %dsec\n",
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
473 (int)(cur_time - tdata->start_time));
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
474
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
475 return NULL;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
476 }
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
477
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
478 void
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
479 show_usage(char *cmd)
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
480 {
74
b6607f6e2851 good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 67
diff changeset
481 #ifdef HAVE_LIBARIB25
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 97
diff changeset
482 fprintf(stderr, "Usage: \n%s [--b25 [--round N] [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] [--device devicefile] [--lnb voltage] [--sid SID1,SID2] channel rectime destfile\n", cmd);
74
b6607f6e2851 good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 67
diff changeset
483 #else
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 97
diff changeset
484 fprintf(stderr, "Usage: \n%s [--strip] [--EMM]] [--udp [--addr hostname --port portnumber]] [--device devicefile] [--lnb voltage] [--sid SID1,SID2] channel rectime destfile\n", cmd);
74
b6607f6e2851 good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 67
diff changeset
485 #endif
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
486 fprintf(stderr, "\n");
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
487 fprintf(stderr, "Remarks:\n");
38
3228f5cde349 recpt1 now accepts 1[HhMmSs] as recording duration. formats like 1Hour or 1hour are also be accepted.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 35
diff changeset
488 fprintf(stderr, "if rectime is '-', records indefinitely.\n");
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
489 fprintf(stderr, "if destfile is '-', stdout is used for output.\n");
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
490 }
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
491
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
492 void
15
1b0883b02b4f fixed typo
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 14
diff changeset
493 show_options(void)
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
494 {
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
495 fprintf(stderr, "Options:\n");
74
b6607f6e2851 good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 67
diff changeset
496 #ifdef HAVE_LIBARIB25
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
497 fprintf(stderr, "--b25: Decrypt using BCAS card\n");
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
498 fprintf(stderr, " --round N: Specify round number\n");
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
499 fprintf(stderr, " --strip: Strip null stream\n");
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
500 fprintf(stderr, " --EMM: Instruct EMM operation\n");
74
b6607f6e2851 good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 67
diff changeset
501 #endif
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
502 fprintf(stderr, "--udp: Turn on udp broadcasting\n");
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
503 fprintf(stderr, " --addr hostname: Hostname or address to connect\n");
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
504 fprintf(stderr, " --port portnumber: Port number to connect\n");
32
6004fe4f37f9 adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 28
diff changeset
505 fprintf(stderr, "--device devicefile: Specify devicefile to use\n");
81
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
506 fprintf(stderr, "--lnb voltage: Specify LNB voltage (0, 11, 15)\n");
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 97
diff changeset
507 fprintf(stderr, "--sid SID1,SID2,...: Specify SID number in CSV format (101,102,...)\n");
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
508 fprintf(stderr, "--help: Show this help\n");
43
9b36fdf7d5d0 show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 42
diff changeset
509 fprintf(stderr, "--version: Show version\n");
57
d3929562b8e7 - added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 49
diff changeset
510 fprintf(stderr, "--list: Show channel list\n");
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
511 }
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
512
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
513 void
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
514 cleanup(thread_data *tdata)
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
515 {
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
516 /* stop recording */
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
517 ioctl(tdata->tfd, STOP_REC, 0);
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
518
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
519 f_exit = TRUE;
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
520
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
521 pthread_cond_signal(&tdata->queue->cond_avail);
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
522 pthread_cond_signal(&tdata->queue->cond_used);
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
523 }
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
524
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
525 /* will be signal handler thread */
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
526 void *
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
527 process_signals(void *t)
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
528 {
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
529 sigset_t waitset;
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
530 int sig;
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
531 thread_data *tdata = (thread_data *)t;
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
532
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
533 sigemptyset(&waitset);
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
534 sigaddset(&waitset, SIGPIPE);
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
535 sigaddset(&waitset, SIGINT);
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
536 sigaddset(&waitset, SIGTERM);
24
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
537 sigaddset(&waitset, SIGUSR1);
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
538 sigaddset(&waitset, SIGUSR2);
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
539
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
540 sigwait(&waitset, &sig);
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
541
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
542 switch(sig) {
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
543 case SIGPIPE:
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
544 fprintf(stderr, "\nSIGPIPE received. cleaning up...\n");
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
545 cleanup(tdata);
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
546 break;
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
547 case SIGINT:
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
548 fprintf(stderr, "\nSIGINT received. cleaning up...\n");
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
549 cleanup(tdata);
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
550 break;
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
551 case SIGTERM:
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
552 fprintf(stderr, "\nSIGTERM received. cleaning up...\n");
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
553 cleanup(tdata);
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
554 break;
24
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
555 case SIGUSR1: /* normal exit*/
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
556 cleanup(tdata);
24
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
557 break;
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
558 case SIGUSR2: /* error */
39
b03685d25fee recpt1 now shows error explanation when write() fails.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 38
diff changeset
559 fprintf(stderr, "Detected an error. cleaning up...\n");
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
560 cleanup(tdata);
24
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
561 break;
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
562 }
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
563
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
564 return NULL; /* dummy */
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
565 }
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
566
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
567 void
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
568 init_signal_handlers(pthread_t *signal_thread, thread_data *tdata)
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
569 {
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
570 sigset_t blockset;
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
571
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
572 sigemptyset(&blockset);
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
573 sigaddset(&blockset, SIGPIPE);
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
574 sigaddset(&blockset, SIGINT);
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
575 sigaddset(&blockset, SIGTERM);
24
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
576 sigaddset(&blockset, SIGUSR1);
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
577 sigaddset(&blockset, SIGUSR2);
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
578
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
579 if(pthread_sigmask(SIG_BLOCK, &blockset, NULL))
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
580 fprintf(stderr, "pthread_sigmask() failed.\n");
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
581
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
582 pthread_create(signal_thread, NULL, process_signals, tdata);
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
583 }
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
584
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
585 int
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
586 main(int argc, char **argv)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
587 {
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
588 time_t cur_time;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
589 pthread_t signal_thread;
24
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
590 pthread_t reader_thread;
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
591 pthread_t ipc_thread;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
592 QUEUE_T *p_queue = create_queue(MAX_QUEUE);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
593 BUFSZ *bufptr;
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
594 decoder *decoder = NULL;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
595 splitter *splitter = NULL;
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
596 static thread_data tdata;
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
597 decoder_options dopt = {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
598 4, /* round */
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
599 0, /* strip */
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
600 0 /* emm */
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
601 };
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
602 tdata.dopt = &dopt;
81
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
603 tdata.lnb = 0;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
604
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
605 int result;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
606 int option_index;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
607 struct option long_options[] = {
74
b6607f6e2851 good citizens never use gray code. wise people never watch TV.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 67
diff changeset
608 #ifdef HAVE_LIBARIB25
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
609 { "b25", 0, NULL, 'b'},
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
610 { "B25", 0, NULL, 'b'},
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
611 { "round", 1, NULL, 'r'},
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
612 { "strip", 0, NULL, 's'},
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
613 { "emm", 0, NULL, 'm'},
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
614 { "EMM", 0, NULL, 'm'},
81
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
615 #endif
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
616 { "LNB", 1, NULL, 'n'},
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
617 { "lnb", 1, NULL, 'n'},
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
618 { "udp", 0, NULL, 'u'},
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
619 { "addr", 1, NULL, 'a'},
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
620 { "port", 1, NULL, 'p'},
32
6004fe4f37f9 adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 28
diff changeset
621 { "device", 1, NULL, 'd'},
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
622 { "help", 0, NULL, 'h'},
43
9b36fdf7d5d0 show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 42
diff changeset
623 { "version", 0, NULL, 'v'},
57
d3929562b8e7 - added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 49
diff changeset
624 { "list", 0, NULL, 'l'},
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 97
diff changeset
625 { "sid", 1, NULL, 'i'},
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
626 {0, 0, NULL, 0} /* terminate */
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
627 };
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
628
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
629 boolean use_b25 = FALSE;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
630 boolean use_udp = FALSE;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
631 boolean fileless = FALSE;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
632 boolean use_stdout = FALSE;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
633 boolean use_splitter = FALSE;
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
634 char *host_to = NULL;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
635 int port_to = 1234;
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
636 sock_data *sockdata = NULL;
32
6004fe4f37f9 adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 28
diff changeset
637 char *device = NULL;
81
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
638 int val;
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
639 char *voltage[] = {"0V", "11V", "15V"};
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
640 char *sid_list = NULL;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
641
98
3fd15032fd3a tweak user interface for sid:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 97
diff changeset
642 while((result = getopt_long(argc, argv, "br:smn:ua:p:d:hvli:",
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
643 long_options, &option_index)) != -1) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
644 switch(result) {
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
645 case 'b':
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
646 use_b25 = TRUE;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
647 fprintf(stderr, "using B25...\n");
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
648 break;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
649 case 's':
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
650 dopt.strip = TRUE;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
651 fprintf(stderr, "enable B25 strip\n");
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
652 break;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
653 case 'm':
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
654 dopt.emm = TRUE;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
655 fprintf(stderr, "enable B25 emm processing\n");
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
656 break;
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
657 case 'u':
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
658 use_udp = TRUE;
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
659 host_to = "localhost";
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
660 fprintf(stderr, "enable UDP broadcasting\n");
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
661 break;
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
662 case 'h':
57
d3929562b8e7 - added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 49
diff changeset
663 fprintf(stderr, "\n");
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
664 show_usage(argv[0]);
57
d3929562b8e7 - added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 49
diff changeset
665 fprintf(stderr, "\n");
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
666 show_options();
57
d3929562b8e7 - added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 49
diff changeset
667 fprintf(stderr, "\n");
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
668 show_channels();
57
d3929562b8e7 - added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 49
diff changeset
669 fprintf(stderr, "\n");
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
670 exit(0);
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
671 break;
43
9b36fdf7d5d0 show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 42
diff changeset
672 case 'v':
9b36fdf7d5d0 show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 42
diff changeset
673 fprintf(stderr, "%s %s\n", argv[0], version);
91
2b55985bbb4c - adapt date format to driver's one
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 89
diff changeset
674 fprintf(stderr, "recorder command for PT1/2 digital tuner.\n");
43
9b36fdf7d5d0 show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 42
diff changeset
675 exit(0);
9b36fdf7d5d0 show version option has been added
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 42
diff changeset
676 break;
57
d3929562b8e7 - added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 49
diff changeset
677 case 'l':
d3929562b8e7 - added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 49
diff changeset
678 show_channels();
d3929562b8e7 - added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 49
diff changeset
679 exit(0);
d3929562b8e7 - added --list option to show channel list.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 49
diff changeset
680 break;
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
681 /* following options require argument */
81
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
682 case 'n':
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
683 val = atoi(optarg);
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
684 switch(val) {
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
685 case 11:
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
686 tdata.lnb = 1;
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
687 break;
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
688 case 15:
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
689 tdata.lnb = 2;
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
690 break;
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
691 default:
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
692 tdata.lnb = 0;
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
693 break;
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
694 }
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
695 fprintf(stderr, "LNB = %s\n", voltage[tdata.lnb]);
6e3bb2c0c5b6 add an option to specify LNB voltage
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 78
diff changeset
696 break;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
697 case 'r':
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
698 dopt.round = atoi(optarg);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
699 fprintf(stderr, "set round %d\n", dopt.round);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
700 break;
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
701 case 'a':
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
702 use_udp = TRUE;
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
703 host_to = optarg;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
704 fprintf(stderr, "UDP destination address: %s\n", host_to);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
705 break;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
706 case 'p':
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
707 port_to = atoi(optarg);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
708 fprintf(stderr, "UDP port: %d\n", port_to);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
709 break;
32
6004fe4f37f9 adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 28
diff changeset
710 case 'd':
6004fe4f37f9 adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 28
diff changeset
711 device = optarg;
6004fe4f37f9 adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 28
diff changeset
712 fprintf(stderr, "using device: %s\n", device);
6004fe4f37f9 adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 28
diff changeset
713 break;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
714 case 'i':
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
715 use_splitter = TRUE;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
716 sid_list = optarg;
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
717 break;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
718 }
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
719 }
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
720
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
721 if(argc - optind < 3) {
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
722 if(argc - optind == 2 && use_udp) {
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
723 fprintf(stderr, "Fileless UDP broadcasting\n");
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
724 fileless = TRUE;
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
725 tdata.wfd = -1;
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
726 }
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
727 else {
14
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
728 fprintf(stderr, "Arguments are necessary!\n");
cad940a903f5 - replace host option with addr option.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 13
diff changeset
729 fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]);
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
730 return 1;
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
731 }
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
732 }
13
003fe2470af8 reorganized options:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 11
diff changeset
733
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
734 fprintf(stderr, "pid = %d\n", getpid());
34
3f2487de156e should not loop if tuner device is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 33
diff changeset
735
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
736 /* tune */
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
737 if(tune(argv[optind], &tdata, device) != 0)
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
738 return 1;
47
edd904628e2f a bit improved support for time format. now recpt1 recognize string such as 1h05m10s.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 43
diff changeset
739
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
740 /* set recsec */
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
741 if(parse_time(argv[optind + 1], &tdata.recsec) != 0) // no other thread --yaz
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
742 return 1;
48
c8051f6da2ab now recpt1 accepts formats like 1:20:05 (hh:mm:ss) or 1:20 (hh:mm).
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 47
diff changeset
743
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
744 if(tdata.recsec == -1)
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
745 tdata.indefinite = TRUE;
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
746
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
747 /* open output file */
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
748 char *destfile = argv[optind + 2];
38
3228f5cde349 recpt1 now accepts 1[HhMmSs] as recording duration. formats like 1Hour or 1hour are also be accepted.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 35
diff changeset
749 if(destfile && !strcmp("-", destfile)) {
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
750 use_stdout = TRUE;
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
751 tdata.wfd = 1; /* stdout */
38
3228f5cde349 recpt1 now accepts 1[HhMmSs] as recording duration. formats like 1Hour or 1hour are also be accepted.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 35
diff changeset
752 }
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
753 else {
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
754 if(!fileless) {
61
f1553492e8bb ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 59
diff changeset
755 int status;
63
ca419e61f7f2 fix for a bug that recpt1 crashes if dirname(3) returns '.'
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 62
diff changeset
756 char *path = strdup(argv[optind + 2]);
ca419e61f7f2 fix for a bug that recpt1 crashes if dirname(3) returns '.'
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 62
diff changeset
757 char *dir = dirname(path);
61
f1553492e8bb ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 59
diff changeset
758 status = mkpath(dir, 0777);
f1553492e8bb ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 59
diff changeset
759 if(status == -1)
f1553492e8bb ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 59
diff changeset
760 perror("mkpath");
63
ca419e61f7f2 fix for a bug that recpt1 crashes if dirname(3) returns '.'
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 62
diff changeset
761 free(path);
61
f1553492e8bb ensure path of destination file exists. imported Jonathan Leffler's mkpath.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 59
diff changeset
762
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
763 tdata.wfd = open(argv[optind + 2], (O_RDWR | O_CREAT | O_TRUNC), 0666);
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
764 if(tdata.wfd < 0) {
34
3f2487de156e should not loop if tuner device is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 33
diff changeset
765 fprintf(stderr, "Cannot open output file: %s\n",
33
f25820d90249 make recpt1 try other tuner devices when it fails to tune a tuner to the specified channel.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 32
diff changeset
766 argv[optind + 2]);
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
767 return 1;
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
768 }
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
769 }
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
770 }
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
771
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
772 /* initialize decoder */
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
773 if(use_b25) {
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
774 decoder = b25_startup(&dopt);
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
775 if(!decoder) {
34
3f2487de156e should not loop if tuner device is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 33
diff changeset
776 fprintf(stderr, "Cannot start b25 decoder\n");
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
777 fprintf(stderr, "Fall back to encrypted recording\n");
103
387d18563ef8 temporary workaround: disable splitter if decoder is disabled.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 100
diff changeset
778 use_b25 = FALSE;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
779 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
780 }
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
781 /* initialize splitter */
103
387d18563ef8 temporary workaround: disable splitter if decoder is disabled.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 100
diff changeset
782 if(use_splitter) {
104
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 103
diff changeset
783 splitter = split_startup(sid_list);
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 103
diff changeset
784 if(splitter->sid_list == NULL) {
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 103
diff changeset
785 fprintf(stderr, "Cannot start TS splitter\n");
afd25d9ebef6 output ECM packet so that former workaround is no longer needed.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 103
diff changeset
786 return 1;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
787 }
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
788 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
789
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
790 /* initialize udp connection */
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
791 if(use_udp) {
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
792 sockdata = calloc(1, sizeof(sock_data));
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
793 struct in_addr ia;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
794 ia.s_addr = inet_addr(host_to);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
795 if(ia.s_addr == INADDR_NONE) {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
796 struct hostent *hoste = gethostbyname(host_to);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
797 if(!hoste) {
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
798 perror("gethostbyname");
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
799 return 1;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
800 }
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
801 ia.s_addr = *(in_addr_t*) (hoste->h_addr_list[0]);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
802 }
28
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
803 if((sockdata->sfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
804 perror("socket");
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
805 return 1;
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
806 }
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
807
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
808 sockdata->addr.sin_family = AF_INET;
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
809 sockdata->addr.sin_port = htons (port_to);
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
810 sockdata->addr.sin_addr.s_addr = ia.s_addr;
28
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
811
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
812 if(connect(sockdata->sfd, (struct sockaddr *)&sockdata->addr,
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
813 sizeof(sockdata->addr)) < 0) {
97c820e30737 limit write length at once so that udp/stdout works well.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 27
diff changeset
814 perror("connect");
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
815 return 1;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
816 }
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
817 }
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
818
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
819 /* prepare thread data */
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
820 tdata.queue = p_queue;
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
821 tdata.decoder = decoder;
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
822 tdata.splitter = splitter;
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
823 tdata.sock_data = sockdata;
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
824 tdata.tune_persistent = FALSE;
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
825
33
f25820d90249 make recpt1 try other tuner devices when it fails to tune a tuner to the specified channel.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 32
diff changeset
826 /* spawn signal handler thread */
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
827 init_signal_handlers(&signal_thread, &tdata);
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
828
33
f25820d90249 make recpt1 try other tuner devices when it fails to tune a tuner to the specified channel.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 32
diff changeset
829 /* spawn reader thread */
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
830 tdata.signal_thread = signal_thread;
24
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
831 pthread_create(&reader_thread, NULL, reader_func, &tdata);
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
832
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
833 /* spawn ipc thread */
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
834 key_t key;
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
835 key = (key_t)getpid();
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
836
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
837 if ((tdata.msqid = msgget(key, IPC_CREAT | 0666)) < 0) {
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
838 perror("msgget");
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
839 }
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
840 pthread_create(&ipc_thread, NULL, mq_recv, &tdata);
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
841
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
842 /* start recording */
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
843 if(ioctl(tdata.tfd, START_REC, 0) < 0) {
34
3f2487de156e should not loop if tuner device is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 33
diff changeset
844 fprintf(stderr, "Tuner cannot start recording\n");
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
845 return 1;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
846 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
847
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
848 fprintf(stderr, "\nRecording...\n");
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
849
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
850 time(&tdata.start_time);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
851
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
852 /* read from tuner */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
853 while(1) {
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
854 if(f_exit)
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
855 break;
26
c6264c15f39d simplify reader_func()
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 25
diff changeset
856
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
857 time(&cur_time);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
858 bufptr = malloc(sizeof(BUFSZ));
88
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
859 if(!bufptr) {
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
860 f_exit = TRUE;
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
861 break;
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
862 }
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
863 bufptr->size = read(tdata.tfd, bufptr->buffer, MAX_READ_SIZE);
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
864 if(bufptr->size <= 0) {
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
865 if((cur_time - tdata.start_time) >= tdata.recsec && !tdata.indefinite) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
866 f_exit = TRUE;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
867 enqueue(p_queue, NULL);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
868 break;
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
869 }
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
870 else {
133
b14397800eae imported eagletmt-san's reuse device patch for fast channel selection in recpt1ctl. The original patch can be obtained at https://gist.github.com/890635/57c3fd93e181b3eb3f6e5ebeae22ad7b5f1f4ec1
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 127
diff changeset
871 free(bufptr);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
872 continue;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
873 }
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
874 }
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
875 enqueue(p_queue, bufptr);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
876
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
877 /* stop recording */
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
878 time(&cur_time);
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
879 if((cur_time - tdata.start_time) >= tdata.recsec && !tdata.indefinite) {
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
880 ioctl(tdata.tfd, STOP_REC, 0);
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
881 /* read remaining data */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
882 while(1) {
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
883 bufptr = malloc(sizeof(BUFSZ));
88
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
884 if(!bufptr) {
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
885 f_exit = TRUE;
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
886 break;
59065b569eec improve stability on changing channel
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 87
diff changeset
887 }
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
888 bufptr->size = read(tdata.tfd, bufptr->buffer, MAX_READ_SIZE);
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
889 if(bufptr->size <= 0) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
890 f_exit = TRUE;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
891 enqueue(p_queue, NULL);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
892 break;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
893 }
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
894 enqueue(p_queue, bufptr);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
895 }
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
896 break;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
897 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
898 }
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
899
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
900 /* delete message queue*/
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
901 msgctl(tdata.msqid, IPC_RMID, NULL);
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
902
24
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
903 pthread_kill(signal_thread, SIGUSR1);
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
904
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
905 /* wait for threads */
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
906 pthread_join(reader_thread, NULL);
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
907 pthread_join(signal_thread, NULL);
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
908 pthread_join(ipc_thread, NULL);
24
f2cce7becf52 fixed a bug that recpt1 could not exit when recsec is specified.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 21
diff changeset
909
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
910 /* close tuner */
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
911 if(close_tuner(&tdata) != 0)
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
912 return 1;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
913
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
914 /* release queue */
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
915 destroy_queue(p_queue);
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
916
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
917 /* close output file */
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
918 if(!use_stdout)
78
5a0126d8af17 landed ipc control functionality branch
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 74
diff changeset
919 close(tdata.wfd);
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
920
16
ecb85bde67b1 added signal handler to perform cleaning up when it receives a signal.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 15
diff changeset
921 /* free socket data */
18
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
922 if(use_udp) {
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
923 close(sockdata->sfd);
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
924 free(sockdata);
84ff6ef710ea - support stdout for output
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 17
diff changeset
925 }
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
926
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
927 /* release decoder */
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
928 if(use_b25) {
140
c9b1d21c5035 separate common function to core library
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 139
diff changeset
929 b25_shutdown(decoder);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
930 }
96
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
931 if(use_splitter) {
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
932 split_shutdown(splitter);
52f8e081763d add an option to specify the necessary service IDs.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 91
diff changeset
933 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
934
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
935 return 0;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
936 }