AVFoundation Support for wav files

  • I need add the ability to open an audio file within my application, decode it and send the media content to an embedded controller for it to play. I have implemented the feature with QAudioDecode as follows:

    in class declaration:

    public slots:
       void readAudioFile( QString filename );    // called when file is selected inside the file dialog

    Function implementation

    void AudioFileForm::readAudioFile( QString file_ref )  {
            // Decode file
        QAudioDecoder* decoder = new QAudioDecoder();
        // Connect decoder error handler
        connect( decoder, QOverload<QAudioDecoder::Error>::of(&QAudioDecoder::error), [=]( QAudioDecoder::Error error ) {
            QString error_text;
            switch( error ) {
            case QAudioDecoder::FormatError:
                error_text = "Format error";
            case QAudioDecoder::ServiceMissingError:
                error_text = "Service missing";
                error_text = "Unknown error";
            qDebug() << "Audio decoder error: " + error_text;
        } );
        // Connect file decoding done
        connect( decoder, &QAudioDecoder::bufferReady, [=]() {
            QAudioBuffer audio_buffer = decoder->read();
            emit audioLoaded( audio_buffer );
        decoder->setSourceFilename( QFileInfo( file_ref ).fileName() );
        decoder->start();       // reads in the file and decodes, throws ready signal when 
                                               // done which is handled by the lambda functions

    I am falling into the error hander with the following:

    defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.audiodecode"
    2020-09-29 10:13:47.432663+0200 VibeCreator[24919:1325702] errors encountered while discovering extensions: Error Domain=PlugInKit 
        Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}

    I am developing on OS X. Looking at https://wiki.qt.io/Qt_5.13_Multimedia_Backends, it is hard to know of QAudioDecoder is supported by the AVFoundation. I also don't know if I have this plugin installed, although I would assume it is installed by default.

    How do I check if AVFoundation is installed on my Mac and if it includes support for QAudioDecode ?

  • Lifetime Qt Champion


    AVFoundation is part of the core librarie of macOS there's no need to install them.

    Based on the matrxi you gave, the audio decoding is currently not supported.

    Out of curiosity, what exactly do you need to send to your device ?

  • Ok, thanks for confirming what I feared. I'll have to try another approach.

    I basically have to send the decoded audio file / "song" which I understand is just a series of pwm values.

  • Any suggestions on the easiest / best way to decode and extract the audio stream from a wav or MP3 file while developing on Mac for OS X & Win 10 ?

  • Lifetime Qt Champion

    On Windows, you can use Qt Multimedia, on macOS Core Audio is the official backend.

Log in to reply