-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodeluid.patch
49 lines (47 loc) · 2.12 KB
/
modeluid.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
diff --git a/RtAudio.cpp b/RtAudio.cpp
index 40fb6a9..b0ff46e 100644
--- a/RtAudio.cpp
+++ b/RtAudio.cpp
@@ -726,6 +726,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
CFRelease( cfname );
free(mname);
+ dataSize = sizeof( CFStringRef );
property.mSelector = kAudioObjectPropertyName;
result = AudioObjectGetPropertyData( id, &property, 0, NULL, &dataSize, &cfname );
if ( result != noErr ) {
@@ -747,6 +748,24 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
CFRelease( cfname );
free(name);
+ dataSize = sizeof( CFStringRef );
+ property.mSelector = kAudioDevicePropertyModelUID;
+ result = AudioObjectGetPropertyData( id, &property, 0, NULL, &dataSize, &cfname );
+ if ( result != noErr )
+ // Instead of returning an error, just use an empty modelUid.
+ cfname = CFSTR("");
+
+ length = CFStringGetLength(cfname);
+ char *modelUid = (char *)malloc(length * 3 + 1);
+#if defined( UNICODE ) || defined( _UNICODE )
+ CFStringGetCString(cfname, modelUid, length * 3 + 1, kCFStringEncodingUTF8);
+#else
+ CFStringGetCString(cfname, modelUid, length * 3 + 1, CFStringGetSystemEncoding());
+#endif
+ info.modelUid = modelUid;
+ CFRelease( cfname );
+ free(modelUid);
+
// Get the output stream "configuration".
AudioBufferList *bufferList = nil;
property.mSelector = kAudioDevicePropertyStreamConfiguration;
diff --git a/RtAudio.h b/RtAudio.h
index 1aa42e0..96337ad 100644
--- a/RtAudio.h
+++ b/RtAudio.h
@@ -299,6 +299,7 @@ class RTAUDIO_DLL_PUBLIC RtAudio
struct DeviceInfo {
bool probed; /*!< true if the device capabilities were successfully probed. */
std::string name; /*!< Character string device identifier. */
+ std::string modelUid; /*!< Unique, non-localized, system-independent identifier for this model of device. */
unsigned int outputChannels{}; /*!< Maximum output channels supported by device. */
unsigned int inputChannels{}; /*!< Maximum input channels supported by device. */
unsigned int duplexChannels{}; /*!< Maximum simultaneous input/output channels supported by device. */