alsabat: clean return value for playback and capture threads

Remove unnecessary prints in playback and capture threads, and replace
the return value "0" with error code for convenience of maintaining.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Lu, Han 2016-03-23 15:52:44 +08:00 committed by Takashi Iwai
parent 2c37a6f9c4
commit eac9b149b4

View file

@ -316,18 +316,13 @@ static int write_to_pcm_loop(struct pcm_container *sndpcm, struct bat *bat)
while (1) { while (1) {
err = generate_input_data(sndpcm, bytes, bat); err = generate_input_data(sndpcm, bytes, bat);
if (err < 0) if (err != 0)
return err;
else if (err > 0)
break; break;
if (bat->debugplay) { if (bat->debugplay) {
err = fwrite(sndpcm->buffer, 1, bytes, fp); if (fwrite(sndpcm->buffer, 1, bytes, fp) != bytes) {
if (err != bytes) { err = -EIO;
fprintf(bat->err, _("Write file error: ")); break;
fprintf(bat->err, _("%s(%d)\n"),
snd_strerror(err), err);
return -EIO;
} }
bytes_total += bytes; bytes_total += bytes;
} }
@ -339,7 +334,7 @@ static int write_to_pcm_loop(struct pcm_container *sndpcm, struct bat *bat)
err = write_to_pcm(sndpcm, frames, bat); err = write_to_pcm(sndpcm, frames, bat);
if (err != 0) if (err != 0)
return err; break;
} }
if (bat->debugplay) { if (bat->debugplay) {
@ -349,7 +344,7 @@ static int write_to_pcm_loop(struct pcm_container *sndpcm, struct bat *bat)
snd_pcm_drain(sndpcm->handle); snd_pcm_drain(sndpcm->handle);
return 0; return err;
} }
/** /**
@ -405,7 +400,7 @@ void *playback_alsa(struct bat *bat)
} }
err = write_to_pcm_loop(&sndpcm, bat); err = write_to_pcm_loop(&sndpcm, bat);
if (err != 0) { if (err < 0) {
retval_play = err; retval_play = err;
goto exit4; goto exit4;
} }
@ -484,14 +479,12 @@ static int read_from_pcm_loop(struct pcm_container *sndpcm, struct bat *bat)
/* read a chunk from pcm device */ /* read a chunk from pcm device */
err = read_from_pcm(sndpcm, frames, bat); err = read_from_pcm(sndpcm, frames, bat);
if (err != 0) if (err != 0)
return err; break;
/* write the chunk to file */ /* write the chunk to file */
err = fwrite(sndpcm->buffer, 1, size, fp); if (fwrite(sndpcm->buffer, 1, size, fp) != size) {
if (err != size) { err = -EIO;
fprintf(bat->err, _("Write file error: %s(%d)\n"), break;
snd_strerror(err), err);
return -EIO;
} }
bytes_read += size; bytes_read += size;
@ -506,7 +499,7 @@ static int read_from_pcm_loop(struct pcm_container *sndpcm, struct bat *bat)
update_wav_header(bat, fp, bytes_read); update_wav_header(bat, fp, bytes_read);
fclose(fp); fclose(fp);
return 0; return err;
} }
static void pcm_cleanup(void *p) static void pcm_cleanup(void *p)