This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository enlightenment.

View the commit online.

commit 8ee2737d1f96ed0f377224fd8fa54ed0388fbe6b
Author: Carsten Haitzler <[email protected]>
AuthorDate: Fri Jan 30 14:39:11 2026 +0000

    mixer - add actions to set or next/prev sink
    
    really handy to bind action to key to switch audio devices...
    
    @feat
---
 src/modules/mixer/backend.c    | 96 +++++++++++++++++++++++++++++++++++++++++-
 src/modules/mixer/backend.h    |  1 +
 src/modules/mixer/e_mod_main.c | 39 +++++++++++++++++
 src/modules/mixer/e_mod_main.h |  2 +
 4 files changed, 136 insertions(+), 2 deletions(-)

diff --git a/src/modules/mixer/backend.c b/src/modules/mixer/backend.c
index c399467d9..6eadfa3ef 100644
--- a/src/modules/mixer/backend.c
+++ b/src/modules/mixer/backend.c
@@ -36,6 +36,9 @@ static void _volume_mute_app_cb(E_Object *obj, const char *params);
 static void _volume_increase_source_cb(E_Object *obj, const char *params);
 static void _volume_decrease_source_cb(E_Object *obj, const char *params);
 static void _volume_mute_source_cb(E_Object *obj, const char *params);
+static void _volume_sink_set_cb(E_Object *obj, const char *params);
+static void _volume_sink_next_cb(E_Object *obj, const char *params);
+static void _volume_sink_prev_cb(E_Object *obj, const char *params);
 static void _actions_register(void);
 static void _actions_unregister(void);
 static void _sink_event(int type, void *info);
@@ -98,6 +101,9 @@ static E_Action *_action_mute_app = NULL;
 static E_Action *_action_incr_source = NULL;
 static E_Action *_action_decr_source = NULL;
 static E_Action *_action_mute_source = NULL;
+static E_Action *_action_set_sink = NULL;
+static E_Action *_action_next_sink = NULL;
+static E_Action *_action_prev_sink = NULL;
 
 static void
 _notify_cb(void *data EINA_UNUSED, unsigned int id)
@@ -335,6 +341,65 @@ _volume_mute_app_cb(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
      }
 }
 
+static void
+_volume_sink_set_cb(E_Object *obj EINA_UNUSED, const char *params)
+{
+  Eina_List *l;
+  Emix_Sink *sink;
+
+  if (!params) return;
+  EINA_LIST_FOREACH(backend_sinks_get(), l, sink)
+    {
+      if ((sink->name) && (!strcmp(sink->name, params)))
+        {
+          backend_sink_default_set(sink);
+          break;
+        }
+    }
+}
+
+static void
+_volume_sink_next_cb(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
+{
+  Eina_List *sinks, *l;
+  Emix_Sink *sink, *cursink;
+
+  cursink = backend_sink_default_get();
+  sinks = backend_sinks_get();
+  EINA_LIST_FOREACH(sinks, l, sink)
+    {
+      if (sink == cursink)
+        {
+          if (l->next) sink = l->next->data;
+          else sink = sinks->data;
+          backend_sink_default_set(sink);
+          popup_all();
+          break;
+        }
+    }
+}
+
+static void
+_volume_sink_prev_cb(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
+{
+  Eina_List *sinks, *l;
+  Emix_Sink *sink, *cursink;
+
+  cursink = backend_sink_default_get();
+  sinks = backend_sinks_get();
+  EINA_LIST_FOREACH(sinks, l, sink)
+    {
+      if (sink == cursink)
+        {
+          if (l->prev) sink = l->prev->data;
+          else sink = eina_list_last_data_get(sinks);
+          backend_sink_default_set(sink);
+          popup_all();
+          break;
+        }
+    }
+}
+
 static void
 _actions_register(void)
 {
@@ -356,7 +421,7 @@ _actions_register(void)
    if (_action_mute)
      {
         _action_mute->func.go = _volume_mute_cb;
-        e_action_predef_name_set("Mixer", _("Mute volume"),
+        e_action_predef_name_set("Mixer", _("Mute Volume"),
                                  "volume_mute", NULL, NULL, 0);
      }
    _action_incr_app = e_action_add("volume_increase_app");
@@ -401,9 +466,30 @@ _actions_register(void)
    if (_action_mute_source)
      {
         _action_mute_source->func.go = _volume_mute_source_cb;
-        e_action_predef_name_set("Mixer", _("Mute Mic volume"),
+        e_action_predef_name_set("Mixer", _("Mute Mic Volume"),
                                  "volume_mute_mic", NULL, NULL, 0);
      }
+   _action_set_sink = e_action_add("volume_sink_set");
+   if (_action_set_sink)
+     {
+        _action_set_sink->func.go = _volume_sink_set_cb;
+        e_action_predef_name_set("Mixer", _("Set Sink Source"),
+                                 "volume_sink_set", NULL, NULL, 0);
+     }
+   _action_next_sink = e_action_add("volume_sink_next");
+   if (_action_next_sink)
+     {
+        _action_next_sink->func.go = _volume_sink_next_cb;
+        e_action_predef_name_set("Mixer", _("Next Sink Source"),
+                                 "volume_sink_next", NULL, NULL, 0);
+     }
+   _action_prev_sink = e_action_add("volume_sink_prev");
+   if (_action_prev_sink)
+     {
+        _action_prev_sink->func.go = _volume_sink_prev_cb;
+        e_action_predef_name_set("Mixer", _("Previous Sink Source"),
+                                 "volume_sink_prev", NULL, NULL, 0);
+     }
 
    e_comp_canvas_keys_ungrab();
    e_comp_canvas_keys_grab();
@@ -1564,6 +1650,12 @@ backend_sink_default_get(void)
    return _sink_default;
 }
 
+EINTERN const Eina_List *
+backend_sinks_get(void)
+{
+   return emix_sinks_get();
+}
+
 //////////////////////////////////////////////////////////////////////////////
 
 EINTERN Eina_Bool
diff --git a/src/modules/mixer/backend.h b/src/modules/mixer/backend.h
index 90122f4d1..a1461414d 100644
--- a/src/modules/mixer/backend.h
+++ b/src/modules/mixer/backend.h
@@ -20,6 +20,7 @@ EINTERN Eina_Bool backend_mute_get(void);
 
 EINTERN void backend_sink_default_set(const Emix_Sink *s);
 EINTERN const Emix_Sink *backend_sink_default_get(void);
+EINTERN const Eina_List *backend_sinks_get(void);
 
 EINTERN Eina_Bool backend_source_active_get(void);
 EINTERN void backend_source_volume_decrease(void);
diff --git a/src/modules/mixer/e_mod_main.c b/src/modules/mixer/e_mod_main.c
index 8cb970545..95d4eb1b7 100644
--- a/src/modules/mixer/e_mod_main.c
+++ b/src/modules/mixer/e_mod_main.c
@@ -45,6 +45,7 @@ struct _Context
    E_Module *module;
    Eina_List *instances;
    E_Menu *menu;
+   Ecore_Timer *popdown_timer;
 };
 
 typedef struct _Mon_Data Mon_Data;
@@ -141,6 +142,7 @@ static void _source_monitor(Instance *inst, Emix_Source *s);
 static void _popup_playback_box_refill(Instance *inst);
 static void _popup_recording_fill(Instance *inst);
 
+
 static void
 _cb_emix_event(void *data, enum Emix_Event event, void *event_info EINA_UNUSED)
 {
@@ -1009,6 +1011,42 @@ _popup_new(Instance *inst)
      elm_list_item_selected_set(default_it, EINA_TRUE);
 }
 
+static Eina_Bool
+_cb_popdown_all_timer(void *data EINA_UNUSED)
+{
+  Eina_List *l;
+  Instance *inst;
+
+  mixer_context->popdown_timer = NULL;
+  EINA_LIST_FOREACH(mixer_context->instances, l, inst)
+    {
+      if (inst->popup) _popup_del(inst);
+    }
+  return EINA_FALSE;
+}
+
+void
+popup_all(void)
+{
+  Eina_List *l;
+  Instance *inst;
+
+  EINA_LIST_FOREACH(mixer_context->instances, l, inst)
+    {
+      if (!inst->popup)
+        {
+          if (inst->gcc->gadcon->zone == e_zone_current_get())
+            {
+              _popup_new(inst);
+              break;
+            }
+        }
+    }
+  if (mixer_context->popdown_timer)
+    ecore_timer_del(mixer_context->popdown_timer);
+  mixer_context->popdown_timer = ecore_timer_add(1.0, _cb_popdown_all_timer, NULL);
+}
+
 static void
 _menu_cb(void *data, E_Menu *menu EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
 {
@@ -1199,6 +1237,7 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED)
    E_FREE_LIST(_handlers, ecore_event_handler_del);
    if (mixer_context)
      {
+        E_FREE_FUNC(mixer_context->popdown_timer, ecore_timer_del);
         free(mixer_context->theme);
         E_FREE(mixer_context);
      }
diff --git a/src/modules/mixer/e_mod_main.h b/src/modules/mixer/e_mod_main.h
index bb624a115..b8e3e3736 100644
--- a/src/modules/mixer/e_mod_main.h
+++ b/src/modules/mixer/e_mod_main.h
@@ -22,4 +22,6 @@ E_API void *e_modapi_init(E_Module *m);
 E_API int   e_modapi_shutdown(E_Module *m);
 E_API int   e_modapi_save(E_Module *m);
 
+void popup_all(void);
+
 #endif /* _E_MOD_MAIN_H_ */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to