$OpenBSD: patch-src_audio_out_audio_sun_out_c,v 1.6 2008/01/15 00:36:46 jakemsr Exp $
--- src/audio_out/audio_sun_out.c.orig	Tue Jan  1 08:30:08 2008
+++ src/audio_out/audio_sun_out.c	Wed Jan  9 01:50:21 2008
@@ -582,9 +582,9 @@ static int ao_sun_bytes_per_frame(ao_driver_t *this_ge
 static int ao_sun_delay(ao_driver_t *this_gen)
 {
   sun_driver_t *this = (sun_driver_t *) this_gen;
+#ifdef __svr4__
   audio_info_t info;
 
-#ifdef __svr4__
   if (ioctl(this->audio_fd, AUDIO_GETINFO, &info) == 0 &&
       (this->frames_in_buffer == 0 || info.play.samples > 0)) {
 
@@ -632,8 +632,9 @@ static int ao_sun_delay(ao_driver_t *this_gen)
 #endif
   }
 #else
-  if (ioctl(this->audio_fd, AUDIO_GETINFO, &info) == 0)
-    return info.play.seek / this->bytes_per_frame;
+  u_long bytes;
+  if (ioctl(this->audio_fd, AUDIO_WSEEK, &bytes) == 0)
+    return bytes / this->bytes_per_frame;
 #endif
   return NOT_REAL_TIME;
 }
@@ -888,8 +889,7 @@ static int ao_sun_ctrl(ao_driver_t *this_gen, int cmd,
 
     this->frames_in_buffer = 0;
     this->last_samplecnt = 0;
-#endif
-#ifdef __NetBSD__
+#else
     ioctl(this->audio_fd, AUDIO_FLUSH);
 #endif
     break;
@@ -964,11 +964,20 @@ static ao_driver_t *ao_sun_open_plugin (audio_driver_c
   status = ioctl(this->audio_fd, AUDIO_SETINFO, &info);
   
   if (status < 0) {
-    xprintf(this->xine, XINE_VERBOSITY_LOG,
+    /* some devices are 48kHz only */
+    AUDIO_INITINFO(&info);
+    info.play.encoding = AUDIO_ENCODING_LINEAR;
+    info.play.precision = AUDIO_PRECISION_16;
+    info.play.sample_rate = 48000;
+    status = ioctl(this->audio_fd, AUDIO_SETINFO, &info);
+
+    if (status < 0) {
+      xprintf(this->xine, XINE_VERBOSITY_LOG,
 	    _("audio_sun_out: audio ioctl on device %s failed: %s\n"), devname, strerror(errno));
 
-    free (this);
-    return NULL;
+      free (this);
+      return NULL;
+    }
   }
 
   /*
