Skip to content
Snippets Groups Projects
Verified Commit 53c66daf authored by rahix's avatar rahix
Browse files

fix(streams): Allow poll_stream to be NULL


Signed-off-by: default avatarRahix <rahix@rahix.de>
parent 8fec99bb
No related branches found
No related tags found
No related merge requests found
...@@ -52,20 +52,22 @@ int epic_stream_read(int sd, void *buf, size_t count) ...@@ -52,20 +52,22 @@ int epic_stream_read(int sd, void *buf, size_t count)
return -ENODEV; return -ENODEV;
} }
/* Poll the stream */ /* Poll the stream, if a poll_stream function exists */
if (stream->poll_stream != NULL) {
int ret = stream->poll_stream(); int ret = stream->poll_stream();
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
}
/* Check buffer sizing */ /* Check buffer size is a multiple of the data packet size */
if (count % stream->item_size != 0) { if (count % stream->item_size != 0) {
return -EINVAL; return -EINVAL;
} }
size_t i; size_t i;
for (i = 0; i < count; i += stream->item_size) { for (i = 0; i < count; i += stream->item_size) {
if (!xQueueReceive(stream->queue, buf + i, 10)) { if (!xQueueReceive(stream->queue, buf + i, STREAM_QUEUE_WAIT)) {
break; break;
} }
} }
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "queue.h" #include "queue.h"
#define STREAM_QUEUE_WAIT pdMS_TO_TICKS(10)
/** /**
* **Stream Descriptors**: * **Stream Descriptors**:
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment