Browse Source

CoreAudio: detection of disabled devices. Avoided some internal exceptions in the demo.

tags/2021-05-28
jules 14 years ago
parent
commit
173e8c083f
2 changed files with 13 additions and 8 deletions
  1. +3
    -3
      extras/JuceDemo/Source/demos/OpenGLDemo.cpp
  2. +10
    -5
      modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp

+ 3
- 3
extras/JuceDemo/Source/demos/OpenGLDemo.cpp View File

@@ -39,25 +39,25 @@ public:
infoLabel.setText ("These sliders demonstrate how components can be added as children "
"of an OpenGLComponent, in which case, their content will be rendered into "
"an OpenGL framebuffer and efficiently overlaid onto your GL content.", false);
infoLabel.setBounds ("parent.width * 0.05, bottom - 150, parent.width * 0.4, parent.height - 60");
infoLabel.setInterceptsMouseClicks (false, false);
addAndMakeVisible (&infoLabel);
infoLabel.setBounds ("parent.width * 0.05, bottom - 150, parent.width * 0.4, parent.height - 60");
speedSlider.setRange (-10.0, 10.0, 0.1);
speedSlider.setPopupMenuEnabled (true);
speedSlider.setValue (Random::getSystemRandom().nextDouble() * 3.0, false, false);
speedSlider.setSliderStyle (Slider::LinearHorizontal);
speedSlider.setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
speedSlider.setBounds ("parent.width * 0.05, parent.height - 65, parent.width * 0.6, top + 24");
addAndMakeVisible (&speedSlider);
speedSlider.setBounds ("parent.width * 0.05, parent.height - 65, parent.width * 0.6, top + 24");
sizeSlider.setRange (0.2, 2.0, 0.01);
sizeSlider.setPopupMenuEnabled (true);
sizeSlider.setValue (Random::getSystemRandom().nextDouble() + 0.5, false, false);
sizeSlider.setSliderStyle (Slider::LinearHorizontal);
sizeSlider.setTextBoxStyle (Slider::TextBoxLeft, false, 80, 20);
sizeSlider.setBounds ("parent.width * 0.05, parent.height - 35, parent.width * 0.6, top + 24");
addAndMakeVisible (&sizeSlider);
sizeSlider.setBounds ("parent.width * 0.05, parent.height - 35, parent.width * 0.6, top + 24");
startTimer (1000 / 30);
}


+ 10
- 5
modules/juce_audio_devices/native/juce_mac_CoreAudio.cpp View File

@@ -177,20 +177,25 @@ public:
const ScopedLock sl (callbackLock);
Float64 sr;
UInt32 size = sizeof (Float64);
AudioObjectPropertyAddress pa;
pa.mSelector = kAudioDevicePropertyNominalSampleRate;
pa.mScope = kAudioObjectPropertyScopeWildcard;
pa.mElement = kAudioObjectPropertyElementMaster;
UInt32 isAlive;
UInt32 size = sizeof (isAlive);
pa.mSelector = kAudioDevicePropertyDeviceIsAlive;
if (OK (AudioObjectGetPropertyData (deviceID, &pa, 0, 0, &size, &isAlive))
&& isAlive == 0)
return;
Float64 sr;
size = sizeof (sr);
pa.mSelector = kAudioDevicePropertyNominalSampleRate;
if (OK (AudioObjectGetPropertyData (deviceID, &pa, 0, 0, &size, &sr)))
sampleRate = sr;
UInt32 framesPerBuf;
size = sizeof (framesPerBuf);
pa.mSelector = kAudioDevicePropertyBufferFrameSize;
if (OK (AudioObjectGetPropertyData (deviceID, &pa, 0, 0, &size, &framesPerBuf)))
{


Loading…
Cancel
Save