X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=utils.c;h=b59e2a40171c5cd139e2722f4c6e423ab50f1eac;hb=refs%2Ftags%2F5.0.2;hp=9476c6914c9150b387e44bee5f2db8b00919efbe;hpb=2478974dfde05063cbf0233e3d3c434ca2f46c7c;p=staging%2Fagl-audio-plugin.git diff --git a/utils.c b/utils.c index 9476c69..b59e2a4 100644 --- a/utils.c +++ b/utils.c @@ -92,7 +92,7 @@ void agl_utils_destroy_null_sink (struct userdata *u, agl_null_sink *ns) if (u && (core = u->core)) { if ((module = pa_idxset_get_by_index (core->modules, ns->module_index))){ pa_log_info ("unloading null sink '%s'", ns->name); - pa_module_unload (core, module, false); + pa_module_unload (module, false); } pa_xfree (ns->name); @@ -120,6 +120,39 @@ pa_source *agl_utils_get_null_source (struct userdata *u, struct agl_null_sink * return sink ? sink->monitor_source : NULL; } +void agl_utils_volume_ramp (struct userdata *u, struct agl_null_sink *ns, bool up) +{ + pa_core *core; + pa_sink *sink; + pa_sink_input *sinp; + uint32_t index; + pa_cvolume_ramp rampvol; + pa_volume_t newvol; + long time; + + if (up) { + newvol = PA_VOLUME_NORM; + time = 5000; + } else { + newvol = PA_VOLUME_NORM *10/100; + time = 3000; + } + + pa_assert (u); + pa_assert_se ((core = u->core)); + + sink = agl_utils_get_null_sink (u, ns); + PA_IDXSET_FOREACH(sinp, core->sink_inputs, index) { + if (sinp->sink && sinp->sink == sink) + break; + sinp = NULL; + } + if (!sinp) return; + + pa_cvolume_ramp_set (&rampvol, sinp->volume.channels, PA_VOLUME_RAMP_TYPE_LINEAR, + time, newvol); + pa_sink_input_set_volume_ramp (sinp, &rampvol, true); +} const char *agl_utils_get_card_name (pa_card *card) { @@ -190,13 +223,13 @@ pa_sink *agl_utils_get_primary_alsa_sink (struct userdata *u) { pa_core *core; pa_sink *sink; - int idx; + uint32_t idx; pa_assert (u); pa_assert_se ((core = u->core)); PA_IDXSET_FOREACH(sink, core->sinks, idx) { - if (sink->name && strstr (sink->name, "alsa_output") && strstr (sink->name, "pci")) + if (sink->name && strstr (sink->name, "alsa_output")) return sink; } @@ -207,7 +240,7 @@ pa_sink *agl_utils_get_alsa_sink (struct userdata *u, const char *name) { pa_core *core; pa_sink *sink; - int idx; + uint32_t idx; pa_assert (u); pa_assert_se ((core = u->core));