mirror of
https://gitlab.gnome.org/GNOME/libgnome-volume-control.git
synced 2024-12-12 07:30:19 +00:00
gvc-mixer-source-output: Update volume and mute status
This commit implements notifying about volume and mute status changes for source outputs (applications that monitor the microphone, in short). https://bugzilla.gnome.org/show_bug.cgi?id=760387
This commit is contained in:
parent
7e5504db3d
commit
d4eda71c49
@ -1776,6 +1776,7 @@ update_source_output (GvcMixerControl *control,
|
|||||||
{
|
{
|
||||||
GvcMixerStream *stream;
|
GvcMixerStream *stream;
|
||||||
gboolean is_new;
|
gboolean is_new;
|
||||||
|
pa_volume_t max_volume;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
@ -1802,10 +1803,14 @@ update_source_output (GvcMixerControl *control,
|
|||||||
name = (const char *)g_hash_table_lookup (control->priv->clients,
|
name = (const char *)g_hash_table_lookup (control->priv->clients,
|
||||||
GUINT_TO_POINTER (info->client));
|
GUINT_TO_POINTER (info->client));
|
||||||
|
|
||||||
|
max_volume = pa_cvolume_max (&info->volume);
|
||||||
|
|
||||||
gvc_mixer_stream_set_name (stream, name);
|
gvc_mixer_stream_set_name (stream, name);
|
||||||
gvc_mixer_stream_set_description (stream, info->name);
|
gvc_mixer_stream_set_description (stream, info->name);
|
||||||
set_application_id_from_proplist (stream, info->proplist);
|
set_application_id_from_proplist (stream, info->proplist);
|
||||||
set_is_event_stream_from_proplist (stream, info->proplist);
|
set_is_event_stream_from_proplist (stream, info->proplist);
|
||||||
|
gvc_mixer_stream_set_volume (stream, (guint)max_volume);
|
||||||
|
gvc_mixer_stream_set_is_muted (stream, info->mute);
|
||||||
set_icon_name_from_proplist (stream, info->proplist, "audio-input-microphone");
|
set_icon_name_from_proplist (stream, info->proplist, "audio-input-microphone");
|
||||||
|
|
||||||
if (is_new) {
|
if (is_new) {
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include <pulse/pulseaudio.h>
|
#include <pulse/pulseaudio.h>
|
||||||
|
|
||||||
#include "gvc-mixer-source-output.h"
|
#include "gvc-mixer-source-output.h"
|
||||||
|
#include "gvc-mixer-stream-private.h"
|
||||||
|
#include "gvc-channel-map-private.h"
|
||||||
|
|
||||||
#define GVC_MIXER_SOURCE_OUTPUT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SOURCE_OUTPUT, GvcMixerSourceOutputPrivate))
|
#define GVC_MIXER_SOURCE_OUTPUT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GVC_TYPE_MIXER_SOURCE_OUTPUT, GvcMixerSourceOutputPrivate))
|
||||||
|
|
||||||
@ -45,8 +47,33 @@ G_DEFINE_TYPE (GvcMixerSourceOutput, gvc_mixer_source_output, GVC_TYPE_MIXER_STR
|
|||||||
static gboolean
|
static gboolean
|
||||||
gvc_mixer_source_output_push_volume (GvcMixerStream *stream, gpointer *op)
|
gvc_mixer_source_output_push_volume (GvcMixerStream *stream, gpointer *op)
|
||||||
{
|
{
|
||||||
/* FIXME: */
|
pa_operation *o;
|
||||||
*op = NULL;
|
guint index;
|
||||||
|
const GvcChannelMap *map;
|
||||||
|
pa_context *context;
|
||||||
|
const pa_cvolume *cv;
|
||||||
|
|
||||||
|
index = gvc_mixer_stream_get_index (stream);
|
||||||
|
|
||||||
|
map = gvc_mixer_stream_get_channel_map (stream);
|
||||||
|
|
||||||
|
cv = gvc_channel_map_get_cvolume(map);
|
||||||
|
|
||||||
|
context = gvc_mixer_stream_get_pa_context (stream);
|
||||||
|
|
||||||
|
o = pa_context_set_source_output_volume (context,
|
||||||
|
index,
|
||||||
|
cv,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (o == NULL) {
|
||||||
|
g_warning ("pa_context_set_source_output_volume() failed");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*op = o;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +81,26 @@ static gboolean
|
|||||||
gvc_mixer_source_output_change_is_muted (GvcMixerStream *stream,
|
gvc_mixer_source_output_change_is_muted (GvcMixerStream *stream,
|
||||||
gboolean is_muted)
|
gboolean is_muted)
|
||||||
{
|
{
|
||||||
/* FIXME: */
|
pa_operation *o;
|
||||||
|
guint index;
|
||||||
|
pa_context *context;
|
||||||
|
|
||||||
|
index = gvc_mixer_stream_get_index (stream);
|
||||||
|
context = gvc_mixer_stream_get_pa_context (stream);
|
||||||
|
|
||||||
|
o = pa_context_set_source_output_mute (context,
|
||||||
|
index,
|
||||||
|
is_muted,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (o == NULL) {
|
||||||
|
g_warning ("pa_context_set_source_output_mute_by_index() failed");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_operation_unref(o);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user