GoboLinux Downloads Documentation Community Recipes Screenshots

GoboLinux Recipe & Package Search Tool

3 versions of APulse.

ProgramAgeSizeByWWWSummary
APulse git-r1 837  2188 Wils...
PulseAudio emulation for ALSA
view entry at GitHub | download recipe.bz2 file
01-firefox_mute_button.patch
Recipe
Resources/BuildInformation
Resources/Dependencies
Resources/Description
From b95688954a0ff5c5b35e87c2b50c6600a02a7a7f Mon Sep 17 00:00:00 2001
From: Hisham <hisham@gobolinux.org>
Date: Sat, 18 Mar 2017 21:03:05 -0300
Subject: [PATCH] Make sink volume a per-stream property.

This makes the "mute" button on each Firefox tab work separately.
Without this patch, muting one tab mutes them all.

Fixes #46.
---
 src/apulse-context.c | 8 +++++---
 src/apulse-stream.c  | 5 ++++-
 src/apulse.h         | 2 +-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/apulse-context.c b/src/apulse-context.c
index 85c53d9..ebb14b0 100644
--- a/src/apulse-context.c
+++ b/src/apulse-context.c
@@ -300,7 +300,6 @@ pa_context_new_with_proplist(pa_mainloop_api *mainloop_api, const \
char *name, pa
     c->streams_ht = g_hash_table_new(g_direct_hash, g_direct_equal);
 
     for (uint32_t k = 0; k < PA_CHANNELS_MAX; k++) {
-        c->sink_volume[k] = PA_VOLUME_NORM;
         c->source_volume[k] = PA_VOLUME_NORM;
     }
 
@@ -342,12 +341,15 @@ pa_context_set_sink_input_mute(pa_context *c, uint32_t idx, \
int mute, pa_context
 static void
 pa_context_set_sink_input_volume_impl(pa_operation *op)
 {
-    memset(&op->c->sink_volume, 0, sizeof(op->c->sink_volume));
+    uint32_t idx = op->int_arg_1;
+    pa_stream *s = g_hash_table_lookup(op->c->streams_ht, GINT_TO_POINTER(idx));
+
+    memset(s->volume, 0, sizeof(s->volume));
 
     const uint32_t channels = MIN(op->pa_cvolume_arg_1.channels, PA_CHANNELS_MAX);
 
     for (uint32_t k = 0; k < channels; k++)
-        op->c->sink_volume[k] = op->pa_cvolume_arg_1.values[k];
+        s->volume[k] = op->pa_cvolume_arg_1.values[k];
 
     if (op->context_success_cb)
         op->context_success_cb(op->c, 1, op->cb_userdata);
diff --git a/src/apulse-stream.c b/src/apulse-stream.c
index 9dfdaf8..242a248 100644
--- a/src/apulse-stream.c
+++ b/src/apulse-stream.c
@@ -124,7 +124,7 @@ data_available_for_stream(pa_mainloop_api *a, pa_io_event *ioe, \
int fd, pa_io_ev
             size_t bytecnt = MIN(buf_size, frame_count * frame_size);
             bytecnt = ringbuffer_read(s->rb, buf, bytecnt);
 
-            pa_apply_volume_multiplier(buf, bytecnt, s->c->sink_volume, &s->ss);
+            pa_apply_volume_multiplier(buf, bytecnt, s->volume, &s->ss);
 
             if (bytecnt == 0) {
                 // application is not ready yet, play silence
@@ -776,6 +776,9 @@ pa_stream_new_with_proplist(pa_context *c, const char *name, \
const pa_sample_spe
     s->rb = ringbuffer_new(72 * 1024);    // TODO: figure out size
     s->peek_buffer = malloc(s->rb->end - s->rb->start);
 
+    for (uint32_t k = 0; k < PA_CHANNELS_MAX; k++)
+        s->volume[k] = PA_VOLUME_NORM;
+
     return s;
 }
 
diff --git a/src/apulse.h b/src/apulse.h
index c38def2..9e34678 100644
--- a/src/apulse.h
+++ b/src/apulse.h
@@ -46,7 +46,6 @@ struct pa_context {
     int                     next_stream_idx;
     GHashTable             *streams_ht;
     pa_volume_t             source_volume[PA_CHANNELS_MAX];
-    pa_volume_t             sink_volume[PA_CHANNELS_MAX];
 };
 
 struct pa_io_event {
@@ -114,6 +113,7 @@ struct pa_stream {
     size_t                  peek_buffer_data_len;
     void                   *write_buffer;
     volatile int            paused;
+    pa_volume_t             volume[PA_CHANNELS_MAX];
 };
 
 struct pa_operation {
APulse 0.1.9-r2 873  2217 Hish...
PulseAudio emulation for ALSA
APulse 0.1.8-r1 898  1460 Hish...
PulseAudio emulation for ALSA