mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-08 07:22:32 +00:00
pulsemixer: Implement MIXER_FLAG_AUTO_NOTIFICATIONS
Add the mixer flag and send notifications when either the volume or muted status changes. https://bugzilla.gnome.org/show_bug.cgi?id=618389
This commit is contained in:
parent
287894a89a
commit
bead93ab7b
2 changed files with 57 additions and 3 deletions
|
@ -61,6 +61,8 @@ gst_pulsemixer_ctrl_sink_info_cb (pa_context * context, const pa_sink_info * i,
|
||||||
int eol, void *userdata)
|
int eol, void *userdata)
|
||||||
{
|
{
|
||||||
GstPulseMixerCtrl *c = userdata;
|
GstPulseMixerCtrl *c = userdata;
|
||||||
|
gboolean vol_chg = FALSE;
|
||||||
|
gboolean old_mute;
|
||||||
|
|
||||||
/* Called from the background thread! */
|
/* Called from the background thread! */
|
||||||
|
|
||||||
|
@ -90,8 +92,10 @@ gst_pulsemixer_ctrl_sink_info_cb (pa_context * context, const pa_sink_info * i,
|
||||||
c->description = g_strdup (i->description);
|
c->description = g_strdup (i->description);
|
||||||
c->index = i->index;
|
c->index = i->index;
|
||||||
c->channel_map = i->channel_map;
|
c->channel_map = i->channel_map;
|
||||||
|
vol_chg = !pa_cvolume_equal (&c->volume, &i->volume);
|
||||||
c->volume = i->volume;
|
c->volume = i->volume;
|
||||||
c->muted = ! !i->mute;
|
old_mute = c->muted;
|
||||||
|
c->muted = !!i->mute;
|
||||||
c->type = GST_PULSEMIXER_SINK;
|
c->type = GST_PULSEMIXER_SINK;
|
||||||
|
|
||||||
if (c->track) {
|
if (c->track) {
|
||||||
|
@ -104,6 +108,19 @@ gst_pulsemixer_ctrl_sink_info_cb (pa_context * context, const pa_sink_info * i,
|
||||||
|
|
||||||
c->operation_success = TRUE;
|
c->operation_success = TRUE;
|
||||||
pa_threaded_mainloop_signal (c->mainloop, 0);
|
pa_threaded_mainloop_signal (c->mainloop, 0);
|
||||||
|
|
||||||
|
if (vol_chg && c->track) {
|
||||||
|
gint volumes[PA_CHANNELS_MAX];
|
||||||
|
gint i;
|
||||||
|
for (i = 0; i < c->volume.channels; i++)
|
||||||
|
volumes[i] = (gint) (c->volume.values[i]);
|
||||||
|
GST_LOG_OBJECT (c->object, "Sending volume change notification");
|
||||||
|
gst_mixer_volume_changed (GST_MIXER (c->object), c->track, volumes);
|
||||||
|
}
|
||||||
|
if ((c->muted != old_mute) && c->track) {
|
||||||
|
GST_LOG_OBJECT (c->object, "Sending mute toggled notification");
|
||||||
|
gst_mixer_mute_toggled (GST_MIXER (c->object), c->track, c->muted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -111,6 +128,8 @@ gst_pulsemixer_ctrl_source_info_cb (pa_context * context,
|
||||||
const pa_source_info * i, int eol, void *userdata)
|
const pa_source_info * i, int eol, void *userdata)
|
||||||
{
|
{
|
||||||
GstPulseMixerCtrl *c = userdata;
|
GstPulseMixerCtrl *c = userdata;
|
||||||
|
gboolean vol_chg = FALSE;
|
||||||
|
gboolean old_mute;
|
||||||
|
|
||||||
/* Called from the background thread! */
|
/* Called from the background thread! */
|
||||||
|
|
||||||
|
@ -140,8 +159,10 @@ gst_pulsemixer_ctrl_source_info_cb (pa_context * context,
|
||||||
c->description = g_strdup (i->description);
|
c->description = g_strdup (i->description);
|
||||||
c->index = i->index;
|
c->index = i->index;
|
||||||
c->channel_map = i->channel_map;
|
c->channel_map = i->channel_map;
|
||||||
|
vol_chg = !pa_cvolume_equal (&c->volume, &i->volume);
|
||||||
c->volume = i->volume;
|
c->volume = i->volume;
|
||||||
c->muted = ! !i->mute;
|
old_mute = c->muted;
|
||||||
|
c->muted = !!i->mute;
|
||||||
c->type = GST_PULSEMIXER_SOURCE;
|
c->type = GST_PULSEMIXER_SOURCE;
|
||||||
|
|
||||||
if (c->track) {
|
if (c->track) {
|
||||||
|
@ -154,6 +175,19 @@ gst_pulsemixer_ctrl_source_info_cb (pa_context * context,
|
||||||
|
|
||||||
c->operation_success = TRUE;
|
c->operation_success = TRUE;
|
||||||
pa_threaded_mainloop_signal (c->mainloop, 0);
|
pa_threaded_mainloop_signal (c->mainloop, 0);
|
||||||
|
|
||||||
|
if (vol_chg && c->track) {
|
||||||
|
gint volumes[PA_CHANNELS_MAX];
|
||||||
|
gint i;
|
||||||
|
for (i = 0; i < c->volume.channels; i++)
|
||||||
|
volumes[i] = (gint) (c->volume.values[i]);
|
||||||
|
GST_LOG_OBJECT (c->object, "Sending volume change notification");
|
||||||
|
gst_mixer_volume_changed (GST_MIXER (c->object), c->track, volumes);
|
||||||
|
}
|
||||||
|
if ((c->muted != old_mute) && c->track) {
|
||||||
|
GST_LOG_OBJECT (c->object, "Sending mute toggled notification");
|
||||||
|
gst_mixer_mute_toggled (GST_MIXER (c->object), c->track, c->muted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -195,7 +229,7 @@ gst_pulsemixer_ctrl_success_cb (pa_context * context, int success,
|
||||||
{
|
{
|
||||||
GstPulseMixerCtrl *c = (GstPulseMixerCtrl *) userdata;
|
GstPulseMixerCtrl *c = (GstPulseMixerCtrl *) userdata;
|
||||||
|
|
||||||
c->operation_success = ! !success;
|
c->operation_success = !!success;
|
||||||
pa_threaded_mainloop_signal (c->mainloop, 0);
|
pa_threaded_mainloop_signal (c->mainloop, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,6 +429,8 @@ gst_pulsemixer_ctrl_new (GObject * object, const gchar * server,
|
||||||
const gchar * device, GstPulseMixerType type)
|
const gchar * device, GstPulseMixerType type)
|
||||||
{
|
{
|
||||||
GstPulseMixerCtrl *c = NULL;
|
GstPulseMixerCtrl *c = NULL;
|
||||||
|
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE ((object),
|
||||||
|
GST_TYPE_MIXER), c);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (object, "new mixer ctrl for %s", device);
|
GST_DEBUG_OBJECT (object, "new mixer ctrl for %s", device);
|
||||||
c = g_new (GstPulseMixerCtrl, 1);
|
c = g_new (GstPulseMixerCtrl, 1);
|
||||||
|
@ -596,3 +632,9 @@ gst_pulsemixer_ctrl_set_mute (GstPulseMixerCtrl * c, GstMixerTrack * track,
|
||||||
|
|
||||||
pa_threaded_mainloop_unlock (c->mainloop);
|
pa_threaded_mainloop_unlock (c->mainloop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GstMixerFlags
|
||||||
|
gst_pulsemixer_ctrl_get_mixer_flags (GstPulseMixerCtrl * mixer)
|
||||||
|
{
|
||||||
|
return GST_MIXER_FLAG_AUTO_NOTIFICATIONS;
|
||||||
|
}
|
||||||
|
|
|
@ -90,6 +90,7 @@ void gst_pulsemixer_ctrl_set_mute (GstPulseMixerCtrl * mixer,
|
||||||
GstMixerTrack * track, gboolean mute);
|
GstMixerTrack * track, gboolean mute);
|
||||||
void gst_pulsemixer_ctrl_set_record (GstPulseMixerCtrl * mixer,
|
void gst_pulsemixer_ctrl_set_record (GstPulseMixerCtrl * mixer,
|
||||||
GstMixerTrack * track, gboolean record);
|
GstMixerTrack * track, gboolean record);
|
||||||
|
GstMixerFlags gst_pulsemixer_ctrl_get_mixer_flags (GstPulseMixerCtrl * mixer);
|
||||||
|
|
||||||
#define GST_IMPLEMENT_PULSEMIXER_CTRL_METHODS(Type, interface_as_function) \
|
#define GST_IMPLEMENT_PULSEMIXER_CTRL_METHODS(Type, interface_as_function) \
|
||||||
static const GList* \
|
static const GList* \
|
||||||
|
@ -146,6 +147,16 @@ interface_as_function ## _set_mute (GstMixer * mixer, GstMixerTrack * track,
|
||||||
\
|
\
|
||||||
gst_pulsemixer_ctrl_set_mute (this->mixer, track, mute); \
|
gst_pulsemixer_ctrl_set_mute (this->mixer, track, mute); \
|
||||||
} \
|
} \
|
||||||
|
static GstMixerFlags \
|
||||||
|
interface_as_function ## _get_mixer_flags (GstMixer * mixer) \
|
||||||
|
{ \
|
||||||
|
Type *this = (Type*) mixer; \
|
||||||
|
\
|
||||||
|
g_return_val_if_fail (this != NULL, GST_MIXER_FLAG_NONE); \
|
||||||
|
g_return_val_if_fail (this->mixer != NULL, GST_MIXER_FLAG_NONE); \
|
||||||
|
\
|
||||||
|
return gst_pulsemixer_ctrl_get_mixer_flags (this->mixer); \
|
||||||
|
} \
|
||||||
static void \
|
static void \
|
||||||
interface_as_function ## _mixer_interface_init (GstMixerClass * klass) \
|
interface_as_function ## _mixer_interface_init (GstMixerClass * klass) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -156,6 +167,7 @@ interface_as_function ## _mixer_interface_init (GstMixerClass * klass)
|
||||||
klass->get_volume = interface_as_function ## _get_volume; \
|
klass->get_volume = interface_as_function ## _get_volume; \
|
||||||
klass->set_mute = interface_as_function ## _set_mute; \
|
klass->set_mute = interface_as_function ## _set_mute; \
|
||||||
klass->set_record = interface_as_function ## _set_record; \
|
klass->set_record = interface_as_function ## _set_record; \
|
||||||
|
klass->get_mixer_flags = interface_as_function ## _get_mixer_flags; \
|
||||||
}
|
}
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
Loading…
Reference in a new issue