How to output 5.1 surround on OS X with libvlc? - macos

I am trying to get my app written to use libvlc to output surround (AC3 5.1) over an HDMI sound device.
The HDMI device is called "HDMI" in the Audio Devices in OSX.
I have tried using libvlc_audio_output_device_set, where I have tried "coreaudio", "auhal" and "HDMI" as the name, and the ID number as the id. I am not sure if this is right, the documents talk of non-portability and specificness to this call.
I have also tried passing arguments when initialising libvlc:
"--aout=auhal"
"core-audio-dev 40"
40 is the ID fro the HDMI device (determined with a dynamic library I have which obtains the device ID number for a specific Audio Device), but in this case I get the error:
vlc: unknown option or missing mandatory argument `--coreaudio-dev 40'
The VLC documentation says this is an option on OSX but it seems not to work.
Selecting audio device in the standalone VLC app works fine (select HDMI).
I am using nightly VLC on OS X 10.8.3.
Can anyone help?

Related

Outputting Audio to the Built-In output device (Not the Default One)

I need to do some system-wide audio processing in my app.
I have installed Soundflower and selected it as my default output device in order to get the system audio. I know that Soundflower merely copies the mix buffer to a ThruBuffer and passes it to the apps so they can get it in their AudioDeviceIOProc callback.
What I don't understand is how to route the audio back to the Built-In output device after I've done the audio processing. I have the Soundflower device as the default, and it produces silence as I try to route the audio to the default output unit. Maybe what I need is to create a Multi-Output device in my program but I'm not sure how to do that.
You can create a multi-output device on osx - they're called "aggregate devices". You can do it manually in Audio MIDI Setup app and use that device in your app, or do it programmatically in your app.
If you do do it in app, example code seems to be rare. I cribbed the info I needed from this blog post.
NB the post is very old, I had to go to the Internet Archive Wayback Machine to find it.

Hide USB Audio device on MAC OS X using custom kext

I am developing an application which does custom audio processing and sends the processed audio to the USB headset. My requirement is that the USB headset should not be visible to the user in the list of Audio output devices in System Preferences. Using "SampleUSBAudioOverrideDriver" code-less kext sample code from Apple, I'm able to change the interface name but I really need to hide it.
Is subclassing AppleUSBAudioDevice an option?
The recommended way to do pre-processing of a USB audio device's input and output streams in kernel space is to use the AppleUSBAudioPlugin API. This kext does not appear in the list of devices because it isn't an instance of IOAudioEngine, so there is no "hiding" involved.

How to programmatically change Mac's audio output device or invoke the system "dong" sound using Ruby?

I have an app on the iMac written in Ruby, and it would give out alert sound using
puts 7.chr
(or it can play an mp3 file). But the problem is that sometimes the Mac is changed to output the audio in System Preferences to the HDTV instead of the internal speakers, and the HDTV can be turned off sometimes.
So is there a way to either programmatically change the output device to the internal speakers, or play the "Dong" sound which is the one when the iMac boots up -- the sound that comes from the inside of the machine?

How do I detect if a bluetooth audio device is connected in Mac OS X?

I'm working on an application that plays audio on OsX. I'm able to list the available output devices with CodeAudio, but I have issues with a bluetooth headset; Even though the device is powered off and not connected, it's still listed in the OsX sound pref pane, and therefore picked up by CoreAudio as a valid output.
I'd like not to display bluetooth outputs if the corresponding device isn't connected already.
I've tried to check CoreAudio properties like those:
kAudioDevicePropertyDeviceIsAlive
kAudioDevicePropertyDeviceIsRunning
kAudioDevicePropertyDeviceIsRunningSomewhere
but there's no difference between the default output and the bluetooth output.
Is this kind of detection something doable with Coreaudio?
For the benefit of future searchers the way I've done it in the past is to:
Enumerate the detected devices
Query the kAudioDevicePropertyTransportType property for each AudioDeviceID
which will return a transport type ID constant.
Match for the
kAudioDeviceTransportTypeBluetooth or
kAudioDeviceTransportTypeBluetoothLE type
That way you can determine the type of connection the device is using (USB, Firewire etc). You can find the full list of transport types in AudioHardwareBase.h

Selecting input mic for Mac Audio Queue Services?

I am currently using the Mac OS X Audio Queue Services API for audio recording and sound analysis. Works fine using the default mic input.
If there is more than one microphone plugged into the Mac (USB, headset jack, etc.), is there a way to programmatically enumerate and select which mic is to be used for audio input within an application? (e.g. not have to send the user to the system preferences panel, which may affect a users other audio applications.) If so, which APIs should be used to select the mic input.
To enumerate available input devices please see my answer to AudioObjectGetPropertyData to get a list of input devices.
Once you've determined the input device you'd like to use, you can set the kAudioQueueProperty_CurrentDevice property to the device's UID.
I fear, no, because AQ is hard-coded to use default input (to my best knowledge). AQ is fairly limited and only iOS gives more control via AutoSessions. However, you can use AUHAL to record from an arbitrary device:
http://developer.apple.com/library/mac/#technotes/tn2091/_index.html
You won't need listing 4 from above because you'll use the AudioDeviceID for the device you have chosen (presumably by getting the list of devices using AudioObjectGetPropertyDataSize and picking the one you want).
FWIW: if you decide that's too much, you can presumably still use AudioHardwareSetProperty to set kAudioHardwarePropertyDefaultInputDevice from your code - not what you wanted but certainly less work...
If you set up the Audio Queue to read from the default input device, then it will read from the mic that is selected as default in the System Preferences->Soubd->Input tab.

Resources