When this application: http://staticz.com/soundsiphon/ is installed, it shows up as a virtual soundcard in the JUCE device list. However when one selects that device, we get a "Couldn't change sample rate" error. Apparently, the virtual device supports only one sample rate, and the kAudioDevicePropertyNominalSampleRate is not writable.
A fix is to check if kAudioDevicePropertyNominalSampleRate is already at the expected value , and attempt to change it only when it is not the good value. For example:
bool sample_rate_is_fine = false; Float64 current_sr; UInt32 sr_size = sizeof(current_sr); if (OK (AudioObjectGetPropertyData(deviceID, &pa, 0, 0, &sr_size, ¤t_sr))) { if (current_sr == sr) sample_rate_is_fine = true; } if (!sample_rate_is_fine && ! OK (AudioObjectSetPropertyData (deviceID, &pa, 0, 0, sizeof (sr), &sr))) { error = "Couldn't change sample rate to " + String(sr) + " Hz"; } else { // Change buffer size ...