From 181e9c6d5d11cb1e5d36a2777eeb233ad8ed00e5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 9 Oct 2008 18:15:23 +0200 Subject: big pile of updates to match more what happened with libcanberra --- src/test-sine.c | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'src/test-sine.c') diff --git a/src/test-sine.c b/src/test-sine.c index 633fabb..9ea6b32 100644 --- a/src/test-sine.c +++ b/src/test-sine.c @@ -1,3 +1,23 @@ +/*** + This file is part of libsydney. + + Copyright 2007-2008 Lennart Poettering + + libsydney is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 2.1 of the + License, or (at your option) any later version. + + libsydney is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with libsydney. If not, see + . +***/ + #ifdef HAVE_CONFIG_H #include #endif @@ -8,47 +28,36 @@ #include #include "sydney.h" - -#define ASSERT_SUCCESS(x) do { \ - int _r; \ - if ((_r = x)) { \ - fprintf(stderr, "Operation <%s> failed: %s%s%s\n", \ - #x, \ - sa_strerror(_r), \ - _r == SA_ERROR_SYSTEM ? "; " : "", _r == SA_ERROR_SYSTEM ? strerror(errno) : ""); \ - } \ - assert(_r == SA_SUCCESS); \ -} while(0) +#include "macro.h" #define FREQ 440 int main(int argc, char *argv[]) { - sa_stream_t *s; + sa_stream *s; float data[4] = { 0.0, 1.0, 0.0, -1.0 }; int i, j; - ASSERT_SUCCESS(sa_stream_create_pcm(&s, "Sine Test", SA_MODE_WRONLY, SA_PCM_FORMAT_FLOAT32_NE, FREQ * 4, 1)); - ASSERT_SUCCESS(sa_stream_change_device(s, "/dev/dsp1")); - sa_stream_change_meta_data(s, SA_META_CLIENT_NAME, argv[0], strlen(argv[0])); - ASSERT_SUCCESS(sa_stream_open(s)); + sa_assert_se(sa_stream_create_pcm(&s, SA_MODE_WRONLY, SA_PCM_FORMAT_FLOAT32_NE, FREQ * 4, 1) == 0); + sa_assert_se(sa_stream_change_device(s, "/dev/dsp1") == 0); + sa_assert_se(sa_stream_open(s) == 0); for (j = 0; j < 10; j++) { int v; v = -j*500; -/* ASSERT_SUCCESS(sa_stream_change_rate(dev, FREQ*4+100*j)); */ - ASSERT_SUCCESS(sa_stream_change_write_volume(s, &v, 1)); +/* sa_assert_se(sa_stream_change_rate(dev, FREQ*4+100*j)); */ + sa_assert_se(sa_stream_change_write_volume(s, &v, 1)); for (i = 0; i < FREQ; i++) - ASSERT_SUCCESS(sa_stream_write(s, data, sizeof(data))); + sa_assert_se(sa_stream_write(s, data, sizeof(data))); } - ASSERT_SUCCESS(sa_stream_drain(s)); + sa_assert_se(sa_stream_drain(s)); - ASSERT_SUCCESS(sa_stream_destroy(s)); + sa_assert_se(sa_stream_destroy(s) == 0); return 0; } -- cgit