From c7e6e5e006b85530b4fc9379b9df746a4116295b Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Mon, 28 Sep 2020 04:29:02 +0300 Subject: [PATCH] check for device access before open --- src/stream.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/stream.c b/src/stream.c index 7dc33ca..dc47c34 100644 --- a/src/stream.c +++ b/src/stream.c @@ -303,10 +303,23 @@ void stream_switch_slowdown(struct stream_t *stream, bool slowdown) { static struct _workers_pool_t *_stream_init_loop(struct stream_t *stream) { struct _workers_pool_t *pool = NULL; + bool wait_for_access = false; LOG_DEBUG("%s: stream->proc->stop=%d", __FUNCTION__, atomic_load(&stream->proc->stop)); while (!atomic_load(&stream->proc->stop)) { + if (access(stream->dev->path, R_OK) < 0) { + if (!wait_for_access) { + LOG_PERROR("Can't access device"); + LOG_INFO("Waiting for the device access ..."); + wait_for_access = true; + } + sleep(stream->dev->error_delay); + continue; + } else { + wait_for_access = false; + } + SEP_INFO('='); if ((pool = _stream_init_one(stream)) == NULL) {