Audio playback buffering in background thread

Hi to all,
I’m writing a simple VST plugin, one of its purposes is to play N audio files, with N >=1 && N < 32, it can play mono, stereo or multichannel files.

My previous version reads audio data directly inside the process callback (I know it is a bad idea but it was very easy to code)

Now I would improve the processing moving the reading stuff inside a background thread witch can read many frames ahead (for example 2sec). This can solve problems with higher sample rate and tiny host block sizes.

Unfortunately I don’t have so much experience in thread programming, I took a look at BufferingAudioSource code.

I need to support many audio file formats so I’m using libsndfile and could not use juce classes to do this task.

Any suggestion on where I can start developing this slice of code?

thanx in advance