mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
[AFV] Request permission to access microphone on MacOS
This commit is contained in:
committed by
Mat Sutcliffe
parent
9f276c8dbf
commit
4827c0e4ab
@@ -111,10 +111,31 @@ namespace BlackCore
|
||||
m_audioInput.reset(new QAudioInput(selectedDevice, m_inputFormat));
|
||||
m_audioInputBuffer.start();
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
CMacOSMicrophoneAccess::AuthorizationStatus status = m_micAccess.getAuthorizationStatus();
|
||||
if (status == CMacOSMicrophoneAccess::Authorized)
|
||||
{
|
||||
m_audioInput->start(&m_audioInputBuffer);
|
||||
connect(&m_audioInputBuffer, &CAudioInputBuffer::frameAvailable, this, &CInput::audioInDataAvailable);
|
||||
m_started = true;
|
||||
return;
|
||||
}
|
||||
else if (status == CMacOSMicrophoneAccess::NotDetermined)
|
||||
{
|
||||
connect(&m_micAccess, &CMacOSMicrophoneAccess::permissionRequestAnswered, this, &CInput::delayedInitMicrophone);
|
||||
m_micAccess.requestAccess();
|
||||
CLogMessage(this).info(u"MacOS requested input device");
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).error(u"Microphone access not granted. Voice input will not work.");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
m_audioInput->start(&m_audioInputBuffer);
|
||||
connect(&m_audioInputBuffer, &CAudioInputBuffer::frameAvailable, this, &CInput::audioInDataAvailable);
|
||||
|
||||
m_started = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CInput::stop()
|
||||
@@ -174,6 +195,15 @@ namespace BlackCore
|
||||
emit opusDataAvailable(opusDataAvailableArgs);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
void CInput::delayedInitMicrophone()
|
||||
{
|
||||
m_audioInput->start(&m_audioInputBuffer);
|
||||
connect(&m_audioInputBuffer, &CAudioInputBuffer::frameAvailable, this, &CInput::audioInDataAvailable);
|
||||
m_started = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user