mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T739, MacOS only mic. access style using #ifdef
Although not required, "hide" mm code on other platforms (avoid CLANG warnings in QtC)
This commit is contained in:
committed by
Mat Sutcliffe
parent
f81a9e8447
commit
8a2d3458b4
@@ -21,6 +21,7 @@ namespace BlackMisc
|
||||
class BLACKMISC_EXPORT CMacOSMicrophoneAccess : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Authorization status
|
||||
enum AuthorizationStatus
|
||||
|
||||
@@ -7,44 +7,46 @@
|
||||
*/
|
||||
|
||||
#include "microphoneaccess.h"
|
||||
#ifdef Q_OS_MAC
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#endif
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
//#ifdef Q_OS_MAC
|
||||
|
||||
BlackMisc::CMacOSMicrophoneAccess::CMacOSMicrophoneAccess(QObject *parent) :
|
||||
QObject(parent)
|
||||
{ }
|
||||
|
||||
void CMacOSMicrophoneAccess::requestAccess()
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
if (@available(macOS 10.14, *))
|
||||
{
|
||||
NSString *mediaType = AVMediaTypeAudio;
|
||||
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted)
|
||||
{
|
||||
emit permissionRequestAnswered(granted);
|
||||
}];
|
||||
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler: ^ (BOOL granted)
|
||||
{
|
||||
emit permissionRequestAnswered(granted);
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
emit permissionRequestAnswered(true);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
CMacOSMicrophoneAccess::AuthorizationStatus CMacOSMicrophoneAccess::getAuthorizationStatus()
|
||||
{
|
||||
#ifdef Q_OS_MAC
|
||||
if (@available(macOS 10.14, *))
|
||||
{
|
||||
NSString *mediaType = AVMediaTypeAudio;
|
||||
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
|
||||
if(authStatus == AVAuthorizationStatusAuthorized)
|
||||
if (authStatus == AVAuthorizationStatusAuthorized)
|
||||
{
|
||||
return AuthorizationStatus::Authorized;
|
||||
}
|
||||
else if(authStatus == AVAuthorizationStatusNotDetermined)
|
||||
else if (authStatus == AVAuthorizationStatusNotDetermined)
|
||||
{
|
||||
return AuthorizationStatus::NotDetermined;
|
||||
}
|
||||
@@ -54,9 +56,9 @@ namespace BlackMisc
|
||||
{
|
||||
return AuthorizationStatus::Authorized;
|
||||
}
|
||||
|
||||
#else
|
||||
return AuthorizationStatus::NotDetermined;
|
||||
#endif
|
||||
}
|
||||
|
||||
// #endif
|
||||
}
|
||||
} // ns
|
||||
|
||||
|
||||
Reference in New Issue
Block a user