mirror of https://gerrit.osmocom.org/gapk
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.
This commit is contained in:
parent
d045f1766f
commit
ac3517e715
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue