Lines Matching +full:diff +full:- +full:channels
1 // SPDX-License-Identifier: GPL-2.0
21 #include "alsa-local.h"
69 timestamp_t now, diff; in timestamp_diff_ms() local
71 if (tstamp->tv_nsec > now.tv_nsec) { in timestamp_diff_ms()
72 diff.tv_sec = now.tv_sec - tstamp->tv_sec - 1; in timestamp_diff_ms()
73 diff.tv_nsec = (now.tv_nsec + 1000000000L) - tstamp->tv_nsec; in timestamp_diff_ms()
75 diff.tv_sec = now.tv_sec - tstamp->tv_sec; in timestamp_diff_ms()
76 diff.tv_nsec = now.tv_nsec - tstamp->tv_nsec; in timestamp_diff_ms()
78 return (diff.tv_sec * 1000) + ((diff.tv_nsec + 500000L) / 1000000L); in timestamp_diff_ms()
92 return -1; in device_from_id()
100 for (pcm_data = pcm_list; pcm_data != NULL; pcm_data = pcm_data->next) { in missing_device()
101 if (pcm_data->card != card) in missing_device()
103 if (pcm_data->device != device) in missing_device()
105 if (pcm_data->subdevice != subdevice) in missing_device()
107 if (pcm_data->stream != stream) in missing_device()
114 pcm_data->card = card; in missing_device()
115 pcm_data->device = device; in missing_device()
116 pcm_data->subdevice = subdevice; in missing_device()
117 pcm_data->stream = stream; in missing_device()
118 pcm_data->next = pcm_missing; in missing_device()
166 card = -1; in find_pcms()
193 err = snd_ctl_card_info_malloc(&card_data->info); in find_pcms()
198 err = snd_ctl_card_info(handle, card_data->info); in find_pcms()
200 card_data->name = snd_ctl_card_info_get_id(card_data->info); in find_pcms()
201 if (!card_data->name) in find_pcms()
207 if (!card_data->name) in find_pcms()
208 card_data->name = "Unknown"; in find_pcms()
210 ksft_print_msg("Card %d/%s - %s (%s)\n", card, in find_pcms()
211 card_data->name, card_name, card_longname); in find_pcms()
215 card_data->card = card; in find_pcms()
216 card_data->next = card_list; in find_pcms()
219 dev = -1; in find_pcms()
238 if (err == -ENOENT) in find_pcms()
244 ksft_print_msg("%s.0 - %s\n", card_data->name, in find_pcms()
258 pcm_data->card = card; in find_pcms()
259 pcm_data->device = dev; in find_pcms()
260 pcm_data->subdevice = subdev; in find_pcms()
261 pcm_data->card_name = card_data->name; in find_pcms()
262 pcm_data->stream = stream; in find_pcms()
263 pcm_data->pcm_config = conf_get_subtree(card_config, key, NULL); in find_pcms()
264 pcm_data->next = pcm_list; in find_pcms()
299 long rate, channels, period_size, buffer_size; in test_pcm_time() local
324 ksft_print_msg("%s.%s.%s.%d.%d.%s - %s\n", in test_pcm_time()
326 data->card_name, data->device, data->subdevice, in test_pcm_time()
327 snd_pcm_stream_name(data->stream), in test_pcm_time()
341 channels = conf_get_long(pcm_cfg, "channels", NULL, 2); in test_pcm_time()
345 samples = malloc((rate * channels * snd_pcm_format_physical_width(format)) / 8); in test_pcm_time()
348 snd_pcm_format_set_silence(format, samples, rate * channels); in test_pcm_time()
350 sprintf(name, "hw:%d,%d,%d", data->card, data->device, data->subdevice); in test_pcm_time()
351 err = snd_pcm_open(&handle, name, data->stream, 0); in test_pcm_time()
373 i = -1; in test_pcm_time()
382 ksft_print_msg("%s.%s.%d.%d.%s.%s format %s -> %s\n", in test_pcm_time()
384 data->card_name, data->device, data->subdevice, in test_pcm_time()
385 snd_pcm_stream_name(data->stream), in test_pcm_time()
389 samples = realloc(samples, (rate * channels * in test_pcm_time()
393 snd_pcm_format_set_silence(format, samples, rate * channels); in test_pcm_time()
401 err = snd_pcm_hw_params_set_channels(handle, hw_params, channels); in test_pcm_time()
403 snprintf(msg, sizeof(msg), "snd_pcm_hw_params_set_channels %ld: %s", channels, snd_strerror(err)); in test_pcm_time()
439 if (data->stream == SND_PCM_STREAM_PLAYBACK) { in test_pcm_time()
462 data->card_name, data->device, data->subdevice, in test_pcm_time()
463 snd_pcm_stream_name(data->stream), in test_pcm_time()
466 (long)rate, (long)channels, in test_pcm_time()
475 if (data->stream == SND_PCM_STREAM_PLAYBACK) { in test_pcm_time()
504 if (ms < duration_ms - margin_ms || ms > duration_ms + margin_ms) { in test_pcm_time()
523 data->card_name, data->device, in test_pcm_time()
524 data->subdevice, in test_pcm_time()
525 snd_pcm_stream_name(data->stream)); in test_pcm_time()
534 data->card_name, data->device, in test_pcm_time()
535 data->subdevice, in test_pcm_time()
536 snd_pcm_stream_name(data->stream)); in test_pcm_time()
540 data->card_name, data->device, in test_pcm_time()
541 data->subdevice, in test_pcm_time()
542 snd_pcm_stream_name(data->stream)); in test_pcm_time()
585 for (pcm = pcm_list; pcm != NULL; pcm = pcm->next) { in card_thread()
586 if (pcm->card != card->card) in card_thread()
590 run_time_tests(pcm, TEST_CLASS_SYSTEM, pcm->pcm_config); in card_thread()
608 global_config = conf_load_from_file("pcm-test.conf"); in main()
617 for (conf = conf_cards; conf; conf = conf->next) in main()
618 if (conf->card < 0) in main()
623 for (pcm = pcm_list; pcm != NULL; pcm = pcm->next) { in main()
625 cfg = pcm->pcm_config; in main()
636 for (conf = conf_cards; conf; conf = conf->next) in main()
637 if (conf->card < 0) in main()
639 conf->filename, conf->config_id); in main()
641 for (pcm = pcm_missing; pcm != NULL; pcm = pcm->next) { in main()
643 pcm->card_name, pcm->device, pcm->subdevice, in main()
644 snd_pcm_stream_name(pcm->stream)); in main()
647 for (card = card_list; card != NULL; card = card->next) { in main()
648 ret = pthread_create(&card->thread, NULL, card_thread, card); in main()
651 card->card, ret, in main()
656 for (card = card_list; card != NULL; card = card->next) { in main()
657 ret = pthread_join(card->thread, &thread_ret); in main()
660 card->card, ret, in main()