summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-05-13 00:49:21 +0000
committerLennart Poettering <lennart@poettering.net>2007-05-13 00:49:21 +0000
commit08ee90ea2e6ea839846c5670afa9d1a19c20ba78 (patch)
tree20179e14950b79d7057d16b95aea7c13274478cc
parente8ef97ff9e0ff4e4ab2b0f24b5d13e4a9c151ef1 (diff)
s/device/stream
git-svn-id: file:///home/lennart/svn/public/libsydney/trunk@7 9ba3c220-e4d3-45a2-8aa3-73fcc9aff6ce
-rw-r--r--TODO1
-rw-r--r--common.c468
-rw-r--r--common.h2
-rw-r--r--converter.c12
-rw-r--r--converter.h6
-rw-r--r--driver.h38
-rw-r--r--oss.c135
-rw-r--r--sydney.h92
-rw-r--r--test-sine.c22
9 files changed, 388 insertions, 388 deletions
diff --git a/TODO b/TODO
index c506e21..a6ef411 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,5 @@
* Replace all "input", "output" with "read", "write"
* Vielleicht client_name nicht erzwingen, stattdessen /proc/self/exename nehmen o..
-* s/sa_device/sa_stream/
* "adjust" channel map
* volume bei codecs?
* non-interleaved "int channel" -> "data[]"
diff --git a/common.c b/common.c
index ea9858c..7219ae5 100644
--- a/common.c
+++ b/common.c
@@ -11,10 +11,10 @@
/* contains code */
#include "meta-name-table.h"
-static sa_device_t *device_alloc(void) {
- sa_device_t *d;
+static sa_stream_t *stream_alloc(void) {
+ sa_stream_t *d;
- if (!(d = sa_new0(sa_device_t, 1)))
+ if (!(d = sa_new0(sa_stream_t, 1)))
return NULL;
/* All fields a carefully chosen in a way that initializing them
@@ -23,23 +23,23 @@ static sa_device_t *device_alloc(void) {
return d;
}
-int sa_device_create_opaque(
- sa_device_t **dev,
+int sa_stream_create_opaque(
+ sa_stream_t **s,
sa_mode_t mode,
const char *codec) {
int error;
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(mode == SA_MODE_RDONLY || mode == SA_MODE_WRONLY || mode == SA_MODE_RDWR, SA_ERROR_INVALID);
sa_return_val_if_fail(codec, SA_ERROR_INVALID);
- if (!(*dev = device_alloc()))
+ if (!(*s = stream_alloc()))
return SA_ERROR_OOM;
- (*dev)->mode = mode;
+ (*s)->mode = mode;
- if (!((*dev)->codec = sa_strdup(codec))) {
+ if (!((*s)->codec = sa_strdup(codec))) {
error = SA_ERROR_OOM;
goto fail;
}
@@ -49,12 +49,12 @@ int sa_device_create_opaque(
return SA_SUCCESS;
fail:
- sa_device_destroy(*dev);
+ sa_stream_destroy(*s);
return error;
}
-int sa_device_create_pcm(
- sa_device_t **dev,
+int sa_stream_create_pcm(
+ sa_stream_t **s,
sa_mode_t mode,
sa_pcm_format_t format,
unsigned rate,
@@ -62,30 +62,30 @@ int sa_device_create_pcm(
int ret;
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(mode == SA_MODE_RDONLY || mode == SA_MODE_WRONLY || mode == SA_MODE_RDWR, SA_ERROR_INVALID);
sa_return_val_if_fail(format < SA_PCM_FORMAT_MAX, SA_ERROR_INVALID);
sa_return_val_if_fail(rate > 0, SA_ERROR_INVALID);
sa_return_val_if_fail(nchannels > 0, SA_ERROR_INVALID);
- if (!(*dev = device_alloc()))
+ if (!(*s = stream_alloc()))
return SA_ERROR_OOM;
- (*dev)->mode = mode;
- (*dev)->pcm_attrs.format = format;
- (*dev)->pcm_attrs.nchannels = nchannels;
- (*dev)->pcm_sample_size = get_pcm_sample_size(format);
- (*dev)->pcm_frame_size = (*dev)->pcm_sample_size * nchannels;
+ (*s)->mode = mode;
+ (*s)->pcm_attrs.format = format;
+ (*s)->pcm_attrs.nchannels = nchannels;
+ (*s)->pcm_sample_size = get_pcm_sample_size(format);
+ (*s)->pcm_frame_size = (*s)->pcm_sample_size * nchannels;
if (nchannels <= 2) {
static const sa_channel_t map_stereo[2] = { SA_CHANNEL_LEFT, SA_CHANNEL_RIGHT };
static const sa_channel_t map_mono[1] = { SA_CHANNEL_MONO };
- if ((ret = sa_device_set_channel_map(*dev, nchannels == 2 ? map_stereo : map_mono)))
+ if ((ret = sa_stream_set_channel_map(*s, nchannels == 2 ? map_stereo : map_mono)))
goto fail;
}
- if ((ret = sa_device_change_rate(*dev, rate)))
+ if ((ret = sa_stream_change_rate(*s, rate)))
goto fail;
oil_init();
@@ -94,457 +94,457 @@ int sa_device_create_pcm(
fail:
- sa_device_destroy(*dev);
+ sa_stream_destroy(*s);
return ret;
}
-int sa_device_open(sa_device_t *dev) {
+int sa_stream_open(sa_stream_t *s) {
int ret;
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_STATE);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_STATE);
- if ((ret = device_open(dev)) == 0)
- dev->state = SA_STATE_STOPPED;
+ if ((ret = driver_open(s)) == 0)
+ s->state = SA_STATE_STOPPED;
return ret;
}
-int sa_device_destroy(sa_device_t *dev) {
+int sa_stream_destroy(sa_stream_t *s) {
int ret;
unsigned u;
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
- ret = device_destroy(dev);
+ ret = driver_destroy(s);
- sa_free(dev->codec);
- sa_free(dev->driver);
- sa_free(dev->device);
- sa_free(dev->pcm_attrs.channel_map);
- sa_free(dev->input_volume);
- sa_free(dev->output_volume);
+ sa_free(s->codec);
+ sa_free(s->driver);
+ sa_free(s->device);
+ sa_free(s->pcm_attrs.channel_map);
+ sa_free(s->input_volume);
+ sa_free(s->output_volume);
for (u = 0; u < META_NAMES_MAX; u++)
- sa_free(dev->meta_data[u]);
+ sa_free(s->meta_data[u]);
- sa_free(dev);
+ sa_free(s);
return ret;
}
-int sa_device_set_write_lower_watermark(sa_device_t *dev, size_t size) {
+int sa_stream_set_write_lower_watermark(sa_stream_t *s, size_t size) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(size > 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_STATE);
- dev->write_lower_watermark = size;
+ s->write_lower_watermark = size;
return SA_SUCCESS;
}
-int sa_device_set_read_lower_watermark(sa_device_t *dev, size_t size) {
+int sa_stream_set_read_lower_watermark(sa_stream_t *s, size_t size) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(size > 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_STATE);
- dev->read_lower_watermark = size;
+ s->read_lower_watermark = size;
return SA_SUCCESS;
}
-int sa_device_set_write_upper_watermark(sa_device_t *dev, size_t size) {
+int sa_stream_set_write_upper_watermark(sa_stream_t *s, size_t size) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(size > 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_STATE);
- dev->write_upper_watermark = size;
+ s->write_upper_watermark = size;
return SA_SUCCESS;
}
-int sa_device_set_read_upper_watermark(sa_device_t *dev, size_t size) {
+int sa_stream_set_read_upper_watermark(sa_stream_t *s, size_t size) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(size > 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_STATE);
- dev->read_upper_watermark = size;
+ s->read_upper_watermark = size;
return SA_SUCCESS;
}
-int sa_device_set_channel_map(sa_device_t *dev, const sa_channel_t *map) {
+int sa_stream_set_channel_map(sa_stream_t *s, const sa_channel_t *map) {
const sa_channel_t *c;
sa_channel_t *m;
unsigned n;
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(map, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_STATE);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_STATE);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_STATE);
- for (c = map, n = dev->pcm_attrs.nchannels; n > 0; c++, n--)
+ for (c = map, n = s->pcm_attrs.nchannels; n > 0; c++, n--)
if (*c >= SA_CHANNEL_MAX)
return SA_ERROR_INVALID;
- if (!(m = sa_memdup(map, sizeof(sa_channel_t) * dev->pcm_attrs.nchannels)))
+ if (!(m = sa_memdup(map, sizeof(sa_channel_t) * s->pcm_attrs.nchannels)))
return SA_ERROR_OOM;
- sa_free(dev->pcm_attrs.channel_map);
- dev->pcm_attrs.channel_map = m;
+ sa_free(s->pcm_attrs.channel_map);
+ s->pcm_attrs.channel_map = m;
return SA_SUCCESS;
}
-int sa_device_set_xrun_mode(sa_device_t *dev, sa_xrun_mode_t mode) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_set_xrun_mode(sa_stream_t *s, sa_xrun_mode_t mode) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(mode == SA_XRUN_MODE_STOP || mode == SA_XRUN_MODE_SPIN, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_STATE);
- dev->xrun_mode = mode;
+ s->xrun_mode = mode;
return SA_SUCCESS;
}
-int sa_device_set_ni(sa_device_t *dev, int enable) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_STATE);
+int sa_stream_set_ni(sa_stream_t *s, int enable) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_INVALID);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_STATE);
- dev->ni_enabled = !!enable;
+ s->ni_enabled = !!enable;
return SA_SUCCESS;
}
-int sa_device_set_dynamic_rate(sa_device_t *dev, int enable) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_STATE);
+int sa_stream_set_dynamic_rate(sa_stream_t *s, int enable) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_INVALID);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_STATE);
- dev->dynamic_rate_enabled = !!enable;
+ s->dynamic_rate_enabled = !!enable;
return SA_SUCCESS;
}
-int sa_device_set_driver(sa_device_t *dev, const char *driver) {
+int sa_stream_set_driver(sa_stream_t *s, const char *driver) {
char *d;
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(driver, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_STATE);
if (!(d = sa_strdup(driver)))
return SA_ERROR_OOM;
- sa_free(dev->driver);
- dev->driver = d;
+ sa_free(s->driver);
+ s->driver = d;
return SA_SUCCESS;
}
-int sa_device_start_thread(sa_device_t *dev, sa_event_callback_t *callback) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_start_thread(sa_stream_t *s, sa_event_callback_t *callback) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(callback, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->codec || dev->pcm_attrs.channel_map, SA_ERROR_NO_INIT);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->codec || s->pcm_attrs.channel_map, SA_ERROR_NO_INIT);
- return device_start_thread(dev, callback);
+ return driver_start_thread(s, callback);
}
-int sa_device_change_device(sa_device_t *dev, const char *device_name) {
+int sa_stream_change_device(sa_stream_t *s, const char *device_name) {
char *d;
int ret;
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(device_name, SA_ERROR_INVALID);
if (!(d = sa_strdup(device_name)))
return SA_ERROR_OOM;
- ret = dev->state == SA_STATE_INIT ? SA_SUCCESS : device_change_device(dev, device_name);
+ ret = s->state == SA_STATE_INIT ? SA_SUCCESS : driver_change_device(s, device_name);
if (ret == SA_SUCCESS) {
- sa_free(dev->device);
- dev->device = d;
+ sa_free(s->device);
+ s->device = d;
} else
sa_free(d);
return ret;
}
-int sa_device_change_input_volume(sa_device_t *dev, const int vol[]) {
+int sa_stream_change_input_volume(sa_stream_t *s, const int vol[]) {
int *v, ret;
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(vol, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_NOT_SUPPORTED);
- sa_return_val_if_fail(dev->mode & SA_MODE_RDONLY, SA_ERROR_STATE);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_NOT_SUPPORTED);
+ sa_return_val_if_fail(s->mode & SA_MODE_RDONLY, SA_ERROR_STATE);
- if (!(v = sa_newdup(vol, int, dev->pcm_attrs.nchannels)))
+ if (!(v = sa_newdup(vol, int, s->pcm_attrs.nchannels)))
return SA_ERROR_OOM;
- ret = dev->state == SA_STATE_INIT ? SA_SUCCESS : device_change_input_volume(dev, v);
+ ret = s->state == SA_STATE_INIT ? SA_SUCCESS : driver_change_input_volume(s, v);
if (ret == SA_SUCCESS) {
- sa_free(dev->input_volume);
- dev->input_volume = v;
+ sa_free(s->input_volume);
+ s->input_volume = v;
} else
sa_free(v);
return ret;
}
-int sa_device_change_output_volume(sa_device_t *dev, const int vol[]) {
+int sa_stream_change_output_volume(sa_stream_t *s, const int vol[]) {
int *v, ret;
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(vol, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_NOT_SUPPORTED);
- sa_return_val_if_fail(dev->mode & SA_MODE_WRONLY, SA_ERROR_STATE);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_NOT_SUPPORTED);
+ sa_return_val_if_fail(s->mode & SA_MODE_WRONLY, SA_ERROR_STATE);
- if (!(v = sa_newdup(vol, int, dev->pcm_attrs.nchannels)))
+ if (!(v = sa_newdup(vol, int, s->pcm_attrs.nchannels)))
return SA_ERROR_OOM;
- ret = dev->state == SA_STATE_INIT ? SA_SUCCESS : device_change_output_volume(dev, v);
+ ret = s->state == SA_STATE_INIT ? SA_SUCCESS : driver_change_output_volume(s, v);
if (ret == SA_SUCCESS) {
- sa_free(dev->output_volume);
- dev->output_volume = v;
+ sa_free(s->output_volume);
+ s->output_volume = v;
} else
sa_free(v);
return ret;
}
-int sa_device_change_rate(sa_device_t *dev, unsigned rate) {
+int sa_stream_change_rate(sa_stream_t *s, unsigned rate) {
int ret;
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(rate > 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->dynamic_rate_enabled || dev->state == SA_STATE_INIT, SA_ERROR_STATE);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->dynamic_rate_enabled || s->state == SA_STATE_INIT, SA_ERROR_STATE);
- ret = dev->state == SA_STATE_INIT ? SA_SUCCESS : device_change_rate(dev, rate);
+ ret = s->state == SA_STATE_INIT ? SA_SUCCESS : driver_change_rate(s, rate);
if (ret == SA_SUCCESS)
- dev->pcm_attrs.rate = rate;
+ s->pcm_attrs.rate = rate;
return ret;
}
-int sa_device_change_user_data(sa_device_t *dev, void *value) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_change_user_data(sa_stream_t *s, void *value) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
- dev->user_data = value;
+ s->user_data = value;
return SA_SUCCESS;
}
-int sa_device_adjust_rate(sa_device_t *dev, sa_adjust_t direction) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_STATE);
+int sa_stream_adjust_rate(sa_stream_t *s, sa_adjust_t direction) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_STATE);
- dev->adjust_rate = direction;
+ s->adjust_rate = direction;
return SA_SUCCESS;
}
-int sa_device_adjust_nchannels(sa_device_t *dev, sa_adjust_t direction) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_STATE);
+int sa_stream_adjust_nchannels(sa_stream_t *s, sa_adjust_t direction) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_STATE);
- dev->adjust_rate = direction;
+ s->adjust_rate = direction;
return SA_SUCCESS;
}
-int sa_device_adjust_pcm_format(sa_device_t *dev, sa_adjust_t direction) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->state == SA_STATE_INIT, SA_ERROR_STATE);
+int sa_stream_adjust_pcm_format(sa_stream_t *s, sa_adjust_t direction) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_INIT, SA_ERROR_STATE);
- dev->adjust_pcm_format = direction;
+ s->adjust_pcm_format = direction;
return SA_SUCCESS;
}
-int sa_device_get_state(sa_device_t *dev, sa_state_t *state) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_get_state(sa_stream_t *s, sa_state_t *state) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(state, SA_ERROR_INVALID);
- return device_get_state(dev, state);
+ return driver_get_state(s, state);
}
-int sa_device_get_rate(sa_device_t *dev, unsigned *rate) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_get_rate(sa_stream_t *s, unsigned *rate) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(rate, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_STATE);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_STATE);
- *rate = dev->pcm_attrs.rate;
+ *rate = s->pcm_attrs.rate;
return SA_SUCCESS;
}
-int sa_device_get_nchannels(sa_device_t *dev, int *nchannels) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_get_nchannels(sa_stream_t *s, int *nchannels) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(nchannels, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_STATE);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_STATE);
- *nchannels = dev->pcm_attrs.nchannels;
+ *nchannels = s->pcm_attrs.nchannels;
return SA_SUCCESS;
}
-int sa_device_get_pcm_format(sa_device_t *dev, sa_pcm_format_t *pcm_format) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_get_pcm_format(sa_stream_t *s, sa_pcm_format_t *pcm_format) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(pcm_format, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_STATE);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_STATE);
- *pcm_format = dev->pcm_attrs.format;
+ *pcm_format = s->pcm_attrs.format;
return SA_SUCCESS;
}
-int sa_device_get_user_data(sa_device_t *dev, void **value) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_get_user_data(sa_stream_t *s, void **value) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(value, SA_ERROR_INVALID);
- *value = dev->user_data;
+ *value = s->user_data;
return SA_SUCCESS;
}
-int sa_device_get_event_error(sa_device_t *dev, sa_error_t *error) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_get_event_error(sa_stream_t *s, sa_error_t *error) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(error, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->event == SA_EVENT_ERROR, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->event == SA_EVENT_ERROR, SA_ERROR_STATE);
- *error = dev->error;
+ *error = s->error;
return SA_SUCCESS;
}
-int sa_device_get_event_notify(sa_device_t *dev, sa_notify_t *notify) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_get_event_notify(sa_stream_t *s, sa_notify_t *notify) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(notify, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->event == SA_EVENT_NOTIFY, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->event == SA_EVENT_NOTIFY, SA_ERROR_STATE);
- *notify = dev->notify;
+ *notify = s->notify;
return SA_SUCCESS;
}
-int sa_device_get_position(sa_device_t *dev, sa_position_t position, int64_t *pos) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_get_position(sa_stream_t *s, sa_position_t position, int64_t *pos) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(pos, SA_ERROR_INVALID);
sa_return_val_if_fail(position < SA_POSITION_MAX, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_RUNNING || dev->state == SA_STATE_STOPPED, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_RUNNING || s->state == SA_STATE_STOPPED, SA_ERROR_STATE);
- return device_get_position(dev, position, pos);
+ return driver_get_position(s, position, pos);
}
-int sa_device_read(sa_device_t *dev, void *data, size_t nbytes) {
- return sa_device_pread(dev, data, nbytes, 0, SA_SEEK_RELATIVE);
+int sa_stream_read(sa_stream_t *s, void *data, size_t nbytes) {
+ return sa_stream_pread(s, data, nbytes, 0, SA_SEEK_RELATIVE);
}
-int sa_device_write(sa_device_t *dev, const void *data, size_t nbytes) {
- return sa_device_pwrite(dev, data, nbytes, 0, SA_SEEK_RELATIVE);
+int sa_stream_write(sa_stream_t *s, const void *data, size_t nbytes) {
+ return sa_stream_pwrite(s, data, nbytes, 0, SA_SEEK_RELATIVE);
}
-int sa_device_read_ni(sa_device_t *dev, unsigned channel, void *data, size_t nbytes) {
- return sa_device_pread_ni(dev, channel, data, nbytes, 0, SA_SEEK_RELATIVE);
+int sa_stream_read_ni(sa_stream_t *s, unsigned channel, void *data, size_t nbytes) {
+ return sa_stream_pread_ni(s, channel, data, nbytes, 0, SA_SEEK_RELATIVE);
}
-int sa_device_write_ni(sa_device_t *dev, unsigned channel, const void *data, size_t nbytes) {
- return sa_device_pwrite_ni(dev, channel, data, nbytes, 0, SA_SEEK_RELATIVE);
+int sa_stream_write_ni(sa_stream_t *s, unsigned channel, const void *data, size_t nbytes) {
+ return sa_stream_pwrite_ni(s, channel, data, nbytes, 0, SA_SEEK_RELATIVE);
}
-int sa_device_pread(sa_device_t *dev, void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_pread(sa_stream_t *s, void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(data, SA_ERROR_INVALID);
sa_return_val_if_fail(nbytes > 0, SA_ERROR_INVALID);
sa_return_val_if_fail(whence == SA_SEEK_RELATIVE || whence == SA_SEEK_ABSOLUTE || whence == SA_SEEK_RELATIVE_END, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->ni_enabled, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->codec || (nbytes % dev->pcm_frame_size) == 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->codec || (offset % dev->pcm_frame_size) == 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->mode & SA_MODE_RDONLY, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->state == SA_STATE_RUNNING || dev->state == SA_STATE_STOPPED, SA_ERROR_STATE);
+ sa_return_val_if_fail(!s->ni_enabled, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->codec || (nbytes % s->pcm_frame_size) == 0, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->codec || (offset % s->pcm_frame_size) == 0, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->mode & SA_MODE_RDONLY, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_RUNNING || s->state == SA_STATE_STOPPED, SA_ERROR_STATE);
- return device_pread(dev, data, nbytes, offset, whence);
+ return driver_pread(s, data, nbytes, offset, whence);
}
-int sa_device_pwrite(sa_device_t *dev, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_pwrite(sa_stream_t *s, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(data, SA_ERROR_INVALID);
sa_return_val_if_fail(nbytes > 0, SA_ERROR_INVALID);
sa_return_val_if_fail(whence == SA_SEEK_RELATIVE || whence == SA_SEEK_ABSOLUTE || whence == SA_SEEK_RELATIVE_END, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->ni_enabled, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->codec || (nbytes % dev->pcm_frame_size) == 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->codec || (offset % dev->pcm_frame_size) == 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->mode & SA_MODE_WRONLY, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->state == SA_STATE_RUNNING || dev->state == SA_STATE_STOPPED, SA_ERROR_STATE);
+ sa_return_val_if_fail(!s->ni_enabled, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->codec || (nbytes % s->pcm_frame_size) == 0, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->codec || (offset % s->pcm_frame_size) == 0, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->mode & SA_MODE_WRONLY, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_RUNNING || s->state == SA_STATE_STOPPED, SA_ERROR_STATE);
- return device_pwrite(dev, data, nbytes, offset, whence);
+ return driver_pwrite(s, data, nbytes, offset, whence);
}
-int sa_device_pread_ni(sa_device_t *dev, unsigned channel, void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_pread_ni(sa_stream_t *s, unsigned channel, void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(data, SA_ERROR_INVALID);
sa_return_val_if_fail(nbytes > 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_STATE);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_STATE);
sa_return_val_if_fail(whence == SA_SEEK_RELATIVE || whence == SA_SEEK_ABSOLUTE || whence == SA_SEEK_RELATIVE_END, SA_ERROR_INVALID);
- sa_return_val_if_fail(channel < dev->pcm_attrs.nchannels, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->ni_enabled, SA_ERROR_STATE);
- sa_return_val_if_fail((nbytes % dev->pcm_sample_size) == 0, SA_ERROR_INVALID);
- sa_return_val_if_fail((offset % dev->pcm_sample_size) == 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->mode & SA_MODE_RDONLY, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->state == SA_STATE_RUNNING || dev->state == SA_STATE_STOPPED, SA_ERROR_STATE);
+ sa_return_val_if_fail(channel < s->pcm_attrs.nchannels, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->ni_enabled, SA_ERROR_STATE);
+ sa_return_val_if_fail((nbytes % s->pcm_sample_size) == 0, SA_ERROR_INVALID);
+ sa_return_val_if_fail((offset % s->pcm_sample_size) == 0, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->mode & SA_MODE_RDONLY, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_RUNNING || s->state == SA_STATE_STOPPED, SA_ERROR_STATE);
- return device_pread_ni(dev, channel, data, nbytes, offset, whence);
+ return driver_pread_ni(s, channel, data, nbytes, offset, whence);
}
-int sa_device_pwrite_ni(sa_device_t *dev, unsigned channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_pwrite_ni(sa_stream_t *s, unsigned channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(data, SA_ERROR_INVALID);
sa_return_val_if_fail(nbytes > 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_STATE);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_STATE);
sa_return_val_if_fail(whence == SA_SEEK_RELATIVE || whence == SA_SEEK_ABSOLUTE || whence == SA_SEEK_RELATIVE_END, SA_ERROR_INVALID);
- sa_return_val_if_fail(channel < dev->pcm_attrs.nchannels, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->ni_enabled, SA_ERROR_STATE);
- sa_return_val_if_fail((nbytes % dev->pcm_sample_size) == 0, SA_ERROR_INVALID);
- sa_return_val_if_fail((offset % dev->pcm_sample_size) == 0, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->mode & SA_MODE_WRONLY, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->state == SA_STATE_RUNNING || dev->state == SA_STATE_STOPPED, SA_ERROR_STATE);
+ sa_return_val_if_fail(channel < s->pcm_attrs.nchannels, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->ni_enabled, SA_ERROR_STATE);
+ sa_return_val_if_fail((nbytes % s->pcm_sample_size) == 0, SA_ERROR_INVALID);
+ sa_return_val_if_fail((offset % s->pcm_sample_size) == 0, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->mode & SA_MODE_WRONLY, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_RUNNING || s->state == SA_STATE_STOPPED, SA_ERROR_STATE);
- return device_pwrite_ni(dev, channel, data, nbytes, offset, whence);
+ return driver_pwrite_ni(s, channel, data, nbytes, offset, whence);
}
-int sa_device_get_read_size(sa_device_t *dev, size_t *size) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_get_read_size(sa_stream_t *s, size_t *size) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(size, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->mode & SA_MODE_RDONLY, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->state == SA_STATE_RUNNING || dev->state == SA_STATE_STOPPED, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->mode & SA_MODE_RDONLY, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_RUNNING || s->state == SA_STATE_STOPPED, SA_ERROR_STATE);
- return device_get_read_size(dev, size);
+ return driver_get_read_size(s, size);
}
-int sa_device_get_write_size(sa_device_t *dev, size_t *size) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+int sa_stream_get_write_size(sa_stream_t *s, size_t *size) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(size, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->mode & SA_MODE_WRONLY, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->state == SA_STATE_RUNNING || dev->state == SA_STATE_STOPPED, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->mode & SA_MODE_WRONLY, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_RUNNING || s->state == SA_STATE_STOPPED, SA_ERROR_STATE);
- return device_get_write_size(dev, size);
+ return driver_get_write_size(s, size);
}
-int sa_device_resume(sa_device_t *dev) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_RUNNING || dev->state == SA_STATE_STOPPED, SA_ERROR_STATE);
+int sa_stream_resume(sa_stream_t *s) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->state == SA_STATE_RUNNING || s->state == SA_STATE_STOPPED, SA_ERROR_STATE);
- return device_resume(dev);
+ return driver_resume(s);
}
-int sa_device_pause(sa_device_t *dev) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->state == SA_STATE_RUNNING || dev->state == SA_STATE_STOPPED, SA_ERROR_STATE);
+int sa_stream_pause(sa_stream_t *s) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->state == SA_STATE_RUNNING || s->state == SA_STATE_STOPPED, SA_ERROR_STATE);
- return device_pause(dev);
+ return driver_pause(s);
}
-int sa_device_drain(sa_device_t *dev) {
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
- sa_return_val_if_fail(dev->mode & SA_MODE_WRONLY, SA_ERROR_STATE);
- sa_return_val_if_fail(dev->state == SA_STATE_RUNNING || dev->state == SA_STATE_STOPPED, SA_ERROR_STATE);
+int sa_stream_drain(sa_stream_t *s) {
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s->mode & SA_MODE_WRONLY, SA_ERROR_STATE);
+ sa_return_val_if_fail(s->state == SA_STATE_RUNNING || s->state == SA_STATE_STOPPED, SA_ERROR_STATE);
- return device_drain(dev);
+ return driver_drain(s);
}
size_t get_pcm_sample_size(sa_pcm_format_t f) {
@@ -652,7 +652,7 @@ static int meta_check_word(const void *data, size_t size) {
typedef int (*meta_check_func_t)(const void *data, size_t size);
-int sa_device_change_meta_data(sa_device_t *dev, const char *name, const void *data, size_t size) {
+int sa_stream_change_meta_data(sa_stream_t *s, const char *name, const void *data, size_t size) {
void *d = NULL;
const struct meta_name *m;
int ret;
@@ -668,7 +668,7 @@ int sa_device_change_meta_data(sa_device_t *dev, const char *name, const void *d
meta_check_word, /* FIXME */
};
- sa_return_val_if_fail(dev, SA_ERROR_INVALID);
+ sa_return_val_if_fail(s, SA_ERROR_INVALID);
sa_return_val_if_fail(name, SA_ERROR_INVALID);
sa_return_val_if_fail(data || size == 0, SA_ERROR_INVALID);
@@ -682,12 +682,12 @@ int sa_device_change_meta_data(sa_device_t *dev, const char *name, const void *d
if (!(d = sa_memdup(data, size)))
return SA_ERROR_OOM;
- ret = dev->state == SA_STATE_INIT ? SA_SUCCESS : device_change_meta_data(dev, name, data, size);
+ ret = s->state == SA_STATE_INIT ? SA_SUCCESS : driver_change_meta_data(s, name, data, size);
if (ret == SA_SUCCESS) {
- sa_free(dev->meta_data[m->idx]);
- dev->meta_data[m->idx] = d;
- dev->meta_data_size[m->idx] = size;
+ sa_free(s->meta_data[m->idx]);
+ s->meta_data[m->idx] = d;
+ s->meta_data_size[m->idx] = size;
}
return ret;
diff --git a/common.h b/common.h
index 16050df..ef92bb7 100644
--- a/common.h
+++ b/common.h
@@ -12,7 +12,7 @@ typedef struct pcm_attrs {
sa_channel_t *channel_map;
} pcm_attrs_t;
-struct sa_device {
+struct sa_stream {
sa_mode_t mode;
pcm_attrs_t pcm_attrs;
diff --git a/converter.c b/converter.c
index e49945c..f439b77 100644
--- a/converter.c
+++ b/converter.c
@@ -388,10 +388,10 @@ static void* get_zero_buffer(converter_t *c, size_t size) {
int converter_go(
converter_t *c,
const void *const src[], const size_t sstr[], int sinterleave,
- const void **dst[], size_t *dstr[], int dinterleave,
+ void **dst[], size_t *dstr[], int dinterleave,
size_t *size) {
- const size_t* stride;
+ size_t* stride;
void** process_data;
int is_bounce;
int interleave;
@@ -400,7 +400,7 @@ int converter_go(
sa_assert(c);
is_bounce = 0;
- stride = sstr;
+ stride = (size_t*) sstr;
process_data = (void**) src;
interleave = !!sinterleave;
dinterleave = !!dinterleave;
@@ -684,7 +684,7 @@ do_interleave:
return SA_SUCCESS;
}
-void converter_set_volume(converter_t *c, int vol[]) {
+void converter_set_volume(converter_t *c, const int vol[]) {
unsigned i;
int no_volume = 1;
@@ -715,7 +715,7 @@ void converter_set_volume(converter_t *c, int vol[]) {
int converter_go_interleaved(
converter_t *c,
const void *const data,
- const void **dst[], size_t *dstr[], int dinterleave,
+ void **dst[], size_t *dstr[], int dinterleave,
size_t *size) {
unsigned i;
@@ -728,7 +728,7 @@ int converter_go_interleaved(
c->from_stride[i] = stride;
}
- return converter_go(c, c->from_process_data, c->from_stride, 1, dst, dstr, dinterleave, size);
+ return converter_go(c, (const void *const*) c->from_process_data, c->from_stride, 1, dst, dstr, dinterleave, size);
}
void converter_set_ratio(converter_t *c, unsigned rate1, unsigned rate2) {
diff --git a/converter.h b/converter.h
index 5be03dc..a4592f1 100644
--- a/converter.h
+++ b/converter.h
@@ -64,16 +64,16 @@ void converter_done(converter_t *c);
int converter_go(
converter_t *c,
const void *const src[], const size_t sstr[], int sinterleave,
- const void **dst[], size_t *dstr[], int dinterleave,
+ void **dst[], size_t *dstr[], int dinterleave,
size_t *size);
int converter_go_interleaved(
converter_t *c,
const void *const data,
- const void **dst[], size_t *dstr[], int dinterleave,
+ void **dst[], size_t *dstr[], int dinterleave,
size_t *size);
-void converter_set_volume(converter_t *c, int vol[]);
+void converter_set_volume(converter_t *c, const int vol[]);
void converter_set_ratio(converter_t *c, unsigned rate1, unsigned rate2);
diff --git a/driver.h b/driver.h
index 0eee0ed..98f65a6 100644
--- a/driver.h
+++ b/driver.h
@@ -3,26 +3,26 @@
#include "sydney.h"
-int device_open(sa_device_t *dev);
-int device_destroy(sa_device_t *dev);
-int device_start_thread(sa_device_t *dev, sa_event_callback_t *callback);
+int driver_open(sa_stream_t *dev);
+int driver_destroy(sa_stream_t *dev);
+int driver_start_thread(sa_stream_t *dev, sa_event_callback_t *callback);
-int device_change_device(sa_device_t *dev, const char *device_name);
-int device_change_input_volume(sa_device_t *dev, const int vol[]);
-int device_change_output_volume(sa_device_t *dev, const int vol[]);
-int device_change_rate(sa_device_t *dev, unsigned rate);
-int device_change_meta_data(sa_device_t *dev, const char *name, const void *data, size_t size);
+int driver_change_device(sa_stream_t *dev, const char *device_name);
+int driver_change_input_volume(sa_stream_t *dev, const int vol[]);
+int driver_change_output_volume(sa_stream_t *dev, const int vol[]);
+int driver_change_rate(sa_stream_t *dev, unsigned rate);
+int driver_change_meta_data(sa_stream_t *dev, const char *name, const void *data, size_t size);
-int device_get_state(sa_device_t *dev, sa_state_t *state);
-int device_get_position(sa_device_t *dev, sa_position_t position, int64_t *pos);
-int device_pread(sa_device_t *dev, void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
-int device_pwrite(sa_device_t *dev, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
-int device_pread_ni(sa_device_t *dev, unsigned channel, void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
-int device_pwrite_ni(sa_device_t *dev, unsigned channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
-int device_get_read_size(sa_device_t *dev, size_t *size);
-int device_get_write_size(sa_device_t *dev, size_t *size);
-int device_resume(sa_device_t *dev);
-int device_pause(sa_device_t *dev);
-int device_drain(sa_device_t *dev);
+int driver_get_state(sa_stream_t *dev, sa_state_t *state);
+int driver_get_position(sa_stream_t *dev, sa_position_t position, int64_t *pos);
+int driver_pread(sa_stream_t *dev, void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
+int driver_pwrite(sa_stream_t *dev, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
+int driver_pread_ni(sa_stream_t *dev, unsigned channel, void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
+int driver_pwrite_ni(sa_stream_t *dev, unsigned channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
+int driver_get_read_size(sa_stream_t *dev, size_t *size);
+int driver_get_write_size(sa_stream_t *dev, size_t *size);
+int driver_resume(sa_stream_t *dev);
+int driver_pause(sa_stream_t *dev);
+int driver_drain(sa_stream_t *dev);
#endif
diff --git a/oss.c b/oss.c
index bd4f12b..0a80379 100644
--- a/oss.c
+++ b/oss.c
@@ -10,22 +10,23 @@
#include "macro.h"
#include "malloc.h"
#include "converter.h"
+#include "driver.h"
#define DEFAULT_DEVICE "/dev/dsp"
#define DRIVER_NAME "oss"
-typedef struct oss_device oss_device_t;
-#define OSS_DEVICE(x) ((oss_device_t*) (x->private))
+typedef struct oss_stream oss_stream_t;
+#define OSS_STREAM(x) ((oss_stream_t*) (x->private))
-struct oss_device {
- sa_device_t *parent;
+struct oss_stream {
+ sa_stream_t *parent;
int fd;
pcm_attrs_t real_pcm_attrs;
converter_t converter_read, converter_write;
};
-int device_open(sa_device_t *dev) {
- oss_device_t *oss;
+int driver_open(sa_stream_t *s) {
+ oss_stream_t *oss;
char *n;
int f, arg, bs, r, phase, i, found, suggested;
unsigned c;
@@ -45,16 +46,16 @@ int device_open(sa_device_t *dev) {
};
static const int try_rates[] = { 8000, 16000, 32000, 44100, 48000, 96000, 192000 };
- if (dev->driver && strcmp(dev->driver, DRIVER_NAME))
+ if (s->driver && strcmp(s->driver, DRIVER_NAME))
return SA_ERROR_NO_DRIVER;
- if (!(dev->private = oss = sa_new0(oss_device_t, 1)))
+ if (!(s->private = oss = sa_new0(oss_stream_t, 1)))
return SA_ERROR_OOM;
- oss->parent = dev;
+ oss->parent = s;
- n = dev->device ? dev->device : DEFAULT_DEVICE;
- if ((oss->fd = open(n, dev->mode == SA_MODE_RDONLY ? O_RDONLY : (dev->mode == SA_MODE_WRONLY ? O_WRONLY : O_RDWR) | O_NOCTTY | O_NONBLOCK)) < 0) {
+ n = s->device ? s->device : DEFAULT_DEVICE;
+ if ((oss->fd = open(n, s->mode == SA_MODE_RDONLY ? O_RDONLY : (s->mode == SA_MODE_WRONLY ? O_WRONLY : O_RDWR) | O_NOCTTY | O_NONBLOCK)) < 0) {
if (errno == ENODEV || errno == ENOENT)
return SA_ERROR_NO_DEVICE;
@@ -64,24 +65,24 @@ int device_open(sa_device_t *dev) {
fcntl(oss->fd, F_SETFL, fcntl(oss->fd, F_GETFL) & ~O_NONBLOCK); /* FIXME*/
- if (!dev->device) {
+ if (!s->device) {
if (!(n = sa_strdup(n)))
return SA_ERROR_OOM;
- dev->device = n;
+ s->device = n;
}
- if (dev->codec) {
+ if (s->codec) {
- if (strcmp(dev->codec, SA_CODEC_AC3) == 0)
+ if (strcmp(s->codec, SA_CODEC_AC3) == 0)
f = AFMT_AC3;
- else if (strcmp(dev->codec, SA_CODEC_MPEG) == 0)
+ else if (strcmp(s->codec, SA_CODEC_MPEG) == 0)
f = AFMT_MPEG;
else
return SA_ERROR_NO_CODEC;
} else
- f = format_map[dev->pcm_attrs.format];
+ f = format_map[s->pcm_attrs.format];
bs = 0;
@@ -120,7 +121,7 @@ int device_open(sa_device_t *dev) {
return SA_ERROR_NO_PCM_FORMAT;
}
- if (!dev->codec) {
+ if (!s->codec) {
switch (f) {
case AFMT_MU_LAW:
@@ -150,10 +151,10 @@ int device_open(sa_device_t *dev) {
found = 0;
- if (dev->adjust_nchannels >= 0) {
+ if (s->adjust_nchannels >= 0) {
/* First try more channels ... */
- for (c = dev->pcm_attrs.nchannels; c < 8 || c == dev->pcm_attrs.nchannels; c ++) {
+ for (c = s->pcm_attrs.nchannels; c < 8 || c == s->pcm_attrs.nchannels; c ++) {
arg = c;
if (ioctl(oss->fd, SNDCTL_DSP_CHANNELS, &arg) < 0)
return SA_ERROR_SYSTEM;
@@ -166,7 +167,7 @@ int device_open(sa_device_t *dev) {
/* ... then try less channels */
if (!found) {
- for (c = dev->pcm_attrs.nchannels - 1; c > 0; c --) {
+ for (c = s->pcm_attrs.nchannels - 1; c > 0; c --) {
arg = c;
if (ioctl(oss->fd, SNDCTL_DSP_CHANNELS, &arg) < 0)
return SA_ERROR_SYSTEM;
@@ -180,7 +181,7 @@ int device_open(sa_device_t *dev) {
} else {
/* First try less channels ... */
- for (c = dev->pcm_attrs.nchannels; c > 0; c --) {
+ for (c = s->pcm_attrs.nchannels; c > 0; c --) {
arg = c;
if (ioctl(oss->fd, SNDCTL_DSP_CHANNELS, &arg) < 0)
return SA_ERROR_SYSTEM;
@@ -193,7 +194,7 @@ int device_open(sa_device_t *dev) {
/* ... then try more channels */
if (!found) {
- for (c = dev->pcm_attrs.nchannels + 1; c < 8; c ++) {
+ for (c = s->pcm_attrs.nchannels + 1; c < 8; c ++) {
arg = c;
if (ioctl(oss->fd, SNDCTL_DSP_CHANNELS, &arg) < 0)
return SA_ERROR_SYSTEM;
@@ -238,7 +239,7 @@ int device_open(sa_device_t *dev) {
break;
}
- r = dev->pcm_attrs.rate;
+ r = s->pcm_attrs.rate;
if (r < 8000)
r = 8000;
@@ -260,7 +261,7 @@ int device_open(sa_device_t *dev) {
if (arg > suggested)
suggested = arg;
- if (dev->adjust_rate >= 0) {
+ if (s->adjust_rate >= 0) {
if (phase == 0) {
/* Find the next higher sample rate to try */
@@ -277,7 +278,7 @@ int device_open(sa_device_t *dev) {
if (i == elementsof(try_rates)) {
phase = 1;
- r = dev->pcm_attrs.rate;
+ r = s->pcm_attrs.rate;
}
}
@@ -312,7 +313,7 @@ int device_open(sa_device_t *dev) {
if (i == 0) {
phase = 1;
- r = dev->pcm_attrs.rate;
+ r = s->pcm_attrs.rate;
}
}
@@ -339,27 +340,27 @@ int device_open(sa_device_t *dev) {
printf("Chosen: %u channels, %uHz, format=%u\n", oss->real_pcm_attrs.nchannels, oss->real_pcm_attrs.rate, oss->real_pcm_attrs.format);
- if (dev->adjust_nchannels != 0)
- dev->pcm_attrs.nchannels = oss->real_pcm_attrs.nchannels;
- if (dev->adjust_rate != 0)
- dev->pcm_attrs.rate = oss->real_pcm_attrs.rate;
- if (dev->adjust_pcm_format != 0)
- dev->pcm_attrs.format = oss->real_pcm_attrs.format;
+ if (s->adjust_nchannels != 0)
+ s->pcm_attrs.nchannels = oss->real_pcm_attrs.nchannels;
+ if (s->adjust_rate != 0)
+ s->pcm_attrs.rate = oss->real_pcm_attrs.rate;
+ if (s->adjust_pcm_format != 0)
+ s->pcm_attrs.format = oss->real_pcm_attrs.format;
- if (dev->mode & SA_MODE_RDONLY)
- if ((r = converter_init(&oss->converter_read, &oss->real_pcm_attrs, &dev->pcm_attrs, dev->dynamic_rate_enabled)) < 0)
+ if (s->mode & SA_MODE_RDONLY)
+ if ((r = converter_init(&oss->converter_read, &oss->real_pcm_attrs, &s->pcm_attrs, s->dynamic_rate_enabled)) < 0)
return r;
- if (dev->mode & SA_MODE_WRONLY)
- if ((r = converter_init(&oss->converter_write, &dev->pcm_attrs, &oss->real_pcm_attrs, dev->dynamic_rate_enabled)) < 0)
+ if (s->mode & SA_MODE_WRONLY)
+ if ((r = converter_init(&oss->converter_write, &s->pcm_attrs, &oss->real_pcm_attrs, s->dynamic_rate_enabled)) < 0)
return r;
}
return SA_SUCCESS;
}
-int device_destroy(sa_device_t *dev) {
- oss_device_t *oss = OSS_DEVICE(dev);
+int driver_destroy(sa_stream_t *s) {
+ oss_stream_t *oss = OSS_STREAM(s);
if (oss->fd >= 0)
close(oss->fd);
@@ -371,55 +372,55 @@ int device_destroy(sa_device_t *dev) {
return SA_SUCCESS;
}
-int device_start_thread(sa_device_t *dev, sa_event_callback_t *callback) {
+int driver_start_thread(sa_stream_t *s, sa_event_callback_t *callback) {
return SA_ERROR_NOT_SUPPORTED;
}
-int device_change_input_volume(sa_device_t *dev, int vol[]) {
- oss_device_t *oss = OSS_DEVICE(dev);
+int driver_change_input_volume(sa_stream_t *s, const int vol[]) {
+ oss_stream_t *oss = OSS_STREAM(s);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_NOT_SUPPORTED);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_NOT_SUPPORTED);
converter_set_volume(&oss->converter_read, vol);
return SA_SUCCESS;
}
-int device_change_output_volume(sa_device_t *dev, int vol[]) {
- oss_device_t *oss = OSS_DEVICE(dev);
+int driver_change_output_volume(sa_stream_t *s, const int vol[]) {
+ oss_stream_t *oss = OSS_STREAM(s);
- sa_return_val_if_fail(!dev->codec, SA_ERROR_NOT_SUPPORTED);
+ sa_return_val_if_fail(!s->codec, SA_ERROR_NOT_SUPPORTED);
converter_set_volume(&oss->converter_write, vol);
return SA_SUCCESS;
}
-int device_change_rate(sa_device_t *dev, unsigned rate) {
- oss_device_t *oss = OSS_DEVICE(dev);
+int driver_change_rate(sa_stream_t *s, unsigned rate) {
+ oss_stream_t *oss = OSS_STREAM(s);
- if (dev->mode & SA_MODE_RDONLY)
- converter_set_ratio(&oss->converter_read, oss->real_pcm_attrs.rate, dev->pcm_attrs.rate);
- if (dev->mode & SA_MODE_WRONLY)
- converter_set_ratio(&oss->converter_write, dev->pcm_attrs.rate, oss->real_pcm_attrs.rate);
+ if (s->mode & SA_MODE_RDONLY)
+ converter_set_ratio(&oss->converter_read, oss->real_pcm_attrs.rate, s->pcm_attrs.rate);
+ if (s->mode & SA_MODE_WRONLY)
+ converter_set_ratio(&oss->converter_write, s->pcm_attrs.rate, oss->real_pcm_attrs.rate);
return SA_SUCCESS;
}
-int device_get_state(sa_device_t *dev, sa_state_t *state) {
+int driver_get_state(sa_stream_t *s, sa_state_t *state) {
return SA_ERROR_NOT_SUPPORTED;
}
-int device_get_position(sa_device_t *dev, sa_position_t position, int64_t *pos) {
+int driver_get_position(sa_stream_t *s, sa_position_t position, int64_t *pos) {
return SA_ERROR_NOT_SUPPORTED;
}
-int device_pread(sa_device_t *dev, void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
+int driver_pread(sa_stream_t *s, void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
return SA_ERROR_NOT_SUPPORTED;
}
-int device_pwrite(sa_device_t *dev, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
- oss_device_t *oss = OSS_DEVICE(dev);
+int driver_pwrite(sa_stream_t *s, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
+ oss_stream_t *oss = OSS_STREAM(s);
void **dst;
size_t *stride;
int ret;
@@ -445,32 +446,32 @@ int device_pwrite(sa_device_t *dev, const void *data, size_t nbytes, int64_t off
return SA_SUCCESS;
}
-int device_pread_ni(sa_device_t *dev, unsigned channel, void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
+int driver_pread_ni(sa_stream_t *s, unsigned channel, void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
return SA_ERROR_NOT_SUPPORTED;
}
-int device_pwrite_ni(sa_device_t *dev, unsigned channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
+int driver_pwrite_ni(sa_stream_t *s, unsigned channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence) {
return SA_ERROR_NOT_SUPPORTED;
}
-int device_get_read_size(sa_device_t *dev, size_t *size) {
+int driver_get_read_size(sa_stream_t *s, size_t *size) {
return SA_ERROR_NOT_SUPPORTED;
}
-int device_get_write_size(sa_device_t *dev, size_t *size) {
+int driver_get_write_size(sa_stream_t *s, size_t *size) {
return SA_ERROR_NOT_SUPPORTED;
}
-int device_resume(sa_device_t *dev) {
+int driver_resume(sa_stream_t *s) {
return SA_ERROR_NOT_SUPPORTED;
}
-int device_pause(sa_device_t *dev) {
+int driver_pause(sa_stream_t *s) {
return SA_ERROR_NOT_SUPPORTED;
}
-int device_drain(sa_device_t *dev) {
- oss_device_t *oss = OSS_DEVICE(dev);
+int driver_drain(sa_stream_t *s) {
+ oss_stream_t *oss = OSS_STREAM(s);
if (ioctl(oss->fd, SNDCTL_DSP_SYNC, NULL) < 0)
return SA_ERROR_SYSTEM;
@@ -480,10 +481,10 @@ int device_drain(sa_device_t *dev) {
/* Unsupported operations */
-int device_change_device(sa_device_t *dev) {
+int driver_change_device(sa_stream_t *s, const char *device) {
return SA_ERROR_NOT_SUPPORTED;
}
-int device_change_meta_data(sa_device_t *dev, const char *name, const void *data, size_t size) {
+int driver_change_meta_data(sa_stream_t *s, const char *name, const void *data, size_t size) {
return SA_ERROR_NOT_SUPPORTED;
}
diff --git a/sydney.h b/sydney.h
index ecb10bc..7c67f86 100644
--- a/sydney.h
+++ b/sydney.h
@@ -27,7 +27,7 @@ async-signal safe.
# error "Cannot determine byte order!"
#endif
-typedef struct sa_device sa_device_t;
+typedef struct sa_stream sa_stream_t;
/** Volume that corresponds to muted in/out */
#define SA_VOLUME_MUTED 0x80000000
@@ -225,95 +225,95 @@ typedef enum {
#define SA_META_XID "sydney.xid" /* X11 window id */
/** Main callback function */
-typedef int (*sa_event_callback_t)(sa_device_t *dev, sa_event_t event);
+typedef int (*sa_event_callback_t)(sa_stream_t *dev, sa_event_t event);
/** Create an opaque (e.g. AC3) codec stream */
-int sa_device_create_opaque(sa_device_t **dev, sa_mode_t mode, const char *codec);
+int sa_stream_create_opaque(sa_stream_t **dev, sa_mode_t mode, const char *codec);
/** Normal way to open a PCM device */
-int sa_device_create_pcm(sa_device_t **dev, sa_mode_t mode, sa_pcm_format_t format, unsigned rate, unsigned nchannels);
+int sa_stream_create_pcm(sa_stream_t **dev, sa_mode_t mode, sa_pcm_format_t format, unsigned rate, unsigned nchannels);
/** Initialise the device */
-int sa_device_open(sa_device_t *dev);
+int sa_stream_open(sa_stream_t *dev);
/** Close/destroy everything */
-int sa_device_destroy(sa_device_t *dev);
+int sa_stream_destroy(sa_stream_t *dev);
/* "Soft" params */
-int sa_device_set_write_lower_watermark(sa_device_t *dev, size_t size);
-int sa_device_set_read_lower_watermark(sa_device_t *dev, size_t size);
+int sa_stream_set_write_lower_watermark(sa_stream_t *dev, size_t size);
+int sa_stream_set_read_lower_watermark(sa_stream_t *dev, size_t size);
-int sa_device_set_write_upper_watermark(sa_device_t *dev, size_t size);
-int sa_device_set_read_upper_watermark(sa_device_t *dev, size_t size);
+int sa_stream_set_write_upper_watermark(sa_stream_t *dev, size_t size);
+int sa_stream_set_read_upper_watermark(sa_stream_t *dev, size_t size);
/** Set the mapping between channels and the loudspeakers */
-int sa_device_set_channel_map(sa_device_t *dev, const sa_channel_t map[]);
+int sa_stream_set_channel_map(sa_stream_t *dev, const sa_channel_t map[]);
/** Whether xruns cause the card to reset */
-int sa_device_set_xrun_mode(sa_device_t *dev, sa_xrun_mode_t mode);
+int sa_stream_set_xrun_mode(sa_stream_t *dev, sa_xrun_mode_t mode);
/** Set the device to non-interleaved mode */
-int sa_device_set_ni(sa_device_t *dev, int enable);
+int sa_stream_set_ni(sa_stream_t *dev, int enable);
/** Require dynamic sample rate */
-int sa_device_set_dynamic_rate(sa_device_t *dev, int enable);
+int sa_stream_set_dynamic_rate(sa_stream_t *dev, int enable);
/** Select driver */
-int sa_device_set_driver(sa_device_t *dev, const char *driver);
+int sa_stream_set_driver(sa_stream_t *dev, const char *driver);
/** Start callback */
-int sa_device_start_thread(sa_device_t *dev, sa_event_callback_t *callback);
+int sa_stream_start_thread(sa_stream_t *dev, sa_event_callback_t *callback);
/** Change the device connected to the stream */
-int sa_device_change_device(sa_device_t *dev, const char *device_name);
+int sa_stream_change_device(sa_stream_t *dev, const char *device_name);
/** volume in hundreths of dB*/
-int sa_device_change_input_volume(sa_device_t *dev, const int vol[]);
+int sa_stream_change_input_volume(sa_stream_t *dev, const int vol[]);
/** volume in hundreths of dB*/
-int sa_device_change_output_volume(sa_device_t *dev, const int vol[]);
+int sa_stream_change_output_volume(sa_stream_t *dev, const int vol[]);
/** Change the sampling rate */
-int sa_device_change_rate(sa_device_t *dev, unsigned rate);
+int sa_stream_change_rate(sa_stream_t *dev, unsigned rate);
/** Change some meta data that is attached to the stream */
-int sa_device_change_meta_data(sa_device_t *dev, const char *name, const void *data, size_t len);
+int sa_stream_change_meta_data(sa_stream_t *dev, const char *name, const void *data, size_t len);
/** Associate opaque user data */
-int sa_device_change_user_data(sa_device_t *dev, void *value);
+int sa_stream_change_user_data(sa_stream_t *dev, void *value);
/* Hardware-related. This is implementation-specific and hardware specific. */
-int sa_device_adjust_rate(sa_device_t *dev, sa_adjust_t direction);
+int sa_stream_adjust_rate(sa_stream_t *dev, sa_adjust_t direction);
-int sa_device_adjust_nchannels(sa_device_t *dev, sa_adjust_t direction);
+int sa_stream_adjust_nchannels(sa_stream_t *dev, sa_adjust_t direction);
-int sa_device_adjust_pcm_format(sa_device_t *dev, sa_adjust_t direction);
+int sa_stream_adjust_pcm_format(sa_stream_t *dev, sa_adjust_t direction);
/* Query functions */
/** Get current state of the audio device */
-int sa_device_get_state(sa_device_t *dev, sa_state_t *state);
+int sa_stream_get_state(sa_stream_t *dev, sa_state_t *state);
/** Get current sampling rate */
-int sa_device_get_rate(sa_device_t *dev, unsigned *rate);
+int sa_stream_get_rate(sa_stream_t *dev, unsigned *rate);
/** Get number of channels */
-int sa_device_get_nchannels(sa_device_t *dev, int *nchannels);
+int sa_stream_get_nchannels(sa_stream_t *dev, int *nchannels);
/** Get format being used */
-int sa_device_get_pcm_format(sa_device_t *dev, sa_pcm_format_t *format);
+int sa_stream_get_pcm_format(sa_stream_t *dev, sa_pcm_format_t *format);
/** Get opaque pointer associated to the device */
-int sa_device_get_user_data(sa_device_t *dev, void **value);
+int sa_stream_get_user_data(sa_stream_t *dev, void **value);
/** Obtain the error code */
-int sa_device_get_event_error(sa_device_t *dev, sa_error_t *error);
+int sa_stream_get_event_error(sa_stream_t *dev, sa_error_t *error);
/** Obtain the notification code */
-int sa_device_get_event_notify(sa_device_t *dev, sa_notify_t *notify);
+int sa_stream_get_event_notify(sa_stream_t *dev, sa_notify_t *notify);
/** sync/timing */
-int sa_device_get_position(sa_device_t *dev, sa_position_t position, int64_t *pos);
+int sa_stream_get_position(sa_stream_t *dev, sa_position_t position, int64_t *pos);
@@ -321,42 +321,42 @@ int sa_device_get_position(sa_device_t *dev, sa_position_t position, int64_t *po
/* Blocking IO calls */
/** Interleaved capture function */
-int sa_device_read(sa_device_t *dev, void *data, size_t nbytes);
+int sa_stream_read(sa_stream_t *dev, void *data, size_t nbytes);
/** Interleaved playback function */
-int sa_device_write(sa_device_t *dev, const void *data, size_t nbytes);
+int sa_stream_write(sa_stream_t *dev, const void *data, size_t nbytes);
/** Non-interleaved capture function */
-int sa_device_read_ni(sa_device_t *dev, unsigned channel, void *data, size_t nbytes);
+int sa_stream_read_ni(sa_stream_t *dev, unsigned channel, void *data, size_t nbytes);
/** Non-interleaved playback function */
-int sa_device_write_ni(sa_device_t *dev, unsigned channel, const void *data, size_t nbytes);
+int sa_stream_write_ni(sa_stream_t *dev, unsigned channel, const void *data, size_t nbytes);
/** Interleaved capture function with seek offset */
-int sa_device_pread(sa_device_t *dev, void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
+int sa_stream_pread(sa_stream_t *dev, void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
/** Interleaved playback function with seek offset */
-int sa_device_pwrite(sa_device_t *dev, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
+int sa_stream_pwrite(sa_stream_t *dev, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
/** Non-interleaved capture function with seek offset */
-int sa_device_pread_ni(sa_device_t *dev, unsigned channel, void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
+int sa_stream_pread_ni(sa_stream_t *dev, unsigned channel, void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
/** Non-interleaved playback function with seek offset */
-int sa_device_pwrite_ni(sa_device_t *dev, unsigned channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
+int sa_stream_pwrite_ni(sa_stream_t *dev, unsigned channel, const void *data, size_t nbytes, int64_t offset, sa_seek_t whence);
/** Query how much can be read without blocking */
-int sa_device_get_read_size(sa_device_t *dev, size_t *size);
+int sa_stream_get_read_size(sa_stream_t *dev, size_t *size);
/** Query how much can be written without blocking */
-int sa_device_get_write_size(sa_device_t *dev, size_t *size);
+int sa_stream_get_write_size(sa_stream_t *dev, size_t *size);
/* Control/xrun */
/** Resume playing after a pause */
-int sa_device_resume(sa_device_t *dev);
+int sa_stream_resume(sa_stream_t *dev);
/** Pause audio playback (do not empty the buffer) */
-int sa_device_pause(sa_device_t *dev);
+int sa_stream_pause(sa_stream_t *dev);
/** Block until all audio has been played */
-int sa_device_drain(sa_device_t *dev);
+int sa_stream_drain(sa_stream_t *dev);
/** Return a human readable error */
const char *sa_strerror(int code);
diff --git a/test-sine.c b/test-sine.c
index d0e28e9..57d38e1 100644
--- a/test-sine.c
+++ b/test-sine.c
@@ -20,32 +20,32 @@
int main(int argc, char *argv[]) {
- sa_device_t *dev;
+ sa_stream_t *dev;
float data[4] = { 0.0, 1.0, 0.0, -1.0 };
int i, j;
- ASSERT_SUCCESS(sa_device_create_pcm(&dev, SA_MODE_WRONLY, SA_PCM_FORMAT_FLOAT32_NE, FREQ * 4, 1));
- ASSERT_SUCCESS(sa_device_change_device(dev, "/dev/dsp1"));
- ASSERT_SUCCESS(sa_device_set_dynamic_rate(dev, 1));
- sa_device_change_meta_data(dev, SA_META_CLIENT_NAME, argv[0], strlen(argv[0]));
- ASSERT_SUCCESS(sa_device_open(dev));
+ ASSERT_SUCCESS(sa_stream_create_pcm(&dev, SA_MODE_WRONLY, SA_PCM_FORMAT_FLOAT32_NE, FREQ * 4, 1));
+ ASSERT_SUCCESS(sa_stream_change_device(dev, "/dev/dsp1"));
+ ASSERT_SUCCESS(sa_stream_set_dynamic_rate(dev, 1));
+ sa_stream_change_meta_data(dev, SA_META_CLIENT_NAME, argv[0], strlen(argv[0]));
+ ASSERT_SUCCESS(sa_stream_open(dev));
for (j = 0; j < 10; j++) {
int v;
v = -j*500;
-/* ASSERT_SUCCESS(sa_device_change_rate(dev, FREQ*4+100*j)); */
- ASSERT_SUCCESS(sa_device_change_output_volume(dev, &v));
+/* ASSERT_SUCCESS(sa_stream_change_rate(dev, FREQ*4+100*j)); */
+ ASSERT_SUCCESS(sa_stream_change_output_volume(dev, &v));
for (i = 0; i < FREQ; i++)
- ASSERT_SUCCESS(sa_device_write(dev, data, sizeof(data)));
+ ASSERT_SUCCESS(sa_stream_write(dev, data, sizeof(data)));
}
- ASSERT_SUCCESS(sa_device_drain(dev));
+ ASSERT_SUCCESS(sa_stream_drain(dev));
- ASSERT_SUCCESS(sa_device_destroy(dev));
+ ASSERT_SUCCESS(sa_stream_destroy(dev));
return 0;
}