Fix audio capture reinitialization
We returned instead of continuing, so audio never worked after reinit. We also had no retry logic if no audio device was available.
This commit is contained in:
@@ -222,14 +222,15 @@ namespace audio {
|
|||||||
case platf::capture_e::timeout:
|
case platf::capture_e::timeout:
|
||||||
continue;
|
continue;
|
||||||
case platf::capture_e::reinit:
|
case platf::capture_e::reinit:
|
||||||
|
BOOST_LOG(info) << "Reinitializing audio capture"sv;
|
||||||
mic.reset();
|
mic.reset();
|
||||||
mic = control->microphone(stream->mapping, stream->channelCount, stream->sampleRate, frame_size);
|
do {
|
||||||
if (!mic) {
|
mic = control->microphone(stream->mapping, stream->channelCount, stream->sampleRate, frame_size);
|
||||||
BOOST_LOG(error) << "Couldn't re-initialize audio input"sv;
|
if (!mic) {
|
||||||
|
BOOST_LOG(warning) << "Couldn't re-initialize audio input"sv;
|
||||||
return;
|
}
|
||||||
}
|
} while (!mic && !shutdown_event->view(5s));
|
||||||
return;
|
continue;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,6 +100,25 @@ namespace safe {
|
|||||||
return _status;
|
return _status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pop and view shoud not be used interchangeably
|
||||||
|
template <class Rep, class Period>
|
||||||
|
status_t
|
||||||
|
view(std::chrono::duration<Rep, Period> delay) {
|
||||||
|
std::unique_lock ul { _lock };
|
||||||
|
|
||||||
|
if (!_continue) {
|
||||||
|
return util::false_v<status_t>;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!_status) {
|
||||||
|
if (!_continue || _cv.wait_for(ul, delay) == std::cv_status::timeout) {
|
||||||
|
return util::false_v<status_t>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _status;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
peek() {
|
peek() {
|
||||||
return _continue && (bool) _status;
|
return _continue && (bool) _status;
|
||||||
|
|||||||
Reference in New Issue
Block a user