AlexZaluffi
AlexZaluffi

Reputation: 11

How to further debug QAudioDecoder when it claims it has QAudioDecoder::NoError

I am trying to make a small piece of code work. It should open an mp3 file and read PCM samples from it (while converting the mp3 format to the PCM with requested parameters).

Looks like this:

QFile fin("C:\\test\\chirp.mp3");
QFile fon("C:\\test\\chirp.raw");
if(!fin.open(QIODevice::ReadOnly)){ qDebug()\<\<"fin: "\<\<fin.errorString();}
if(!fon.open(QIODevice::WriteOnly)){ qDebug()\<\<"fon: "\<\<fon.errorString();}
QAudioDecoder decoder;
QAudioFormat qaf;
qaf.setSampleFormat(QAudioFormat::Int16);
qaf.setChannelCount(2);
qaf.setSampleRate(44100);
decoder.setAudioFormat(qaf);
decoder.setSourceDevice(&fin);
QEventLoop qel;

QAudioDecoder::connect(&decoder, SIGNAL(finished()), &qel, SLOT(exit()));
QAudioDecoder::connect(&decoder, &QAudioDecoder::bufferReady, &decoder, [&decoder, &fon](){
    QAudioBuffer buffer = decoder.read();
    const char *data = buffer.constData<char>();
    fon.write(data, buffer.byteCount());
    qDebug() << "SLICE: " << buffer.byteCount() << decoder.error();
});
qDebug() << "PRE-START" << decoder.error();
decoder.start();
qDebug() << "POST-START" << decoder.error();
qel.exec();
qDebug() << "DONE.";

When I compile this code on Linux - it works. When I compile this code on Windows (MinGW), it works on Windows (but not in WINE).

However, I want to build it as a static .exe, for which I use the MXE on Linux - and the 6.6 version of Qt - which uses the FFmpeg plugin. So theoretically, it should work everywhere (Windows and WINE), without installing WMF or any codec pack.

When I try to run MXE-compiled version on WINE or Windows, it shows the following output in the log:

Debug: PRE-START QAudioDecoder::NoError 
Debug: POST-START QAudioDecoder::NoError 
Debug: SLICE:  0 QAudioDecoder::NoError

And hangs on qel.exec(); - the DONE. prints only when I try to close the app - it prints DONE and exits.

Also, it displays the following line in the console:

[mp3float @ 0000000000771d80] Could not update timestamps for skipped samples.

Which looks to me as an FFmpeg log warning, so it should mean that libav\* was indeed linked to the binary.

What am I missing? Is there something to do with QEventLoop?

Upvotes: 1

Views: 58

Answers (0)

Related Questions