#ifdef HAVE_CONFIG_H #include #endif #include #include #include #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) #define FREQ 440 int main(int argc, char *argv[]) { sa_stream_t *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)); 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)); for (i = 0; i < FREQ; i++) ASSERT_SUCCESS(sa_stream_write(s, data, sizeof(data))); } ASSERT_SUCCESS(sa_stream_drain(s)); ASSERT_SUCCESS(sa_stream_destroy(s)); return 0; }