#593641 SoX encoder fails with SoX >= 14.1.0 (I think)

Package:
libk3b6
Source:
k3b
Submitter:
Torbjörn Andersson
Date:
2023-04-25 10:15:29 UTC
Severity:
normal
#593641#5
Date:
2010-08-19 19:48:05 UTC
From:
To:
I noticed that if I try to rip an audio CD and select the SoX encoder,
K3b will claim that it succeeded but no audio files are created. The
same thing happened with most file types, actually, but I think they too
use the SoX plugin.

I turned on debugging, and noticed the following messages in the output:

k3b(14809) K3bSoxEncoder::initEncoderInternal: "/usr/bin/sox -t raw -r
44100 -s -2 -c 2 - -t wav -r 44100 -c 2 -w -a <filename withheld>"
k3b(14809) K3bSoxEncoder::slotSoxOutputLine: (sox)  "/usr/bin/sox:
invalid option -- w"
k3b(14809) K3bSoxEncoder::slotSoxOutputLine: (sox)  "/usr/bin/sox FAIL
sox: invalid option"

According to the SoX changelog, the -w option was deprecated in 13.0.0
and removed in 14.1.0. (Debian unstable currently uses 14.3.1.) It was
replaced by the -2 option. K3b tries to detect this and act accordingly,
but is only partly successful. Here's what happens in
plugins/encoder/sox/k3bsoxencoder.cpp

    179          if ( soxBin->version >= K3b::Version( 13, 0, 0 ) )
    180              *d->process << "-2";
    181          else
    182              *d->process << "-w";        // 16-bit words

    ...

    195              int size = grp.readEntry( "data size",
DEFAULT_DATA_SIZE );
    196              *d->process << ( size == 8 ? QString("-b") : ( size
== 32 ? QString("-l") : QString("-w") ) );

I believe the first snippet sets the options for the input file and the
second one sets them for the output file, but only the first one checks
the SoX version. I believe it's sufficient to add such a check to the
second snippet, to make it use -1, -2 and -4 instead of -b, -w and -l.

Sincerely,

Torbjörn Andersson