annotate recpt1/recpt1.c @ 8:6da603afd363

added udp capability
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Mon, 23 Feb 2009 03:06:17 +0900
parents 407af34cfbd9
children 4615eaf04415
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
1 #include <stdio.h>
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
2 #include <fcntl.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
3 #include <sys/types.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
4 #include <sys/stat.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
5 #include <time.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
6 #include <stdlib.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
7 #include <string.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
8 #include <pthread.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
9 #include <unistd.h>
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
10 #include <getopt.h>
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
11
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
12 #include <netdb.h>
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
13 #include <arpa/inet.h>
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
14 #include <netinet/in.h>
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
15
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
16 #include <sys/ioctl.h>
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
17 #include "pt1_ioctl.h"
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
18
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
19 #include "recpt1.h"
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
20 #include "decoder.h"
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
21
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
22 /* globals */
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
23 int f_exit = FALSE;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
24
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
25 typedef struct sock_data {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
26 int sfd; /* socket fd */
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
27 struct sockaddr_in addr;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
28 } sock_data;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
29
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
30 typedef struct thread_data {
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
31 QUEUE_T *queue;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
32 decoder *decoder;
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
33 int wfd; /* output file fd */
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
34 sock_data *sock_data;
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
35 } thread_data;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
36
6
d898fd27547f cleanups
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 5
diff changeset
37 /* lookup frequency conversion table*/
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
38 ISDB_T_FREQ_CONV_TABLE *
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
39 searchrecoff(char *channel)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
40 {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
41 int lp;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
42
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
43 for(lp = 0; isdb_t_conv_table[lp].parm_freq != NULL; lp++){
6
d898fd27547f cleanups
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 5
diff changeset
44 /* return entry number in the table when strings match and
d898fd27547f cleanups
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 5
diff changeset
45 * lengths are same. */
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
46 if((memcmp(isdb_t_conv_table[lp].parm_freq, channel,
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
47 strlen(channel)) == 0) &&
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
48 (strlen(channel) == strlen(isdb_t_conv_table[lp].parm_freq))){
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
49 return &isdb_t_conv_table[lp];
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
50 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
51 }
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
52 return NULL;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
53 }
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
54
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
55 QUEUE_T *
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
56 create_queue(size_t size)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
57 {
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
58 QUEUE_T *p_queue;
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
59 int memsize = sizeof(QUEUE_T) + size * sizeof(BUFSZ);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
60
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
61 p_queue = (QUEUE_T*)calloc(memsize, sizeof(char));
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
62
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
63 if(p_queue != NULL) {
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
64 p_queue->size = size;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
65 p_queue->no_full = size;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
66 p_queue->no_empty = 0;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
67 pthread_mutex_init(&p_queue->mutex, NULL);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
68 pthread_cond_init(&p_queue->cond_full, NULL);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
69 pthread_cond_init(&p_queue->cond_empty, NULL);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
70 }
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
71
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
72 return p_queue;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
73 }
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
74
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
75 void
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
76 destroy_queue(QUEUE_T *p_queue)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
77 {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
78 if(!p_queue)
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
79 return;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
80
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
81 pthread_mutex_destroy(&p_queue->mutex);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
82 pthread_cond_destroy(&p_queue->cond_full);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
83 pthread_cond_destroy(&p_queue->cond_empty);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
84 free(p_queue);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
85 }
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
86
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
87 /* 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
88 void
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
89 enqueue(QUEUE_T *p_queue, BUFSZ *data)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
90 {
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
91 pthread_mutex_lock(&p_queue->mutex);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
92 /* entered critical section */
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
93
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
94 /* wait until queue is not full */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
95 while(!p_queue->no_full) {
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
96 pthread_cond_wait(&p_queue->cond_full, &p_queue->mutex);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
97 fprintf(stderr, "Full\n");
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
98 }
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
99
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
100 p_queue->buffer[p_queue->in] = data;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
101
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
102 p_queue->in++;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
103 p_queue->in %= p_queue->size;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
104
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
105 p_queue->no_full--;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
106 p_queue->no_empty++;
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
107
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
108 /* leaving critical section */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
109 pthread_mutex_unlock(&p_queue->mutex);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
110 pthread_cond_signal(&p_queue->cond_empty);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
111 }
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
112
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
113 /* 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
114 BUFSZ *
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
115 dequeue(QUEUE_T *p_queue)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
116 {
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
117 BUFSZ *buffer;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
118
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
119 pthread_mutex_lock(&p_queue->mutex);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
120 /* entered the critical section*/
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
121
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
122 /* wait until queue is filled */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
123 while (!p_queue->no_empty) {
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
124 pthread_cond_wait(&p_queue->cond_empty, &p_queue->mutex);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
125 }
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
126
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
127 /* take buffer address */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
128 buffer = p_queue->buffer[p_queue->out];
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
129
6
d898fd27547f cleanups
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 5
diff changeset
130 /* move location marker to next position */
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
131 p_queue->out++;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
132 p_queue->out %= p_queue->size;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
133
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
134 /* update flags */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
135 p_queue->no_full++;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
136 p_queue->no_empty--;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
137
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
138 /* leaving the critical section */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
139 pthread_mutex_unlock(&p_queue->mutex);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
140 pthread_cond_signal(&p_queue->cond_full);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
141
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
142 return buffer;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
143 }
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
144
6
d898fd27547f cleanups
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 5
diff changeset
145 /* this function will be reader thread */
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
146 void *
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
147 write_func(void *p)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
148 {
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
149 thread_data *data = (thread_data *)p;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
150 QUEUE_T *p_queue = data->queue;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
151 decoder *dec = data->decoder;
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
152 int wfd = data->wfd;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
153 int use_b25 = dec ? 1 : 0;
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
154 int use_udp = data->sock_data ? 1 : 0;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
155 int sfd = 0;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
156 struct sockaddr *addr = NULL;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
157 BUFSZ *buf;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
158 ARIB_STD_B25_BUFFER sbuf, dbuf;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
159 int code;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
160
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
161 if(use_udp) {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
162 sfd = data->sock_data->sfd;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
163 addr = (struct sockaddr *)&data->sock_data->addr;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
164 }
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
165
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
166 while(1) {
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
167 buf = dequeue(p_queue);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
168 /* no entry in the queue */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
169 if(buf == NULL){
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
170 close(wfd);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
171 break;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
172 }
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
173
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
174 sbuf.data = buf->buffer;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
175 sbuf.size = buf->size;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
176
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
177 if(use_b25) {
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
178 /* write data to output file*/
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
179 code = b25_decode(dec, &sbuf, &dbuf);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
180 if(code < 0) {
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
181 fprintf(stderr, "b25_decode failed\n");
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
182 close(wfd);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
183 break;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
184 }
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
185 write(wfd, dbuf.data, dbuf.size);
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
186
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
187 if(use_udp && sfd) {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
188 sendto(sfd, dbuf.data, dbuf.size, 0,
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
189 addr, sizeof(struct sockaddr_in));
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
190 }
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
191 free(buf);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
192 } else {
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
193 write(wfd, sbuf.data, sbuf.size);
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
194
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
195 if(use_udp && sfd) {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
196 sendto(sfd, sbuf.data, sbuf.size, 0,
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
197 addr, sizeof(struct sockaddr_in));
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
198 }
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
199 free(buf);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
200 }
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
201
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
202 /* normal exit */
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
203 if((f_exit) && (!p_queue->no_empty)) {
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
204 if(use_b25) {
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
205 code = b25_finish(dec, &sbuf, &dbuf);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
206 if(code < 0) {
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
207 fprintf(stderr, "b25_finish failed\n");
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
208 close(wfd);
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
209 close(sfd);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
210 break;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
211 }
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
212 write(wfd, dbuf.data, dbuf.size);
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
213
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
214 if(use_udp && sfd) {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
215 sendto(sfd, dbuf.data, dbuf.size, 0,
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
216 addr, sizeof(struct sockaddr_in));
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
217 }
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
218 }
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
219 close(wfd);
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
220 close(sfd);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
221 break;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
222 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
223 }
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
224
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
225 return NULL;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
226 }
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
227
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
228 void
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
229 show_usage(char *cmd)
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
230 {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
231 fprintf(stderr, "Usage: %s [--b25 [--round N] [--strip] [--EMM]] [--udp hostname [--port port]] channel recsec destfile\n", cmd);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
232 }
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
233
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
234 int
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
235 main(int argc, char **argv)
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
236 {
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
237 int tfd, wfd;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
238 int lp;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
239 int recsec;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
240 time_t start_time, cur_time;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
241 FREQUENCY freq;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
242 ISDB_T_FREQ_CONV_TABLE *ptr;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
243 pthread_t dequeue_threads;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
244 QUEUE_T *p_queue = create_queue(MAX_QUEUE);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
245 BUFSZ *bufptr;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
246 decoder *dec = NULL;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
247 thread_data tdata;
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
248 decoder_options dopt = {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
249 4, /* round */
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
250 0, /* strip */
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
251 0 /* emm */
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
252 };
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
253
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
254 int result;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
255 int option_index;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
256 struct option long_options[] = {
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
257 { "b25", 0, NULL, 'b'},
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
258 { "B25", 0, NULL, 'b'},
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
259 { "round", 1, NULL, 'r'},
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
260 { "strip", 0, NULL, 's'},
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
261 { "emm", 0, NULL, 'm'},
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
262 { "EMM", 0, NULL, 'm'},
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
263 { "udp", 1, NULL, 'u'},
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
264 { "port", 1, NULL, 'p'}
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
265 };
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
266
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
267 int use_b25 = 0;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
268 int use_udp = 0;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
269 char *host_to = NULL;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
270 int port_to = 1234;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
271 sock_data *sdata = NULL;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
272
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
273 while((result = getopt_long(argc, argv, "br:sm" "u:p:", long_options, &option_index)) != -1) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
274 switch(result) {
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
275 case 'b':
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
276 use_b25 = 1;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
277 fprintf(stderr, "using B25...\n");
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
278 break;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
279 case 's':
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
280 dopt.strip = 1;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
281 fprintf(stderr, "enable B25 strip\n");
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
282 break;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
283 case 'm':
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
284 dopt.emm = 1;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
285 fprintf(stderr, "enable B25 emm processing\n");
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
286 break;
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
287 case 'r':
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
288 dopt.round = atoi(optarg);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
289 fprintf(stderr, "set round %d\n", dopt.round);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
290 break;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
291 case ':':
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
292 fprintf(stderr, "%c needs value\n", result);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
293 break;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
294 case '?':
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
295 show_usage(argv[0]);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
296 break;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
297 case 'u':
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
298 use_udp = 1;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
299 host_to = optarg;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
300 fprintf(stderr, "UDP destination address: %s\n", host_to);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
301 break;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
302 case 'p':
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
303 port_to = atoi(optarg);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
304 fprintf(stderr, "UDP port: %d\n", port_to);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
305 break;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
306 }
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
307 }
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
308
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
309 if(argc - optind < 3) {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
310 show_usage(argv[0]);
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
311 printf("channel =\n");
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
312 printf("151ch¡§BSÄ«Æü\n");
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
313 printf("161ch¡§BS-i\n");
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
314 printf("191ch¡§WOWOW\n");
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
315 printf("171ch¡§BS¥¸¥ã¥Ñ¥ó\n");
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
316 printf("200ch¡§¥¹¥¿¡¼¥Á¥ã¥ó¥Í¥ë\n");
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
317 printf("211ch¡§BS11¥Ç¥¸¥¿¥ë\n");
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
318 printf("222ch¡§TwellV\n");
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
319 printf("141ch¡§BSÆü¥Æ¥ì\n");
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
320 printf("181ch¡§BS¥Õ¥¸\n");
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
321 printf("101ch¡§NHK±ÒÀ±Âè1ÊüÁ÷(BS1)\n");
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
322 printf("102ch¡§NHK±ÒÀ±Âè2ÊüÁ÷(BS2)\n");
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
323 printf("103ch¡§NHK¥Ï¥¤¥Ó¥¸¥ç¥ó(BShi)\n");
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
324 printf("CS2-CS24¡§CS¥Á¥ã¥ó¥Í¥ë\n");
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
325 return 1;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
326 }
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
327 ptr = searchrecoff(argv[optind]);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
328 if(ptr == NULL){
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
329 printf("Channel Select Error(%s)\n", argv[optind]);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
330 return 1;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
331 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
332
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
333 freq.frequencyno = ptr->set_freq;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
334 freq.slot = ptr->add_freq;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
335
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
336 if(ptr->type == CHTYPE_SATELLITE) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
337 for(lp = 0; lp < 2; lp++) {
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
338 tfd = open(bsdev[lp], O_RDONLY);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
339 if(tfd >= 0) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
340 break;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
341 }
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
342 }
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
343 if(tfd < 0) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
344 fprintf(stderr, "Device Open Error\n");
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
345 return 1;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
346 }
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
347 } else {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
348 for(lp = 0; lp < 2; lp++) {
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
349 tfd = open(isdb_t_dev[lp], O_RDONLY);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
350 if(tfd >= 0) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
351 break;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
352 }
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
353 }
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
354 if(tfd < 0) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
355 fprintf(stderr, "Device Open Error\n");
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
356 return 1;
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
357 }
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
358 }
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
359 recsec = atoi(argv[optind + 1]);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
360
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
361 /* initialize decoder */
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
362 if(use_b25) {
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
363 dec = b25_startup(&dopt);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
364 if(!dec) {
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
365 fprintf(stderr, "cannot start b25 decoder\n");
7
407af34cfbd9 now falls back to encrypted recording when b25 decoder is not available
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 6
diff changeset
366 fprintf(stderr, "fall back to encrypted recording\n");
407af34cfbd9 now falls back to encrypted recording when b25 decoder is not available
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 6
diff changeset
367 use_b25 = 0;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
368 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
369 }
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
370
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
371 /* initialize udp connection */
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
372 if(use_udp) {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
373 sdata = calloc(1, sizeof(sock_data));
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
374 struct in_addr ia;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
375 ia.s_addr = inet_addr(host_to);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
376 if(ia.s_addr == INADDR_NONE) {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
377 struct hostent *hoste = gethostbyname(host_to);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
378 if(!hoste) {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
379 perror("failed to get host by name");
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
380 return 1;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
381 }
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
382 ia.s_addr = *(in_addr_t*) (hoste->h_addr_list[0]);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
383 }
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
384 sdata->addr.sin_family = AF_INET;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
385 sdata->addr.sin_port = htons (port_to);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
386 sdata->addr.sin_addr.s_addr = ia.s_addr;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
387 if((sdata->sfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
388 perror("socket");
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
389 return 1;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
390 }
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
391 }
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
392
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
393 /* open output file */
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
394 wfd = open(argv[optind + 2], (O_RDWR | O_CREAT | O_TRUNC), 0666);
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
395 if(wfd < 0) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
396 fprintf(stderr, "Output File Open Error(%s)\n", argv[optind + 2]);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
397 return 1;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
398 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
399
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
400 if(ioctl(tfd, SET_CHANNEL, &freq) < 0) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
401 fprintf(stderr, "Tuner Select Error\n");
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
402 return 1;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
403 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
404
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
405 /* make reader thread */
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
406 tdata.queue = p_queue;
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
407 tdata.decoder = dec;
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
408 tdata.wfd = wfd;
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
409 tdata.sock_data = sdata;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
410 pthread_create(&dequeue_threads, NULL, write_func, &tdata);
3
6801fe7e04ff updated to ariv25v023
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
411
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
412 /* start recording */
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
413 if(ioctl(tfd, START_REC, 0) < 0) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
414 fprintf(stderr, "Tuner Start Error\n");
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
415 return 1;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
416 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
417
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
418 time(&start_time);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
419
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
420 /* read from tuner */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
421 while(1) {
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
422 time(&cur_time);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
423 bufptr = malloc(sizeof(BUFSZ));
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
424 bufptr->size = read(tfd, bufptr->buffer, MAX_READ_SIZE);
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
425 if(bufptr->size <= 0) {
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
426 if((cur_time - start_time) >= recsec) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
427 f_exit = TRUE;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
428 enqueue(p_queue, NULL);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
429 break;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
430 } else {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
431 continue;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
432 }
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
433 }
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
434 enqueue(p_queue, bufptr);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
435
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
436 /* stop recording */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
437 if((cur_time - start_time) >= recsec) {
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
438 ioctl(tfd, STOP_REC, 0);
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
439 /* read remaining data */
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
440 while(1) {
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
441 bufptr = malloc(sizeof(BUFSZ));
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
442 bufptr->size = read(tfd, bufptr->buffer, MAX_READ_SIZE);
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
443 if(bufptr->size <= 0) {
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
444 f_exit = TRUE;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
445 enqueue(p_queue, NULL);
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
446 break;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
447 }
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
448 enqueue(p_queue, bufptr);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
449 }
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
450 break;
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
451 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
452 }
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
453 /* close tuner */
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
454 close(tfd);
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
455
6
d898fd27547f cleanups
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 5
diff changeset
456 /* wait reader thread */
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
457 pthread_join(dequeue_threads, NULL);
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
458 destroy_queue(p_queue);
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
459
8
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
460 /* close socket */
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
461 if(use_udp) {
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
462 close(sdata->sfd);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
463 free(sdata);
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
464 }
6da603afd363 added udp capability
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
465
4
43d177fa65c9 fixed indentation
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 3
diff changeset
466 /* release decoder */
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
467 if(use_b25) {
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
468 b25_shutdown(dec);
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
469 }
2
8ac7c59fefc9 added b25 decode functionality
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
470
5
97fd2315114e - now it can handle options.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 4
diff changeset
471 return 0;
0
67e8eca28a80 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
472 }