[pulseaudio-discuss] [PATCH 2/3] pactl: Add signal receiver
Georg Chini
georg at chini.tk
Mon Apr 9 18:27:46 UTC 2018
---
man/pactl.1.xml.in | 2 +-
src/utils/pactl.c | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/man/pactl.1.xml.in b/man/pactl.1.xml.in
index 66c0bda9..5279791b 100644
--- a/man/pactl.1.xml.in
+++ b/man/pactl.1.xml.in
@@ -254,7 +254,7 @@ License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
<option>
<p><opt>subscribe</opt></p>
- <optdesc><p>Subscribe to events, pactl does not exit by itself, but keeps waiting for new events.</p></optdesc>
+ <optdesc><p>Subscribe to events and signals, pactl does not exit by itself, but keeps waiting for new events.</p></optdesc>
</option>
</section>
diff --git a/src/utils/pactl.c b/src/utils/pactl.c
index 1f13e60c..87827d38 100644
--- a/src/utils/pactl.c
+++ b/src/utils/pactl.c
@@ -1251,6 +1251,17 @@ static void context_subscribe_callback(pa_context *c, pa_subscription_event_type
fflush(stdout);
}
+static void context_signal_callback(pa_context *c, const char *signal_object_path, const char *signal, char *signal_parameters, void *userdata) {
+ pa_assert(c);
+
+ printf(_("Signal '%s' from %s\n"),
+ signal,
+ signal_object_path);
+ if (signal_parameters)
+ printf(_("Signal parameters: '%s'\n"), signal_parameters);
+ fflush(stdout);
+}
+
static void context_state_callback(pa_context *c, void *userdata) {
pa_operation *o = NULL;
@@ -1498,6 +1509,15 @@ static void context_state_callback(pa_context *c, void *userdata) {
PA_SUBSCRIPTION_MASK_CARD,
NULL,
NULL);
+ if (o) {
+ pa_operation_unref(o);
+ actions++;
+ }
+
+ pa_context_set_signal_callback(c, context_signal_callback, NULL);
+
+ o = pa_context_subscribe_signals(c, (uint64_t) -1, NULL, NULL);
+
break;
default:
--
2.14.1
More information about the pulseaudio-discuss
mailing list