4 This file is part of PulseAudio.
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
31 #include <pulse/xmalloc.h>
33 #include <pulsecore/sink-input.h>
34 #include <pulsecore/gccmacro.h>
36 #include "play-memblockq.h"
38 static void sink_input_kill(pa_sink_input
*i
) {
45 pa_sink_input_disconnect(i
);
46 pa_sink_input_unref(i
);
51 static int sink_input_peek(pa_sink_input
*i
, pa_memchunk
*chunk
) {
59 return pa_memblockq_peek(q
, chunk
);
62 static void si_kill(PA_GCC_UNUSED pa_mainloop_api
*m
, void *i
) {
66 static void sink_input_drop(pa_sink_input
*i
, const pa_memchunk
*chunk
, size_t length
) {
75 pa_memblockq_drop(q
, chunk
, length
);
77 if (pa_memblockq_get_length(q
) <= 0)
78 pa_mainloop_api_once(i
->sink
->core
->mainloop
, si_kill
, i
);
81 int pa_play_memblockq(
84 const pa_sample_spec
*ss
,
85 const pa_channel_map
*map
,
87 pa_cvolume
*cvolume
) {
95 if (pa_memblockq_get_length(q
) <= 0) {
100 if (cvolume
&& pa_cvolume_is_muted(cvolume
)) {
101 pa_memblockq_free(q
);
105 if (!(si
= pa_sink_input_new(sink
, name
, __FILE__
, ss
, map
, cvolume
, 0, PA_RESAMPLER_INVALID
)))
108 si
->peek
= sink_input_peek
;
109 si
->drop
= sink_input_drop
;
110 si
->kill
= sink_input_kill
;
114 pa_sink_notify(sink
);