mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 11:14: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;
|
AUGraph fGraph;
|
||||||
MusicPlayer fPlayer;
|
MusicPlayer fPlayer;
|
||||||
AudioUnit fOutputUnit;
|
AudioUnit fOutputUnit;
|
||||||
|
AudioUnit fLimiterUnit;
|
||||||
AudioUnit fSynthUnit;
|
AudioUnit fSynthUnit;
|
||||||
private:
|
private:
|
||||||
MusicSequence fMusic;
|
MusicSequence fMusic;
|
||||||
|
@ -236,6 +237,7 @@ void VLAUSoundOut::InitSoundOutput(bool fileOutput)
|
||||||
AUGraphConnectNodeInput(fGraph, limiterNode, 0, outNode, 0);
|
AUGraphConnectNodeInput(fGraph, limiterNode, 0, outNode, 0);
|
||||||
|
|
||||||
R(AUGraphNodeInfo(fGraph, outNode, NULL, &fOutputUnit));
|
R(AUGraphNodeInfo(fGraph, outNode, NULL, &fOutputUnit));
|
||||||
|
R(AUGraphNodeInfo(fGraph, limiterNode, NULL, &fLimiterUnit));
|
||||||
R(AUGraphNodeInfo(fGraph, synthNode, NULL, &fSynthUnit));
|
R(AUGraphNodeInfo(fGraph, synthNode, NULL, &fSynthUnit));
|
||||||
|
|
||||||
if (fileOutput) {
|
if (fileOutput) {
|
||||||
|
@ -250,6 +252,7 @@ void VLAUSoundOut::InitSoundOutput(bool fileOutput)
|
||||||
kAudioUnitScope_Global, 0,
|
kAudioUnitScope_Global, 0,
|
||||||
&value, sizeof(value)));
|
&value, sizeof(value)));
|
||||||
} else {
|
} else {
|
||||||
|
PropagateProperty(kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0);
|
||||||
AudioUnitAddPropertyListener(fOutputUnit,
|
AudioUnitAddPropertyListener(fOutputUnit,
|
||||||
kAudioUnitProperty_MaximumFramesPerSlice,
|
kAudioUnitProperty_MaximumFramesPerSlice,
|
||||||
VLAUSoundOutPropagateProperty,
|
VLAUSoundOutPropagateProperty,
|
||||||
|
@ -280,15 +283,24 @@ void VLAUSoundOut::PropagateProperty(AudioUnitPropertyID inID,
|
||||||
goto reinitialize;
|
goto reinitialize;
|
||||||
data.resize(sz);
|
data.resize(sz);
|
||||||
if (!AudioUnitGetProperty(fOutputUnit, inID, inScope, inElement, &data[0], &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)) {
|
&data[0], sz)) {
|
||||||
if (status == kAudioUnitErr_Initialized) {
|
if (status == kAudioUnitErr_Initialized) {
|
||||||
AudioUnitUninitialize(fSynthUnit);
|
AudioUnitUninitialize(fSynthUnit);
|
||||||
status = AudioUnitSetProperty(fSynthUnit, inID, inScope, inElement,
|
status = AudioUnitSetProperty(fSynthUnit, inID, kAudioUnitScope_Global, inElement,
|
||||||
&data[0], sz);
|
&data[0], sz);
|
||||||
AudioUnitInitialize(fSynthUnit);
|
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:
|
reinitialize:
|
||||||
if (running)
|
if (running)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user