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:
Harald Welte 2017-05-28 20:03:25 +02:00
parent d045f1766f
commit ac3517e715
2 changed files with 4 additions and 4 deletions

View File

@ -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);
}

View File

@ -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;
}