Hello everyone,
I have a running audio plug-in based on core audio user-space dirver examples.
https://developer.apple.com/library/content/samplecode/AudioDriverExamples/Introduction/Intro.html
my goal is to notfiy the audio plugin whenever change of sampling rate occurs. i have a live feed in which the sampling rate may differ from source to source (44.1 vs 48.0khz). Right now my plug-in has only 1 default sampling rate. (doesn't matter 44.1 or 48khz).
I can see audio my sampling rate property update on the application's UI when I do this in my code (not knowing the correct way..):
CADispatchQueue::GetGlobalSerialQueue().Dispatch(false, ^{
AudioObjectPropertyAddress theChangedProperties[] = {
{kAudioStreamPropertyAvailableVirtualFormats, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster },
{kAudioStreamPropertyAvailablePhysicalFormats, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster },
{kAudioDevicePropertyAvailableNominalSampleRates, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster },
{kAudioDevicePropertyNominalSampleRate, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster },
{kAudioStreamPropertyPhysicalFormat, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster },
{kAudioStreamPropertyVirtualFormat, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster },
};
However, I would get ton's of error messages in console.
AVRecorder[11476]: [09:11:07.038] __fadcGetAnchorTimeInternal_block_invoke signalled err=-1 (-1) (sample rate change without stop/start; intere listener fiCoreMedia_frameworks/CoreMedia-1731.15.207/Sources/Core/FigSync/FigAudioDeviceClock.c line 599
and
AVRecorder[32061]: [17:16:34.850] piqca_setUpcomingImageInfo signalled err=-12810 (kFigImageQueueParameterErr) (kFigImageQueueUpcomingImageTimeMinMaxKnown with non-numeric minUpcomingImageTime or maxUpcomingImageTime) at /Library/Caches/com.apple.xbs/Sources/CoreMedia/CoreMedia-1731.15.207/Prototypes/VisualContexts/FigImageQueueForCoreAnimation.c line 2834
Do I have to restart to audio I/O according to the error message?
What is the proper way to do this from the bottom up so that audio plug-in would know and reflect the proper change?
I tried this but no success so far.
AudioObjectID theDeviceObjectID = GetObjectID();
CADispatchQueue::GetGlobalSerialQueue().Dispatch(false, ^{
SA_PlugIn::Host_RequestDeviceConfigurationChange(theDeviceObjectID, theNewSampleRate, NULL);
});
which leads to
OSStatus (*RequestDeviceConfigurationChange)(AudioServerPlugInHostRef inHost, AudioObjectID inDeviceObjectID, UInt64 inChangeAction, void *inChangeInfo);
in AudioServerPlugIn.h
Any help is greatly appreciated.
Allen.