Mercurial > mplayer.hg
annotate stream/tvi_bsdbt848.c @ 24681:1ecf2ff1d512
in update_stats() removed a wrong 'else' that would prevent h264 headers to be recognized:
all 0x12x headers were accounted for only in num_elementary_packets12x.
Fixes detection of certain H264 in ES/PS streams
author | nicodvb |
---|---|
date | Thu, 04 Oct 2007 17:15:06 +0000 |
parents | a6ead1d94378 |
children | 454f3a34d408 |
rev | line source |
---|---|
5081 | 1 /* |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
2 (C)2002 Charles R. Henrich (henrich@msu.edu) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
3 *BSD (hopefully, requires working driver!) BrookTree capture support. |
5081 | 4 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
5 Still in (active) development! |
5081 | 6 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
7 v1.1 Mar 13 2002 Fully functional, need to move ring buffer to |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
8 the kernel driver. |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
9 v1.0 Feb 19 2002 First Release, need to add support for changing |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
10 audio parameters. |
5081 | 11 */ |
12 | |
13 #include "config.h" | |
14 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
15 #define RINGSIZE 8 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
16 #define FRAGSIZE 4096 /* (2^12 see SETFRAGSIZE below) */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
17 |
5081 | 18 #define TRUE (1==1) |
19 #define FALSE (1==0) | |
20 | |
21 #define PAL_WIDTH 768 | |
22 #define PAL_HEIGHT 576 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
23 #define PAL_FPS 25 |
5081 | 24 |
25 #define NTSC_WIDTH 640 | |
26 #define NTSC_HEIGHT 480 | |
8953
1ebf4c3ab032
NTSC is 29.97 fps, not 30. wrong values here are likely to cause
rfelker
parents:
5886
diff
changeset
|
27 #define NTSC_FPS 29.97 |
5081 | 28 |
29 #include <stdio.h> | |
30 #include <stdlib.h> | |
31 #include <unistd.h> | |
32 #include <fcntl.h> | |
33 #include <sys/types.h> | |
34 #include <sys/mman.h> | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
35 #include <sys/filio.h> |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
36 #include <sys/time.h> |
5081 | 37 #include <signal.h> |
38 #include <string.h> | |
39 | |
11723 | 40 #include <sys/param.h> |
22934 | 41 #ifdef USE_SUN_AUDIO |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
42 #include <sys/audioio.h> |
22934 | 43 #endif |
44 | |
45 #ifdef IOCTL_METEOR_H_NAME | |
46 #include IOCTL_METEOR_H_NAME | |
47 #endif | |
48 | |
49 #ifdef IOCTL_BT848_H_NAME | |
50 #include IOCTL_BT848_H_NAME | |
5872 | 51 #endif |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
52 |
5142 | 53 #ifdef HAVE_SYS_SOUNDCARD_H |
54 #include <sys/soundcard.h> | |
55 #else | |
5886
d4307620912d
soundcard.h fix, by Bernd Ernesti <mplayer@lists.veego.de>
arpi
parents:
5872
diff
changeset
|
56 #ifdef HAVE_SOUNDCARD_H |
d4307620912d
soundcard.h fix, by Bernd Ernesti <mplayer@lists.veego.de>
arpi
parents:
5872
diff
changeset
|
57 #include <soundcard.h> |
d4307620912d
soundcard.h fix, by Bernd Ernesti <mplayer@lists.veego.de>
arpi
parents:
5872
diff
changeset
|
58 #else |
5081 | 59 #include <machine/soundcard.h> |
5142 | 60 #endif |
5886
d4307620912d
soundcard.h fix, by Bernd Ernesti <mplayer@lists.veego.de>
arpi
parents:
5872
diff
changeset
|
61 #endif |
5081 | 62 |
17012 | 63 #include "libaf/af_format.h" |
19431
ac69ba536915
Explicitly include libmpcodecs/img_format.h and libvo/fastmemcpy.h.
diego
parents:
19271
diff
changeset
|
64 #include "libmpcodecs/img_format.h" |
5081 | 65 #include "tv.h" |
24411 | 66 #include "help_mp.h" |
24193 | 67 #include "mp_msg.h" |
5081 | 68 |
23883 | 69 static tvi_handle_t *tvi_init_bsdbt848(tv_param_t* tv_param); |
5081 | 70 /* information about this file */ |
22381
6cabac4d35b5
tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents:
21848
diff
changeset
|
71 tvi_info_t tvi_info_bsdbt848 = { |
6cabac4d35b5
tv driver loading rework. As a side effect "-tv driver=help" option is
voroshil
parents:
21848
diff
changeset
|
72 tvi_init_bsdbt848, |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
73 "Brooktree848 Support", |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
74 "bsdbt848", |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
75 "Charles Henrich", |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
76 "in development" |
5081 | 77 }; |
78 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
79 typedef struct { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
80 int dirty; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
81 double timestamp; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
82 char *buf; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
83 } RBFRAME; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
84 |
5081 | 85 /* private data's */ |
86 typedef struct { | |
87 | |
88 /* Audio */ | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
89 char *dspdev; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
90 int dspready; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
91 int dspfd; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
92 int dspsamplesize; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
93 int dspstereo; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
94 int dspspeed; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
95 int dspfmt; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
96 int dspframesize; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
97 int dsprate; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
98 long long dspbytesread; |
5081 | 99 |
100 /* Video */ | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
101 char *btdev; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
102 int videoready; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
103 int btfd; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
104 int source; |
10019 | 105 float maxfps; |
106 float fps; | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
107 int iformat; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
108 int maxheight; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
109 int maxwidth; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
110 struct meteor_geomet geom; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
111 struct meteor_capframe capframe; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
112 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
113 /* Frame Buffer */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
114 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
115 int framebufsize; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
116 float timestamp; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
117 int curpaintframe; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
118 int curbufframe; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
119 unsigned char *livebuf; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
120 RBFRAME framebuf[RINGSIZE]; |
5081 | 121 |
122 /* Inputs */ | |
123 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
124 int input; |
5081 | 125 |
126 /* Tuner */ | |
127 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
128 char *tunerdev; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
129 int tunerfd; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
130 int tunerready; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
131 u_long tunerfreq; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
132 struct bktr_chnlset cset; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
133 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
134 /* Other */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
135 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
136 int immediatemode; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
137 double starttime; |
5081 | 138 |
23883 | 139 tv_param_t *tv_param; |
5081 | 140 } priv_t; |
141 | |
142 #include "tvi_def.h" | |
143 | |
144 static priv_t *G_private=NULL; | |
145 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
146 static int getinput(int innumber); |
5081 | 147 |
148 static void processframe(int signal) | |
149 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
150 struct timeval curtime; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
151 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
152 if(G_private->immediatemode == TRUE) return; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
153 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
154 gettimeofday(&curtime, NULL); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
155 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
156 if(G_private->framebuf[G_private->curpaintframe].dirty == TRUE) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
157 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
158 memcpy(G_private->framebuf[G_private->curpaintframe].buf, |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
159 G_private->livebuf, G_private->framebufsize); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
160 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
161 G_private->framebuf[G_private->curpaintframe].dirty = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
162 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
163 G_private->framebuf[G_private->curpaintframe].timestamp = |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
164 curtime.tv_sec + curtime.tv_usec*.000001; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
165 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
166 G_private->curpaintframe++; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
167 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
168 if(G_private->curpaintframe >= RINGSIZE) G_private->curpaintframe = 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
169 } |
5081 | 170 |
171 return; | |
172 } | |
173 | |
174 /* handler creator - entry point ! */ | |
23883 | 175 static tvi_handle_t *tvi_init_bsdbt848(tv_param_t* tv_param) |
5081 | 176 { |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
177 char* sep ; |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
178 tvi_handle_t* tvh; |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
179 priv_t* priv; |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
180 |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
181 tvh=new_handle(); |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
182 if(!tvh) |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
183 return NULL; |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
184 priv=(priv_t*)tvh->priv; |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
185 /* |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
186 if user needs to specify both /dev/bktr<n> and /dev/tuner<n> |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
187 it can do this with "-tv device=/dev/bktr1,/dev/tuner1" |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
188 */ |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
189 |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
190 /* set video device name */ |
23883 | 191 if (!tv_param->device){ |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
192 priv->btdev = strdup("/dev/bktr0"); |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
193 priv->tunerdev = strdup("/dev/tuner0"); |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
194 }else{ |
23883 | 195 sep = strchr(tv_param->device,','); |
196 priv->btdev = strdup(tv_param->device); | |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
197 if(sep){ |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
198 // tuner device is also passed |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
199 priv->tunerdev = strdup(sep+1); |
23883 | 200 priv->btdev[sep - tv_param->device] = 0; |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
201 }else{ |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
202 priv->tunerdev = strdup("/dev/tuner0"); |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
203 } |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
204 } |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
205 |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
206 /* set audio device name */ |
23883 | 207 if (!tv_param->adevice) |
22934 | 208 #ifdef USE_SUN_AUDIO |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
209 priv->dspdev = strdup("/dev/sound"); |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
210 #else |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
211 priv->dspdev = strdup("/dev/dsp"); |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
212 #endif |
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
213 else |
23883 | 214 priv->dspdev = strdup(tv_param->adevice); |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
215 |
23925
f54903679ad0
10l: wrong pointer was initialized (causes crash during startup).
voroshil
parents:
23884
diff
changeset
|
216 priv->tv_param=tv_param; |
22898
b5b63e82bb3e
Ability to specify video and audio capture device names
voroshil
parents:
22381
diff
changeset
|
217 return tvh; |
5081 | 218 } |
219 | |
220 static int control(priv_t *priv, int cmd, void *arg) | |
221 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
222 switch(cmd) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
223 { |
5081 | 224 |
225 /* Tuner Controls */ | |
226 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
227 case TVI_CONTROL_IS_TUNER: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
228 if(priv->tunerready == FALSE) return TVI_CONTROL_FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
229 return(TVI_CONTROL_TRUE); |
5081 | 230 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
231 case TVI_CONTROL_TUN_GET_FREQ: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
232 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
233 if(ioctl(priv->tunerfd, TVTUNER_GETFREQ, &priv->tunerfreq) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
234 { |
24193 | 235 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "TVTUNER_GETFREQ", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
236 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
237 } |
5081 | 238 |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
239 *(int *)arg = priv->tunerfreq; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
240 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
241 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
242 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
243 case TVI_CONTROL_TUN_SET_FREQ: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
244 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
245 priv->tunerfreq = *(int *)arg; |
5081 | 246 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
247 if(ioctl(priv->tunerfd, TVTUNER_SETFREQ, &priv->tunerfreq) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
248 { |
24193 | 249 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "TVTUNER_SETFREQ", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
250 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
251 } |
5081 | 252 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
253 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
254 } |
24192
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
255 case TVI_CONTROL_TUN_GET_SIGNAL: |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
256 { |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
257 int status; |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
258 if(ioctl(priv->tunerfd, TVTUNER_GETSTATUS, &status) < 0) |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
259 { |
24193 | 260 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "GETSTATUS", strerror(errno)); |
24192
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
261 return(0); |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
262 } |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
263 *(int*)arg=(status & 0x02)? 100 : 0; |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
264 return (TVI_CONTROL_TRUE); |
588a590819f0
Implement TVI_CONTROL_TUN_GET_SIGNAL in *BSD BT848 driver.
voroshil
parents:
24033
diff
changeset
|
265 } |
5081 | 266 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
267 case TVI_CONTROL_TUN_GET_TUNER: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
268 case TVI_CONTROL_TUN_SET_TUNER: |
5081 | 269 |
270 /* Inputs */ | |
271 | |
272 case TVI_CONTROL_SPC_GET_INPUT: | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
273 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
274 if(ioctl(priv->btfd, METEORGINPUT, &priv->input) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
275 { |
24193 | 276 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORGINPUT", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
277 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
278 } |
5081 | 279 |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
280 *(int *)arg = priv->input; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
281 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
282 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
283 |
5081 | 284 case TVI_CONTROL_SPC_SET_INPUT: |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
285 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
286 priv->input = getinput(*(int *)arg); |
5081 | 287 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
288 if(ioctl(priv->btfd, METEORSINPUT, &priv->input) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
289 { |
24193 | 290 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSINPUT", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
291 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
292 } |
5081 | 293 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
294 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
295 } |
5081 | 296 |
297 /* Audio Controls */ | |
298 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
299 case TVI_CONTROL_IS_AUDIO: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
300 if(priv->dspready == FALSE) return TVI_CONTROL_FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
301 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
302 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
303 case TVI_CONTROL_AUD_GET_FORMAT: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
304 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
305 *(int *)arg = AF_FORMAT_S16_LE; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
306 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
307 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
308 case TVI_CONTROL_AUD_GET_CHANNELS: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
309 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
310 *(int *)arg = 2; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
311 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
312 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
313 case TVI_CONTROL_AUD_SET_SAMPLERATE: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
314 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
315 int dspspeed = *(int *)arg; |
5081 | 316 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
317 if(ioctl(priv->dspfd, SNDCTL_DSP_SPEED, &dspspeed) == -1) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
318 { |
24193 | 319 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848InvalidAudioRate, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
320 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
321 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
322 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
323 priv->dspspeed = dspspeed; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
324 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
325 priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
326 priv->fps * (priv->dspstereo+1); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
327 priv->dsprate = priv->dspspeed * priv->dspsamplesize/8* |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
328 (priv->dspstereo+1); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
329 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
330 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
331 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
332 case TVI_CONTROL_AUD_GET_SAMPLERATE: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
333 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
334 *(int *)arg = priv->dspspeed; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
335 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
336 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
337 case TVI_CONTROL_AUD_GET_SAMPLESIZE: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
338 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
339 *(int *)arg = priv->dspsamplesize/8; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
340 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
341 } |
5081 | 342 |
343 /* Video Controls */ | |
344 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
345 case TVI_CONTROL_IS_VIDEO: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
346 if(priv->videoready == FALSE) return TVI_CONTROL_FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
347 return(TVI_CONTROL_TRUE); |
5081 | 348 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
349 case TVI_CONTROL_TUN_SET_NORM: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
350 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
351 int req_mode = *(int *)arg; |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
352 u_short tmp_fps; |
5081 | 353 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
354 priv->iformat = METEOR_FMT_AUTOMODE; |
5081 | 355 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
356 if(req_mode == TV_NORM_PAL) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
357 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
358 priv->iformat = METEOR_FMT_PAL; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
359 priv->maxheight = PAL_HEIGHT; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
360 priv->maxwidth = PAL_WIDTH; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
361 priv->maxfps = PAL_FPS; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
362 priv->fps = PAL_FPS; |
5081 | 363 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
364 if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; |
5081 | 365 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
366 if(priv->geom.rows > priv->maxheight) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
367 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
368 priv->geom.rows = priv->maxheight; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
369 } |
5081 | 370 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
371 if(priv->geom.columns > priv->maxwidth) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
372 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
373 priv->geom.columns = priv->maxwidth; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
374 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
375 } |
5081 | 376 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
377 if(req_mode == TV_NORM_NTSC) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
378 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
379 priv->iformat = METEOR_FMT_NTSC; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
380 priv->maxheight = NTSC_HEIGHT; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
381 priv->maxwidth = NTSC_WIDTH; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
382 priv->maxfps = NTSC_FPS; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
383 priv->fps = NTSC_FPS; |
5081 | 384 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
385 priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
386 priv->fps * (priv->dspstereo+1); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
387 priv->dsprate = priv->dspspeed * priv->dspsamplesize/8 * |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
388 (priv->dspstereo+1); |
5081 | 389 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
390 if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; |
5081 | 391 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
392 if(priv->geom.rows > priv->maxheight) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
393 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
394 priv->geom.rows = priv->maxheight; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
395 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
396 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
397 if(priv->geom.columns > priv->maxwidth) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
398 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
399 priv->geom.columns = priv->maxwidth; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
400 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
401 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
402 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
403 if(req_mode == TV_NORM_SECAM) priv->iformat = METEOR_FMT_SECAM; |
5081 | 404 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
405 if(ioctl(priv->btfd, METEORSFMT, &priv->iformat) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
406 { |
24193 | 407 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSFMT", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
408 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
409 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
410 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
411 if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
412 { |
24193 | 413 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSETGEO", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
414 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
415 } |
5081 | 416 |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
417 tmp_fps = priv->fps; |
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
418 if(ioctl(priv->btfd, METEORSFPS, &tmp_fps) < 0) |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
419 { |
24193 | 420 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSFPS", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
421 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
422 } |
5081 | 423 |
10822
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
424 #ifdef BT848_SAUDIO |
12608
fbd18fae40f1
10l, patch by Michael Nottebrock <michaelnottebrock@gmx.net>
faust3
parents:
12140
diff
changeset
|
425 if(priv->tunerready == TRUE && |
23884 | 426 ioctl(priv->tunerfd, BT848_SAUDIO, &priv->tv_param->audio_id) < 0) |
10822
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
427 { |
24193 | 428 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "BT848_SAUDIO", strerror(errno)); |
10822
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
429 } |
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
430 #endif |
6377c7d0459e
audio id setting support for bsdbt848 by Nikolay Nikolaev <nicknickolaev@yahoo.com>
alex
parents:
10019
diff
changeset
|
431 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
432 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
433 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
434 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
435 case TVI_CONTROL_VID_GET_FORMAT: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
436 *(int *)arg = IMGFMT_UYVY; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
437 return(TVI_CONTROL_TRUE); |
5081 | 438 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
439 case TVI_CONTROL_VID_SET_FORMAT: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
440 { |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
441 int req_fmt = *(int *)arg; |
5081 | 442 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
443 if(req_fmt != IMGFMT_UYVY) return(TVI_CONTROL_FALSE); |
5081 | 444 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
445 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
446 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
447 case TVI_CONTROL_VID_SET_WIDTH: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
448 priv->geom.columns = *(int *)arg; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
449 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
450 if(priv->geom.columns > priv->maxwidth) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
451 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
452 priv->geom.columns = priv->maxwidth; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
453 } |
5081 | 454 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
455 if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
456 { |
24193 | 457 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorSettingWidth, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
458 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
459 } |
5081 | 460 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
461 return(TVI_CONTROL_TRUE); |
5081 | 462 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
463 case TVI_CONTROL_VID_GET_WIDTH: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
464 *(int *)arg = priv->geom.columns; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
465 return(TVI_CONTROL_TRUE); |
5081 | 466 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
467 case TVI_CONTROL_VID_SET_HEIGHT: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
468 priv->geom.rows = *(int *)arg; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
469 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
470 if(priv->geom.rows > priv->maxheight) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
471 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
472 priv->geom.rows = priv->maxheight; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
473 } |
5081 | 474 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
475 if(priv->geom.rows <= priv->maxheight / 2) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
476 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
477 priv->geom.oformat |= METEOR_GEO_EVEN_ONLY; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
478 } |
5081 | 479 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
480 if(ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
481 { |
24193 | 482 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorSettingWidth, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
483 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
484 } |
5081 | 485 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
486 return(TVI_CONTROL_TRUE); |
5081 | 487 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
488 case TVI_CONTROL_VID_GET_HEIGHT: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
489 *(int *)arg = priv->geom.rows; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
490 return(TVI_CONTROL_TRUE); |
5081 | 491 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
492 case TVI_CONTROL_VID_GET_FPS: |
10019 | 493 *(float *)arg = priv->fps; |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
494 return(TVI_CONTROL_TRUE); |
5081 | 495 |
496 /* | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
497 case TVI_CONTROL_VID_SET_FPS: |
20145
d7fbd215d8c9
Change occurrences of "(int)*(void **)arg" to "*(int *)arg".
uau
parents:
19431
diff
changeset
|
498 priv->fps = *(int *)arg; |
5081 | 499 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
500 if(priv->fps > priv->maxfps) priv->fps = priv->maxfps; |
5081 | 501 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
502 if(ioctl(priv->btfd, METEORSFPS, &priv->fps) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
503 { |
24193 | 504 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSFPS", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
505 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
506 } |
5081 | 507 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
508 return(TVI_CONTROL_TRUE); |
5081 | 509 */ |
510 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
511 case TVI_CONTROL_VID_CHK_WIDTH: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
512 case TVI_CONTROL_VID_CHK_HEIGHT: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
513 return(TVI_CONTROL_TRUE); |
5081 | 514 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
515 case TVI_CONTROL_IMMEDIATE: |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
516 priv->immediatemode = TRUE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
517 return(TVI_CONTROL_TRUE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
518 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
519 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
520 return(TVI_CONTROL_UNKNOWN); |
5081 | 521 } |
522 | |
523 static int init(priv_t *priv) | |
524 { | |
525 int marg; | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
526 int count; |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
527 u_short tmp_fps; |
5081 | 528 |
529 G_private = priv; /* Oooh, sick */ | |
530 | |
531 /* Video Configuration */ | |
532 | |
533 priv->videoready = TRUE; | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
534 priv->immediatemode = FALSE; |
5081 | 535 priv->iformat = METEOR_FMT_PAL; |
536 priv->maxheight = PAL_HEIGHT; | |
537 priv->maxwidth = PAL_WIDTH; | |
538 priv->maxfps = PAL_FPS; | |
539 priv->source = METEOR_INPUT_DEV0; | |
540 priv->fps = priv->maxfps; | |
541 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
542 priv->starttime=0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
543 priv->curpaintframe=0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
544 priv->curbufframe=0; |
5081 | 545 |
546 priv->geom.columns = priv->maxwidth; | |
547 priv->geom.rows = priv->maxheight; | |
548 priv->geom.frames = 1; | |
549 priv->geom.oformat = METEOR_GEO_YUV_PACKED; | |
550 | |
551 priv->btfd = open(priv->btdev, O_RDONLY); | |
552 | |
553 if(priv->btfd < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
554 { |
24193 | 555 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorOpeningBktrDev, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
556 priv->videoready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
557 } |
5081 | 558 |
559 if(priv->videoready == TRUE && | |
560 ioctl(priv->btfd, METEORSFMT, &priv->iformat) < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
561 { |
24193 | 562 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "SETEORSFMT", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
563 } |
5081 | 564 |
565 if(priv->videoready == TRUE && | |
566 ioctl(priv->btfd, METEORSINPUT, &priv->source) < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
567 { |
24193 | 568 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSINPUT", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
569 } |
5081 | 570 |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
571 tmp_fps = priv->fps; |
5081 | 572 if(priv->videoready == TRUE && |
12139
e34f9638aa51
correct typeconversion of fps, patches by several ppl
alex
parents:
11725
diff
changeset
|
573 ioctl(priv->btfd, METEORSFPS, &tmp_fps) < 0) |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
574 { |
24193 | 575 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSFPS", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
576 } |
5081 | 577 |
578 if(priv->videoready == TRUE && | |
579 ioctl(priv->btfd, METEORSETGEO, &priv->geom) < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
580 { |
24193 | 581 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSGEQ", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
582 } |
5081 | 583 |
584 if(priv->videoready == TRUE) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
585 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
586 priv->framebufsize = (priv->geom.columns * priv->geom.rows * 2); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
587 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
588 priv->livebuf = (u_char *)mmap((caddr_t)0, priv->framebufsize, PROT_READ, |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
589 MAP_SHARED, priv->btfd, (off_t)0); |
5081 | 590 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
591 if(priv->livebuf == (u_char *) MAP_FAILED) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
592 { |
24193 | 593 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848MmapFailed, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
594 priv->videoready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
595 } |
5081 | 596 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
597 for(count=0;count<RINGSIZE;count++) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
598 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
599 priv->framebuf[count].buf = malloc(priv->framebufsize); |
5081 | 600 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
601 if(priv->framebuf[count].buf == NULL) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
602 { |
24193 | 603 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848FrameBufAllocFailed, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
604 priv->videoready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
605 break; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
606 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
607 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
608 priv->framebuf[count].dirty = TRUE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
609 priv->framebuf[count].timestamp = 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
610 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
611 } |
5081 | 612 |
613 /* Tuner Configuration */ | |
614 | |
615 priv->tunerready = TRUE; | |
616 | |
617 priv->tunerfd = open(priv->tunerdev, O_RDONLY); | |
618 | |
619 if(priv->tunerfd < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
620 { |
24193 | 621 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorOpeningTunerDev, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
622 priv->tunerready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
623 } |
5081 | 624 |
625 /* Audio Configuration */ | |
626 | |
627 priv->dspready = TRUE; | |
628 priv->dspsamplesize = 16; | |
629 priv->dspstereo = 1; | |
630 priv->dspspeed = 44100; | |
631 priv->dspfmt = AFMT_S16_LE; | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
632 priv->dspbytesread = 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
633 priv->dsprate = priv->dspspeed * priv->dspsamplesize/8*(priv->dspstereo+1); |
5081 | 634 priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/priv->fps * |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
635 (priv->dspstereo+1); |
5081 | 636 |
12140 | 637 if((priv->dspfd = open (priv->dspdev, O_RDONLY, 0)) < 0) |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
638 { |
24193 | 639 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorOpeningDspDev, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
640 priv->dspready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
641 } |
5081 | 642 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
643 marg = (256 << 16) | 12; |
5081 | 644 |
645 if (ioctl(priv->dspfd, SNDCTL_DSP_SETFRAGMENT, &marg ) < 0 ) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
646 { |
24193 | 647 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "SNDCTL_DSP_SETFRAGMENT", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
648 priv->dspready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
649 } |
5081 | 650 |
651 if((priv->dspready == TRUE) && | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
652 ((ioctl(priv->dspfd, SNDCTL_DSP_SAMPLESIZE, &priv->dspsamplesize) == -1) || |
5081 | 653 (ioctl(priv->dspfd, SNDCTL_DSP_STEREO, &priv->dspstereo) == -1) || |
654 (ioctl(priv->dspfd, SNDCTL_DSP_SPEED, &priv->dspspeed) == -1) || | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
655 (ioctl(priv->dspfd, SNDCTL_DSP_SETFMT, &priv->dspfmt) == -1))) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
656 { |
24193 | 657 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorConfiguringDsp, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
658 close(priv->dspfd); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
659 priv->dspready = FALSE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
660 } |
5081 | 661 |
662 return(1); | |
663 } | |
664 | |
665 /* that's the real start, we'got the format parameters (checked with control) */ | |
666 static int start(priv_t *priv) | |
667 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
668 int tmp; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
669 struct timeval curtime; |
5081 | 670 int marg; |
671 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
672 fprintf(stderr,"START\n"); |
5081 | 673 if(priv->videoready == FALSE) return(0); |
674 | |
675 signal(SIGUSR1, processframe); | |
676 signal(SIGALRM, processframe); | |
677 | |
678 marg = SIGUSR1; | |
679 | |
680 if(ioctl(priv->btfd, METEORSSIGNAL, &marg) < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
681 { |
24193 | 682 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSSIGNAL", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
683 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
684 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
685 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
686 read(priv->dspfd, &tmp, 2); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
687 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
688 gettimeofday(&curtime, NULL); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
689 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
690 priv->starttime = curtime.tv_sec + (curtime.tv_usec *.000001); |
5081 | 691 |
692 marg = METEOR_CAP_CONTINOUS; | |
693 | |
694 if(ioctl(priv->btfd, METEORCAPTUR, &marg) < 0) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
695 { |
24193 | 696 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORCAPTUR", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
697 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
698 } |
5081 | 699 |
700 return(1); | |
701 } | |
702 | |
703 static int uninit(priv_t *priv) | |
704 { | |
705 int marg; | |
706 | |
707 if(priv->videoready == FALSE) return(0); | |
708 | |
709 marg = METEOR_SIG_MODE_MASK; | |
710 | |
711 if(ioctl( priv->btfd, METEORSSIGNAL, &marg) < 0 ) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
712 { |
24193 | 713 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "METEORSSIGNAL", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
714 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
715 } |
5081 | 716 |
717 marg = METEOR_CAP_STOP_CONT; | |
718 | |
719 if(ioctl(priv->btfd, METEORCAPTUR, &marg) < 0 ) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
720 { |
24193 | 721 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848UnableToStopCapture, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
722 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
723 } |
5081 | 724 |
725 close(priv->btfd); | |
726 close(priv->dspfd); | |
727 | |
728 priv->dspfd = -1; | |
729 priv->btfd = -1; | |
730 | |
731 priv->dspready = priv->videoready = FALSE; | |
732 | |
733 return(1); | |
734 } | |
735 | |
736 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
737 static double grabimmediate_video_frame(priv_t *priv, char *buffer, int len) |
5081 | 738 { |
739 sigset_t sa_mask; | |
740 | |
741 if(priv->videoready == FALSE) return(0); | |
742 | |
743 alarm(1); | |
744 sigfillset(&sa_mask); | |
745 sigdelset(&sa_mask,SIGINT); | |
746 sigdelset(&sa_mask,SIGUSR1); | |
747 sigdelset(&sa_mask,SIGALRM); | |
748 sigsuspend(&sa_mask); | |
749 alarm(0); | |
750 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
751 memcpy(buffer, priv->livebuf, len); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
752 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
753 /* PTS = 0, show the frame NOW, this routine is only used in playback mode |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
754 without audio capture .. */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
755 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
756 return(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
757 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
758 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
759 static double grab_video_frame(priv_t *priv, char *buffer, int len) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
760 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
761 double timestamp=0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
762 sigset_t sa_mask; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
763 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
764 if(priv->videoready == FALSE) return(0); |
5081 | 765 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
766 if(priv->immediatemode == TRUE) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
767 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
768 return grabimmediate_video_frame(priv, buffer, len); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
769 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
770 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
771 while(priv->framebuf[priv->curbufframe].dirty == TRUE) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
772 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
773 alarm(1); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
774 sigemptyset(&sa_mask); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
775 sigsuspend(&sa_mask); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
776 alarm(0); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
777 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
778 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
779 memcpy(buffer, priv->framebuf[priv->curbufframe].buf, len); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
780 timestamp = priv->framebuf[priv->curbufframe].timestamp; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
781 priv->framebuf[priv->curbufframe].dirty = TRUE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
782 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
783 priv->curbufframe++; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
784 if(priv->curbufframe >= RINGSIZE) priv->curbufframe = 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
785 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
786 return(timestamp-priv->starttime); |
5081 | 787 } |
788 | |
789 static int get_video_framesize(priv_t *priv) | |
790 { | |
791 return(priv->geom.columns*priv->geom.rows*16/8); | |
792 } | |
793 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
794 static double grab_audio_frame(priv_t *priv, char *buffer, int len) |
5081 | 795 { |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
796 struct timeval curtime; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
797 double curpts; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
798 double timeskew; |
5081 | 799 int bytesread; |
800 int ret; | |
801 | |
802 if(priv->dspready == FALSE) return 0; | |
803 | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
804 gettimeofday(&curtime, NULL); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
805 |
5081 | 806 /* Get exactly one frame of audio, which forces video sync to audio.. */ |
807 | |
808 bytesread=read(priv->dspfd, buffer, len); | |
809 | |
810 while(bytesread < len) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
811 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
812 ret=read(priv->dspfd, &buffer[bytesread], len-bytesread); |
5081 | 813 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
814 if(ret == -1) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
815 { |
24193 | 816 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848ErrorReadingAudio, strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
817 return 0; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
818 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
819 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
820 bytesread+=ret; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
821 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
822 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
823 priv->dspbytesread += bytesread; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
824 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
825 curpts = curtime.tv_sec + curtime.tv_usec * .000001; |
5081 | 826 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
827 timeskew = priv->dspbytesread * 1.0 / priv->dsprate - (curpts-priv->starttime); |
5081 | 828 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
829 if(timeskew > .125/priv->fps) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
830 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
831 priv->starttime -= timeskew; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
832 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
833 else |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
834 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
835 if(timeskew < -.125/priv->fps) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
836 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
837 priv->starttime -= timeskew; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
838 } |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
839 } |
5081 | 840 |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
841 return(priv->dspbytesread * 1.0 / priv->dsprate); |
5081 | 842 } |
843 | |
844 static int get_audio_framesize(priv_t *priv) | |
845 { | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
846 int bytesavail; |
22934 | 847 #ifdef USE_SUN_AUDIO |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
848 struct audio_info auinf; |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
849 #endif |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
850 |
5081 | 851 if(priv->dspready == FALSE) return 0; |
852 | |
22934 | 853 #ifdef USE_SUN_AUDIO |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
854 if(ioctl(priv->dspfd, AUDIO_GETINFO, &auinf) < 0) |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
855 { |
24193 | 856 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "AUDIO_GETINFO", strerror(errno)); |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
857 return(TVI_CONTROL_FALSE); |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
858 } |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
859 else |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
860 bytesavail = auinf.record.seek; /* *priv->dspsamplesize; */ |
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
861 #else |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
862 if(ioctl(priv->dspfd, FIONREAD, &bytesavail) < 0) |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
863 { |
24193 | 864 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "FIONREAD", strerror(errno)); |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
865 return(TVI_CONTROL_FALSE); |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
866 } |
11725
64137954a868
sync with netbsd ports: audio grabbing support fixed
alex
parents:
11723
diff
changeset
|
867 #endif |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
868 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
869 /* When mencoder wants audio data, it wants data.. |
11000 | 870 it won't go do anything else until it gets it :( */ |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
871 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
872 if(bytesavail == 0) return FRAGSIZE; |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
873 |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
874 return(bytesavail); |
5081 | 875 } |
876 | |
877 static int getinput(int innumber) | |
878 { | |
879 switch(innumber) | |
5572
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
880 { |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
881 case 0: return METEOR_INPUT_DEV0; /* RCA */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
882 case 1: return METEOR_INPUT_DEV1; /* Tuner */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
883 case 2: return METEOR_INPUT_DEV2; /* In 1 */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
884 case 3: return METEOR_INPUT_DEV3; /* In 2 */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
885 case 4: return METEOR_INPUT_DEV_RGB; /* RGB */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
886 case 5: return METEOR_INPUT_DEV_SVIDEO; /* SVid */ |
8cd761968f35
BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents:
5142
diff
changeset
|
887 } |
5081 | 888 |
889 return 0; | |
890 } |