mirror of https://github.com/AxioDL/boo.git
Safer null-pointer handling in AudioQueueServices
This commit is contained in:
parent
a464f3d68c
commit
db8c002f4e
|
@ -42,7 +42,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
||||||
AudioQueueBufferRef m_buffers[3];
|
AudioQueueBufferRef m_buffers[3];
|
||||||
size_t m_frameBytes;
|
size_t m_frameBytes;
|
||||||
|
|
||||||
MIDIClientRef m_midiClient;
|
MIDIClientRef m_midiClient = 0;
|
||||||
|
|
||||||
std::mutex m_engineMutex;
|
std::mutex m_engineMutex;
|
||||||
std::condition_variable m_engineEnterCv;
|
std::condition_variable m_engineEnterCv;
|
||||||
|
@ -115,6 +115,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> enumerateMIDIDevices() const
|
std::vector<std::pair<std::string, std::string>> enumerateMIDIDevices() const
|
||||||
{
|
{
|
||||||
|
if (!m_midiClient)
|
||||||
|
return {};
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> ret;
|
std::vector<std::pair<std::string, std::string>> ret;
|
||||||
|
|
||||||
ItemCount numDevices = MIDIGetNumberOfDevices();
|
ItemCount numDevices = MIDIGetNumberOfDevices();
|
||||||
|
@ -368,6 +371,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
||||||
|
|
||||||
std::unique_ptr<IMIDIIn> newVirtualMIDIIn(ReceiveFunctor&& receiver)
|
std::unique_ptr<IMIDIIn> newVirtualMIDIIn(ReceiveFunctor&& receiver)
|
||||||
{
|
{
|
||||||
|
if (!m_midiClient)
|
||||||
|
return {};
|
||||||
|
|
||||||
std::unique_ptr<IMIDIIn> ret = std::make_unique<MIDIIn>(true, std::move(receiver));
|
std::unique_ptr<IMIDIIn> ret = std::make_unique<MIDIIn>(true, std::move(receiver));
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return {};
|
return {};
|
||||||
|
@ -387,6 +393,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
||||||
|
|
||||||
std::unique_ptr<IMIDIOut> newVirtualMIDIOut()
|
std::unique_ptr<IMIDIOut> newVirtualMIDIOut()
|
||||||
{
|
{
|
||||||
|
if (!m_midiClient)
|
||||||
|
return {};
|
||||||
|
|
||||||
std::unique_ptr<IMIDIOut> ret = std::make_unique<MIDIOut>(true);
|
std::unique_ptr<IMIDIOut> ret = std::make_unique<MIDIOut>(true);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return {};
|
return {};
|
||||||
|
@ -403,6 +412,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
||||||
|
|
||||||
std::unique_ptr<IMIDIInOut> newVirtualMIDIInOut(ReceiveFunctor&& receiver)
|
std::unique_ptr<IMIDIInOut> newVirtualMIDIInOut(ReceiveFunctor&& receiver)
|
||||||
{
|
{
|
||||||
|
if (!m_midiClient)
|
||||||
|
return {};
|
||||||
|
|
||||||
std::unique_ptr<IMIDIInOut> ret = std::make_unique<MIDIInOut>(true, std::move(receiver));
|
std::unique_ptr<IMIDIInOut> ret = std::make_unique<MIDIInOut>(true, std::move(receiver));
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return {};
|
return {};
|
||||||
|
@ -430,6 +442,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
||||||
|
|
||||||
std::unique_ptr<IMIDIIn> newRealMIDIIn(const char* name, ReceiveFunctor&& receiver)
|
std::unique_ptr<IMIDIIn> newRealMIDIIn(const char* name, ReceiveFunctor&& receiver)
|
||||||
{
|
{
|
||||||
|
if (!m_midiClient)
|
||||||
|
return {};
|
||||||
|
|
||||||
MIDIEndpointRef src = LookupMIDISource(name);
|
MIDIEndpointRef src = LookupMIDISource(name);
|
||||||
if (!src)
|
if (!src)
|
||||||
return {};
|
return {};
|
||||||
|
@ -454,6 +469,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
||||||
|
|
||||||
std::unique_ptr<IMIDIOut> newRealMIDIOut(const char* name)
|
std::unique_ptr<IMIDIOut> newRealMIDIOut(const char* name)
|
||||||
{
|
{
|
||||||
|
if (!m_midiClient)
|
||||||
|
return {};
|
||||||
|
|
||||||
MIDIEndpointRef dst = LookupMIDIDest(name);
|
MIDIEndpointRef dst = LookupMIDIDest(name);
|
||||||
if (!dst)
|
if (!dst)
|
||||||
return {};
|
return {};
|
||||||
|
@ -476,6 +494,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
||||||
|
|
||||||
std::unique_ptr<IMIDIInOut> newRealMIDIInOut(const char* name, ReceiveFunctor&& receiver)
|
std::unique_ptr<IMIDIInOut> newRealMIDIInOut(const char* name, ReceiveFunctor&& receiver)
|
||||||
{
|
{
|
||||||
|
if (!m_midiClient)
|
||||||
|
return {};
|
||||||
|
|
||||||
MIDIEndpointRef src = LookupMIDISource(name);
|
MIDIEndpointRef src = LookupMIDISource(name);
|
||||||
if (!src)
|
if (!src)
|
||||||
return {};
|
return {};
|
||||||
|
@ -648,7 +669,8 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine
|
||||||
~AQSAudioVoiceEngine()
|
~AQSAudioVoiceEngine()
|
||||||
{
|
{
|
||||||
AudioQueueDispose(m_queue, false);
|
AudioQueueDispose(m_queue, false);
|
||||||
MIDIClientDispose(m_midiClient);
|
if (m_midiClient)
|
||||||
|
MIDIClientDispose(m_midiClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pumpAndMixVoices()
|
void pumpAndMixVoices()
|
||||||
|
|
Loading…
Reference in New Issue