d11f853ac6
ok biorn@ (MAINTAINER), ajacoutot@, brad@
140 lines
3.9 KiB
Plaintext
140 lines
3.9 KiB
Plaintext
$OpenBSD: patch-libao2_ao_sun_c,v 1.4 2008/02/08 17:32:41 jakemsr Exp $
|
|
--- libao2/ao_sun.c.orig Sun Oct 7 12:49:27 2007
|
|
+++ libao2/ao_sun.c Mon Feb 4 05:07:06 2008
|
|
@@ -102,6 +102,7 @@ static int af2sunfmt(int format)
|
|
// sample counter information
|
|
static int realtime_samplecounter_available(char *dev)
|
|
{
|
|
+#ifdef __svr4__
|
|
int fd = -1;
|
|
audio_info_t info;
|
|
int rtsc_ok = RTSC_DISABLED;
|
|
@@ -217,6 +218,9 @@ error:
|
|
}
|
|
|
|
return rtsc_ok;
|
|
+#else
|
|
+ return RTSC_DISABLED;
|
|
+#endif
|
|
}
|
|
|
|
|
|
@@ -440,7 +444,7 @@ static int control(int cmd,void *arg){
|
|
else
|
|
info.play.balance = (vol->right - vol->left + volume) * AUDIO_RIGHT_BALANCE / (2*volume);
|
|
}
|
|
-#if !defined (__OpenBSD__) && !defined (__NetBSD__)
|
|
+#if !defined (__NetBSD__)
|
|
info.output_muted = (volume == 0);
|
|
#endif
|
|
ioctl( fd,AUDIO_SETINFO,&info );
|
|
@@ -566,11 +570,20 @@ static int init(int rate,int channels,int format,int f
|
|
ao_data.bps = byte_per_sec = bytes_per_sample * ao_data.samplerate;
|
|
ao_data.outburst = byte_per_sec > 100000 ? 16384 : 8192;
|
|
|
|
+#if defined(__OpenBSD__) || defined(__NetBSD__)
|
|
AUDIO_INITINFO(&info);
|
|
+ info.blocksize = ao_data.outburst;
|
|
+ ioctl (audio_fd, AUDIO_SETINFO, &info);
|
|
+#endif
|
|
+#ifdef __svr4__
|
|
+ AUDIO_INITINFO(&info);
|
|
info.play.samples = 0;
|
|
info.play.eof = 0;
|
|
info.play.error = 0;
|
|
ioctl (audio_fd, AUDIO_SETINFO, &info);
|
|
+#else
|
|
+ ioctl (audio_fd, AUDIO_FLUSH);
|
|
+#endif
|
|
|
|
queued_bursts = 0;
|
|
queued_samples = 0;
|
|
@@ -607,9 +620,11 @@ static void reset(void){
|
|
: AUDIO_PRECISION_8);
|
|
info.play.channels = ao_data.channels;
|
|
info.play.sample_rate = ao_data.samplerate;
|
|
+#ifdef __svr4__
|
|
info.play.samples = 0;
|
|
info.play.eof = 0;
|
|
info.play.error = 0;
|
|
+#endif
|
|
ioctl (audio_fd, AUDIO_SETINFO, &info);
|
|
queued_bursts = 0;
|
|
queued_samples = 0;
|
|
@@ -636,7 +651,11 @@ static void audio_resume(void)
|
|
|
|
// return: how many bytes can be played without blocking
|
|
static int get_space(void){
|
|
+#if defined(__OpenBSD__)
|
|
+ audio_bufinfo_t ab;
|
|
+#else
|
|
audio_info_t info;
|
|
+#endif
|
|
|
|
// check buffer
|
|
#ifdef HAVE_AUDIO_SELECT
|
|
@@ -651,14 +670,22 @@ static int get_space(void){
|
|
}
|
|
#endif
|
|
|
|
+#if defined(__OpenBSD__)
|
|
+ ioctl(audio_fd, AUDIO_GETPRINFO, &ab);
|
|
+ if (ab.hiwat * ab.blksize - ab.seek < ao_data.outburst)
|
|
+ return 0;
|
|
+ else
|
|
+ return ao_data.outburst;
|
|
+#else
|
|
ioctl(audio_fd, AUDIO_GETINFO, &info);
|
|
-#if !defined (__OpenBSD__) && !defined(__NetBSD__)
|
|
+#if !defined(__NetBSD__)
|
|
if (queued_bursts - info.play.eof > 2)
|
|
return 0;
|
|
return ao_data.outburst;
|
|
#else
|
|
return info.hiwat * info.blocksize - info.play.seek;
|
|
#endif
|
|
+#endif // __OpenBSD__
|
|
|
|
}
|
|
|
|
@@ -666,6 +693,16 @@ static int get_space(void){
|
|
// it should round it down to outburst*n
|
|
// return: number of bytes played
|
|
static int play(void* data,int len,int flags){
|
|
+#ifdef __OpenBSD__
|
|
+ if(len==0)
|
|
+ return len;
|
|
+ if(len>ao_data.outburst || !(flags & AOPLAY_FINAL_CHUNK)) {
|
|
+ len/=ao_data.outburst;
|
|
+ len*=ao_data.outburst;
|
|
+ }
|
|
+ len=write(audio_fd,data,len);
|
|
+ return len;
|
|
+#else
|
|
if (len < ao_data.outburst) return 0;
|
|
len /= ao_data.outburst;
|
|
len *= ao_data.outburst;
|
|
@@ -679,16 +716,19 @@ static int play(void* data,int len,int flags){
|
|
queued_bursts ++;
|
|
}
|
|
return len;
|
|
+#endif
|
|
}
|
|
|
|
|
|
// return: delay in seconds between first and last sample in buffer
|
|
static float get_delay(void){
|
|
- audio_info_t info;
|
|
- ioctl(audio_fd, AUDIO_GETINFO, &info);
|
|
#if defined (__OpenBSD__) || defined(__NetBSD__)
|
|
- return (float) info.play.seek/ (float)byte_per_sec ;
|
|
+ u_long bytes;
|
|
+ ioctl(audio_fd, AUDIO_WSEEK, &bytes);
|
|
+ return (float) bytes/ (float)byte_per_sec ;
|
|
#else
|
|
+ audio_info_t info;
|
|
+ ioctl(audio_fd, AUDIO_GETINFO, &info);
|
|
if (info.play.samples && enable_sample_timing == RTSC_ENABLED)
|
|
return (float)(queued_samples - info.play.samples) / (float)ao_data.samplerate;
|
|
else
|