1 /*
2 * Pulseaudio common
3 * Copyright (c) 2014 Lukasz Marek
4 * Copyright (c) 2011 Luca Barbato <lu_zero@gentoo.org>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
28
30 {
43 default: return PA_SAMPLE_INVALID;
44 }
45 }
46
51 };
52
59
61 {
63
64 switch (pa_context_get_state(
c)) {
65 case PA_CONTEXT_FAILED:
66 case PA_CONTEXT_TERMINATED:
68 break;
69 case PA_CONTEXT_READY:
71 break;
72 default:
73 break;
74 }
75 }
76
78 {
81
82 if (*pa_ctx) {
83 pa_context_set_state_callback(*pa_ctx,
NULL,
NULL);
84 pa_context_disconnect(*pa_ctx);
85 pa_context_unref(*pa_ctx);
86 }
87 if (*pa_ml)
88 pa_mainloop_free(*pa_ml);
91 }
92
95 {
97 pa_mainloop_api *pa_mlapi =
NULL;
99
102
105
106 if (!(*pa_ml = pa_mainloop_new()))
108 if (!(pa_mlapi = pa_mainloop_get_api(*pa_ml))) {
111 }
112 if (!(*pa_ctx = pa_context_new(pa_mlapi,
description))) {
115 }
116 pa_context_set_state_callback(*pa_ctx,
pa_state_cb, &context_state);
117 if (pa_context_connect(*pa_ctx, server, 0,
NULL) < 0) {
120 }
121
123 pa_mainloop_iterate(*pa_ml, 1,
NULL);
127 }
128 return 0;
129
133 }
134
137 {
140
141 if (
info->error_code)
142 return;
143
145 if (!new_device) {
147 return;
148 }
149
152
156 }
157
159 &
info->devices->nb_devices, new_device)) < 0) {
162 }
163 return;
164
169
170 }
171
173 int eol, void *userdata)
174 {
175 if (!eol)
177 }
178
180 int eol, void *userdata)
181 {
182 if (!eol)
184 }
185
187 {
191 else
193 if (!
info->default_device)
195 }
196
198 {
199 pa_mainloop *pa_ml =
NULL;
200 pa_operation *pa_op =
NULL;
201 pa_context *pa_ctx =
NULL;
202 enum pa_operation_state op_state;
205
208 if (!devices)
212
215
218 else
220 while ((op_state = pa_operation_get_state(pa_op)) == PA_OPERATION_RUNNING)
221 pa_mainloop_iterate(pa_ml, 1,
NULL);
222 if (op_state != PA_OPERATION_DONE)
224 pa_operation_unref(pa_op);
227
229 while ((op_state = pa_operation_get_state(pa_op)) == PA_OPERATION_RUNNING)
230 pa_mainloop_iterate(pa_ml, 1,
NULL);
231 if (op_state != PA_OPERATION_DONE)
233 pa_operation_unref(pa_op);
236
241 break;
242 }
243 }
244
249 }