AudioThumbnail setSource()


#1

I’m having some problem changing the source an audiothumbnail? I’m just using the same procedure Jule’s does in the demo:

    void setFile (const File& file)
    {
        thumbnail.setSource (new FileInputSource(file));
	startTime = 0;
        endTime = thumbnail.getTotalLength();
	repaint();
    }

The problem happens when I try to call this method again, I get an exception and my debugger takes me to:

void FileInputStream::openHandle()
{
    HANDLE h = CreateFile (file.getFullPathName().toWideCharPointer(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0,
                           OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0);

    if (h != INVALID_HANDLE_VALUE)
        fileHandle = (void*) h;
    else
        status = WindowsFileHelpers::getResultForLastError();
}

I’ve tried all sorts of clearing and resetting but nothing seems to work. Can anyone suggest any likely problems that might be causing this? Can it be that the file that is being passed to setSource() is not being freed and therefore when I try to overwrite it I get problems?


#2

Seems the problem was caused by a threading issue.