[pulseaudio-commits] r1486 - /branches/lennart/src/modules/oss-util.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sat Jun 23 13:01:41 PDT 2007


Author: lennart
Date: Sat Jun 23 22:01:40 2007
New Revision: 1486

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1486&root=3Dpulseaudio&vi=
ew=3Drev
Log:
minor cleanups and optimizations

Modified:
    branches/lennart/src/modules/oss-util.c

Modified: branches/lennart/src/modules/oss-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/os=
s-util.c?rev=3D1486&root=3Dpulseaudio&r1=3D1485&r2=3D1486&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/modules/oss-util.c (original)
+++ branches/lennart/src/modules/oss-util.c Sat Jun 23 22:01:40 2007
@@ -26,7 +26,6 @@
 #include <config.h>
 #endif
 =

-#include <assert.h>
 #include <sys/soundcard.h>
 #include <sys/ioctl.h>
 #include <stdio.h>
@@ -40,6 +39,7 @@
 #include <pulsecore/core-error.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 =

 #include "oss-util.h"
 =

@@ -47,24 +47,23 @@
     int fd =3D -1;
     int caps;
 =

-    assert(device && mode && (*mode =3D=3D O_RDWR || *mode =3D=3D O_RDONLY=
 || *mode =3D=3D O_WRONLY));
+    pa_assert(device);
+    pa_assert(mode);
+    pa_assert(*mode =3D=3D O_RDWR || *mode =3D=3D O_RDONLY || *mode =3D=3D=
 O_WRONLY);
 =

     if(!pcaps)
         pcaps =3D &caps;
 =

     if (*mode =3D=3D O_RDWR) {
-        if ((fd =3D open(device, O_RDWR|O_NDELAY)) >=3D 0) {
-            int dcaps, *tcaps;
+        if ((fd =3D open(device, O_RDWR|O_NDELAY|O_NOCTTY)) >=3D 0) {
             ioctl(fd, SNDCTL_DSP_SETDUPLEX, 0);
 =

-            tcaps =3D pcaps ? pcaps : &dcaps;
-
-            if (ioctl(fd, SNDCTL_DSP_GETCAPS, tcaps) < 0) {
+            if (ioctl(fd, SNDCTL_DSP_GETCAPS, pcaps) < 0) {
                 pa_log("SNDCTL_DSP_GETCAPS: %s", pa_cstrerror(errno));
                 goto fail;
             }
 =

-            if (*tcaps & DSP_CAP_DUPLEX)
+            if (*pcaps & DSP_CAP_DUPLEX)
                 goto success;
 =

             pa_log_warn("'%s' doesn't support full duplex", device);
@@ -72,20 +71,18 @@
             close(fd);
         }
 =

-        if ((fd =3D open(device, (*mode =3D O_WRONLY)|O_NDELAY)) < 0) {
-            if ((fd =3D open(device, (*mode =3D O_RDONLY)|O_NDELAY)) < 0) {
+        if ((fd =3D open(device, (*mode =3D O_WRONLY)|O_NDELAY|O_NOCTTY)) =
< 0) {
+            if ((fd =3D open(device, (*mode =3D O_RDONLY)|O_NDELAY|O_NOCTT=
Y)) < 0) {
                 pa_log("open('%s'): %s", device, pa_cstrerror(errno));
                 goto fail;
             }
         }
     } else {
-        if ((fd =3D open(device, *mode|O_NDELAY)) < 0) {
+        if ((fd =3D open(device, *mode|O_NDELAY|O_NOCTTY)) < 0) {
             pa_log("open('%s'): %s", device, pa_cstrerror(errno));
             goto fail;
         }
     }
-
-success:
 =

     *pcaps =3D 0;
 =

@@ -93,6 +90,8 @@
         pa_log("SNDCTL_DSP_GETCAPS: %s", pa_cstrerror(errno));
         goto fail;
     }
+
+success:
 =

     pa_log_debug("capabilities:%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
                  *pcaps & DSP_CAP_BATCH ? " BATCH" : "",
@@ -166,7 +165,8 @@
         [PA_SAMPLE_FLOAT32BE] =3D AFMT_QUERY, /* not supported */
     };
 =

-    assert(fd >=3D 0 && ss);
+    pa_assert(fd >=3D 0);
+    pa_assert(ss);
 =

     orig_format =3D ss->format;
 =

@@ -199,7 +199,7 @@
         pa_log("SNDCTL_DSP_CHANNELS: %s", pa_cstrerror(errno));
         return -1;
     }
-    assert(channels > 0);
+    pa_assert(channels > 0);
 =

     if (ss->channels !=3D channels) {
         pa_log_warn("device doesn't support %i channels, using %i channels=
.", ss->channels, channels);
@@ -211,7 +211,7 @@
         pa_log("SNDCTL_DSP_SPEED: %s", pa_cstrerror(errno));
         return -1;
     }
-    assert(speed > 0);
+    pa_assert(speed > 0);
 =

     if (ss->rate !=3D (unsigned) speed) {
         pa_log_warn("device doesn't support %i Hz, changed to %i Hz.", ss-=
>rate, speed);
@@ -252,9 +252,9 @@
     char cv[PA_CVOLUME_SNPRINT_MAX];
     unsigned vol;
 =

-    assert(fd >=3D 0);
-    assert(ss);
-    assert(volume);
+    pa_assert(fd >=3D 0);
+    pa_assert(ss);
+    pa_assert(volume);
 =

     if (ioctl(fd, mixer, &vol) < 0)
         return -1;
@@ -357,7 +357,7 @@
 =

         if (device =3D=3D n) {
             char *k =3D strchr(line, ':');
-            assert(k);
+            pa_assert(k);
             k++;
             k +=3D strspn(k, " ");
 =





More information about the pulseaudio-commits mailing list