X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=utils.c;h=b59e2a40171c5cd139e2722f4c6e423ab50f1eac;hb=refs%2Ftags%2Feel_5.0.2;hp=88425d270694d1b0103e375cbc40cdaba5c5a1ab;hpb=acb229813f5845e8b38bea56870211319887f3b4;p=staging%2Fagl-audio-plugin.git diff --git a/utils.c b/utils.c index 88425d2..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,7 +223,7 @@ 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)); @@ -203,6 +236,24 @@ pa_sink *agl_utils_get_primary_alsa_sink (struct userdata *u) return NULL; } +pa_sink *agl_utils_get_alsa_sink (struct userdata *u, const char *name) +{ + pa_core *core; + pa_sink *sink; + 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, name)) + return sink; + } + + return NULL; +} + void agl_utils_init_stamp (void) { stamp = 0;