1 /*
2 * Copyright (c) 2013 Lukasz Marek <lukasz.m.luki@gmail.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <pulse/simple.h>
22 #include <pulse/error.h>
29
39
41 {
45 pa_sample_spec ss;
46 pa_buffer_attr attr = { -1, -1, -1, -1, -1 };
48
52 }
54
55 if (!stream_name) {
58 else
59 stream_name = "Playback";
60 }
61
65
66 s->
pa = pa_simple_new(s->
server,
// Server
67 s->
name,
// Application name
68 PA_STREAM_PLAYBACK,
70 stream_name, // Description of a stream
71 &ss, // Sample format
72 NULL, // Use default channel map
73 &attr, // Buffering attributes
74 &ret); // Result
75
79 }
80
82
83 return 0;
84 }
85
87 {
89 pa_simple_flush(s->
pa, NULL);
90 pa_simple_free(s->
pa);
92 return 0;
93 }
94
96 {
98 int error;
99
100 if (!pkt) {
101 if (pa_simple_flush(s->
pa, &error) < 0) {
104 }
105 return 0;
106 }
107
110
113 } else {
119 }
120
121 if (pa_simple_write(s->
pa, pkt->
data, pkt->
size, &error) < 0) {
124 }
125
126 return 0;
127 }
128
130 {
132 pa_usec_t latency = pa_simple_get_latency(s->
pa, NULL);
135 }
136
137 #define OFFSET(a) offsetof(PulseData, a)
138 #define E AV_OPT_FLAG_ENCODING_PARAM
139
145 { NULL }
146 };
147
153 };
154
167 };