You are not logged in.

#1 2010-04-23 01:08:39

Odysseus
Member
Registered: 2009-02-15
Posts: 141

Oggdec's standard out in vorbis-tools 1.4 broken?

I have a script that plays my music by doing something like this:

oggdec somefile.ogg -o- | aplay

But since vorbis-tools has been upgraded to version 1.4 from 1.2, all I get is static.
Decoding to a file still works, however.

Can someone verify this for me?  If so, then I'll add an issue to the bug tracker.


I'm the type to fling myself headlong through the magical wardrobe, and then incinerate the ornate mahogany portal behind me with a Molotov cocktail.

Offline

#2 2010-04-23 01:27:50

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: Oggdec's standard out in vorbis-tools 1.4 broken?

It works if you pass /dev/stdout instead of -. Not sure why this is.

Offline

#3 2010-04-23 02:05:15

Odysseus
Member
Registered: 2009-02-15
Posts: 141

Re: Oggdec's standard out in vorbis-tools 1.4 broken?

Peasantoid wrote:

It works if you pass /dev/stdout instead of -. Not sure why this is.

Interesting.  Why would it do anything different?

Off to the bug tracker then.


I'm the type to fling myself headlong through the magical wardrobe, and then incinerate the ornate mahogany portal behind me with a Molotov cocktail.

Offline

#4 2010-04-23 02:33:18

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: Oggdec's standard out in vorbis-tools 1.4 broken?

Well, I imagine a glance at the code would provide the answer. *fires up text editor*

Last edited by Peasantoid (2010-04-23 03:28:20)

Offline

#5 2010-04-23 03:28:32

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: Oggdec's standard out in vorbis-tools 1.4 broken?

Found it!

If you head the output from the static-producing command, you will notice that the first part is a line saying 'oggdec from vorbis-tools 1.4.0', then a newline, then the audio header. Bad!

And so, here's a quick walkthrough of what's going on (oggdec/oggdec.c in either version, function main()):

if(!quiet)
    version();

This calls version(), which looks like this in 1.2:

static void version (void) {
    fprintf (stderr, _("oggdec from %s %s\n"), PACKAGE, VERSION);
}

and in 1.4:

static void version (void) {
    fprintf(stdout, _("oggdec from %s %s\n"), PACKAGE, VERSION);
}

You'll see that 1.4 writes it to stdout, whereas 1.2 writes to stderr. This is the crucial difference. You'll see that quiet only ever gets set if you pass the -Q flag (see parse_options()). So in 1.4, no matter what happens, that version string is being written to stdout. That means if you use stdout as the outfile, you get the version string in front, with predictably undesirable results.

Now, I'm not sure why passing - and /dev/stdout have different results, but I imagine it's because open_output() reuses the current (FILE *)stdout if you passed '-', whereas it re-opens /dev/stdout if you passed '/dev/stdout'. This on its own shouldn't change anything, but I guess it's a quirk of the system IO - probably has something to do with flushing or some such.

So there's your answer. I'm not sure why oggdec would even be calling version() in the first place unless you explicitly asked for it, since that's a violation of the *nix philosophy.

Offline

#6 2010-04-23 05:36:25

Odysseus
Member
Registered: 2009-02-15
Posts: 141

Re: Oggdec's standard out in vorbis-tools 1.4 broken?

Wow, would you look at that.  That was some nice sleuthing!


I'm the type to fling myself headlong through the magical wardrobe, and then incinerate the ornate mahogany portal behind me with a Molotov cocktail.

Offline

#7 2010-04-23 05:37:29

Themaister
Member
From: Trondheim, Norway
Registered: 2008-07-21
Posts: 652
Website

Re: Oggdec's standard out in vorbis-tools 1.4 broken?

Looks like a good find. But really, why would you print a version string to stdout? I though stuff like that was meant for stderr, as you can't corrupt a pipe that way wink

Offline

#8 2010-04-23 19:36:07

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: Oggdec's standard out in vorbis-tools 1.4 broken?

This bug belongs at trac.xiph.org, if it's not already there.

Offline

Board footer

Powered by FluxBB