From 75c1fd9c1d8f41800a00b572634b1475fa2c721b Mon Sep 17 00:00:00 2001 From: ods15 Date: Sat, 18 Nov 2006 20:13:18 +0000 Subject: [PATCH] Add disabled EAGAIN testing code for libnut git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21038 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_nut.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/libmpdemux/demux_nut.c b/libmpdemux/demux_nut.c index 31669701d7..4668aec0c9 100644 --- a/libmpdemux/demux_nut.c +++ b/libmpdemux/demux_nut.c @@ -23,10 +23,17 @@ static size_t mp_read(void * h, size_t len, uint8_t * buf) { stream_t * stream = (stream_t*)h; if(stream_eof(stream)) return 0; + //len = MIN(len, 5); return stream_read(stream, buf, len); } +static int mp_eof(void * h) { + stream_t * stream = (stream_t*)h; + if(stream_eof(stream)) return 1; + return 0; +} + static off_t mp_seek(void * h, long long pos, int whence) { stream_t * stream = (stream_t*)h; @@ -64,7 +71,7 @@ static demuxer_t * demux_open_nut(demuxer_t * demuxer) { .priv = demuxer->stream, .seek = mp_seek, .read = mp_read, - .eof = NULL, + .eof = mp_eof, .file_pos = stream_tell(demuxer->stream), }, .alloc = { .malloc = NULL }, @@ -77,7 +84,8 @@ static demuxer_t * demux_open_nut(demuxer_t * demuxer) { int ret; int i; - if ((ret = nut_read_headers(nut, &s, NULL))) { + while ((ret = nut_read_headers(nut, &s, NULL)) == NUT_ERR_EAGAIN); + if (ret) { mp_msg(MSGT_HEADER, MSGL_ERR, "NUT error: %s\n", nut_error(ret)); nut_demuxer_uninit(nut); free(priv); @@ -180,7 +188,7 @@ static int demux_nut_fill_buffer(demuxer_t * demuxer, demux_stream_t * dsds) { demuxer->filepos = stream_tell(demuxer->stream); if (stream_eof(demuxer->stream)) return 0; - ret = nut_read_next_packet(nut, &pd); + while ((ret = nut_read_next_packet(nut, &pd)) == NUT_ERR_EAGAIN); if (ret) { if (ret != NUT_ERR_EOF) mp_msg(MSGT_HEADER, MSGL_ERR, "NUT error: %s\n", @@ -202,7 +210,7 @@ static int demux_nut_fill_buffer(demuxer_t * demuxer, demux_stream_t * dsds) { } else { uint8_t buf[pd.len]; - ret = nut_read_frame(nut, &pd.len, buf); + while ((ret = nut_read_frame(nut, &pd.len, buf)) == NUT_ERR_EAGAIN); if (ret) { mp_msg(MSGT_HEADER, MSGL_ERR, "NUT error: %s\n", nut_error(ret)); @@ -220,7 +228,9 @@ static int demux_nut_fill_buffer(demuxer_t * demuxer, demux_stream_t * dsds) { dp->pos = demuxer->filepos; dp->flags= (pd.flags & NUT_FLAG_KEY) ? 0x10 : 0; - ret = nut_read_frame(nut, &pd.len, dp->buffer); + {int len = pd.len; + while ((ret = nut_read_frame(nut, &len, dp->buffer + pd.len-len)) == NUT_ERR_EAGAIN); + } if (ret) { mp_msg(MSGT_HEADER, MSGL_ERR, "NUT error: %s\n", nut_error(ret)); @@ -249,7 +259,7 @@ static void demux_seek_nut(demuxer_t * demuxer, float time_pos, float audio_dela (double)priv->s[0].time_base.nom / priv->s[0].time_base.den; - ret = nut_seek(nut, time_pos, nutflags, tmp); + while ((ret = nut_seek(nut, time_pos, nutflags, tmp)) == NUT_ERR_EAGAIN); if (ret) mp_msg(MSGT_HEADER, MSGL_ERR, "NUT error: %s\n", nut_error(ret)); if (sh_audio) resync_audio_stream(sh_audio); }