[vlc-devel] [PATCH] Allow 'no data available yet' for imem callback

Nir Halay nirhalay at gmail.com
Wed Oct 4 17:40:01 CEST 2017


Allow 'no data available yet' return value (-1) for 'imem-read' callback.
This fix allows more natural call to 'vlc_stream_ReadPartial' that does not suppose to wait for data.
Docs updated as well.
---
 include/vlc/libvlc_media.h   | 2 +-
 modules/access/imem-access.c | 5 -----
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/include/vlc/libvlc_media.h b/include/vlc/libvlc_media.h
index 383f366..cc12b35 100644
--- a/include/vlc/libvlc_media.h
+++ b/include/vlc/libvlc_media.h
@@ -358,7 +358,7 @@ typedef int (*libvlc_media_open_cb)(void *opaque, void **datap,
  * \param len bytes length of the buffer
  *
  * \return strictly positive number of bytes read, 0 on end-of-stream,
- *         or -1 on non-recoverable error
+ *         or -1 when data is not available yet.
  *
  * \note If no data is immediately available, then the callback should sleep.
  * \warning The application is responsible for avoiding deadlock situations.
diff --git a/modules/access/imem-access.c b/modules/access/imem-access.c
index da544c3..5cd3e8d 100644
--- a/modules/access/imem-access.c
+++ b/modules/access/imem-access.c
@@ -43,11 +43,6 @@ static ssize_t Read(stream_t *access, void *buf, size_t len)
 
     ssize_t val = sys->read_cb(sys->opaque, buf, len);
 
-    if (val < 0) {
-        msg_Err(access, "read error");
-        val = 0;
-    }
-
     return val;
 }
 
-- 
2.7.4



More information about the vlc-devel mailing list