diff options
author | Lennart Poettering <lennart@poettering.net> | 2007-10-01 20:16:28 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2007-10-01 20:16:28 +0000 |
commit | 7d83e5c7816b5e343695a75ba58b32dbe1be969a (patch) | |
tree | bfd1dfc9b7c8f4a2aaf66c1b30e78355dee8c88a /test-pull.c | |
parent | 762196328ab7e60f1d2908fd5a337d2ca99726dd (diff) |
move all sources down to a seperate src/ tree
git-svn-id: file:///home/lennart/svn/public/libsydney/trunk@34 9ba3c220-e4d3-45a2-8aa3-73fcc9aff6ce
Diffstat (limited to 'test-pull.c')
-rw-r--r-- | test-pull.c | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/test-pull.c b/test-pull.c deleted file mode 100644 index 7f93906..0000000 --- a/test-pull.c +++ /dev/null @@ -1,73 +0,0 @@ -#include <errno.h> -#include <stdio.h> -#include <assert.h> -#include <string.h> -#include <unistd.h> - -#include "sydney.h" -#include "macro.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) - -#define FREQ 440 - -static const float data[4] = { 0.0, 1.0, 0.0, -1.0 }; - -static int callback(sa_stream_t *s, sa_event_t e) { - switch (e) { - case SA_EVENT_INIT_THREAD: - printf("Thread initialized.\n"); - return 0; - - case SA_EVENT_ERROR: { - int e; - ASSERT_SUCCESS(sa_stream_get_event_error(s, &e)); - printf("Error: %s\n", sa_strerror(e)); - return -1; - } - - case SA_EVENT_NOTIFY: - printf("Notified.\n"); - return 0; - - case SA_EVENT_REQUEST_IO: - - ASSERT_SUCCESS(sa_stream_write(s, data, sizeof(data))); - return 0; - - case _SA_EVENT_MAX: - ; - } - - sa_assert_not_reached(); -} - -int main(int argc, char *argv[]) { - - sa_stream_t *s; - - ASSERT_SUCCESS(sa_stream_create_pcm(&s, "Sine Test (pull)", SA_MODE_WRONLY, SA_PCM_FORMAT_FLOAT32_NE, FREQ * 4, 1)); - ASSERT_SUCCESS(sa_stream_change_device(s, "/dev/dsp1")); - ASSERT_SUCCESS(sa_stream_open(s)); - - ASSERT_SUCCESS(sa_stream_start_thread(s, callback)); - - sleep(20); - - ASSERT_SUCCESS(sa_stream_stop_thread(s)); - - ASSERT_SUCCESS(sa_stream_drain(s)); - - ASSERT_SUCCESS(sa_stream_destroy(s)); - - return 0; -} |