]>
code.delx.au - pulseaudio/blob - src/tests/stripnul.c
2f87e877631bbf6a48c2f16b28e49a8609cd01d6
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
30 #include <pulse/xmalloc.h>
31 #include <pulsecore/macro.h>
33 int main(int argc
, char *argv
[]) {
39 pa_assert_se(argc
>= 2);
40 pa_assert_se((granularity
= atoi(argv
[1])) >= 1);
41 pa_assert_se((i
= (argc
>= 3) ? fopen(argv
[2], "r") : stdin
));
42 pa_assert_se((o
= (argc
>= 4) ? fopen(argv
[3], "w") : stdout
));
44 zero
= pa_xmalloc0(granularity
);
47 uint8_t buffer
[16*1024], *p
;
50 k
= fread(buffer
, granularity
, sizeof(buffer
)/granularity
, i
);
56 pa_assert_se(fwrite(buffer
, granularity
, k
, o
) == k
);
58 for (p
= buffer
; (p
-buffer
)/granularity
< k
; p
+= granularity
)
59 if (memcmp(p
, zero
, granularity
)) {
62 left
= k
- (p
-buffer
)/granularity
;
63 pa_assert_se(fwrite(p
, granularity
, left
, o
) == left
);