Commit Graph

160 Commits

Author SHA1 Message Date
Stefano Pigozzi af6ad6717f ao_coreaudio: reduce verbosity of the chmapping code 2013-07-22 21:53:18 +02:00
Stefano Pigozzi df39121206 ao_coreaudio: revert to original device format on digital uninit
This is not done automatically by CoreAudio. I am told that it would a PITA
to have to switch back the format manually on the device (especially if the
same device is used for lpcm output).
2013-07-22 21:53:18 +02:00
Stefano Pigozzi c11c744998 ao_coreaudio: refactor chmap detection
b2f9e0610 introduced this functionality with code that was quite 'monolithic'.
Split the functionality over several functions and ose the new macros to get
array properties.
2013-07-22 21:53:18 +02:00
Stefano Pigozzi 18777ecfe8 ao_coreaudio: refactor properties code
Introduce some macros to deal with properties. These allow to work around the
limitation of CoreAudio's API being `void **` based. The macros allow to keep
their client's code DRY, by not asking size and other details which can be
derived by the macro itself. I have no idea why Apple didn't design their API
like this in the first place.
2013-07-22 21:53:18 +02:00
Stefano Pigozzi 1ed1175636 ao_coreaudio: move utils functions to snake_case 2013-07-22 21:53:18 +02:00
Stefano Pigozzi 1e37965597 ao_coreaudio: split ao_coreaudio_common in two files
* ao_coreaudio_utils: contains several utility function
 * ao_coreaudio_properties: contains functions to set and get  audio object
   properties.

Conflicts:
	audio/out/ao_coreaudio.c
2013-07-22 21:53:18 +02:00
Stefano Pigozzi 5a195845e3 ao_coreaudio: store asbd only when selected
Previous code needlessly stored the input asbd before actually testing it's
support against the hardware.
2013-07-22 21:53:18 +02:00
Stefano Pigozzi 4e0618dab9 ao_coreaudio: fallback to waveext on non surround inputs 2013-07-22 21:53:18 +02:00
Stefano Pigozzi c2de6fdf34 ao_coreaudio: set channel layout based on hardware query
this is a wip
2013-07-22 21:53:18 +02:00
Stefano Pigozzi 9652245ef0 ao_coreaudio: fix regression in digital stream selection
The condition was checked wrongly on asbd which is the input format
description. This lead to the condition always being true, thus selecting lpcm
streams for digital input.
2013-07-22 21:53:18 +02:00
Stefano Pigozzi e61102e637 ao_coreaudio: return errors instead false in init functions 2013-07-22 21:53:18 +02:00
Stefano Pigozzi b41fcc1e2c ao_coreaudio: remove useless function declaration 2013-07-22 21:53:18 +02:00
Stefano Pigozzi b174d647e5 ao_coreaudio: only set chmap_sel info for lpcm 2013-07-22 21:53:18 +02:00
Stefano Pigozzi 4d15f1bb60 ao_coreaudio: set channel layout bitmap 2013-07-22 21:53:18 +02:00
Stefano Pigozzi 24cad42363 ao_coreaudio: move digital detection before asbd creation 2013-07-22 21:53:18 +02:00
Stefano Pigozzi 6473cc59b1 ao_coreaudio: remove chmap selection if format is digital 2013-07-22 21:53:18 +02:00
Stefano Pigozzi 6d2f9a2804 ao_coreaudio: remove volume multiplication by 4
kHALOutputParam_Volume is the linear gain so it should be at maximum 1 to
keep the audio quality good. No idea why it was more than that.
2013-07-22 21:53:18 +02:00
Stefano Pigozzi a2d106cb31 ao_coreaudio: remove device property listener on uninit
Also extract this functionality inside a function in coreaudio_common
2013-07-22 21:53:18 +02:00
Stefano Pigozzi 7b2b292343 ao_coreaudio: print help string in one go 2013-07-22 21:53:18 +02:00
Stefano Pigozzi 5a4ae42892 ao_coreaudio: change all ++var to var++
Luckily they all were inside for loops so the functionality does not actually
change.
2013-07-22 21:53:18 +02:00
Stefano Pigozzi d3fb585b58 ao_coreaudio: change private vars names to match mpv conventions 2013-07-22 21:53:17 +02:00
Stefano Pigozzi d9c0dc7733 ao_coreaudio: remove packetSize private variable 2013-07-22 21:53:17 +02:00
Stefano Pigozzi 7d7381f9cf ao_coreaudio: refactor play/pause 2013-07-22 21:53:17 +02:00
Stefano Pigozzi d4b161f37d ao_coreaudio: refactor uninit 2013-07-22 21:53:17 +02:00
Stefano Pigozzi f392ffe95c ao_coreaudio: remove a fixme since that seems fixed 2013-07-22 21:53:17 +02:00
Stefano Pigozzi 6e44b12240 ao_coreaudio: ca_msg: add trailing \n where missing 2013-07-22 21:53:17 +02:00
Stefano Pigozzi 88425625cf ao_coreaudio: refactor play 2013-07-22 21:53:17 +02:00
Stefano Pigozzi 065e446e04 ao_coreaudio: extract mixmode set/unset in utility functions 2013-07-22 21:53:17 +02:00
Stefano Pigozzi 838fa07376 ao_coreaudio: move AudioStreamChangeFormat to common file and refactor 2013-07-22 21:53:17 +02:00
Stefano Pigozzi 40f6e2e041 ao_coreaudio: extract methods to lock/unlock device for digital output 2013-07-22 21:53:17 +02:00
Stefano Pigozzi e3ce0f0f8e ao_coreaudio: lpcm: remove buffer size calculation depending on audio unit 2013-07-22 21:53:17 +02:00
Stefano Pigozzi 1640ce3262 ao_coreaudio: refactor initialization
The initialization is split more clearly between compressed and lpcm case.
For the compressed case, format selection is simplified a lot and negotiation
removed. The way it was written it just passed back to the core the original
requested format, not what was found available on hardware.

Since this is most likely useless for the compressed case, I didn't bother
with this. In the future I'd like to split this AO in two one that only uses
the AUHAL and the other with direct access to the hardware so that even
passthrough of lcpm can be possible. This would decrease the latency,
audiophiles would like that.
2013-07-22 21:53:17 +02:00
Stefano Pigozzi f9a31bc3d9 ao_coreaudio: refactor print_help 2013-07-22 21:53:17 +02:00
Stefano Pigozzi f35f6a34b5 ao_coreaudio: split out some utility functions and refactor them
Split out some utility functions that use the CoreAudio API but are not related
the main task of the AOs (which is to move data correctly to the ringbuffer).
These are mainly need for the verbosity of the CoreAudio API and are just
obscuring the 'real' code.
2013-07-22 21:53:17 +02:00
Stefano Pigozzi dc8eb9d77a ao_coreaudio: make variable names shorter
property_address -> p_addr
2013-07-22 21:53:17 +02:00
Stefano Pigozzi 45479825ba ao_coreaudio: add error check function and macro
WIP
2013-07-22 21:53:17 +02:00
Stefano Pigozzi 3edb605172 ao_coreaudio: dry up ca_msg and use it everywhere
Change the ca_msg macro to pass along MSGT_AO automatically. Also use it for
every output for consistency.
2013-07-22 21:53:17 +02:00
Stefano Pigozzi c4bed92280 ao_coreaudio: simplify digital render callback
It was reported that it also works by not setting the read size in the
AudioBuffer (now idea how, but I will discover it later).
2013-07-22 21:53:17 +02:00
Stefano Pigozzi 8cf36cf950 ao_coreaudio: rewrite spdif render callback 2013-07-22 21:53:17 +02:00
Stefano Pigozzi d427b4fd1c ao_coreaudio: simplify render callback
Read only the requested amount by the AUHAL (instead of all the buffered data).
No idea what the deal is with pausing the audio units if there is no audio to
play, maybe to avoid underruns of some sort. Anyway from my tests this
condition never occurred so I'm removing it all.
2013-07-22 21:53:16 +02:00
Diogo Franco (Kovensky) 58338f9240 ao_wasapi: Make default on Windows.
Ahead of OSS because cygwin provides OSS.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) 1b2dc3613f ao_wasapi: Fix S/PDIF passthrough init
MSDN tells me to multiply the samplerates by 4 (for setting up the S/PDIF
signal frequency), but doesn't mention that I'm only supposed to do it
on the new, NT6.1+ IEC 61937 structs. Works on my Realtek Digital Output,
but as I can't connect any hardware to it I can't hear the result.

Also, always ask for little-endian AC3. I'm not sure if this is supposed
to be LE or NE, but Windows is LE on all platforms, so we go with LE.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) 9fe2772780 ao_wasapi: Log the passthrough format in MSGL_V 2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) a8b4be274c ao_wasapi: Also do passthrough for AF_FORMAT_MPEG2
That's the sample format ad_spdif uses when the source is MP3.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) dcf38e0190 ao_wasapi: Support S/PDIF passthrough
Entirely untested as this troper has no S/PDIF hardware.

Refuses trying any other format if we can't use passthrough, or we would
end up sending white noise at the user.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) 58e3d3f207 ao_wasapi: Fix double free on uninit
Caused by incorrect conversion to the m_option API: since we don't allocate
the state ourselves, we also don't free it ourselves.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) c62395dc09 ao_wasapi: Support loading devices by name
Do an strstr match against the device description and, if we have only
a single match, take it. This works as long as the devices in the system
don't change, but it's not supposed to be reliable; if one wants
reliability, one uses the device ID string.

Formatting.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) ad6acddbcf ao_wasapi: Don't search for devices as part of validation
This could turn valid parameters into syntax errors by the mere presence
or abscence of a device (e.g. USB audio devices), so don't do that.

We do validate that, if the parameter is an integer, it is not negative.
We also respond to the "help" parameter, which does the same as the "list"
suboption but exits after listing.

Demote the validation logging to MSGL_DBG2.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) d68fa0531f ao_wasapi: Change function macros to require semicolon after invocation
Add semicolons where they were missing.
2013-07-22 02:42:38 +02:00
Diogo Franco (Kovensky) 964341b02d ao_wasapi: Use OPT_STRING_VALIDATE for device suboption
Validates by trying to pick the device using the device enumerator and
aborting with out of range on failure.

Refactors find_and_load_device to not use the wasapi_state; it might be
called during validation. Adds missing CoInitialize/CoUninitialize calls.
Remove unused variables (the SAFE_RELEASE macros keep them referenced so
compiler warnings don't help finding them...).

Remove the IMMDeviceEnumerator from the wasapi_state, it's only needed
during initialization and initialization is now well factored enough to
get rid of it.

Try and connect to unplugged devices as well when using the device ID
string.
2013-07-22 02:42:38 +02:00