Filechooser errors


#1

Hi there,

So im getting an error trying to use the filechooser in a plugin. Someone else here had the same problem, but here it got fixed by updating and im working on the latest version already…

This is my code:

    FileChooser chooser ("Choose a file", {}, "*.wav");
    
    if (chooser.browseForFileToOpen()) {
        File myFile;
        
        auto* reader = formatManager.createReaderFor(myFile);

this is the error:
objc[678]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fffaaa42b68) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x11648fcd8). One of the two will be used. Which one is undefined.
errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 “query cancelled” UserInfo={NSLocalizedDescription=query cancelled}

Could anyone help me with this?


#2

You haven’t set myFile so formatManager.createReaderFor(myFile); will just return a nullptr which probably causes an access error if you try and do anything with. I suspect you meant to do the following:
File myFile = chooser.getResult ();

I’m not sure what that error means, but I think it’s a redherring!


#3

Thanks so much! The audio file loads properly now.
Howerver i still dont get any output.

this is how i pass the information:

        if (reader != nullptr) {
            std::unique_ptr<AudioFormatReaderSource> tempSource (new AudioFormatReaderSource (reader, true));
            transport.setSource(tempSource.get(), 0, nullptr, reader->sampleRate);
            readerSource.reset();
        }

And this is the processblock:

if (readerSource.get() == nullptr)
{
    ASCI.clearActiveBufferRegion();
    return;
}

ASCI.buffer = &buffer;
ASCI.startSample = 0;
ASCI.numSamples = buffer.getNumSamples();

transport.getNextAudioBlock(ASCI);

Anyone knows what might be wrong about this?


#4

The unique_ptr is designed to delete the object, that it is pointing to, when it goes out of scope, which is right after readerSource.reset().

What you probably intended was:

readerSource.reset (tempSource.release());  // returns the object and stops owning it

Hope that helps


#5

yes! that did it, thanks