[vlc-commits] stream_access: simplify
Rémi Denis-Courmont
git at videolan.org
Thu Jul 21 21:30:19 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jul 21 22:10:40 2016 +0300| [94b7183f5117c7d1ad8d96cdf558e4ce9e78a9f8] | committer: Rémi Denis-Courmont
stream_access: simplify
(only reason it is not removed is input stats at this point)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=94b7183f5117c7d1ad8d96cdf558e4ce9e78a9f8
---
src/input/access.c | 52 +++++++++++++++++-----------------------------------
1 file changed, 17 insertions(+), 35 deletions(-)
diff --git a/src/input/access.c b/src/input/access.c
index 6369075..5c0cbf9 100644
--- a/src/input/access.c
+++ b/src/input/access.c
@@ -185,21 +185,17 @@ static block_t *AStreamReadBlock(stream_t *s, bool *restrict eof)
input_thread_t *input = s->p_input;
block_t * block;
- do
+ if (vlc_stream_Eof(access))
{
- if (vlc_access_Eof(access))
- {
- *eof = true;
- return NULL;
- }
- if (vlc_killed())
- return NULL;
-
- block = vlc_access_Block(access);
+ *eof = true;
+ return NULL;
}
- while (block == NULL);
+ if (vlc_killed())
+ return NULL;
+
+ block = vlc_stream_ReadBlock(access);
- if (input != NULL)
+ if (block != NULL && input != NULL)
{
uint64_t total;
@@ -218,29 +214,15 @@ static ssize_t AStreamReadStream(stream_t *s, void *buf, size_t len)
{
access_t *access = s->p_sys;
input_thread_t *input = s->p_input;
- ssize_t val = 0;
- char dummy[(buf != NULL) ? 1 : (len <= 2048) ? len : 2048];
- if (buf == NULL)
- {
- buf = dummy;
- len = sizeof (dummy);
- }
-
- do
- {
- if (vlc_access_Eof(access))
- return 0;
- if (vlc_killed())
- return -1;
+ if (vlc_stream_Eof(access))
+ return 0;
+ if (vlc_killed())
+ return -1;
- val = vlc_access_Read(access, buf, len);
- if (val == 0)
- return 0; /* EOF */
- }
- while (val < 0);
+ ssize_t val = vlc_stream_ReadPartial(access, buf, len);
- if (input != NULL)
+ if (val > 0 && input != NULL)
{
uint64_t total;
@@ -267,21 +249,21 @@ static int AStreamSeek(stream_t *s, uint64_t offset)
{
access_t *access = s->p_sys;
- return vlc_access_Seek(access, offset);
+ return vlc_stream_Seek(access, offset);
}
static int AStreamControl(stream_t *s, int cmd, va_list args)
{
access_t *access = s->p_sys;
- return access_vaControl(access, cmd, args);
+ return vlc_stream_vaControl(access, cmd, args);
}
static void AStreamDestroy(stream_t *s)
{
access_t *access = s->p_sys;
- vlc_access_Delete(access);
+ vlc_stream_Delete(access);
}
stream_t *stream_AccessNew(vlc_object_t *parent, input_thread_t *input,
More information about the vlc-commits
mailing list