0

I am not able to make QAudioDecoder (Qt 5.9.5) work on Xubuntu 18.04. Specifically, I always get that the audio format returned by QAudioDecoder::audioFormat() is not valid, no matter which file I try.

For instance, the following trivial program ends at "Invalid original audio format":

int main(int argc, char **argv)
{
    QApplication app (argc, argv);

    const char sampleAudioFilename[] =
            "/home/alx/Downloads/M1F1-Alaw-AFsp.wav";
    QAudioDecoder* track = new QAudioDecoder();
    qInfo("%s%s","Opening ",sampleAudioFilename);
    track->setSourceFilename(sampleAudioFilename);
    track->start();
    if (track->error() != QAudioDecoder::NoError) {
        qFatal("%s",track->errorString().toStdString().data());
    }
    QAudioFormat originalFormat = track->audioFormat();
    if (!originalFormat.isValid()) {
        qFatal("Not valid original audio format");
    }
return (0);
}

Interestingly, track->error() does not return any issue even though the properties of originalFormat are not valid. I previously installed all gstreamer and libgstreamer related packages available on my distro. Indeed, I am able to both play and to inspect successfully the test file by command line gstreamer's tools, e.g.,

gst-play-1.0 -v /home/alx/Downloads/M1F1-Alaw-AFsp.wav

as well as to play it with VLC.

Any idea? Could you help me, please? Thank you in advance.

JtTest
  • 47
  • 9
  • The API is asynchronous, start() won't block. did you try to wait for the stateChanged() signal? Also you will have to enter the event loop to avoid the application terminating immediately. – Frank Osterfeld Apr 03 '19 at 16:15
  • @Frank Commenting track->start() does not change the result. I manually debugged step by step in QtCreator, so I don't think it is a problem of waiting async results. – JtTest Apr 03 '19 at 16:29

0 Answers0