diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-10-07 16:53:24 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-10-07 16:53:24 +0000 |
commit | 4f97d6740411fb53a4fb5f6e1af03e1f1b28c1ba (patch) | |
tree | 7e0e07b9d8d50fc5dd352d5b36d74fa3cb3427db /cras/src/server/cras_dsp_pipeline.c | |
parent | 8d2c5b2edb9023b91d79709f2900ee1b643a3127 (diff) | |
parent | 8cfb92904b40ff98c82dd5309698999a28c91388 (diff) | |
download | adhd-4f97d6740411fb53a4fb5f6e1af03e1f1b28c1ba.tar.gz |
Snap for 7803083 from 8cfb92904b40ff98c82dd5309698999a28c91388 to mainline-tzdata2-release
Change-Id: Ice40f0028ec451c06ea7097e88c4152da1105d57
Diffstat (limited to 'cras/src/server/cras_dsp_pipeline.c')
-rw-r--r-- | cras/src/server/cras_dsp_pipeline.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/cras/src/server/cras_dsp_pipeline.c b/cras/src/server/cras_dsp_pipeline.c index 945e5c3e..9e492ac5 100644 --- a/cras/src/server/cras_dsp_pipeline.c +++ b/cras/src/server/cras_dsp_pipeline.c @@ -144,8 +144,8 @@ struct pipeline { int64_t total_samples; }; -static struct instance *find_instance_by_plugin(instance_array *instances, - struct plugin *plugin) +static struct instance *find_instance_by_plugin(const instance_array *instances, + const struct plugin *plugin) { int i; struct instance *instance; @@ -161,9 +161,9 @@ static struct instance *find_instance_by_plugin(instance_array *instances, /* Finds out where the data sent to plugin:index come from. The issue * we need to handle here is the previous plugin may be disabled, so * we need to go upstream until we find the real origin */ -static int find_origin_port(struct ini *ini, instance_array *instances, - struct plugin *plugin, int index, - struct plugin **origin, int *origin_index) +static int find_origin_port(struct ini *ini, const instance_array *instances, + const struct plugin *plugin, int index, + const struct plugin **origin, int *origin_index) { enum port_type type; struct port *port; @@ -226,7 +226,7 @@ static int find_origin_port(struct ini *ini, instance_array *instances, } static struct audio_port *find_output_audio_port(instance_array *instances, - struct plugin *plugin, + const struct plugin *plugin, int index) { int i; @@ -246,7 +246,7 @@ static struct audio_port *find_output_audio_port(instance_array *instances, } static struct control_port *find_output_control_port(instance_array *instances, - struct plugin *plugin, + const struct plugin *plugin, int index) { int i; @@ -317,7 +317,7 @@ static int topological_sort(struct pipeline *pipeline, ARRAY_ELEMENT_FOREACH (&plugin->ports, i, port) { int need_connect = (port->flow_id != INVALID_FLOW_ID && port->direction == PORT_INPUT); - struct plugin *origin = NULL; + const struct plugin *origin = NULL; int origin_index = 0; if (need_connect) { @@ -435,6 +435,7 @@ struct pipeline *cras_dsp_pipeline_create(struct ini *ini, if (rc < 0) { syslog(LOG_ERR, "failed to construct pipeline"); + cras_dsp_pipeline_free(pipeline); return NULL; } @@ -524,6 +525,17 @@ static int allocate_buffers(struct pipeline *pipeline) peak_buf = MAX(peak_buf, need_buf); } } + /* + * cras_dsp_pipeline_create creates pipeline with source and sink and it + * makes sure all ports could be accessed from some sources, which means + * that there is at least one source with out > 0 and in == 0. + * This will give us peak_buf > 0 in the previous calculation. + */ + if (peak_buf <= 0) { + syslog(LOG_ERR, "peak_buf = %d, which must be greater than 0.", + peak_buf); + return -1; + } /* then allocate the buffers */ pipeline->peak_buf = peak_buf; @@ -970,9 +982,10 @@ void cras_dsp_pipeline_dump(struct dumper *d, struct pipeline *pipeline) pipeline->min_time); dumpf(d, " max processing time per block: %" PRId64 "ns\n", pipeline->max_time); - dumpf(d, " cpu load: %g%%\n", - pipeline->total_time * 1e-9 / pipeline->total_samples * - pipeline->sample_rate * 100); + if (pipeline->total_samples) + dumpf(d, " cpu load: %g%%\n", + pipeline->total_time * 1e-9 / pipeline->total_samples * + pipeline->sample_rate * 100); dumpf(d, " instances (%d):\n", ARRAY_COUNT(&pipeline->instances)); ARRAY_ELEMENT_FOREACH (&pipeline->instances, i, instance) { struct dsp_module *module = instance->module; |