• Home
  • Raw
  • Download

Lines Matching refs:pipeline

100 struct pipeline {  struct
277 static int topological_sort(struct pipeline *pipeline, in topological_sort() argument
287 struct ini *ini = pipeline->ini; in topological_sort()
304 if (topological_sort(pipeline, env, flow->from, visited) < 0) in topological_sort()
312 instance = ARRAY_APPEND_ZERO(&pipeline->instances); in topological_sort()
323 if (find_origin_port(ini, &pipeline->instances, plugin, in topological_sort()
340 &pipeline->instances, origin, in topological_sort()
360 &pipeline->instances, origin, in topological_sort()
401 struct pipeline *cras_dsp_pipeline_create(struct ini *ini, in cras_dsp_pipeline_create()
405 struct pipeline *pipeline; in cras_dsp_pipeline_create() local
421 pipeline = calloc(1, sizeof(struct pipeline)); in cras_dsp_pipeline_create()
422 if (!pipeline) { in cras_dsp_pipeline_create()
427 pipeline->ini = ini; in cras_dsp_pipeline_create()
428 pipeline->purpose = purpose; in cras_dsp_pipeline_create()
432 rc = topological_sort(pipeline, env, sink, visited); in cras_dsp_pipeline_create()
440 pipeline->source_instance = find_instance_by_plugin( in cras_dsp_pipeline_create()
441 &pipeline->instances, source); in cras_dsp_pipeline_create()
442 pipeline->sink_instance = find_instance_by_plugin( in cras_dsp_pipeline_create()
443 &pipeline->instances, sink); in cras_dsp_pipeline_create()
445 if (!pipeline->source_instance || !pipeline->sink_instance) { in cras_dsp_pipeline_create()
448 cras_dsp_pipeline_free(pipeline); in cras_dsp_pipeline_create()
452 pipeline->input_channels = ARRAY_COUNT( in cras_dsp_pipeline_create()
453 &pipeline->source_instance->output_audio_ports); in cras_dsp_pipeline_create()
454 pipeline->output_channels = ARRAY_COUNT( in cras_dsp_pipeline_create()
455 &pipeline->sink_instance->input_audio_ports); in cras_dsp_pipeline_create()
456 if (pipeline->output_channels > pipeline->input_channels) { in cras_dsp_pipeline_create()
459 cras_dsp_pipeline_free(pipeline); in cras_dsp_pipeline_create()
463 return pipeline; in cras_dsp_pipeline_create()
503 static int allocate_buffers(struct pipeline *pipeline) in allocate_buffers() argument
511 FOR_ARRAY_ELEMENT(&pipeline->instances, i, instance) { in allocate_buffers()
528 pipeline->peak_buf = peak_buf; in allocate_buffers()
529 pipeline->buffers = (float **)calloc(peak_buf, sizeof(float *)); in allocate_buffers()
531 if (!pipeline->buffers) { in allocate_buffers()
543 pipeline->buffers[i] = buf; in allocate_buffers()
548 FOR_ARRAY_ELEMENT(&pipeline->instances, i, instance) { in allocate_buffers()
596 int cras_dsp_pipeline_load(struct pipeline *pipeline) in cras_dsp_pipeline_load() argument
601 FOR_ARRAY_ELEMENT(&pipeline->instances, i, instance) { in cras_dsp_pipeline_load()
607 if (allocate_buffers(pipeline) != 0) in cras_dsp_pipeline_load()
614 static void calculate_audio_delay(struct pipeline *pipeline) in calculate_audio_delay() argument
619 FOR_ARRAY_ELEMENT(&pipeline->instances, i, instance) { in calculate_audio_delay()
630 &pipeline->instances, audio_port->peer->plugin); in calculate_audio_delay()
638 int cras_dsp_pipeline_instantiate(struct pipeline *pipeline, int sample_rate) in cras_dsp_pipeline_instantiate() argument
643 FOR_ARRAY_ELEMENT(&pipeline->instances, i, instance) { in cras_dsp_pipeline_instantiate()
650 pipeline->sample_rate = sample_rate; in cras_dsp_pipeline_instantiate()
652 FOR_ARRAY_ELEMENT(&pipeline->instances, i, instance) { in cras_dsp_pipeline_instantiate()
665 float *buf = pipeline->buffers[audio_port->buf_index]; in cras_dsp_pipeline_instantiate()
674 float *buf = pipeline->buffers[audio_port->buf_index]; in cras_dsp_pipeline_instantiate()
711 calculate_audio_delay(pipeline); in cras_dsp_pipeline_instantiate()
715 void cras_dsp_pipeline_deinstantiate(struct pipeline *pipeline) in cras_dsp_pipeline_deinstantiate() argument
720 FOR_ARRAY_ELEMENT(&pipeline->instances, i, instance) { in cras_dsp_pipeline_deinstantiate()
727 pipeline->sample_rate = 0; in cras_dsp_pipeline_deinstantiate()
730 int cras_dsp_pipeline_get_delay(struct pipeline *pipeline) in cras_dsp_pipeline_get_delay() argument
732 return pipeline->sink_instance->total_delay; in cras_dsp_pipeline_get_delay()
735 int cras_dsp_pipeline_get_sample_rate(struct pipeline *pipeline) in cras_dsp_pipeline_get_sample_rate() argument
737 return pipeline->sample_rate; in cras_dsp_pipeline_get_sample_rate()
740 int cras_dsp_pipeline_get_num_input_channels(struct pipeline *pipeline) in cras_dsp_pipeline_get_num_input_channels() argument
742 return pipeline->input_channels; in cras_dsp_pipeline_get_num_input_channels()
745 int cras_dsp_pipeline_get_num_output_channels(struct pipeline *pipeline) in cras_dsp_pipeline_get_num_output_channels() argument
747 return pipeline->output_channels; in cras_dsp_pipeline_get_num_output_channels()
750 int cras_dsp_pipeline_get_peak_audio_buffers(struct pipeline *pipeline) in cras_dsp_pipeline_get_peak_audio_buffers() argument
752 return pipeline->peak_buf; in cras_dsp_pipeline_get_peak_audio_buffers()
755 static float *find_buffer(struct pipeline *pipeline, in find_buffer() argument
764 return pipeline->buffers[audio_port->buf_index]; in find_buffer()
769 float *cras_dsp_pipeline_get_source_buffer(struct pipeline *pipeline, int index) in cras_dsp_pipeline_get_source_buffer() argument
771 return find_buffer(pipeline, in cras_dsp_pipeline_get_source_buffer()
772 &pipeline->source_instance->output_audio_ports, in cras_dsp_pipeline_get_source_buffer()
776 float *cras_dsp_pipeline_get_sink_buffer(struct pipeline *pipeline, int index) in cras_dsp_pipeline_get_sink_buffer() argument
778 return find_buffer(pipeline, in cras_dsp_pipeline_get_sink_buffer()
779 &pipeline->sink_instance->input_audio_ports, in cras_dsp_pipeline_get_sink_buffer()
783 void cras_dsp_pipeline_set_sink_ext_module(struct pipeline *pipeline, in cras_dsp_pipeline_set_sink_ext_module() argument
787 pipeline->sink_instance->module, in cras_dsp_pipeline_set_sink_ext_module()
791 void cras_dsp_pipeline_run(struct pipeline *pipeline, int sample_count) in cras_dsp_pipeline_run() argument
796 FOR_ARRAY_ELEMENT(&pipeline->instances, i, instance) { in cras_dsp_pipeline_run()
802 void cras_dsp_pipeline_add_statistic(struct pipeline *pipeline, in cras_dsp_pipeline_add_statistic() argument
812 if (pipeline->total_blocks == 0) { in cras_dsp_pipeline_add_statistic()
813 pipeline->max_time = t; in cras_dsp_pipeline_add_statistic()
814 pipeline->min_time = t; in cras_dsp_pipeline_add_statistic()
816 pipeline->max_time = MAX(pipeline->max_time, t); in cras_dsp_pipeline_add_statistic()
817 pipeline->min_time = MIN(pipeline->min_time, t); in cras_dsp_pipeline_add_statistic()
820 pipeline->total_blocks++; in cras_dsp_pipeline_add_statistic()
821 pipeline->total_samples += samples; in cras_dsp_pipeline_add_statistic()
822 pipeline->total_time += t; in cras_dsp_pipeline_add_statistic()
825 int cras_dsp_pipeline_apply(struct pipeline *pipeline, uint8_t *buf, in cras_dsp_pipeline_apply() argument
831 unsigned int input_channels = pipeline->input_channels; in cras_dsp_pipeline_apply()
832 unsigned int output_channels = pipeline->output_channels; in cras_dsp_pipeline_apply()
838 if (!pipeline || frames == 0) in cras_dsp_pipeline_apply()
845 source[i] = cras_dsp_pipeline_get_source_buffer(pipeline, i); in cras_dsp_pipeline_apply()
847 sink[i] = cras_dsp_pipeline_get_sink_buffer(pipeline, i); in cras_dsp_pipeline_apply()
862 cras_dsp_pipeline_run(pipeline, chunk); in cras_dsp_pipeline_apply()
876 cras_dsp_pipeline_add_statistic(pipeline, &delta, frames); in cras_dsp_pipeline_apply()
880 void cras_dsp_pipeline_free(struct pipeline *pipeline) in cras_dsp_pipeline_free() argument
885 FOR_ARRAY_ELEMENT(&pipeline->instances, i, instance) { in cras_dsp_pipeline_free()
903 pipeline->ini = NULL; in cras_dsp_pipeline_free()
904 ARRAY_FREE(&pipeline->instances); in cras_dsp_pipeline_free()
906 for (i = 0; i < pipeline->peak_buf; i++) in cras_dsp_pipeline_free()
907 free(pipeline->buffers[i]); in cras_dsp_pipeline_free()
908 free(pipeline->buffers); in cras_dsp_pipeline_free()
909 free(pipeline); in cras_dsp_pipeline_free()
948 void cras_dsp_pipeline_dump(struct dumper *d, struct pipeline *pipeline) in cras_dsp_pipeline_dump() argument
954 dumpf(d, "pipeline (%s):\n", pipeline->purpose); in cras_dsp_pipeline_dump()
955 dumpf(d, " input channels: %d\n", pipeline->input_channels); in cras_dsp_pipeline_dump()
956 dumpf(d, " output channels: %d\n", pipeline->output_channels); in cras_dsp_pipeline_dump()
957 dumpf(d, " sample_rate: %d\n", pipeline->sample_rate); in cras_dsp_pipeline_dump()
958 dumpf(d, " processed samples: %" PRId64 "\n", pipeline->total_samples); in cras_dsp_pipeline_dump()
959 dumpf(d, " processed blocks: %" PRId64 "\n", pipeline->total_blocks); in cras_dsp_pipeline_dump()
961 pipeline->total_time); in cras_dsp_pipeline_dump()
962 if (pipeline->total_blocks) { in cras_dsp_pipeline_dump()
964 pipeline->total_samples / pipeline->total_blocks); in cras_dsp_pipeline_dump()
966 pipeline->total_time / pipeline->total_blocks); in cras_dsp_pipeline_dump()
969 pipeline->min_time); in cras_dsp_pipeline_dump()
971 pipeline->max_time); in cras_dsp_pipeline_dump()
972 dumpf(d, " cpu load: %g%%\n", pipeline->total_time * 1e-9 in cras_dsp_pipeline_dump()
973 / pipeline->total_samples * pipeline->sample_rate * 100); in cras_dsp_pipeline_dump()
975 ARRAY_COUNT(&pipeline->instances)); in cras_dsp_pipeline_dump()
976 FOR_ARRAY_ELEMENT(&pipeline->instances, i, instance) { in cras_dsp_pipeline_dump()
992 dumpf(d, " peak_buf = %d\n", pipeline->peak_buf); in cras_dsp_pipeline_dump()