Re: [FFmpeg-devel] [PATCH 7/8] ffmdec: don't return AVERROR(EAGAIN) from ffm_is_avail_data

2015-03-09 Thread Michael Niedermayer
On Mon, Mar 09, 2015 at 12:33:38PM +0100, Andreas Cadhalpun wrote:
 On 09.03.2015 03:56, Michael Niedermayer wrote:
 On Mon, Mar 09, 2015 at 12:05:01AM +0100, Andreas Cadhalpun wrote:
 Hi,
 
 if AVERROR(EAGAIN) is returned from ffm_is_avail_data it always
 causes an infinite EAGAIN loop.
 
 it should only loop until more data is written into the ffm file
 (this of course is not guranteed to ever happen)
 
 How should this work?
 
 If ffm_is_avail_data returns AVERROR(EAGAIN), this error is
 immediately forwarded to avformat_find_stream_info, which just tries
 reading a frame again, leading to ffm_read_packet, which first calls
 ffm_is_avail_data.
 Nothing changed the FFMContext, even if more data was written into
 the ffm file, so it returns AVERROR(EAGAIN) again.

ffm_set_write_index() from ffserver could, this looks like ffm should
export a clean API to be used by ffserver though
also we really need regression tests for this ...

CCing reynaldo as he probably knows the code better 

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 7/8] ffmdec: don't return AVERROR(EAGAIN) from ffm_is_avail_data

2015-03-09 Thread Andreas Cadhalpun

On 09.03.2015 03:56, Michael Niedermayer wrote:

On Mon, Mar 09, 2015 at 12:05:01AM +0100, Andreas Cadhalpun wrote:

Hi,

if AVERROR(EAGAIN) is returned from ffm_is_avail_data it always
causes an infinite EAGAIN loop.


it should only loop until more data is written into the ffm file
(this of course is not guranteed to ever happen)


How should this work?

If ffm_is_avail_data returns AVERROR(EAGAIN), this error is immediately 
forwarded to avformat_find_stream_info, which just tries reading a frame 
again, leading to ffm_read_packet, which first calls ffm_is_avail_data.
Nothing changed the FFMContext, even if more data was written into the 
ffm file, so it returns AVERROR(EAGAIN) again.


Best regards,
Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 7/8] ffmdec: don't return AVERROR(EAGAIN) from ffm_is_avail_data

2015-03-08 Thread Michael Niedermayer
On Mon, Mar 09, 2015 at 12:05:01AM +0100, Andreas Cadhalpun wrote:
 Hi,
 
 if AVERROR(EAGAIN) is returned from ffm_is_avail_data it always
 causes an infinite EAGAIN loop.

it should only loop until more data is written into the ffm file
(this of course is not guranteed to ever happen)

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 7/8] ffmdec: don't return AVERROR(EAGAIN) from ffm_is_avail_data

2015-03-08 Thread Andreas Cadhalpun

Hi,

if AVERROR(EAGAIN) is returned from ffm_is_avail_data it always causes 
an infinite EAGAIN loop.


Best regards,
Andreas
From 115425287fe1f898baa79705f05d495c061e310a Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun andreas.cadhal...@googlemail.com
Date: Sun, 8 Mar 2015 23:34:29 +0100
Subject: [PATCH 7/8] ffmdec: don't return AVERROR(EAGAIN) from
 ffm_is_avail_data

If AVERROR(EAGAIN) is returned, ffm_read_packet is called again
immediately, which calls ffm_is_avail_data before changing the ffm
context, so that this will return AVERROR(EAGAIN) again, leading
to an infinite loop (again).

Signed-off-by: Andreas Cadhalpun andreas.cadhal...@googlemail.com
---
 libavformat/ffmdec.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 60df51d..9f00fc4 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -46,10 +46,7 @@ static int ffm_is_avail_data(AVFormatContext *s, int size)
 return AVERROR_EOF;
 avail_size = ffm-file_size - pos;
 } else {
-if (pos == ffm-write_index) {
-/* exactly at the end of stream */
-return AVERROR(EAGAIN);
-} else if (pos  ffm-write_index) {
+if (pos  ffm-write_index) {
 avail_size = ffm-write_index - pos;
 } else {
 avail_size = (ffm-file_size - pos) + (ffm-write_index - FFM_PACKET_SIZE);
@@ -59,7 +56,7 @@ static int ffm_is_avail_data(AVFormatContext *s, int size)
 if (size = avail_size)
 return 1;
 else
-return AVERROR(EAGAIN);
+return AVERROR_INVALIDDATA;
 }
 
 static int ffm_resync(AVFormatContext *s, int state)
-- 
2.1.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel