]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
oss: issue OSS_GETVERSION ioctl only when needed
authormalc <av1474@comtv.ru>
Sat, 9 Jan 2010 14:54:07 +0000 (17:54 +0300)
committerAurelien Jarno <aurelien@aurel32.net>
Sun, 25 Apr 2010 10:20:01 +0000 (12:20 +0200)
Signed-off-by: malc <av1474@comtv.ru>
(cherry picked from commit 6d246526ce3c145b2831285def6983f5de6190d3)

audio/ossaudio.c

index fe6fb523bca73ad0a2f88d3d8fe3dbaac9abd0f4..79d1daa1c0d877cfc4ac2a617ca383f1390a8c9e 100644 (file)
@@ -244,9 +244,6 @@ static int oss_open (int in, struct oss_params *req,
                      struct oss_params *obt, int *pfd)
 {
     int fd;
-#ifdef USE_DSP_POLICY
-    int version;
-#endif
     int oflags = conf.exclusive ? O_EXCL : 0;
     audio_buf_info abinfo;
     int fmt, freq, nchannels;
@@ -288,22 +285,25 @@ static int oss_open (int in, struct oss_params *req,
     }
 
 #ifdef USE_DSP_POLICY
-    if (ioctl (fd, OSS_GETVERSION, &version)) {
-        oss_logerr2 (errno, typ, "Failed to get OSS version\n");
-        version = 0;
-    }
+    if (conf.policy >= 0) {
+        int version;
 
-    if (conf.debug) {
-        dolog ("OSS version = %#x\n", version);
-    }
+        if (ioctl (fd, OSS_GETVERSION, &version)) {
+            oss_logerr2 (errno, typ, "Failed to get OSS version\n");
+            version = 0;
+        }
 
-    if (conf.policy >= 0 && version >= 0x040000)
-    {
-        int policy = conf.policy;
-        if (ioctl (fd, SNDCTL_DSP_POLICY, &policy)) {
-            oss_logerr2 (errno, typ, "Failed to set timing policy to %d\n",
-                         conf.policy);
-            goto err;
+        if (conf.debug) {
+            dolog ("OSS version = %#x\n", version);
+        }
+
+        if (version >= 0x040000) {
+            int policy = conf.policy;
+            if (ioctl (fd, SNDCTL_DSP_POLICY, &policy)) {
+                oss_logerr2 (errno, typ, "Failed to set timing policy to %d\n",
+                             conf.policy);
+                goto err;
+            }
         }
     }
     else