# HG changeset patch # User reimar # Date 1179662716 0 # Node ID f665e123e6f959ce5f1d784e60d5c01997c9eb49 # Parent c51b952364137b4fb0c76109889e2bf761a17f93 Implement flushing of audio data. Fixes bug #754. Based on patch by Sergey Svishchev (svs ropnet ru). diff -r c51b95236413 -r f665e123e6f9 libao2/ao_sun.c --- a/libao2/ao_sun.c Sun May 20 11:36:50 2007 +0000 +++ b/libao2/ao_sun.c Sun May 20 12:05:16 2007 +0000 @@ -65,6 +65,13 @@ } enable_sample_timing; +static void flush_audio(int fd) { +#ifdef AUDIO_FLUSH + ioctl(fd, AUDIO_FLUSH, 0); +#elif defined(__svr4__) + ioctl(fd, I_FLUSH, FLUSHW); +#endif +} // convert an OSS audio format specification into a sun audio encoding static int af2sunfmt(int format) @@ -203,12 +210,9 @@ error: if (silence != NULL) free(silence); if (fd >= 0) { -#ifdef __svr4__ // remove the 0 bytes from the above measurement from the // audio driver's STREAMS queue - ioctl(fd, I_FLUSH, FLUSHW); -#endif - //ioctl(fd, AUDIO_DRAIN, 0); + flush_audio(fd); close(fd); } @@ -576,11 +580,9 @@ // close audio device static void uninit(int immed){ -#ifdef __svr4__ // throw away buffered data in the audio driver's STREAMS queue if (immed) - ioctl(audio_fd, I_FLUSH, FLUSHW); -#endif + flush_audio(audio_fd); close(audio_fd); }