@@ -101,33 +101,30 @@ namespace swift::core::afv::audio
101
101
if (!m_audioInputBuffer) { m_audioInputBuffer = new CAudioInputBuffer (this ); }
102
102
else { m_audioInputBuffer->disconnect (); } // make sure disconnected in any case
103
103
m_audioInputBuffer->start (m_inputFormat);
104
+ const QString format = toQString (m_inputFormat);
105
+ CLogMessage (this ).info (u" Starting: '%1' with: %2" ) << selectedDevice.description () << format;
106
+
107
+ #ifdef Q_OS_MAC
108
+ this ->initMicrophoneMacOS ();
109
+ #else
110
+ this ->initMicrophone ();
111
+ #endif
112
+ }
104
113
105
114
#ifdef Q_OS_MAC
115
+ void CInput::initMicrophoneMacOS ()
116
+ {
106
117
CMacOSMicrophoneAccess::AuthorizationStatus status = m_micAccess.getAuthorizationStatus ();
107
- if (status == CMacOSMicrophoneAccess::Authorized)
108
- {
109
- // void
110
- // Audio start will be handled below
111
- }
118
+ if (status == CMacOSMicrophoneAccess::Authorized) { this ->initMicrophone (); }
112
119
else if (status == CMacOSMicrophoneAccess::NotDetermined)
113
120
{
114
- connect (&m_micAccess, &CMacOSMicrophoneAccess::permissionRequestAnswered, this ,
115
- &CInput::delayedInitMicrophone);
121
+ connect (&m_micAccess, &CMacOSMicrophoneAccess::permissionRequestAnswered, this , &CInput::initMicrophone);
116
122
m_micAccess.requestAccess ();
117
- CLogMessage (this ).info (u" MacOS requested input device" );
118
- }
119
- else
120
- {
121
- CLogMessage (this ).error (u" Microphone access not granted. Voice input will not work." );
122
- return ;
123
+ CLogMessage (this ).info (u" Request macOS permission for microphone" );
123
124
}
124
- #endif
125
- m_audioInput->start (m_audioInputBuffer);
126
- connect (m_audioInputBuffer, &CAudioInputBuffer::frameAvailable, this , &CInput::audioInDataAvailable);
127
- m_started = true ;
128
- const QString format = toQString (m_inputFormat);
129
- CLogMessage (this ).info (u" Starting: '%1' with: %2" ) << selectedDevice.description () << format;
125
+ else { CLogMessage (this ).error (u" Microphone access not granted. Voice input will not work." ); }
130
126
}
127
+ #endif
131
128
132
129
void CInput::stop ()
133
130
{
@@ -187,13 +184,12 @@ namespace swift::core::afv::audio
187
184
emit opusDataAvailable (opusDataAvailableArgs);
188
185
}
189
186
190
- #ifdef Q_OS_MAC
191
- void CInput::delayedInitMicrophone ()
187
+ void CInput::initMicrophone ()
192
188
{
193
189
m_audioInput->start (m_audioInputBuffer);
194
190
connect (m_audioInputBuffer, &CAudioInputBuffer::frameAvailable, this , &CInput::audioInDataAvailable);
195
191
m_started = true ;
192
+ CLogMessage (this ).info (u" Started input" );
196
193
}
197
- #endif
198
194
199
195
} // namespace swift::core::afv::audio
0 commit comments