#24 Playing from HTTP skips bits

closed-fixed
Joe Drew
Networking (5)
6
2004-09-27
2003-06-08
No

Playing from an HTTP stream sounds like it's skipping
bits (the stream plays out too quickly and it sounds
jerky). The same file played locally works properly.

It's not a problem with HTTP delay - the same problem
occurs when the file is played from a webserver
on the same network. Haven't really gotten into the
code enough to debug it further, but as an incentive for
someone else to, a patch for HTTP proxy server support
is included in the next bug report. ;-)

This problem occurs both with the most recent release
(0.2.10) and with a freshly checked out CVS copy.

Running on FreeBSD 4.8-STABLE

Discussion

  • Logged In: YES
    user_id=2636

    Ahh - found the bug. The read_from_fd function in mad.c isn't checking
    the return value from read(). There's no guarantee that read actually reads
    as many bytes as you tell it to. The fix is to check the return value and
    pass the right buffer length into mad_stream_buffer. A patch is attached.

    While I'm at it, the debugging printf for the "Frame#" should end with \n, not
    \r...

     
    • priority: 5 --> 6
     
  • Logged In: YES
    user_id=2636

    Oops. Forgot that patch. :-)

     
  • Fixes skipped bytes reading from HTTP

     
    Attachments
  • Joe Drew
    Joe Drew
    2003-06-08

    Logged In: YES
    user_id=330927

    Actually the \r is both wanted and desired; the frame number
    in verbose mode should stay on the same line.

    Thanks for your patches; I'll be getting back to hacking
    mpg321 once I get Linux up and running on my iBook.

     
  • Logged In: NO

    same problem when trying to read on an ipv6 stream on linux
    using the following command:

    lynx -dump http://ipv6.lkml.org:8000/difm | ./mpg321 -
    since mpg321 doesn't natively run over ipv6 yet :)

    the patch made the last cvs working for me, but it "talks"
    too much :)
    (why isn't it in cvs already? ;))
    ...
    Read bytes: 4096 BUF_SIZE: 1048576
    Playbuf length: 1048576
    Read bytes: 4096 BUF_SIZE: 1048576
    Playbuf length: 1048576
    ....

     
  • Kernel Jake
    Kernel Jake
    2003-08-21

    Logged In: YES
    user_id=595644

    Regarding the "talks too much" comment: This patch adds a
    printf("Playbuf length:...") that will confuse client
    applications that are using the "remote" protocol via
    stdin/stdout such as irmp3. That printf("Playbuf
    length:...") should be removed in the next codedrop to CVS.

     
  • Kernel Jake
    Kernel Jake
    2003-08-21

    Logged In: YES
    user_id=595644

    I have problems pausing/unpausing HTTP streams via the
    remote protocol using this patch. If I don't have the patch
    applied, I can "P"ause and un"P"ause to my heart's content.
    When I apply the patch, I sometimes cannot unpause HTTP
    streams I have paused using "P" via the remote protocol.
    HTTP is being transmitted over the wire when I unpause, but
    no sound comes out. I can't make this happen all the time,
    it's nondeterministic.

    example$ ./mpg321 -R -
    @R MPG123
    L http://205.188.234.4:8028/
    @I 205.188.234
    (... lots of frame data here ...)
    P
    @P 1
    (wait about 10 seconds)
    P
    @P 2
    (no sound, yet lots of network activity)
    P
    http://205.188.234.4: No such file or directory

    example$ uname -a
    Linux example 2.4.18 #10 Thu Jul 3 22:14:17 CDT 2003 i686
    athlon i386 GNU/Linux

     
    • status: open --> closed-fixed