Print informative error messages for sherpa-onnx-alsa on errors. (#486)
This commit is contained in:
@@ -144,6 +144,24 @@ const std::vector<float> &Alsa::Read(int32_t num_samples) {
|
||||
|
||||
// count is in frames. Each frame contains actual_channel_count_ samples
|
||||
int32_t count = snd_pcm_readi(capture_handle_, samples_.data(), num_samples);
|
||||
if (count == -EPIPE) {
|
||||
static int32_t n = 0;
|
||||
if (++n > 5) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"Too many overruns. It is very likely that the RTF on your board is "
|
||||
"larger than 1. Please use ./bin/sherpa-onnx to compute the RTF.\n");
|
||||
exit(-1);
|
||||
}
|
||||
fprintf(stderr, "XRUN.\n");
|
||||
snd_pcm_prepare(capture_handle_);
|
||||
|
||||
static std::vector<float> tmp;
|
||||
return tmp;
|
||||
} else if (count < 0) {
|
||||
fprintf(stderr, "Can't read PCM device: %s\n", snd_strerror(count));
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
samples_.resize(count * actual_channel_count_);
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ as the device_name.
|
||||
|
||||
int32_t segment_index = 0;
|
||||
while (!stop) {
|
||||
const std::vector<float> samples = alsa.Read(chunk);
|
||||
const std::vector<float> &samples = alsa.Read(chunk);
|
||||
|
||||
stream->AcceptWaveform(expected_sample_rate, samples.data(),
|
||||
samples.size());
|
||||
|
||||
Reference in New Issue
Block a user