Commits

Joris Kluivers  committed a593f64

Accessor for the default audio output device

  • Participants
  • Parent commits e513706

Comments (0)

Files changed (2)

File AirplaySelection/JKAudioManager.h

 
 #import <Foundation/Foundation.h>
 
+@class JKAudioDevice;
+
 @interface JKAudioManager : NSObject
 
 + (JKAudioManager *) sharedManager;
 
+- (JKAudioDevice *) defaultOutputDevice;
 - (NSArray *) outputDevices;
 
 @end

File AirplaySelection/JKAudioManager.m

 	AudioObjectRemovePropertyListenerBlock(kAudioObjectSystemObject, &addr, dispatch_get_current_queue(), _deviceListenerBlock);
 }
 
+- (JKAudioDevice *) defaultOutputDevice
+{
+	const AudioObjectPropertyAddress addr = {
+		kAudioHardwarePropertyDefaultOutputDevice,
+		kAudioObjectPropertyScopeGlobal,
+		kAudioObjectPropertyElementMaster
+	};
+	
+	AudioDeviceID deviceID;
+	UInt32 dataSize = sizeof(AudioDeviceID);
+	AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, 0, NULL, &dataSize, &deviceID);
+	
+	return [[JKAudioDevice alloc] initWithDeviceID:deviceID];
+}
+
 - (void) browseDevices {
 	[self willChangeValueForKey:@"outputDevices"];