From f2f6583ee671194b7f32887517e4b7f31d7c9eda Mon Sep 17 00:00:00 2001 From: "Lu, Han" Date: Mon, 21 Mar 2016 19:05:48 +0800 Subject: [PATCH] alsabat: fix fopen and messages All files should be opened in either "rb" or "wb" in current usage. Remove incorrect and unneccesary prints. Signed-off-by: Lu, Han Signed-off-by: Takashi Iwai --- bat/alsa.c | 11 +++++------ bat/analyze.c | 2 +- bat/bat.c | 7 +++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/bat/alsa.c b/bat/alsa.c index 638012a..2540ab8 100644 --- a/bat/alsa.c +++ b/bat/alsa.c @@ -303,8 +303,8 @@ static int write_to_pcm_loop(struct pcm_container *sndpcm, struct bat *bat) fp = fopen(bat->debugplay, "wb"); err = -errno; if (fp == NULL) { - fprintf(bat->err, _("Cannot open file for capture: ")); - fprintf(bat->err, _("%s %d\n"), bat->debugplay, err); + fprintf(bat->err, _("Cannot open file: %s %d\n"), + bat->debugplay, err); return err; } /* leave space for wav header */ @@ -404,8 +404,7 @@ void *playback_alsa(struct bat *bat) bat->fp = fopen(bat->playback.file, "rb"); err = -errno; if (bat->fp == NULL) { - fprintf(bat->err, _("Cannot open file for capture: ")); - fprintf(bat->err, _("%s %d\n"), + fprintf(bat->err, _("Cannot open file: %s %d\n"), bat->playback.file, err); retval_play = 1; goto exit3; @@ -545,10 +544,10 @@ void *record_alsa(struct bat *bat) } remove(bat->capture.file); - fp = fopen(bat->capture.file, "w+"); + fp = fopen(bat->capture.file, "wb"); err = -errno; if (fp == NULL) { - fprintf(bat->err, _("Cannot open file for capture: %s %d\n"), + fprintf(bat->err, _("Cannot open file: %s %d\n"), bat->capture.file, err); retval_record = 1; goto exit3; diff --git a/bat/analyze.c b/bat/analyze.c index 63481fb..58781d6 100644 --- a/bat/analyze.c +++ b/bat/analyze.c @@ -296,7 +296,7 @@ int analyze_capture(struct bat *bat) bat->fp = fopen(bat->capture.file, "rb"); err = -errno; if (bat->fp == NULL) { - fprintf(bat->err, _("Cannot open file for capture: %s %d\n"), + fprintf(bat->err, _("Cannot open file: %s %d\n"), bat->capture.file, err); goto exit1; } diff --git a/bat/bat.c b/bat/bat.c index 4821532..85a7282 100644 --- a/bat/bat.c +++ b/bat/bat.c @@ -469,8 +469,8 @@ static int bat_init(struct bat *bat) bat->log = fopen(bat->logarg, "wb"); err = -errno; if (bat->log == NULL) { - fprintf(bat->err, _("Cannot open file for capture:")); - fprintf(bat->err, _(" %s %d\n"), bat->logarg, err); + fprintf(bat->err, _("Cannot open file: %s %d\n"), + bat->logarg, err); return err; } bat->err = bat->log; @@ -533,8 +533,7 @@ static int bat_init(struct bat *bat) bat->fp = fopen(bat->playback.file, "rb"); err = -errno; if (bat->fp == NULL) { - fprintf(bat->err, _("Cannot open file for playback:")); - fprintf(bat->err, _(" %s %d\n"), + fprintf(bat->err, _("Cannot open file: %s %d\n"), bat->playback.file, err); return err; }