On Thu, Dec 11, 2008 at 12:45:57AM -0500, Brad wrote: > The following diff adds a sndio backend to the Xine-lib library > which is used by Kaffeine / Xine(-ui), Gwenview (via Kaffeine) > and some parts of KDE via kdemultimedia. > > I must note that while working on the sndio backend I found that > once implemented that even without using the aucat sound server, > Xine(-lib) based apps gracefully would deal with the lack of an > audio device if it was already open by another app. Where as with > the existing Sun audio backend the other apps would just outright > not play the content at all if the backend failed to open the > device, which I found really annoying. aucat is just icing on the > cake :) > > Please test as much as possible. Nothing special needs to be done > other than building and upgrading the xine-lib package. The new > sndio backend has the highest priority so it'll be used automatically > over the Sun backend unless specifically overridden in the application > settings. >
very cool. I can't test it right now (no access to openbsd), so i quickly comment the diff. More comments this evening. > Index: files/audio_sndio_out.c > =================================================================== > RCS file: files/audio_sndio_out.c > diff -N files/audio_sndio_out.c > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ files/audio_sndio_out.c 11 Dec 2008 03:54:26 -0000 > @@ -0,0 +1,415 @@ > +/* -*- Mode: C; c-basic-offset: 2; indent-tabs-mode: nil -*- */ > + > +/* > + * Copyright (C) 2008 the xine project > + * > + * This file is part of xine, a free video player. > + * > + * xine is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + * files in files/ subdirectories should use license.template. Once the code is ready to go upstream we're supposed to send the files with the project license if necessary. That's what i got after a private discussion with [EMAIL PROTECTED] > +static int ao_sndio_delay (ao_driver_t *this_gen) > +{ > + sndio_driver_t *this = (sndio_driver_t *) this_gen; > + int ret = 0; > + > + return ret; > +} afaiu this is the delay (sample periods) between the moment the last sample was written and the moment the user hears it. It cannot be zero. See for instance ports/x11/mplayer/files/ao_libsndio.c or src/regress/lib/libsndio/play/play.c if you're bored by this stuff and can wait until this week-end i can add the missing bits, let me know > + > +static int ao_sndio_set_property (ao_driver_t *this_gen, int property, int > value) > +{ > + sndio_driver_t *this = (sndio_driver_t *) this_gen; > + int vol; > + > + switch(property) { > + case AO_PROP_PCM_VOL: > + case AO_PROP_MIXER_VOL: > + this->mixer.volume = value; > + if (!this->mixer.mute) > + sio_setvol(this->hdl, this->mixer.volume); > + return this->mixer.volume; > + break; > + if two knobs control the volume, there will be abrupt jumps in the volume if both knobs are touched. Imo you should either ignore AO_PROP_MIXER or (if you think both are required) use the product of the two values: val = val_mixer * val_pcm / 127; > +static int ao_sndio_ctrl(ao_driver_t *this_gen, int cmd, ...) > +{ > + sndio_driver_t *this = (sndio_driver_t *) this_gen; > + int ret = 0; > + > + switch (cmd) { > + case AO_CTRL_FLUSH_BUFFERS: > + break; > + > + case AO_CTRL_PLAY_RESUME: > + if (!sio_start(this->hdl)) { > + xprintf (this->xine, XINE_VERBOSITY_DEBUG, > + "audio_sndio_out: ao_sndio_ctrl could not start\n"); > + ret = 1; > + } > + break; > + > + case AO_CTRL_PLAY_PAUSE: > + if (!sio_stop(this->hdl)) { > + xprintf (this->xine, XINE_VERBOSITY_DEBUG, > + "audio_sndio_out: ao_sndio_ctrl could not stop\n"); > + ret = 1; > + } > + break; > + } > + if you implement ao_sndio_delay() this will hurt you because sio_stop() will consume the buffered samples and video/audio will go out of sync. The easier is to leave pause/resume stuff empty; libsndio pauses audio if there are no more samples to play and resumes when there are enough samples again. > + > + /* > + * set capabilities > + */ > + this->capabilities = > + AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO | AO_CAP_MODE_4CHANNEL | > + AO_CAP_MODE_4_1CHANNEL | AO_CAP_MODE_5CHANNEL | AO_CAP_MODE_5_1CHANNEL | > + AO_CAP_MIXER_VOL | AO_CAP_PCM_VOL | AO_CAP_MUTE_VOL | > + AO_CAP_8BITS | AO_CAP_16BITS | AO_CAP_24BITS | AO_CAP_FLOAT32; we don't support AU_CAP_FLOAT32 encoding. -- Alexandre