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"; break; default: error_text = "Unknown error"; break; } 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 ?
-
Hi,
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 ?
-
On Windows, you can use Qt Multimedia, on macOS Core Audio is the official backend.