diff options
author | Heiko Schaefer <heikos@users.sourceforge.net> | 2001-09-30 23:12:05 +0000 |
---|---|---|
committer | Heiko Schaefer <heikos@users.sourceforge.net> | 2001-09-30 23:12:05 +0000 |
commit | 1ad13804022b42f569c735296fbda1eb3277a393 (patch) | |
tree | abbb8331279cd2c3c5fa5e1f8a18807c54a9d973 /src | |
parent | b1bac12ebd2cd279a1e3b031347b57bcc8c24a42 (diff) | |
download | xine-lib-1ad13804022b42f569c735296fbda1eb3277a393.tar.gz xine-lib-1ad13804022b42f569c735296fbda1eb3277a393.tar.bz2 |
use SNDCTL_DSP_GETODELAY if available. fixes sync problem with the freebsd audio driver for sb128.
CVS patchset: 710
CVS date: 2001/09/30 23:12:05
Diffstat (limited to 'src')
-rw-r--r-- | src/audio_out/audio_oss_out.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/audio_out/audio_oss_out.c b/src/audio_out/audio_oss_out.c index fedea2ef0..b176cfb14 100644 --- a/src/audio_out/audio_oss_out.c +++ b/src/audio_out/audio_oss_out.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_oss_out.c,v 1.39 2001/09/28 10:19:08 jkeil Exp $ + * $Id: audio_oss_out.c,v 1.40 2001/09/30 23:12:05 heikos Exp $ * * 20-8-2001 First implementation of Audio sync and Audio driver separation. * Copyright (C) 2001 James Courtier-Dutton James@superbug.demon.co.uk @@ -96,6 +96,7 @@ #endif static int checked_getoptr = 0; +static int use_getodelay = 0; typedef struct oss_driver_s { @@ -274,6 +275,19 @@ static int ao_oss_open(ao_driver_t *this_gen, checked_getoptr = 1; } + /* + * check if SNDCTL_DSP_GETODELAY works. if so, using it is preferred. + */ + if ( this->audio_has_realtime && checked_getoptr ) { + count_info info; + int ret = ioctl(this->audio_fd, SNDCTL_DSP_GETODELAY, &info); + if ( ret != -1 && errno != EINVAL ) { + printf("audio_oss_out: using SNDCTL_DSP_GETODELAY\n"); + use_getodelay = 1; + } + } + + return this->output_sample_rate; } @@ -305,14 +319,17 @@ static int ao_oss_delay(ao_driver_t *this_gen) int bytes_left; if (this->audio_has_realtime) { - ioctl (this->audio_fd, SNDCTL_DSP_GETOPTR, &info); - - /* calc delay */ - - bytes_left = this->bytes_in_buffer - info.bytes; + if (use_getodelay) { + ioctl (this->audio_fd, SNDCTL_DSP_GETODELAY, &bytes_left); + } else { + ioctl (this->audio_fd, SNDCTL_DSP_GETOPTR, &info); + + bytes_left = this->bytes_in_buffer - info.bytes; /* calc delay */ + + if (bytes_left<=0) /* buffer ran dry */ + bytes_left = 0; + } - if (bytes_left<=0) /* buffer ran dry */ - bytes_left = 0; } else { bytes_left = this->static_delay; } |