Here is an audio callback routine for use with portaudio.
The part I don't understand is how or why you can use the name of the class AudioReaderPortAudio as a type in a cast, like the line
int sz = static_cast<AudioReaderPortAudio*>(userdata)->sizes.advance_size;
Parameter userdata is defined as void *. So you can say nothing about what object it refers to. After the casting the compiler knows that the object has data member sizes.advance_size of type int.