• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: API for switching audio output device or disabling output altogether
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: API for switching audio output device or disabling output altogether


  • Subject: Re: API for switching audio output device or disabling output altogether
  • From: tahome izwah <email@hidden>
  • Date: Fri, 11 Dec 2009 07:49:41 +0100

Not sure if this helps but you can get the current default system
output device via

AudioDeviceID currentDevice;
UInt32 propsize = sizeof(AudioDeviceID);
OSStatus err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
&propsize, &currentDevice);

In order to find the built-in device you iterate through all audio
devices calling

UInt32 transportType;
UInt32 propsize=sizeof(AudioDeviceID);
OSStatus err = AudioDeviceGetProperty(deviceID, 0, false,
kAudioDevicePropertyTransportType, &propsize, &transportType);

on each device. The built-in audio hardware has transportType ==
kIOAudioDeviceTransportTypeBuiltIn. You can set it system wide via
this call when required:

OSStatus err = AudioHardwareSetProperty(kAudioHardwarePropertyDefaultOutputDevice,
sizeof(AudioDeviceID), &outputDevice);

So you should be able to switch your device as required. Whether or
not this is good practice from a user experience POV I do not know - I
would think that Apple has a good reason for switching devices when
plugging in cables so I probably would not interefere with this.

After all you can still play through the built-in device in your app
if you don't use the system output for playback.

HTH
--th

2009/12/11 Roger Thornhill <email@hidden>:
> When an optical cable is inserted into the audio output port on an iMac, a
> hardware switch is triggered and the sound output device is automatically
> changed to "Digital Out".  I'd like to know if there's a way to prevent this
> from happening by programmatically disabling or enabling the optical output.
>  Right now the only way to switch from optical out to internal speakers is
> to physically disconnect the cable from the optical output port.  I'd like
> to figure out if there's a method to do this through software.  If there's
> no public API to do this, if anyone can point me in the direction of where I
> might look for private API calls, that would be useful as well.
> Roger
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: API for switching audio output device or disabling output altogether
      • From: William Stewart <email@hidden>
References: 
 >API for switching audio output device or disabling output altogether (From: Roger Thornhill <email@hidden>)

  • Prev by Date: API for switching audio output device or disabling output altogether
  • Next by Date: AudioQueueOfflineRender
  • Previous by thread: API for switching audio output device or disabling output altogether
  • Next by thread: Re: API for switching audio output device or disabling output altogether
  • Index(es):
    • Date
    • Thread