Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Loading certain ogg files in SFML 2.4.2 causes program to hang forever.  (Read 3522 times)

0 Members and 1 Guest are viewing this topic.

jamiltron

  • Newbie
  • *
  • Posts: 3
    • View Profile
Hello,

I am updating an application that uses sfml-audio from 2.1 to 2.4.2 that consistently hangs forever when loading certain ogg files. These files did not hang in 2.1, and it is only specific files that cause this.

Here is a link to one of the ogg files that causes our program to hang: https://www.dropbox.com/s/1gxh56ym6kk2nla/hangs_forever.ogg?dl=0

Here is a link to a minimal example showing the error, assuming the above ogg file is downloaded into the working directory: https://gist.github.com/jamiltron/ada86682674717ab0bd9e0f2f90343dc

The above fails if you remove the stream and change the .openFromStream(stream) to .openFromFile("hangs_forever.ogg"). This file plays fine in every media player I've tried, and also loads and plays using another client solution.

This happens on Windows 10 with both the 32-bit Visual Studio 2015 prebuilt, as well as a version built from source containing the following patch to libvorbis: https://trac.xiph.org/ticket/2327

Any help is greatly appreciated!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
The above fails if you remove the stream and change the .openFromStream(stream) to .openFromFile("hangs_forever.ogg").
I can't confirm this. It plays fine when I open it with sf::Music directly (using MinGW).

creating stream from ./hangs_forever.ogg
opening from stream
playing...
done playing ./hangs_forever.ogg

Quickly firing up the debugger and stepping through the SFML code, it seems like the OGG file is for some reason throwing off the FLAC decoder. The way SFML has implemented the audio format detection is that it would pass it to the various decoder libraries and let them judge whether it's a format they can read.
For some reason FLAC__stream_decoder_process_until_end_of_metadata never returns when you pass it your stream.

Currently I've something I need to take care of, so I can't further debug the issue, but I think it should be fairly easy to pick up where I left off and dig down where in your stream class starts to hang.
And/or what the FLAC decoder expects the stream to return.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jamiltron

  • Newbie
  • *
  • Posts: 3
    • View Profile
Thanks for taking a look at this!

I can't confirm this. It plays fine when I open it with sf::Music directly (using MinGW).

Well its failing using sf::Music openFromFile (everything related to streams and anything else having to do with the file nixed right out) on the 32bit version of Visual Studio 2015, using the version downloaded from the SFML page in Windows 10, with the libs/includes/dlls all set up pretty standard, nothing fancy or custom.

Quickly firing up the debugger and stepping through the SFML code, it seems like the OGG file is for some reason throwing off the FLAC decoder.

Why would it throw off the FLAC decoder when my file is encoded via vorbis?

$ oggz codecs hangs_forever.ogg
> vorbis

The way SFML has implemented the audio format detection is that it would pass it to the various decoder libraries and let them judge whether it's a format they can read.

Is there an easy way I can override this and force it to use vorbis?
« Last Edit: June 16, 2017, 09:01:23 am by jamiltron »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
If you have just data (stream), then you can't tell what codec has been used, so you'll need to test all the different decoders and see if one of them detects the format of the data.
SFML simply iterates through all sound readers and does a call to the check function.

If you want to "force" vorbis, you could change the registered reader order or remove all readers from registering. But that's just a workaround not a solution.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jamiltron

  • Newbie
  • *
  • Posts: 3
    • View Profile
Ok, I'll try stepping through this to see why the Flac decoder is getting hung up and see if there's something I can do with my InputStream to ensure that its correctly identified as Vorbis. Thanks for the help!