]> code.delx.au - pulseaudio/blob - src/pulsecore/play-memchunk.c
commit glitch-free work
[pulseaudio] / src / pulsecore / play-memchunk.c
1 /* $Id$ */
2
3 /***
4 This file is part of PulseAudio.
5
6 Copyright 2004-2006 Lennart Poettering
7
8 PulseAudio is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published
10 by the Free Software Foundation; either version 2 of the License,
11 or (at your option) any later version.
12
13 PulseAudio is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with PulseAudio; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 USA.
22 ***/
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <string.h>
31
32 #include <pulse/xmalloc.h>
33
34 #include <pulsecore/sink-input.h>
35 #include <pulsecore/gccmacro.h>
36 #include <pulsecore/thread-mq.h>
37 #include <pulsecore/play-memblockq.h>
38
39 #include "play-memchunk.h"
40
41 int pa_play_memchunk(
42 pa_sink *sink,
43 const pa_sample_spec *ss,
44 const pa_channel_map *map,
45 const pa_memchunk *chunk,
46 pa_cvolume *volume,
47 pa_proplist *p,
48 uint32_t *sink_input_index) {
49
50 pa_memblockq *q;
51 int r;
52
53 pa_assert(sink);
54 pa_assert(ss);
55 pa_assert(chunk);
56
57 q = pa_memblockq_new(0, chunk->length, 0, pa_frame_size(ss), 0, 0, 0, NULL);
58 pa_assert_se(pa_memblockq_push(q, chunk) >= 0);
59
60 if ((r = pa_play_memblockq(sink, ss, map, q, volume, p, sink_input_index)) < 0) {
61 pa_memblockq_free(q);
62 return r;
63 }
64
65 return 0;
66 }