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