Subject: Re: pkg/29653: another bug (with patch, this one)
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Antoine Reilles <Antoine.Reilles@loria.fr>
List: pkgsrc-bugs
Date: 03/11/2005 16:17:02
The following reply was made to PR pkg/29653; it has been noted by GNATS.

From: Antoine Reilles <Antoine.Reilles@loria.fr>
To: gnats-bugs@NetBSD.org
Cc: rh@NetBSD.org
Subject: Re: pkg/29653: another bug (with patch, this one)
Date: Fri, 11 Mar 2005 17:13:56 +0100

 Hi,
 
 There is a bug in gst-plugins-0.8.7 which prevents tunesbrowser to play
 aac files. Ths bug is fixed in gst-plugins-0.8.8, but since pkgsrc is
 frozen now, i've made a patch (extracted from gst-plugins cvs) for
 allowing reading qt files in a pipe. 
 
 
 --- gst/qtdemux/qtdemux.c.orig	2004-12-23 13:42:49.000000000 +0100
 +++ gst/qtdemux/qtdemux.c	2005-03-11 16:47:54.000000000 +0100
 @@ -511,10 +511,11 @@
  
    switch (GST_STATE_TRANSITION (element)) {
      case GST_STATE_NULL_TO_READY:
 -      break;
 -    case GST_STATE_READY_TO_PAUSED:
        qtdemux->bs = gst_bytestream_new (qtdemux->sinkpad);
        qtdemux->state = QTDEMUX_STATE_HEADER;
 +      GST_DEBUG("new bytestream");
 +      break;
 +    case GST_STATE_READY_TO_PAUSED:
        break;
      case GST_STATE_PAUSED_TO_PLAYING:
        break;
 @@ -524,9 +525,9 @@
        qtdemux->last_ts = GST_CLOCK_TIME_NONE;
        qtdemux->need_discont = FALSE;
        qtdemux->need_flush = FALSE;
 -      gst_bytestream_destroy (qtdemux->bs);
        break;
      case GST_STATE_READY_TO_NULL:
 +      gst_bytestream_destroy (qtdemux->bs);
        break;
      default:
        break;
 @@ -614,6 +615,7 @@
                break;
              }
            } while (1);
 +          qtdemux->offset += length;
  
            qtdemux_parse_moov (qtdemux, GST_BUFFER_DATA (moov), length);
            if (1) {
 @@ -632,11 +634,18 @@
        }
        ret = gst_bytestream_seek (qtdemux->bs, cur_offset + length,
            GST_SEEK_METHOD_SET);
 -      if (!ret) {
 -        g_warning ("seek failed");
 +      GST_DEBUG ("seek returned %d", ret);
 +      if (ret == FALSE) {
 +        length = cur_offset + length;
 +        cur_offset = qtdemux->offset;
 +        length -= cur_offset;
 +        if (gst_bytestream_flush (qtdemux->bs, length) == FALSE) {
 +          if (!gst_qtdemux_handle_sink_event (qtdemux)) {
 +            return;
 +          }
 +        }
        }
        qtdemux->offset = cur_offset + length;
 -      GST_DEBUG ("seek returned %d", ret);
        break;
      }
      case QTDEMUX_STATE_SEEKING_EOS:
 @@ -685,8 +694,8 @@
                GST_DATA (gst_event_new (GST_EVENT_EOS)));
          }
          ret = gst_bytestream_seek (qtdemux->bs, 0, GST_SEEK_METHOD_END);
 -        if (!ret) {
 -          g_warning ("seek failed");
 +        if (ret == FALSE) {
 +          gst_bytestream_flush(qtdemux->bs, 0xffffffff);
          }
          GST_DEBUG ("seek returned %d", ret);
  
 @@ -706,16 +715,23 @@
  
        /* don't believe bytestream */
        //cur_offset = gst_bytestream_tell (qtdemux->bs);
 +      cur_offset = qtdemux->offset;
  
        if (offset != cur_offset) {
          GST_DEBUG ("seeking to offset %d (currently at %d)", offset,
              cur_offset);
          ret = gst_bytestream_seek (qtdemux->bs, offset, GST_SEEK_METHOD_SET);
 -        if (!ret) {
 -          g_warning ("seek failed");
 +        GST_DEBUG ("seek returned %d", ret);
 +        if (ret == FALSE && offset > cur_offset) {
 +          if (gst_bytestream_flush (qtdemux->bs, offset - cur_offset) == FALSE) {
 +            if (!gst_qtdemux_handle_sink_event (qtdemux)) {
 +              return;
 +            }
          }
 +        }
 +        else if (ret == FALSE && offset < cur_offset)
 +          GST_ERROR("cannot flush backwards");
          qtdemux->offset = offset;
 -        GST_DEBUG ("seek returned %d", ret);
          return;
        }
  
 @@ -732,6 +748,7 @@
            break;
          }
        } while (TRUE);
 +      qtdemux->offset += size;
  
        if (buf) {
          /* hum... FIXME changing framerate breaks horribly, better set
 
 
 
 
 putting this as patch-ac, then make makepatchsum, and rebuild
 gst-plugins , and tunesbrowser is happy.
 
 
 regards,
 antoine