From 363f03a0603c3bdc25ea1ed0b9f542fa23e1db02 Mon Sep 17 00:00:00 2001
From: Warren Dukes <shank@xiph.org>
Date: Tue, 9 Mar 2004 00:05:44 +0000
Subject: [PATCH] do GETBLKSIZE after setting bitrate, sample size, and
 channels b/c the optimal fragment size depends on these settings, but also
 GEBLKSIZE causes the fragment size to be set (which cannot be changed w/o
 closing and reopening the device). This fixes a problem a user was having
 with oss emu10k1 driver where libao app's were skipping.

git-svn-id: http://svn.xiph.org/trunk/ao@5919 0101bb08-14d6-0310-b084-bc0e0c8e3800
---
 src/plugins/oss/ao_oss.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/plugins/oss/ao_oss.c b/src/plugins/oss/ao_oss.c
index e047699..7c19625 100644
--- a/src/plugins/oss/ao_oss.c
+++ b/src/plugins/oss/ao_oss.c
@@ -220,16 +220,6 @@ int ao_plugin_open(ao_device *device, ao_sample_format *format)
 
 	/* Now set all of the parameters */
 
-	internal->buf_size = -1;
-	if ((ioctl(internal->fd,SNDCTL_DSP_GETBLKSIZE,
-				&(internal->buf_size)) < 0) ||
-			internal->buf_size<=0 )
-	{
-		fprintf(stderr, "libao - OSS cannot get buffer size for "
-				" device\n");
-		goto ERR;
-	}
-
 	switch (format->channels)
 	{
 	case 1: tmp = 0;
@@ -279,6 +269,17 @@ int ao_plugin_open(ao_device *device, ao_sample_format *format)
 		goto ERR;
 	}
 
+	/* this calculates and sets the fragment size */
+	internal->buf_size = -1;
+	if ((ioctl(internal->fd,SNDCTL_DSP_GETBLKSIZE,
+				&(internal->buf_size)) < 0) ||
+			internal->buf_size<=0 )
+	{
+		fprintf(stderr, "libao - OSS cannot get buffer size for "
+				" device\n");
+		goto ERR;
+	}
+
 	return 1; /* Open successful */
 
  ERR:
-- 
GitLab