|
Line 0
Link Here
|
|
|
1 |
$OpenBSD: patch-src_plugins_sndio_ao_sndio_c,v 1.3 2014/05/27 19:44:56 naddy Exp $ |
| 2 |
--- src/plugins/sndio/ao_sndio.c.orig 2012-02-14 00:46:06 UTC |
| 3 |
+++ src/plugins/sndio/ao_sndio.c |
| 4 |
@@ -99,6 +99,7 @@ int ao_plugin_set_option(ao_device *devi |
| 5 |
int ao_plugin_open(ao_device *device, ao_sample_format *format) |
| 6 |
{ |
| 7 |
ao_sndio_internal *internal = (ao_sndio_internal *) device->internal; |
| 8 |
+ struct sio_hdl *hdl; |
| 9 |
struct sio_par par; |
| 10 |
|
| 11 |
if(!internal->dev && internal->id>=0){ |
| 12 |
@@ -107,20 +108,26 @@ int ao_plugin_open(ao_device *device, ao |
| 13 |
internal->dev = strdup(buf); |
| 14 |
} |
| 15 |
|
| 16 |
- internal->hdl = sio_open(internal->dev, SIO_PLAY, 0); |
| 17 |
- if (internal->hdl == NULL) |
| 18 |
+ hdl = sio_open(internal->dev, SIO_PLAY, 0); |
| 19 |
+ if (hdl == NULL) |
| 20 |
return 0; |
| 21 |
+ internal->hdl = hdl; |
| 22 |
|
| 23 |
sio_initpar(&par); |
| 24 |
par.sig = 1; |
| 25 |
- par.le = SIO_LE_NATIVE; |
| 26 |
+ if (format->bits > 8) |
| 27 |
+ par.le = device->client_byte_format == AO_FMT_LITTLE ? 1 : 0; |
| 28 |
par.bits = format->bits; |
| 29 |
par.rate = format->rate; |
| 30 |
par.pchan = device->output_channels; |
| 31 |
- if (!sio_setpar(internal->hdl, &par)) |
| 32 |
+ if (!sio_setpar(hdl, &par)) |
| 33 |
return 0; |
| 34 |
- device->driver_byte_format = AO_FMT_NATIVE; |
| 35 |
- if (!sio_start(internal->hdl)) |
| 36 |
+ if (!sio_getpar(hdl, &par)) |
| 37 |
+ return 0; |
| 38 |
+ if (par.bits != format->bits) |
| 39 |
+ return 0; |
| 40 |
+ device->driver_byte_format = par.le ? AO_FMT_LITTLE : AO_FMT_BIG; |
| 41 |
+ if (!sio_start(hdl)) |
| 42 |
return 0; |
| 43 |
|
| 44 |
if(!device->inter_matrix){ |
| 45 |
@@ -148,9 +155,10 @@ int ao_plugin_close(ao_device *device) |
| 46 |
ao_sndio_internal *internal = (ao_sndio_internal *) device->internal; |
| 47 |
struct sio_hdl *hdl = internal->hdl; |
| 48 |
|
| 49 |
- if(hdl) |
| 50 |
- if (!sio_stop(hdl)) |
| 51 |
- return 0; |
| 52 |
+ if(hdl){ |
| 53 |
+ sio_close(hdl); |
| 54 |
+ internal->hdl = NULL; |
| 55 |
+ } |
| 56 |
return 1; |
| 57 |
} |
| 58 |
|