diff options
author | Taylor Holberton <taylorcholberton@gmail.com> | 2017-04-06 23:14:14 -0700 |
---|---|---|
committer | Taylor Holberton <taylorcholberton@gmail.com> | 2017-04-06 23:14:19 -0700 |
commit | ea06b977fabd88a3e22c89021ae8020baeebb427 (patch) | |
tree | f3700f189a2e550668fb6b8072043dd0b77c7c39 | |
parent | 851dd8073e08200836bf18c8d9c8283bbc35c299 (diff) |
simplified pcm_read() and pcm_write()
-rw-r--r-- | src/pcm.c | 13 |
1 files changed, 3 insertions, 10 deletions
@@ -48,6 +48,7 @@ #include <sound/asound.h> #include <tinyalsa/pcm.h> +#include <tinyalsa/limits.h> #define PARAM_MAX SNDRV_PCM_HW_PARAM_LAST_INTERVAL #define SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP (1<<2) @@ -626,11 +627,7 @@ int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count) */ int pcm_write(struct pcm *pcm, const void *data, unsigned int count) { - int ret = pcm_writei(pcm, data, pcm_bytes_to_frames(pcm, count)); - if (ret < 0){ - return ret; - } - return 0; + return pcm_writei(pcm, data, pcm_bytes_to_frames(pcm, count)); } /** Reads audio samples from PCM. @@ -646,11 +643,7 @@ int pcm_write(struct pcm *pcm, const void *data, unsigned int count) */ int pcm_read(struct pcm *pcm, void *data, unsigned int count) { - int ret = pcm_readi(pcm, data, pcm_bytes_to_frames(pcm, count)); - if (ret < 0) { - return ret; - } - return 0; + return pcm_readi(pcm, data, pcm_bytes_to_frames(pcm, count)); } static struct pcm bad_pcm = { |