summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2010-04-11 16:53:56 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2010-04-11 16:53:56 +0000
commitccf04ea2b34dd74589c83b99def187a1a5dcbe11 (patch)
tree3dea66722e5ba6d4a8176a2b6eb7367f1310ecf8 /lib
parentb6c9747cf6101a5b9256a830708d10450543a20f (diff)
audio(4) doesn't require to be started explicitely, so the device is
started immediately after it's opened in record only mode. Pause it in sio_open() and sio_stop(), since libsndio requires an explicit call to sio_start(). discussed with jakemsr
Diffstat (limited to 'lib')
-rw-r--r--lib/libsndio/sun.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/libsndio/sun.c b/lib/libsndio/sun.c
index 11a61053add..e6bde90a1a1 100644
--- a/lib/libsndio/sun.c
+++ b/lib/libsndio/sun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sun.c,v 1.28 2010/04/06 20:07:01 ratchov Exp $ */
+/* $OpenBSD: sun.c,v 1.29 2010/04/11 16:53:55 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -349,6 +349,7 @@ struct sio_hdl *
sio_open_sun(const char *str, unsigned mode, int nbio)
{
int fd, flags, fullduplex;
+ struct audio_info aui;
struct sun_hdl *hdl;
struct sio_par par;
char path[PATH_MAX];
@@ -377,6 +378,18 @@ sio_open_sun(const char *str, unsigned mode, int nbio)
hdl->fd = fd;
/*
+ * pause the device
+ */
+ AUDIO_INITINFO(&aui);
+ if (hdl->sio.mode & SIO_PLAY)
+ aui.play.pause = 1;
+ if (hdl->sio.mode & SIO_REC)
+ aui.record.pause = 1;
+ if (ioctl(hdl->fd, AUDIO_SETINFO, &aui) < 0) {
+ DPERROR("sio_open_sun: setinfo");
+ goto bad_close;
+ }
+ /*
* If both play and record are requested then
* set full duplex mode.
*/
@@ -499,6 +512,10 @@ sun_stop(struct sio_hdl *sh)
*/
AUDIO_INITINFO(&aui);
aui.mode = 0;
+ if (hdl->sio.mode & SIO_PLAY)
+ aui.play.pause = 1;
+ if (hdl->sio.mode & SIO_REC)
+ aui.record.pause = 1;
if (ioctl(hdl->fd, AUDIO_SETINFO, &aui) < 0) {
DPERROR("sun_stop: setinfo1");
hdl->sio.eof = 1;