aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-05-28 20:03:25 +0200
committerHarald Welte <laforge@gnumonks.org>2017-05-28 20:06:01 +0200
commitac3517e715d31b5d2046e46ec578cc8573eff305 (patch)
tree033c08d7b62a1d1acf0f3f5efdfe1065a7814c6e /src
parentd045f1766f68cca56d6961311fde79d8f8211a62 (diff)
alsa/file input: return -1 on eof (short read)
This will permit for a more graceful error than the next element in the processing chain complaining that there's a 0-length input.
Diffstat (limited to 'src')
-rw-r--r--src/pq_alsa.c4
-rw-r--r--src/pq_file.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/pq_alsa.c b/src/pq_alsa.c
index 2a4264e..9cee426 100644
--- a/src/pq_alsa.c
+++ b/src/pq_alsa.c
@@ -46,8 +46,8 @@ pq_cb_alsa_input(void *_state, uint8_t *out, const uint8_t *in, unsigned int in_
unsigned int num_samples = state->blk_len/2;
int rv;
rv = snd_pcm_readi(state->pcm_handle, out, num_samples);
- if (rv < 0)
- return rv;
+ if (rv <= 0)
+ return -1;
return rv * sizeof(uint16_t);
}
diff --git a/src/pq_file.c b/src/pq_file.c
index e191a0a..96f7b3f 100644
--- a/src/pq_file.c
+++ b/src/pq_file.c
@@ -39,8 +39,8 @@ pq_cb_file_input(void *_state, uint8_t *out, const uint8_t *in, unsigned int in_
struct pq_state_file *state = _state;
int rv;
rv = fread(out, state->blk_len, 1, state->fh);
- if (rv < 0)
- return rv;
+ if (rv <= 0)
+ return -1;
return rv * state->blk_len;
}