mixer - properly update default sink and set def sink too in mixer popup

mixer popup SAVED the def mixer but never SET it...  and this led to a
bunch of issues when getting gixed. now its saved and set. NOW the
mixer popup has a quick way to select the output sink (device). handy
if uyou use usb audio for heapdhones but on board audio for speakers
for example (or hdmi audio or something).

@fix
This commit is contained in:
Carsten Haitzler 2021-03-07 11:09:41 +00:00
parent b16b0bda20
commit 434833e9da
2 changed files with 13 additions and 9 deletions

View File

@ -71,6 +71,7 @@ static void _backend_changed(void);
static int _backend_log_domain = 0;
static int _volume_init = 0;
static Eina_Bool _backend_init_flag = EINA_FALSE;
static Eina_Bool _restored = EINA_FALSE;
EINTERN int E_EVENT_MIXER_BACKEND_CHANGED = 0;
EINTERN int E_EVENT_MIXER_SINKS_CHANGED = 0;
@ -405,6 +406,7 @@ _disconnected(void)
e_client_volume_sink_del(sink);
}
_sink_default = NULL;
_restored = EINA_FALSE;
_backend_changed();
}
@ -421,7 +423,7 @@ _ready(void)
_sink_default = emix_sinks_get()->data;
}
if (emix_config_save_get())
if (emix_config_save_get() && !_restored)
{
Emix_Sink *s;
const char *sinkname;
@ -442,6 +444,7 @@ _ready(void)
}
}
emix_config_save_state_restore();
_restored = EINA_TRUE;
}
_backend_changed();
@ -1181,7 +1184,7 @@ backend_init(void)
if (!backend_loaded) goto err;
if (emix_sink_default_support())
_sink_default = emix_sink_default_get();
_sink_default = emix_sink_default_get();
_actions_register();
@ -1332,6 +1335,7 @@ backend_sink_default_set(const Emix_Sink *s)
if (s)
{
DBG("Sink default set %s", s->name);
emix_sink_default_set((Emix_Sink *)s);
emix_config_save_sink_set(s->name);
}
_backend_changed();

View File

@ -669,7 +669,7 @@ _sink_default_cb(pa_context *c EINA_UNUSED, const pa_sink_info *info, int eol,
{
Eina_Bool prev_default = sink->base.default_sink;
sink->base.default_sink = (uint32_t)sink->idx == info->index;
if (ctx->cb && prev_default != sink->base.default_sink)
if (ctx->cb && (prev_default != sink->base.default_sink))
ctx->cb((void *)ctx->userdata, EMIX_SINK_CHANGED_EVENT,
(Emix_Sink *)sink);
}
@ -719,11 +719,12 @@ _server_info_cb(pa_context *c, const pa_server_info *info,
{
pa_operation *o;
if (pa_context_errno(c) != PA_OK)
{
WRN("Could not get pa server info, error: %d", pa_context_errno(c));
return;
}
// this seems to trap old errors then forget to update defaults as below
// if (pa_context_errno(c) != PA_OK)
// {
// WRN("Could not get pa server info, error: %d", pa_context_errno(c));
// return;
// }
EINA_SAFETY_ON_NULL_RETURN(info);
@ -1359,7 +1360,6 @@ _sink_input_volume_set(Emix_Sink_Input *input, Emix_Volume *volume)
pa_cvolume vol = _emix_volume_convert(volume);
EINA_SAFETY_ON_FALSE_RETURN(ctx && ctx->context && input != NULL);
if (!(o = pa_context_set_sink_input_volume(ctx->context,
sink_input->idx, &vol,
NULL, NULL)))