thestk / rtaudio

A set of C++ classes that provide a common API for realtime audio input/output across Linux (native ALSA, JACK, PulseAudio and OSS), Macintosh OS X (CoreAudio and JACK), and Windows (DirectSound, ASIO, and WASAPI) operating systems.
Other
1.49k stars 318 forks source link

[ask question] Pass sample rate and channel count to the callback. #377

Closed fasxmut closed 1 year ago

fasxmut commented 1 year ago

I dont know where to ask question, so I ask here.

int my_callback(void * out, void * in, std::uint32_t frames, double time, RtAudioStreamStatus status, void * user_data)
{
        return 0;
}

audio.openStream(&out_param, nullptr, RTAUDIO_FLOAT64, sample_rate, &frames, my_callback, user_data);

I can not find way to get the sample rate and channel count in the my_callback function, so I pass them through user_data, but in this way, the data is sent twice by openStream. Do you have better solution?

garyscavone commented 1 year ago

Passing those values via the user_data pointer is normal. I'm not quite sure what you mean by "data is sent twice."