mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 03:04:00 +00:00
Fix problems when changing output sample rate
This commit is contained in:
parent
d4660814f0
commit
a0e47688a4
|
@ -61,6 +61,7 @@ protected:
|
|||
AUGraph fGraph;
|
||||
MusicPlayer fPlayer;
|
||||
AudioUnit fOutputUnit;
|
||||
AudioUnit fLimiterUnit;
|
||||
AudioUnit fSynthUnit;
|
||||
private:
|
||||
MusicSequence fMusic;
|
||||
|
@ -236,6 +237,7 @@ void VLAUSoundOut::InitSoundOutput(bool fileOutput)
|
|||
AUGraphConnectNodeInput(fGraph, limiterNode, 0, outNode, 0);
|
||||
|
||||
R(AUGraphNodeInfo(fGraph, outNode, NULL, &fOutputUnit));
|
||||
R(AUGraphNodeInfo(fGraph, limiterNode, NULL, &fLimiterUnit));
|
||||
R(AUGraphNodeInfo(fGraph, synthNode, NULL, &fSynthUnit));
|
||||
|
||||
if (fileOutput) {
|
||||
|
@ -250,6 +252,7 @@ void VLAUSoundOut::InitSoundOutput(bool fileOutput)
|
|||
kAudioUnitScope_Global, 0,
|
||||
&value, sizeof(value)));
|
||||
} else {
|
||||
PropagateProperty(kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0);
|
||||
AudioUnitAddPropertyListener(fOutputUnit,
|
||||
kAudioUnitProperty_MaximumFramesPerSlice,
|
||||
VLAUSoundOutPropagateProperty,
|
||||
|
@ -280,15 +283,24 @@ void VLAUSoundOut::PropagateProperty(AudioUnitPropertyID inID,
|
|||
goto reinitialize;
|
||||
data.resize(sz);
|
||||
if (!AudioUnitGetProperty(fOutputUnit, inID, inScope, inElement, &data[0], &sz)) {
|
||||
if (OSStatus status = AudioUnitSetProperty(fSynthUnit, inID, inScope, inElement,
|
||||
if (OSStatus status = AudioUnitSetProperty(fSynthUnit, inID, kAudioUnitScope_Global, inElement,
|
||||
&data[0], sz)) {
|
||||
if (status == kAudioUnitErr_Initialized) {
|
||||
AudioUnitUninitialize(fSynthUnit);
|
||||
status = AudioUnitSetProperty(fSynthUnit, inID, inScope, inElement,
|
||||
status = AudioUnitSetProperty(fSynthUnit, inID, kAudioUnitScope_Global, inElement,
|
||||
&data[0], sz);
|
||||
AudioUnitInitialize(fSynthUnit);
|
||||
}
|
||||
}
|
||||
if (OSStatus status = AudioUnitSetProperty(fLimiterUnit, inID, kAudioUnitScope_Global, inElement,
|
||||
&data[0], sz)) {
|
||||
if (status == kAudioUnitErr_Initialized) {
|
||||
AudioUnitUninitialize(fLimiterUnit);
|
||||
status = AudioUnitSetProperty(fLimiterUnit, inID, kAudioUnitScope_Global, inElement,
|
||||
&data[0], sz);
|
||||
AudioUnitInitialize(fLimiterUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
reinitialize:
|
||||
if (running)
|
||||
|
|
Loading…
Reference in New Issue
Block a user