1 /*
2 * Pulseaudio input
3 * Copyright (c) 2011 Luca Barbato <lu_zero@gentoo.org>
4 *
5 * This file is part of Libav.
6 *
7 * Libav is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * Libav is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with Libav; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * PulseAudio input using the simple API.
25 * @author Luca Barbato <lu_zero@gentoo.org>
26 */
27
28 #include <pulse/simple.h>
29 #include <pulse/rtclock.h>
30 #include <pulse/error.h>
31
35
36 #define DEFAULT_CODEC_ID AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE)
37
51
53 switch (codec_id) {
65 default: return PA_SAMPLE_INVALID;
66 }
67 }
68
70 {
74 int ret;
80
81 pa_buffer_attr attr = { -1 };
82
84
85 if (!st) {
88 }
89
91
94
96 PA_STREAM_RECORD,
99
102 pa_strerror(ret));
104 }
105 /* take real parameters */
111
115
116 return 0;
117 }
118
120 {
122 int res;
123 pa_usec_t latency;
124
127 }
128
129 if ((pa_simple_read(pd->
s, pkt->
data, pkt->
size, &res)) < 0) {
131 pa_strerror(res));
134 }
135
136 if ((latency = pa_simple_get_latency(pd->
s, &res)) == (pa_usec_t) -1) {
138 pa_strerror(res));
140 }
141
144 }
145
147
149
150 return 0;
151 }
152
154 {
156 pa_simple_free(pd->
s);
157 return 0;
158 }
159
160 #define OFFSET(a) offsetof(PulseData, a)
161 #define D AV_OPT_FLAG_DECODING_PARAM
162
170 {
"fragment_size",
"buffering size, affects latency and cpu usage",
OFFSET(fragment_size),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX,
D },
172 };
173
179 };
180
189 .priv_class = &pulse_demuxer_class,
190 };