mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 04:15:44 +01:00
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:
parent
2c37a6f9c4
commit
eac9b149b4
1 changed files with 12 additions and 19 deletions
31
bat/alsa.c
31
bat/alsa.c
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue