comparison libao2/ao_sun.c @ 23334:f665e123e6f9

Implement flushing of audio data. Fixes bug #754. Based on patch by Sergey Svishchev (svs ropnet ru).
author reimar
date Sun, 20 May 2007 12:05:16 +0000
parents 0471ad67050e
children 69696caa0b1b
comparison
equal deleted inserted replaced
23333:c51b95236413 23334:f665e123e6f9
63 RTSC_ENABLED, 63 RTSC_ENABLED,
64 RTSC_DISABLED 64 RTSC_DISABLED
65 } enable_sample_timing; 65 } enable_sample_timing;
66 66
67 67
68 static void flush_audio(int fd) {
69 #ifdef AUDIO_FLUSH
70 ioctl(fd, AUDIO_FLUSH, 0);
71 #elif defined(__svr4__)
72 ioctl(fd, I_FLUSH, FLUSHW);
73 #endif
74 }
68 75
69 // convert an OSS audio format specification into a sun audio encoding 76 // convert an OSS audio format specification into a sun audio encoding
70 static int af2sunfmt(int format) 77 static int af2sunfmt(int format)
71 { 78 {
72 switch (format){ 79 switch (format){
201 208
202 209
203 error: 210 error:
204 if (silence != NULL) free(silence); 211 if (silence != NULL) free(silence);
205 if (fd >= 0) { 212 if (fd >= 0) {
206 #ifdef __svr4__
207 // remove the 0 bytes from the above measurement from the 213 // remove the 0 bytes from the above measurement from the
208 // audio driver's STREAMS queue 214 // audio driver's STREAMS queue
209 ioctl(fd, I_FLUSH, FLUSHW); 215 flush_audio(fd);
210 #endif
211 //ioctl(fd, AUDIO_DRAIN, 0);
212 close(fd); 216 close(fd);
213 } 217 }
214 218
215 return rtsc_ok; 219 return rtsc_ok;
216 } 220 }
574 return 1; 578 return 1;
575 } 579 }
576 580
577 // close audio device 581 // close audio device
578 static void uninit(int immed){ 582 static void uninit(int immed){
579 #ifdef __svr4__
580 // throw away buffered data in the audio driver's STREAMS queue 583 // throw away buffered data in the audio driver's STREAMS queue
581 if (immed) 584 if (immed)
582 ioctl(audio_fd, I_FLUSH, FLUSHW); 585 flush_audio(audio_fd);
583 #endif
584 close(audio_fd); 586 close(audio_fd);
585 } 587 }
586 588
587 // stop playing and empty buffers (for seeking/pause) 589 // stop playing and empty buffers (for seeking/pause)
588 static void reset(void){ 590 static void reset(void){