|
27 | 27 |
|
28 | 28 | AudioComponent::AudioComponent() : isPlaying(false) |
29 | 29 | { |
30 | | - // if this is nonempty, we got an error |
31 | | - String error = deviceManager.initialise(0, // numInputChannelsNeeded |
32 | | - 2, // numOutputChannelsNeeded |
33 | | - 0, // *savedState (XmlElement) |
34 | | - true, // selectDefaultDeviceOnFailure |
35 | | - String::empty, // preferred device |
36 | | - 0); // preferred device setup options |
37 | | - if (error != String::empty) |
| 30 | + bool initialized = false; |
| 31 | + while (!initialized) |
38 | 32 | { |
39 | | - String titleMessage = String("Audio device initialization error"); |
40 | | - String contentMessage = String("There was a problem initializing the audio device:\n" + error); |
41 | | - // this uses a bool since there are only two options |
42 | | - // also, omitting parameters works fine, even though the docs don't show defaults |
43 | | - bool retryButtonClicked = AlertWindow::showOkCancelBox(AlertWindow::QuestionIcon, |
44 | | - titleMessage, |
45 | | - contentMessage, |
46 | | - String("Retry"), |
47 | | - String("Quit")); |
48 | | - |
49 | | - if (retryButtonClicked) |
| 33 | + // if this is nonempty, we got an error |
| 34 | + String error = deviceManager.initialise(0, // numInputChannelsNeeded |
| 35 | + 2, // numOutputChannelsNeeded |
| 36 | + 0, // *savedState (XmlElement) |
| 37 | + true, // selectDefaultDeviceOnFailure |
| 38 | + String::empty, // preferred device |
| 39 | + 0); // preferred device setup options |
| 40 | + |
| 41 | + if (error == String::empty) |
50 | 42 | { |
51 | | - // as above |
52 | | - error = deviceManager.initialise(0, 2, 0, true, String::empty, 0); |
| 43 | + initialized = true; |
53 | 44 | } |
54 | | - else // quit button clicked |
| 45 | + else |
55 | 46 | { |
56 | | - JUCEApplication::quit(); |
| 47 | + String titleMessage = String("Audio device initialization error"); |
| 48 | + String contentMessage = String("There was a problem initializing the audio device:\n" + error); |
| 49 | + // this uses a bool since there are only two options |
| 50 | + // also, omitting parameters works fine, even though the docs don't show defaults |
| 51 | + bool retryButtonClicked = AlertWindow::showOkCancelBox(AlertWindow::QuestionIcon, |
| 52 | + titleMessage, |
| 53 | + contentMessage, |
| 54 | + String("Retry"), |
| 55 | + String("Quit")); |
| 56 | + |
| 57 | + if (!retryButtonClicked) // quit button clicked |
| 58 | + { |
| 59 | + JUCEApplication::quit(); |
| 60 | + break; |
| 61 | + } |
57 | 62 | } |
58 | 63 | } |
59 | 64 |
|
60 | | - |
61 | 65 | AudioIODevice* aIOd = deviceManager.getCurrentAudioDevice(); |
62 | 66 |
|
63 | 67 | // the error string doesn't tell you if there's no audio device found... |
|
0 commit comments