Commit Graph

640 Commits

Author SHA1 Message Date
wm4 8b7035c8ff ao: log reordered versions of channel maps
Useful for debugging cases when no standard orders are used.
2015-05-08 19:45:16 +02:00
wm4 ad9bce2a5c ao_alsa: log requested numbers of channels if ALSA rejects them 2015-05-08 14:24:20 +02:00
wm4 b91b4944bd audio: define only a single NA speaker ID
Remove the requirement from mp_chmap that speaker entries must be
unique. Use this to get rid of all the redundant NA speaker IDs.
2015-05-07 23:07:14 +02:00
wm4 1bcb82ec93 ao_coreaudio_utils: don't list some formats as "unusable"
While mpv has no internal equivalent representation, they can still be
used as physical CoreAudio formats. Thus this label is confusing.
2015-05-07 20:55:00 +02:00
wm4 cd5ab98ff9 ao_sndio: add notice about padding channels
(I won't do this, but someone else seeing this might.)
2015-05-06 21:48:40 +02:00
wm4 85fc6b2a05 ao_alsa: use new padding channels support
Sometimes, ALSA will return channel layouts with padded channels (NA
speakers). Use them instead of failing.

This still includes the old "braindeath" code to retry with a layout
without NA channels. This might be helpful for performance, and also the
padded channel layout string looks confusing.

To be fair, I have not encountered a case yet which would really need
this, and for which the old "braindeath" code did not fix it.
2015-05-06 21:48:40 +02:00
wm4 d577872a28 ao_alsa: move ALSA -> mp channel map to a function
One side effect is that the warning about too many channels goes away,
and is replaced with printing the ALSA channel map as "unknown".
2015-05-06 21:48:40 +02:00
wm4 0ae0e90eb5 ao_coreaudio_exclusive: check new format before waiting for change
It seems if the format was already set, setting the same format will
not cause a property change.
2015-05-06 21:48:39 +02:00
wm4 4444ff48fa ao_coreaudio_exclusive: use atomics instead of volatile
volatile barely means anything.

The polling is kind of bad too, but relatively harmless as device
opening/closing is a rare event, and the format change is not expected
to take long.

Remove the pointless talloc call too (must have been a leftover
from previous refactoring).
2015-05-06 21:48:36 +02:00
wm4 028739932b ao_coreaudio_exclusive: rename "digital" -> "compressed"
PCM is digital too.
2015-05-06 18:54:53 +02:00
wm4 1e1045b13e ao_coreaudio_exclusive: explicitly check for spdif formats 2015-05-06 18:51:31 +02:00
wm4 32bc61ae07 ao_coreaudio_exclusive: merge init_digital() function
No reason to keep them separate. It's an artifact from the old
ao_coreaudio.c, which kept usage of two different APIs in the same file.
Removes a forward reference too.
2015-05-06 18:46:51 +02:00
wm4 4ffcf2531b ao_coreaudio_utils: decide formats by comparing raw bits
Instead of trying to use af_format_conversion_score() (which tries to be
all kinds of clever), just compare the raw bits as a quality measure. Do
this because otherwise, weird formats like padded 24 bit formats will be
excluded, even though they might be the highest precision formats for
some hardware.

This means that for now, the user would have to check whether the format
is usable at all before calling ca_asbd_is_better(). But since this is
currently only used for ao_coreaudio.c and for the physical format, it
doesn't matter.

If coreaudio-exclusive should get PCM support, the best would be to
revert this change, and to add support for 24 bit formats directly.
2015-05-05 22:10:33 +02:00
wm4 656703e279 ao_coreaudio: log considered physical formats 2015-05-05 22:09:44 +02:00
wm4 86d65c80e1 ao_coreaudio: restore old physical format if format was changed 2015-05-05 22:09:39 +02:00
wm4 934109a35b ao_coreaudio: move channel mapping code to a separate file
Move all of the channel map retrieval/negotiation code to a separate
file. This will (probably) be helpful when extending
ao_coreaudio_exclusive.c.

Nothing else changes, other than some minor cosmetics and renaming,
and changing some details for decoupling it from the ao_coreaudio.c
internals.
2015-05-05 21:47:19 +02:00
wm4 399267393b ao_coreaudio_utils: don't require talloc for fourcc_repr()
Instead, apply a trick to make the caller allocate enough space on the
stack.
2015-05-05 21:47:04 +02:00
wm4 7a5f5a8adf ao_coreaudio_utils: unbreak default device selection
It appears this is the reason coreaudio-exclusive does not work without
explicitly specifying a device, even if the default device maps to
something passthrough-capable.
2015-05-05 21:46:54 +02:00
wm4 bbedceb467 ao_coreaudio_exclusive: fix latency calculation non-sense
Didn't use the properties it was supposed to use.
2015-05-05 21:46:39 +02:00
wm4 fd6809f98a ao_coreaudio_utils: refine format selection
Instead of always picking a somehow better format over the previous one,
select a format that is equal to or better the requested format, but is
also reasonably close.

Drop the mFormatID comparison - checking the sample format handles this
already.

Make sure to exclude channel counts that can't be used.
2015-05-05 21:46:17 +02:00
wm4 66f4e7cce4 ao_coreaudio: change physical format before channel negotiation
If for example the physical format is set to stereo, the reported
multichannel layout will actually be stereo. It fixes itself only after
the physical format is changed.
2015-05-05 21:45:55 +02:00
wm4 8121529a6c ao_coreaudio: add an option for changing the physical format
ao_coreaudio uses AudioUnit - the OSX software mixer. In theory, it
supports multichannel audio just fine. But in practice, this might be
disabled by default, and the user is supposed to select a multichannel
base format in the "Audio MIDI Setup" utility.

This option attempts to change this setting automatically. Some possible
disadvantages and caveats are listed in the manpage additions. It is off
by default, since changing this might be rather bad behavior for a
normal application.
2015-05-05 01:11:16 +02:00
wm4 305a85cc9a ao_coreaudio_utils: add a format negotiation helper function 2015-05-05 01:11:16 +02:00
wm4 4d8a7e0394 ao_coreaudio: support padded channel layouts
If for example the audio settings are set to 5.1 output, but the
hardware does 8 channels natively (HDMI), the reported channel
layout will have 2 dummy channels. To avoid falling back to stereo,
we have to write audio in this format to the device.
2015-05-05 01:11:16 +02:00
wm4 eead97f103 ao_coreaudio: fix out of bounds access
ca_label_to_mp_speaker_id() checked whether the last entry was >= 0, but
actually this condition was never true, and MP_SPEAKER_ID_UNKNOWN0 is
not negative.
2015-05-04 23:54:38 +02:00
wm4 382434d45a ao_coreaudio_exclusive: check format explicitly on change notifcation
This should for now be equivalent; it's merely more explicit and will
be required if we add PCM support.

Note that the property listeners actually tell you what property
exactly changed, but resolving the current listener mess would be too
hard. So check for changes manually.
2015-04-29 23:10:45 +02:00
wm4 34a5229b23 ao_coreaudio_utils: log mp format with CoreAudio format description
As a consequence, it also logs whether mpv can a this format at all.
2015-04-29 23:07:36 +02:00
wm4 32b835c03b ao_coreaudio_utils: add function for ASBD -> mp format lookup
Useful with some of the following commits.

ca_fill_asbd() should behave exactly as before.

Instead of actually implementing the inverse function of ca_fill_asbd(),
just loop over the (small) list of mpv functions and check if any mpv
equivalent to a given ASBD exists.
2015-04-29 23:06:10 +02:00
wm4 3295ce48ab ao_coreaudio_utils: float is not a signed integer format
kAudioFormatFlagIsSignedInteger implicates that it's only used with
integer formats. The mpv internal flag on the other hand signals the
presence of a sign, and this is set on float formats.

Until now, this probably worked fine, because at least AudioUnit is
ignoring the uncorrect flag.
2015-04-29 22:39:28 +02:00
wm4 8b4ca58062 ao_coreaudio_exclusive: move code for getting original format
Should be almost equivalent, unless there are streams on which this call
does not work for unknown reasons.
2015-04-28 22:11:43 +02:00
wm4 d5e9bf66a1 ao_coreaudio_utils: change audio format logging
Make it easier to distinguish the fields.
2015-04-28 22:11:05 +02:00
wm4 5f86fad2f0 ao_coreaudio_exclusive: account for additional latency
Whether this is correct is unknown. This change tripples the latency
from ~15ms to ~45ms.

XBMC does this, VLC does not from what I could see.
2015-04-28 22:09:51 +02:00
wm4 570f4b136f ao_null: add an option for testing channel layout selection 2015-04-27 23:21:58 +02:00
wm4 2896afaa39 ao_alsa: fallback to stereo channel layout if everything else fails
mp_chmap_from_channels_alsa() doesn't always succeed - there are a bunch
of channel counts for which no defined ALSA layout exists. Fallback to
stereo in this case. (Normally, this code path shouldn't happen at all.)
2015-04-14 21:19:01 +02:00
Marcin Kurczewski f43017bfe9 Update license headers
Signed-off-by: wm4 <wm4@nowhere>
2015-04-13 12:10:01 +02:00
wm4 77869e5914 ao_coreaudio: fix inverted condition
And also use the correct type for the printf call below.
2015-04-10 13:51:13 +02:00
wm4 e98ab5e596 ao_alsa: change log output
Silence the usually user-visible warning about unsupported channel maps.
This might be an ALSA bug, but ALSA will never fix this behavior anyway.
(Or maybe it's a feature.)

Log some other information that might be useful.
2015-04-07 18:11:27 +02:00
wm4 5574820f13 ao_coreaudio: do not error if retrieving info for verbose mode fails
The message log level shouldn't get to decide whether something fails
or not. So replace the fatal error check on the verbose output code
path with a warning.
2015-04-07 12:23:24 +02:00
Kevin Mitchell 642f84f922 ao/wasapi: use atomic state variable instead of different events
Unfortunately, because we have proxy objects (pAudioVolumeProxy,
pEndpointVolumeProxy, pSessionControlProxy) it looks like we still
have to use MsgWaitForMultipleObjects and watch for and dispatch
pending messages:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms680112%28v=vs.85%29.aspx
2015-04-04 16:31:14 -07:00
Kevin Mitchell fe60cff03b ao/wasapi: reorder priv members 2015-04-04 16:31:14 -07:00
Kevin Mitchell bf3e0bc1da ao_wasapi: code formatting and alignment 2015-04-03 15:40:01 -07:00
Kevin Mitchell 46b9df9f9e audio: make all format query shortcuts macros
af_fmt_is_float and af_fmt_is_planar were previously inconsistent with
AF_FORAMT_IS_SPECIAL/AF_FORMAT_IS_IEC61937
2015-04-03 15:40:01 -07:00
Kevin Mitchell 07671ac57b ao_wasapi: passthrough rework
* unify passthrough and pcm exclusive mode format setting/testing
* set passthrough format parameters correctly
* support all of mpv's existing passthrough formats
* automatically test passthrough with exclusive mode and enable
  exclusive if it succeeds, even if it was not explictly requested.
  this obviates the need for --ao=wasapi,wasapi=exclusive
* if passthrough fails (such as the device doesn't support the
  format), fallback to either exclusive pcm or shared mode depending
  on what the user specified. Right now this isn't very useful as
  it still fails due to the decoder path remainin stuck on spdif.

fixes #1742
2015-04-03 15:39:51 -07:00
Kevin Mitchell 4987c1906d ao_wasapi: abstract HRESULT_to_str 2015-04-01 02:30:19 -07:00
wm4 ab3a64ee4c ao_coreaudio: do not signal per-app volume
CoreAudio doesn't seem to have this concept. The volume is reset the
next time audio is opened.
2015-04-01 01:10:23 +02:00
Kevin Mitchell e408dd20c7 ao_wasapi: remove redundant casts 2015-03-31 14:13:58 -07:00
Kevin Mitchell b6c28dd26b ao_wasapi: simplify hotplug
Take advantage of the fact that list_devs is called with a
hotplug_inited ao. Also eliminate unnecessary nested function
abstraction of hotplug_(un)init and list_devs. However, keep list_devs
in ao_wasapi_utils.c since it uses the private functions get_device_id,
get_device_name and exposing these would require including headers for
IMMDevice in ao_wasapi_utils.h.
2015-03-31 13:43:32 -07:00
Kevin Mitchell ea00fe0eeb ao_wasapi: fix device listing
remove depricated and convoluted validation. refer instead to the
--audio-device option.
2015-03-31 12:28:41 -07:00
Kevin Mitchell a6bf38bcad ao/wasapi: add ao hotplug
Create a second copy of the change_notify structure for the hotplug
ao. change_notify->is_hotplug distinguishes the hotplug version from
the regular one monitoring the currently playing ao. Also make the
change notification less verbose now that there might be two of them around.
2015-03-31 02:02:54 -07:00
wm4 b561ec99ff ao_alsa: add an option to ignore ALSA channel map negotiation
This was requested, more or less.
2015-03-28 23:53:49 +01:00