[pulseaudio-discuss] [PATCH 2/3] pactl: Add signal receiver
Georg Chini
georg at chini.tk
Mon Oct 30 15:00:22 UTC 2017
---
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 e444f973..d0d80ab9 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 c7dc57ac..d4d95fb2 100644
--- a/src/utils/pactl.c
+++ b/src/utils/pactl.c
@@ -1232,6 +1232,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 *sender, const char *signal, const char *signal_parameters, void *userdata) {
+ pa_assert(c);
+
+ printf(_("Signal '%s' from %s\n"),
+ signal,
+ sender);
+ 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;
@@ -1479,6 +1490,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