Mercurial > mplayer.hg
annotate libao2/ao_ivtv.c @ 31997:a3890036b137
Add proper include instead of declaring the vo_pts variable extern.
author | diego |
---|---|
date | Wed, 08 Sep 2010 18:16:06 +0000 |
parents | a465b54b0897 |
children | ddb9036e140a |
rev | line source |
---|---|
19224 | 1 /* |
26743
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
2 * audio output for WinTV PVR-150/250/350 (a.k.a IVTV) cards |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
3 * through Connexant hardware MPEG decoder |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
4 * See http://ivtvdriver.org/index.php/Main_Page for more details on the |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
5 * cards supported by the ivtv driver. |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
6 * |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
7 * WARNING: You need to force -ac hwmpa for audio output to work. |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
8 * |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
9 * Copyright (C) 2006 Benjamin Zores |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
10 * |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
11 * This file is part of MPlayer. |
19224 | 12 * |
26743
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
13 * MPlayer is free software; you can redistribute it and/or modify |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
14 * it under the terms of the GNU General Public License as published by |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
15 * the Free Software Foundation; either version 2 of the License, or |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
16 * (at your option) any later version. |
19224 | 17 * |
26743
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
18 * MPlayer is distributed in the hope that it will be useful, |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
21 * GNU General Public License for more details. |
19224 | 22 * |
26743
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
23 * You should have received a copy of the GNU General Public License along |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
24 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
0f42fb42843c
Use standard license headers with standard formatting.
diego
parents:
19224
diff
changeset
|
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19224 | 26 */ |
27 | |
28 #include <inttypes.h> | |
29 | |
30 #include "config.h" | |
31 | |
32 #include "mp_msg.h" | |
33 #include "help_mp.h" | |
34 | |
35 #include "audio_out.h" | |
36 #include "audio_out_internal.h" | |
37 #include "libaf/af_format.h" | |
38 #include "libmpdemux/mpeg_packetizer.h" | |
31353
a465b54b0897
Add header for ivtv_write() instead of forward declaring it.
diego
parents:
31352
diff
changeset
|
39 #include "libvo/vo_ivtv.h" |
31997
a3890036b137
Add proper include instead of declaring the vo_pts variable extern.
diego
parents:
31353
diff
changeset
|
40 #include "libvo/video_out.h" |
19224 | 41 |
42 #define MPEG_AUDIO_ID 0x1C0 | |
43 | |
44 static int freq = 0; | |
45 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
46 static const ao_info_t info = |
19224 | 47 { |
48 "IVTV MPEG Audio Decoder output", | |
49 "ivtv", | |
50 "Benjamin Zores", | |
51 "" | |
52 }; | |
53 | |
54 LIBAO_EXTERN(ivtv) | |
55 | |
56 /* to set/get/query special features/parameters */ | |
57 static int | |
58 control (int cmd,void *arg) | |
59 { | |
60 return CONTROL_UNKNOWN; | |
61 } | |
62 | |
63 /* open & setup audio device */ | |
64 static int | |
65 init (int rate, int channels, int format, int flags) | |
66 { | |
67 extern int ivtv_fd; | |
68 | |
69 if (ivtv_fd < 0) | |
70 return 0; | |
71 | |
72 if (format != AF_FORMAT_MPEG2) | |
73 { | |
74 mp_msg (MSGT_AO, MSGL_FATAL, | |
75 "AO: [ivtv] can only handle MPEG audio streams.\n"); | |
76 return 0; | |
77 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
78 |
19224 | 79 ao_data.outburst = 2048; |
80 ao_data.samplerate = rate; | |
81 ao_data.channels = channels; | |
82 ao_data.format = AF_FORMAT_MPEG2; | |
83 ao_data.buffersize = 2048; | |
84 ao_data.bps = rate * 2 * 2; | |
85 ao_data.pts = 0; | |
86 freq = rate; | |
87 | |
88 /* check for supported audio rate */ | |
89 if (rate != 32000 || rate != 41000 || rate != 48000) | |
90 { | |
91 mp_msg (MSGT_AO, MSGL_ERR, MSGTR_AO_MPEGPES_UnsupSamplerate, rate); | |
92 rate = 48000; | |
93 } | |
94 | |
95 return 1; | |
96 } | |
97 | |
98 /* close audio device */ | |
99 static void | |
100 uninit (int immed) | |
101 { | |
102 /* nothing to do */ | |
103 } | |
104 | |
105 /* stop playing and empty buffers (for seeking/pause) */ | |
106 static void | |
107 reset (void) | |
108 { | |
109 /* nothing to do */ | |
110 } | |
111 | |
112 /* stop playing, keep buffers (for pause) */ | |
113 static void | |
114 audio_pause (void) | |
115 { | |
116 reset (); | |
117 } | |
118 | |
119 /* resume playing, after audio_pause() */ | |
120 static void | |
121 audio_resume (void) | |
122 { | |
123 /* nothing to do */ | |
124 } | |
125 | |
126 /* how many bytes can be played without blocking */ | |
127 static int | |
128 get_space (void) | |
129 { | |
130 float x; | |
131 int y; | |
132 | |
133 x = (float) (vo_pts - ao_data.pts) / 90000.0; | |
134 if (x <= 0) | |
135 return 0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
136 |
19224 | 137 y = freq * 4 * x; |
138 y /= ao_data.outburst; | |
139 y *= ao_data.outburst; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
140 |
19224 | 141 if (y > 32000) |
142 y = 32000; | |
143 | |
144 return y; | |
145 } | |
146 | |
147 /* number of bytes played */ | |
148 static int | |
149 play (void *data, int len, int flags) | |
150 { | |
151 if (ao_data.format != AF_FORMAT_MPEG2) | |
152 return 0; | |
153 | |
154 send_mpeg_pes_packet (data, len, MPEG_AUDIO_ID, ao_data.pts, 2, ivtv_write); | |
155 | |
156 return len; | |
157 } | |
158 | |
159 /* delay in seconds between first and last sample in buffer */ | |
160 static float | |
161 get_delay (void) | |
162 { | |
163 return 0.0; | |
164 } |