• Home
  • Raw
  • Download

Lines Matching refs:bat

58 static int format_convert(struct bat *bat, snd_pcm_format_t *fmt)  in format_convert()  argument
63 if (t->format_bat == bat->format) { in format_convert()
68 fprintf(bat->err, _("Invalid format!\n")); in format_convert()
72 static int set_snd_pcm_params(struct bat *bat, struct pcm_container *sndpcm) in set_snd_pcm_params() argument
85 err = format_convert(bat, &format); in set_snd_pcm_params()
95 fprintf(bat->err, _("Set parameter to device error: ")); in set_snd_pcm_params()
96 fprintf(bat->err, _("default params: %s: %s(%d)\n"), in set_snd_pcm_params()
105 fprintf(bat->err, _("Set parameter to device error: ")); in set_snd_pcm_params()
106 fprintf(bat->err, _("access type: %s: %s(%d)\n"), in set_snd_pcm_params()
114 fprintf(bat->err, _("Set parameter to device error: ")); in set_snd_pcm_params()
115 fprintf(bat->err, _("PCM format: %d %s: %s(%d)\n"), format, in set_snd_pcm_params()
122 params, bat->channels); in set_snd_pcm_params()
124 fprintf(bat->err, _("Set parameter to device error: ")); in set_snd_pcm_params()
125 fprintf(bat->err, _("channel number: %d %s: %s(%d)\n"), in set_snd_pcm_params()
126 bat->channels, in set_snd_pcm_params()
132 rate = bat->rate; in set_snd_pcm_params()
134 params, &bat->rate, in set_snd_pcm_params()
137 fprintf(bat->err, _("Set parameter to device error: ")); in set_snd_pcm_params()
138 fprintf(bat->err, _("sample rate: %d %s: %s(%d)\n"), in set_snd_pcm_params()
139 bat->rate, in set_snd_pcm_params()
143 if ((float) rate * (1 + RATE_RANGE) < bat->rate in set_snd_pcm_params()
144 || (float) rate * (1 - RATE_RANGE) > bat->rate) { in set_snd_pcm_params()
145 fprintf(bat->err, _("Invalid parameters: sample rate: ")); in set_snd_pcm_params()
146 fprintf(bat->err, _("requested %dHz, got %dHz\n"), in set_snd_pcm_params()
147 rate, bat->rate); in set_snd_pcm_params()
151 if (bat->buffer_size > 0 && bat->period_size == 0) in set_snd_pcm_params()
152 bat->period_size = bat->buffer_size / DIV_BUFFERSIZE; in set_snd_pcm_params()
154 if (bat->roundtriplatency && bat->buffer_size == 0) { in set_snd_pcm_params()
159 fprintf(bat->err, in set_snd_pcm_params()
161 fprintf(bat->err, _("buffer size min: %d %s: %s(%d)\n"), in set_snd_pcm_params()
169 fprintf(bat->err, in set_snd_pcm_params()
171 fprintf(bat->err, _("period size min: %d %s: %s(%d)\n"), in set_snd_pcm_params()
176 bat->buffer_size = (int) buffer_size; in set_snd_pcm_params()
177 bat->period_size = (int) period_size; in set_snd_pcm_params()
180 if (bat->buffer_size > 0) { in set_snd_pcm_params()
181 buffer_size = bat->buffer_size; in set_snd_pcm_params()
182 period_size = bat->period_size; in set_snd_pcm_params()
184 fprintf(bat->log, _("Set period size: %d buffer size: %d\n"), in set_snd_pcm_params()
190 fprintf(bat->err, _("Set parameter to device error: ")); in set_snd_pcm_params()
191 fprintf(bat->err, _("buffer size: %d %s: %s(%d)\n"), in set_snd_pcm_params()
200 fprintf(bat->err, _("Set parameter to device error: ")); in set_snd_pcm_params()
201 fprintf(bat->err, _("period size: %d %s: %s(%d)\n"), in set_snd_pcm_params()
209 fprintf(bat->err, in set_snd_pcm_params()
211 fprintf(bat->err, _("buffer time: %d %s: %s(%d)\n"), in set_snd_pcm_params()
226 fprintf(bat->err, _("Set parameter to device error: ")); in set_snd_pcm_params()
227 fprintf(bat->err, _("buffer time: %d %s: %s(%d)\n"), in set_snd_pcm_params()
236 fprintf(bat->err, _("Set parameter to device error: ")); in set_snd_pcm_params()
237 fprintf(bat->err, _("period time: %d %s: %s(%d)\n"), in set_snd_pcm_params()
246 fprintf(bat->err, _("Set parameter to device error: ")); in set_snd_pcm_params()
247 fprintf(bat->err, _("hw params: %s: %s(%d)\n"), in set_snd_pcm_params()
255 fprintf(bat->err, _("Get parameter from device error: ")); in set_snd_pcm_params()
256 fprintf(bat->err, _("period size: %zd %s: %s(%d)\n"), in set_snd_pcm_params()
264 fprintf(bat->err, _("Get parameter from device error: ")); in set_snd_pcm_params()
265 fprintf(bat->err, _("buffer size: %zd %s: %s(%d)\n"), in set_snd_pcm_params()
272 fprintf(bat->err, _("Invalid parameters: can't use period ")); in set_snd_pcm_params()
273 fprintf(bat->err, _("equal to buffer size (%zd)\n"), in set_snd_pcm_params()
278 fprintf(bat->log, _("Get period size: %d buffer size: %d\n"), in set_snd_pcm_params()
283 fprintf(bat->err, _("Invalid parameters: ")); in set_snd_pcm_params()
284 fprintf(bat->err, _("snd_pcm_format_physical_width: %d\n"), in set_snd_pcm_params()
290 sndpcm->frame_bits = sndpcm->sample_bits * bat->channels; in set_snd_pcm_params()
296 fprintf(bat->err, _("Not enough memory: size=%zd\n"), in set_snd_pcm_params()
305 int frames, struct bat *bat) in write_to_pcm() argument
317 fprintf(bat->err, _("Underrun: %s(%d)\n"), in write_to_pcm()
319 if (bat->roundtriplatency) in write_to_pcm()
320 bat->latency.xrun_error = true; in write_to_pcm()
328 fprintf(bat->err, _("Write PCM device error: %s(%d)\n"), in write_to_pcm()
346 struct bat *bat) in latencytest_process_output() argument
352 bat->latency.is_playing = true; in latencytest_process_output()
356 err = handleoutput(bat, sndpcm->buffer, bytes, frames); in latencytest_process_output()
360 err = write_to_pcm(sndpcm, frames, bat); in latencytest_process_output()
365 if (bat->latency.xrun_error == true) in latencytest_process_output()
368 if (bat->latency.state == LATENCY_STATE_COMPLETE_SUCCESS) in latencytest_process_output()
371 bat->periods_played++; in latencytest_process_output()
374 bat->latency.is_playing = false; in latencytest_process_output()
379 static int write_to_pcm_loop(struct pcm_container *sndpcm, struct bat *bat) in write_to_pcm_loop() argument
387 if (bat->debugplay) { in write_to_pcm_loop()
388 fp = fopen(bat->debugplay, "wb"); in write_to_pcm_loop()
391 fprintf(bat->err, _("Cannot open file: %s %d\n"), in write_to_pcm_loop()
392 bat->debugplay, err); in write_to_pcm_loop()
404 err = generate_input_data(bat, sndpcm->buffer, bytes, frames); in write_to_pcm_loop()
408 if (bat->debugplay) { in write_to_pcm_loop()
416 bat->periods_played++; in write_to_pcm_loop()
417 if (bat->period_is_limited in write_to_pcm_loop()
418 && bat->periods_played >= bat->periods_total) in write_to_pcm_loop()
421 err = write_to_pcm(sndpcm, frames, bat); in write_to_pcm_loop()
426 if (bat->debugplay) { in write_to_pcm_loop()
427 update_wav_header(bat, fp, bytes_total); in write_to_pcm_loop()
439 void *playback_alsa(struct bat *bat) in playback_alsa() argument
444 fprintf(bat->log, _("Entering playback thread (ALSA).\n")); in playback_alsa()
449 err = snd_pcm_open(&sndpcm.handle, bat->playback.device, in playback_alsa()
452 fprintf(bat->err, _("Cannot open PCM playback device: ")); in playback_alsa()
453 fprintf(bat->err, _("%s(%d)\n"), snd_strerror(err), err); in playback_alsa()
458 err = set_snd_pcm_params(bat, &sndpcm); in playback_alsa()
464 if (bat->playback.file == NULL) { in playback_alsa()
465 fprintf(bat->log, _("Playing generated audio sine wave")); in playback_alsa()
466 bat->sinus_duration == 0 ? in playback_alsa()
467 fprintf(bat->log, _(" endlessly\n")) : in playback_alsa()
468 fprintf(bat->log, _("\n")); in playback_alsa()
470 fprintf(bat->log, _("Playing input audio file: %s\n"), in playback_alsa()
471 bat->playback.file); in playback_alsa()
472 bat->fp = fopen(bat->playback.file, "rb"); in playback_alsa()
474 if (bat->fp == NULL) { in playback_alsa()
475 fprintf(bat->err, _("Cannot open file: %s %d\n"), in playback_alsa()
476 bat->playback.file, err); in playback_alsa()
481 err = read_wav_header(bat, bat->playback.file, bat->fp, true); in playback_alsa()
488 if (bat->roundtriplatency) in playback_alsa()
489 err = latencytest_process_output(&sndpcm, bat); in playback_alsa()
491 err = write_to_pcm_loop(&sndpcm, bat); in playback_alsa()
498 if (bat->playback.file) in playback_alsa()
499 fclose(bat->fp); in playback_alsa()
509 int frames, struct bat *bat) in read_from_pcm() argument
522 fprintf(bat->err, _("Overrun: %s(%d)\n"), in read_from_pcm()
524 if (bat->roundtriplatency) in read_from_pcm()
525 bat->latency.xrun_error = true; in read_from_pcm()
532 fprintf(bat->err, _("Read PCM device error: %s(%d)\n"), in read_from_pcm()
546 static int read_from_pcm_loop(struct pcm_container *sndpcm, struct bat *bat) in read_from_pcm_loop() argument
552 int bytes_count = bat->frames * bat->frame_size; in read_from_pcm_loop()
555 remove(bat->capture.file); in read_from_pcm_loop()
556 fp = fopen(bat->capture.file, "wb"); in read_from_pcm_loop()
559 fprintf(bat->err, _("Cannot open file: %s %d\n"), in read_from_pcm_loop()
560 bat->capture.file, err); in read_from_pcm_loop()
576 err = read_from_pcm(sndpcm, frames, bat); in read_from_pcm_loop()
588 bat->periods_played++; in read_from_pcm_loop()
590 if (bat->period_is_limited in read_from_pcm_loop()
591 && bat->periods_played >= bat->periods_total) in read_from_pcm_loop()
595 update_wav_header(bat, fp, bytes_read); in read_from_pcm_loop()
605 struct bat *bat) in latencytest_process_input() argument
612 int bytes_count = bat->frames * bat->frame_size; in latencytest_process_input()
614 remove(bat->capture.file); in latencytest_process_input()
615 fp = fopen(bat->capture.file, "wb"); in latencytest_process_input()
618 fprintf(bat->err, _("Cannot open file: %s %d\n"), in latencytest_process_input()
619 bat->capture.file, err); in latencytest_process_input()
628 bat->latency.is_capturing = true; in latencytest_process_input()
632 err = read_from_pcm(sndpcm, frames, bat); in latencytest_process_input()
637 if (bat->latency.xrun_error == true) in latencytest_process_input()
640 err = handleinput(bat, sndpcm->buffer, frames); in latencytest_process_input()
644 if (bat->latency.is_playing == false) in latencytest_process_input()
656 bat->latency.is_capturing = false; in latencytest_process_input()
658 update_wav_header(bat, fp, bytes_read); in latencytest_process_input()
673 void *record_alsa(struct bat *bat) in record_alsa() argument
680 fprintf(bat->log, _("Entering capture thread (ALSA).\n")); in record_alsa()
685 err = snd_pcm_open(&sndpcm.handle, bat->capture.device, in record_alsa()
688 fprintf(bat->err, _("Cannot open PCM capture device: ")); in record_alsa()
689 fprintf(bat->err, _("%s(%d)\n"), snd_strerror(err), err); in record_alsa()
694 err = set_snd_pcm_params(bat, &sndpcm); in record_alsa()
705 fprintf(bat->log, _("Recording ...\n")); in record_alsa()
706 if (bat->roundtriplatency) in record_alsa()
707 err = latencytest_process_input(&sndpcm, bat); in record_alsa()
709 err = read_from_pcm_loop(&sndpcm, bat); in record_alsa()