{
int err;
snd_config_t *config;
- FILE *fp;
+ snd_input_t *in;
+ snd_output_t *out;
int stdio;
err = snd_config_top(&config);
return err;
}
stdio = !strcmp(file, "-");
- if (!stdio && (fp = fopen(file, "r"))) {
- err = snd_config_load(config, fp);
- if (!stdio)
- fclose(fp);
+ if (!stdio && (err = snd_input_stdio_open(&in, file)) >= 0) {
+ err = snd_config_load(config, in);
+ snd_input_close(in);
#if 0
if (err < 0) {
error("snd_config_load error: %s", snd_strerror(err));
}
}
- if (stdio)
- fp = stdout;
+ if (stdio)
+ err = snd_output_stdio_attach(&out, stdout, 0);
else
- fp = fopen(file, "w");
- if (!fp) {
+ err = snd_output_stdio_open(&out, file);
+ if (err < 0) {
error("Cannot open %s for writing", file);
return -errno;
}
- err = snd_config_save(config, fp);
- if (!stdio)
- fclose(fp);
+ err = snd_config_save(config, out);
+ snd_output_close(out);
if (err < 0)
error("snd_config_save: %s", snd_strerror(err));
return 0;
{
int err;
snd_config_t *config;
- FILE *fp;
+ snd_input_t *in;
int stdio;
err = snd_config_top(&config);
}
stdio = !strcmp(file, "-");
if (stdio)
- fp = stdin;
+ err = snd_input_stdio_attach(&in, stdin, 0);
else
- fp = fopen(file, "r");
- if (fp) {
- err = snd_config_load(config, fp);
- if (!stdio)
- fclose(fp);
+ err = snd_input_stdio_open(&in, file);
+ if (err >= 0) {
+ err = snd_config_load(config, in);
+ snd_input_close(in);
if (err < 0) {
error("snd_config_load error: %s", snd_strerror(err));
return err;
static size_t chunk_bytes;
static int digtype = SND_CONTROL_TYPE_NONE;
static snd_digital_audio_t diga;
+static snd_output_t *log;
static int count;
static int vocmajor, vocminor;
static void pcm_list(void)
{
snd_config_t *conf;
+ snd_output_t *out;
int err = snd_config_update();
if (err < 0)
error("snd_pcm_update: %s", snd_strerror(err));
+ err = snd_output_stdio_attach(&out, stderr, 0);
+ assert(err >= 0);
err = snd_config_search(snd_config, "pcm", &conf);
if (err < 0)
return;
fprintf(stderr, "PCM list:");
- snd_config_save(conf, stderr);
+ snd_config_save(conf, out);
+ snd_output_close(out);
}
static void version(void)
char *pcm_name = "plug:0,0";
int tmp, err, c;
+ err = snd_output_stdio_attach(&log, stderr, 0);
+ assert(err >= 0);
+
command = argv[0];
file_type = FORMAT_DEFAULT;
if (strstr(argv[0], "arecord")) {
}
snd_pcm_close(handle);
free(audiobuf);
+ snd_output_close(log);
return EXIT_SUCCESS;
}
err = snd_pcm_hw_params(handle, ¶ms);
if (err < 0) {
fprintf(stderr, "Unable to install hw params:\n");
- snd_pcm_hw_params_dump(¶ms, stderr);
+ snd_pcm_hw_params_dump(¶ms, log);
exit(EXIT_FAILURE);
}
chunk_size = snd_pcm_hw_param_value(¶ms, SND_PCM_HW_PARAM_PERIOD_SIZE, 0);
assert(err >= 0);
if (snd_pcm_sw_params(handle, &swparams) < 0) {
error("unable to install sw params:");
- snd_pcm_sw_params_dump(&swparams, stderr);
+ snd_pcm_sw_params_dump(&swparams, log);
exit(EXIT_FAILURE);
}
if (snd_pcm_prepare(handle) < 0) {
}
if (verbose)
- snd_pcm_dump(handle, stderr);
+ snd_pcm_dump(handle, log);
bits_per_sample = snd_pcm_format_physical_width(hwparams.format);
bits_per_frame = bits_per_sample * hwparams.channels;
fprintf(stderr, "xrun!!! (at least %.3f ms long)\n", diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
if (verbose) {
fprintf(stderr, "Status:\n");
- snd_pcm_status_dump(&status, stderr);
+ snd_pcm_status_dump(&status, log);
}
if ((res = snd_pcm_prepare(handle))<0) {
error("xrun: prepare error: %s", snd_strerror(res));