• Home
  • Raw
  • Download

Lines Matching full:bat

43 static int format_convert(struct bat *bat, struct pcm_config *config)  in format_convert()  argument
48 if (t->format_bat == bat->format) { in format_convert()
53 fprintf(bat->err, _("Invalid format!\n")); in format_convert()
57 static int init_config(struct bat *bat, struct pcm_config *config) in init_config() argument
59 config->channels = bat->channels; in init_config()
60 config->rate = bat->rate; in init_config()
61 if (bat->period_size > 0) in init_config()
62 config->period_size = bat->period_size; in init_config()
70 return format_convert(bat, config); in init_config()
87 static int check_param(struct bat *bat, struct pcm_params *params, in check_param() argument
97 fprintf(bat->err, in check_param()
105 fprintf(bat->err, in check_param()
117 static int check_playback_params(struct bat *bat, in check_playback_params() argument
121 unsigned int card = bat->playback.card_tiny; in check_playback_params()
122 unsigned int device = bat->playback.device_tiny; in check_playback_params()
127 fprintf(bat->err, _("Unable to open PCM device %u!\n"), in check_playback_params()
132 err = check_param(bat, params, PCM_PARAM_RATE, in check_playback_params()
136 err = check_param(bat, params, PCM_PARAM_CHANNELS, in check_playback_params()
140 err = check_param(bat, params, PCM_PARAM_SAMPLE_BITS, in check_playback_params()
141 bat->sample_size * 8, "Bitrate", " bits"); in check_playback_params()
144 err = check_param(bat, params, PCM_PARAM_PERIOD_SIZE, in check_playback_params()
148 err = check_param(bat, params, PCM_PARAM_PERIODS, in check_playback_params()
162 static int latencytest_process_output(struct bat *bat, struct pcm *pcm, in latencytest_process_output() argument
166 int frames = bytes / bat->frame_size; in latencytest_process_output()
168 fprintf(bat->log, _("Play sample with %d frames buffer\n"), frames); in latencytest_process_output()
170 bat->latency.is_playing = true; in latencytest_process_output()
174 err = handleoutput(bat, buffer, bytes, frames); in latencytest_process_output()
182 if (bat->latency.state == LATENCY_STATE_COMPLETE_SUCCESS) in latencytest_process_output()
185 bat->periods_played++; in latencytest_process_output()
188 bat->latency.is_playing = false; in latencytest_process_output()
196 static int play_sample(struct bat *bat, struct pcm *pcm, in play_sample() argument
200 int frames = bytes / bat->frame_size; in play_sample()
204 if (bat->debugplay) { in play_sample()
205 fp = fopen(bat->debugplay, "wb"); in play_sample()
208 fprintf(bat->err, _("Cannot open file: %s %d\n"), in play_sample()
209 bat->debugplay, err); in play_sample()
221 err = generate_input_data(bat, buffer, bytes, frames); in play_sample()
225 if (bat->debugplay) { in play_sample()
233 bat->periods_played++; in play_sample()
234 if (bat->period_is_limited in play_sample()
235 && bat->periods_played >= bat->periods_total) in play_sample()
243 if (bat->debugplay) { in play_sample()
244 update_wav_header(bat, fp, bytes_total); in play_sample()
250 static int get_tiny_device(struct bat *bat, char *alsa_device, in get_tiny_device() argument
275 fprintf(bat->err, _("Invalid tiny device: %s\n"), alsa_device); in get_tiny_device()
282 void *playback_tinyalsa(struct bat *bat) in playback_tinyalsa() argument
290 fprintf(bat->log, _("Entering playback thread (tinyalsa).\n")); in playback_tinyalsa()
295 err = get_tiny_device(bat, bat->playback.device, in playback_tinyalsa()
296 &bat->playback.card_tiny, in playback_tinyalsa()
297 &bat->playback.device_tiny); in playback_tinyalsa()
304 err = init_config(bat, &config); in playback_tinyalsa()
311 err = check_playback_params(bat, &config); in playback_tinyalsa()
318 pcm = pcm_open(bat->playback.card_tiny, bat->playback.device_tiny, in playback_tinyalsa()
321 fprintf(bat->err, _("Unable to open PCM device %u (%s)!\n"), in playback_tinyalsa()
322 bat->playback.device_tiny, pcm_get_error(pcm)); in playback_tinyalsa()
336 if (bat->playback.file == NULL) { in playback_tinyalsa()
337 fprintf(bat->log, _("Playing generated audio sine wave")); in playback_tinyalsa()
338 bat->sinus_duration == 0 ? in playback_tinyalsa()
339 fprintf(bat->log, _(" endlessly\n")) : in playback_tinyalsa()
340 fprintf(bat->log, _("\n")); in playback_tinyalsa()
342 fprintf(bat->log, _("Playing input audio file: %s\n"), in playback_tinyalsa()
343 bat->playback.file); in playback_tinyalsa()
344 bat->fp = fopen(bat->playback.file, "rb"); in playback_tinyalsa()
346 if (bat->fp == NULL) { in playback_tinyalsa()
347 fprintf(bat->err, _("Cannot open file: %s %d\n"), in playback_tinyalsa()
348 bat->playback.file, err); in playback_tinyalsa()
353 err = read_wav_header(bat, bat->playback.file, bat->fp, true); in playback_tinyalsa()
360 if (bat->roundtriplatency) in playback_tinyalsa()
361 err = latencytest_process_output(bat, pcm, buffer, bufbytes); in playback_tinyalsa()
363 err = play_sample(bat, pcm, buffer, bufbytes); in playback_tinyalsa()
370 if (bat->playback.file) in playback_tinyalsa()
371 fclose(bat->fp); in playback_tinyalsa()
383 static int capture_sample(struct bat *bat, struct pcm *pcm, in capture_sample() argument
389 unsigned int bytes_count = bat->frames * bat->frame_size; in capture_sample()
391 remove(bat->capture.file); in capture_sample()
392 fp = fopen(bat->capture.file, "wb"); in capture_sample()
395 fprintf(bat->err, _("Cannot open file: %s %d\n"), in capture_sample()
396 bat->capture.file, err); in capture_sample()
412 bat->periods_played++; in capture_sample()
414 if (bat->period_is_limited in capture_sample()
415 && bat->periods_played >= bat->periods_total) in capture_sample()
419 err = update_wav_header(bat, fp, bytes_read); in capture_sample()
428 static int latencytest_process_input(struct bat *bat, struct pcm *pcm, in latencytest_process_input() argument
434 unsigned int bytes_count = bat->frames * bat->frame_size; in latencytest_process_input()
436 remove(bat->capture.file); in latencytest_process_input()
437 fp = fopen(bat->capture.file, "wb"); in latencytest_process_input()
440 fprintf(bat->err, _("Cannot open file: %s %d\n"), in latencytest_process_input()
441 bat->capture.file, err); in latencytest_process_input()
451 bat->latency.is_capturing = true; in latencytest_process_input()
457 err = handleinput(bat, buffer, bytes / bat->frame_size); in latencytest_process_input()
461 if (bat->latency.is_playing == false) in latencytest_process_input()
467 bat->latency.is_capturing = false; in latencytest_process_input()
469 err = update_wav_header(bat, fp, bytes_read); in latencytest_process_input()
478 void *record_tinyalsa(struct bat *bat) in record_tinyalsa() argument
488 fprintf(bat->log, _("Entering capture thread (tinyalsa).\n")); in record_tinyalsa()
493 err = get_tiny_device(bat, bat->capture.device, in record_tinyalsa()
494 &bat->capture.card_tiny, in record_tinyalsa()
495 &bat->capture.device_tiny); in record_tinyalsa()
502 err = init_config(bat, &config); in record_tinyalsa()
509 pcm = pcm_open(bat->capture.card_tiny, bat->capture.device_tiny, in record_tinyalsa()
512 fprintf(bat->err, _("Unable to open PCM device (%s)!\n"), in record_tinyalsa()
531 fprintf(bat->log, _("Recording ...\n")); in record_tinyalsa()
532 if (bat->roundtriplatency) in record_tinyalsa()
533 err = latencytest_process_input(bat, pcm, buffer, bufbytes); in record_tinyalsa()
535 err = capture_sample(bat, pcm, buffer, bufbytes); in record_tinyalsa()