2
* Copyright (c) 2008 Alexandre Ratchov <alex at caoua.org>
4
* Permission to use, copy, modify, and distribute this software for any
5
* purpose with or without fee is hereby granted, provided that the above
6
* copyright notice and this permission notice appear in all copies.
8
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
#include <ao/plugin.h>
20
static char * ao_sndio_options[] = {
28
ao_info ao_sndio_info = {
32
"Alexandre Ratchov <alex at caoua.org>",
33
"Outputs to the sndio library",
40
typedef struct ao_alsa_internal
50
hdl = sio_open(NULL, SIO_PLAY, 0);
57
ao_info *ao_plugin_driver_info(void)
59
return &ao_sndio_info;
62
int ao_plugin_device_init(ao_device *device)
64
ao_sndio_internal *internal;
65
internal = (ao_sndio_internal *) calloc(1,sizeof(*internal));
66
device->internal = internal;
67
device->output_matrix_order = AO_OUTPUT_MATRIX_FIXED;
71
int ao_plugin_set_option(ao_device *device, const char *key, const char *value)
73
ao_sndio_internal *internal = (ao_sndio_internal *) device->internal;
75
if (!strcmp(key, "dev")) {
81
if (!(internal->dev = strdup(value)))
88
int ao_plugin_open(ao_device *device, ao_sample_format *format)
90
ao_sndio_internal *internal = (ao_sndio_internal *) device->internal;
93
internal->hdl = sio_open(internal->dev, SIO_PLAY, 0);
94
if (internal->hdl == NULL)
99
par.le = SIO_LE_NATIVE;
100
par.bits = format->bits;
101
par.rate = format->rate;
102
par.pchan = device->output_channels;
103
if (!sio_setpar(hdl, &par))
105
device->driver_byte_format = AO_FMT_NATIVE;
109
if(!device->inter_matrix){
110
/* set up matrix such that users are warned about > stereo playback */
111
if(device->output_channels<=2)
112
device->inter_matrix=strdup("L,R");
113
//else no matrix, which results in a warning
119
int ao_plugin_play(ao_device *device, const char *output_samples, uint_32 num_bytes)
121
ao_sndio_internal *internal = (ao_sndio_internal *) device->internal;
122
struct sio_hdl *hdl = internal->hdl;
124
if (!sio_write(hdl, output_samples, num_bytes))
129
int ao_plugin_close(ao_device *device)
131
ao_sndio_internal *internal = (ao_sndio_internal *) device->internal;
132
struct sio_hdl *hdl = internal->hdl;
139
void ao_plugin_device_clear(ao_device *device)
141
ao_sndio_internal *internal = (ao_sndio_internal *) device->internal;
142
struct sio_hdl *hdl = internal->hdl;