annotate stream/tvi_bsdbt848.c @ 24387:13dcc81c0013

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