]> code.delx.au - pulseaudio/blob - polyp/mcalign.h
add simple hardware auto detection module
[pulseaudio] / polyp / mcalign.h
1 #ifndef foomcalignhfoo
2 #define foomcalignhfoo
3
4 /* $Id$ */
5
6 /***
7 This file is part of polypaudio.
8
9 polypaudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as
11 published by the Free Software Foundation; either version 2.1 of the
12 License, or (at your option) any later version.
13
14 polypaudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with polypaudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 USA.
23 ***/
24
25 #include "memblock.h"
26 #include "memchunk.h"
27
28 /* An alignment object, used for aligning memchunks to multiples of
29 * the frame size. */
30
31 /* Method of operation: the user creates a new mcalign object by
32 * calling pa_mcalign_new() with the appropriate aligning
33 * granularity. After that he may call pa_mcalign_push() for an input
34 * memchunk. After exactly one memchunk the user has to call
35 * pa_mcalign_pop() until it returns -1. If pa_mcalign_pop() returns
36 * 0, the memchunk *c is valid and aligned to the granularity. Some
37 * pseudocode illustrating this:
38 *
39 * pa_mcalign *a = pa_mcalign_new(4, NULL);
40 *
41 * for (;;) {
42 * pa_memchunk input;
43 *
44 * ... fill input ...
45 *
46 * pa_mcalign_push(m, &input);
47 * pa_memblock_unref(input.memblock);
48 *
49 * for (;;) {
50 * pa_memchunk output;
51 *
52 * if (pa_mcalign_pop(m, &output) < 0)
53 * break;
54 *
55 * ... consume output ...
56 *
57 * pa_memblock_unref(output.memblock);
58 * }
59 * }
60 *
61 * pa_memchunk_free(a);
62 * */
63
64 typedef struct pa_mcalign pa_mcalign;
65
66 pa_mcalign *pa_mcalign_new(size_t base, pa_memblock_stat *s);
67 void pa_mcalign_free(pa_mcalign *m);
68
69 /* Push a new memchunk into the aligner. The caller of this routine
70 * has to free the memchunk by himself. */
71 void pa_mcalign_push(pa_mcalign *m, const pa_memchunk *c);
72
73 /* Pop a new memchunk from the aligner. Returns 0 when sucessful,
74 * nonzero otherwise. */
75 int pa_mcalign_pop(pa_mcalign *m, pa_memchunk *c);
76
77 #endif