[pulseaudio-commits] r1638 - /branches/lennart/src/modules/module-hal-detect.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sat Aug 11 09:51:22 PDT 2007


Author: lennart
Date: Sat Aug 11 18:51:21 2007
New Revision: 1638

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1638&root=3Dpulseaudio&vi=
ew=3Drev
Log:
make sure that the device access event sound is only generated once

Modified:
    branches/lennart/src/modules/module-hal-detect.c

Modified: branches/lennart/src/modules/module-hal-detect.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-hal-detect.c?rev=3D1638&root=3Dpulseaudio&r1=3D1637&r2=3D1638&view=3Dd=
iff
=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/module-hal-detect.c (original)
+++ branches/lennart/src/modules/module-hal-detect.c Sat Aug 11 18:51:21 20=
07
@@ -68,6 +68,7 @@
     uint32_t index;
     char *udi;
     char *sink_name, *source_name;
+    int acl_race_fix;
 };
 =

 struct userdata {
@@ -329,6 +330,7 @@
         return NULL;
 =

     d =3D pa_xnew(struct device, 1);
+    d->acl_race_fix =3D 0;
     d->udi =3D pa_xstrdup(udi);
     d->index =3D m->index;
     d->sink_name =3D sink_name;
@@ -559,23 +561,27 @@
             udi =3D dbus_message_get_path(message);
             =

             if ((d =3D pa_hashmap_get(u->devices, udi))) {
-                =

+                int send_acl_race_fix_message =3D 0;
+
+                d->acl_race_fix =3D 0;                            =

+
                 if (d->sink_name) {
                     pa_sink *sink;
                     =

                     if ((sink =3D pa_namereg_get(u->core, d->sink_name, PA=
_NAMEREG_SINK, 0))) {
-                        =

                         int prev_suspended =3D pa_sink_get_state(sink) =3D=
=3D PA_SINK_SUSPENDED;
 =

-                        if (pa_sink_suspend(sink, suspend) >=3D 0) {
-                            if (!suspend && prev_suspended)
+                        if (prev_suspended && !suspend) {
+                            /* resume */
+                            if (pa_sink_suspend(sink, 0) >=3D 0)
                                 pa_scache_play_item_by_name(u->core, "puls=
e-access", d->sink_name, PA_VOLUME_NORM, 0);
-                            else if (suspend && !prev_suspended) {
-                                DBusMessage *msg;
-                                msg =3D dbus_message_new_signal(udi, "org.=
pulseaudio.Server", "DirtyGiveUpMessage");
-                                dbus_connection_send(pa_dbus_connection_ge=
t(u->connection), msg, NULL);
-                                dbus_message_unref(msg);
-                            }
+                            else
+                                d->acl_race_fix =3D 1;
+                            =

+                        } else if (!prev_suspended && suspend) {
+                            /* suspend */
+                            if (pa_sink_suspend(sink, 1) >=3D 0)
+                                send_acl_race_fix_message =3D 1;
                         }
                     }
                 }
@@ -583,10 +589,29 @@
                 if (d->source_name) {
                     pa_source *source;
 =

-                    if ((source =3D pa_namereg_get(u->core, d->source_name=
, PA_NAMEREG_SOURCE, 0)))
-                        pa_source_suspend(source, suspend);
+                    if ((source =3D pa_namereg_get(u->core, d->source_name=
, PA_NAMEREG_SOURCE, 0))) {
+                        int prev_suspended =3D pa_source_get_state(source)=
 =3D=3D PA_SOURCE_SUSPENDED;
+
+                        if (prev_suspended && !suspend) {
+                            /* resume */
+                            if (pa_source_suspend(source, 0) < 0)
+                                d->acl_race_fix =3D 1;
+
+                        } else if (!prev_suspended && suspend) {
+                            /* suspend */
+                            if (pa_source_suspend(source, 0) >=3D 0)
+                                send_acl_race_fix_message =3D 1;
+                        }
+                    }
                 }
-                =

+
+                if (send_acl_race_fix_message) {
+                    DBusMessage *msg;
+                    msg =3D dbus_message_new_signal(udi, "org.pulseaudio.S=
erver", "DirtyGiveUpMessage");
+                    dbus_connection_send(pa_dbus_connection_get(u->connect=
ion), msg, NULL);
+                    dbus_message_unref(msg);
+                }
+                    =

             } else if (!suspend)
                 device_added_cb(u->context, udi);
         }
@@ -600,30 +625,38 @@
         const char *udi;
         struct device *d;
 =

-        pa_log_debug("Got dirty give up message, trying resume ...");
-
         udi =3D dbus_message_get_path(message);
         =

-        if ((d =3D pa_hashmap_get(u->devices, udi))) {
-
+        if ((d =3D pa_hashmap_get(u->devices, udi)) && d->acl_race_fix) {
+            pa_log_debug("Got dirty give up message for '%s', trying resum=
e ...", udi);
+
+            d->acl_race_fix =3D 0;
+            =

             if (d->sink_name) {
                 pa_sink *sink;
                 =

                 if ((sink =3D pa_namereg_get(u->core, d->sink_name, PA_NAM=
EREG_SINK, 0))) {
 =

                     int prev_suspended =3D pa_sink_get_state(sink) =3D=3D =
PA_SINK_SUSPENDED;
-                    =

-                    if (pa_sink_suspend(sink, 0) >=3D 0)
-                        if (prev_suspended && !prev_suspended)
+
+                    if (prev_suspended) {
+                        /* resume */
+                        if (pa_sink_suspend(sink, 0) >=3D 0)
                             pa_scache_play_item_by_name(u->core, "pulse-ac=
cess", d->sink_name, PA_VOLUME_NORM, 0);
+                    }
                 }
             }
             =

             if (d->source_name) {
                 pa_source *source;
                 =

-                if ((source =3D pa_namereg_get(u->core, d->source_name, PA=
_NAMEREG_SOURCE, 0)))
-                    pa_source_suspend(source, 0);
+                if ((source =3D pa_namereg_get(u->core, d->source_name, PA=
_NAMEREG_SOURCE, 0))) {
+
+                    int prev_suspended =3D pa_source_get_state(source) =3D=
=3D PA_SOURCE_SUSPENDED;
+
+                    if (prev_suspended)
+                        pa_source_suspend(source, 0);
+                }
             }
             =

         } else =





More information about the pulseaudio-commits mailing list