Commit Graph

927 Commits

Author SHA1 Message Date
wm4 9c974b2a1b audio/filter: actually set fmt_in/fmt_out fields 2015-01-14 22:15:51 +01:00
wm4 f6a0a1554c af_scaletempo: use refcounted frames 2015-01-14 22:15:39 +01:00
wm4 218c749a16 af_lavrresample: use refcounted frames 2015-01-14 22:15:31 +01:00
wm4 7b8862760d audio: add missing declaration 2015-01-14 22:15:00 +01:00
wm4 c8ecb66269 ao_pcm: add append mode
Pretty useful for debugging, although a bit useless or possibly
misleading too (see comments in the manpage).
2015-01-14 22:14:56 +01:00
wm4 4cabd08e8a audio: fix initial audio PTS
Commit 5e25a3d2 broke handling of the initial frame (the one decoded
with initial_audio_decode()). It didn't update the pts_offset field,
leading to a shift in timestamps by one audio frame.

Fix by calling the actual decode function in a single place. This
requires slightly more changes than what would be necessary to fix the
bug, but it also somewhat simplifies the data flow.
2015-01-14 22:14:46 +01:00
wm4 3cb2add636 audio: fix assertion failure on audio decoding
There are several cases in which a decoder may need several packets to
produce some output audio. Commit 5e25a3d2 broke this.

Fixes #1471.
2015-01-14 07:58:01 +01:00
wm4 ecca64e182 af_convert24: use refcounted frames
This requires allocating a fully new frame. 32->24 could be in-place,
but this is not possible for 24->32.
2015-01-13 20:17:08 +01:00
wm4 983f5efa3c audio/filters: use refcounted frames for some in-place filters
These are also quite simple, but require requesting write access to the
frames. The error handling (for OOM) is a bit annoying.
2015-01-13 20:17:03 +01:00
wm4 1fde40732e audio/filters: use refcounted frames for some simple filters
These are read-only, and very trivial to convert.
2015-01-13 20:16:59 +01:00
wm4 772c42a95c af_volume: use refcounted frames 2015-01-13 20:15:53 +01:00
wm4 5e25a3d216 audio: use refcounted frames in the filter chain
The goal is switching the whole audio chain to using refcounted frames.
This brings the architecture closer to FFmpeg, enables better
integration with libavfilter, will reduce useless copying somewhat, and
will probably allow better timestamp tracking.

For now, every filter goes through a semi-awful wrapper in
af_do_filter(), though. This will be fixed step by step, and the wrapper
should eventually be removed. Another thing that will have to be done is
improving the timestamp handling and avoiding extra copies for the AO.

Some of the new code is rather similar to the video filter code (the
core filter code basically just has types replaced). Such code
duplication is normally very unwanted, but in this case there's probably
no other choice. On the other hand, this code is pretty simple (even if
somewhat tricky). Maybe there will be unified filter code in the future,
but this is still far away.
2015-01-13 20:15:43 +01:00
wm4 97becbc31b audio: add some utility functions for refcounted frames
Used in the following commits.
2015-01-13 20:14:25 +01:00
wm4 0bbd65b09c audio/filter: remove unused af_calc_filter_multiplier()
The purpose of this function was to filter only as much audio input as
needed to produce a certain amount of audio output. This could (in
theory) avoid excessive buffering when e.g. changing playback speed with
resampling.

Use of this was already removed in commit 5fd8a1e0. No problems were
experienced, so let's assume this feature is practically worthless.
(Though it's possible that it was quite useful over a decade ago, or in
some cornercases with evil files.)
2015-01-13 20:14:02 +01:00
wm4 2c9180f47b ao_pulse: exit AO if stream fails
This can for example reproduced by killing the pulseaudio server. If
this happens, just try to reload the AO, instead of breaking everything
forever.
2015-01-11 04:19:40 +01:00
wm4 7f2b78846b ao_alsa: fix dtshd passthrough
We must not try to remap channels with this. Whethever ALSA gives us,
and whatever we do with it, the result will probably be nonsense.

Untested, as I don't have the required hardware.
2015-01-09 03:58:47 +01:00
wm4 5a7719594e ao: remove coreaudio_exclusive from autoprobing list
Apparently this was a mistake.
2015-01-07 22:31:34 +01:00
wm4 dc2d0539c7 ao_pulse: disable latency calculation hacks by default
This used to be required to workaround PulseAudio bugs. Even later, when
the bugs were (partially?) fixed in PulseAudio, I had the feeling the
hacks gave better behavior. On the other hand, I couldn't actually
reproduce any bad behavior without the hacks lately. On top of this, it
seems our hacks sometimes perform much worse than PulseAudio's native
implementation (see #1430).

So disable the hacks by default, but still leave the code and the option
in case it still helps somewhere. Also, being able to blame PulseAudio's
code by using its native API is much easier than trying to debug our own
(mplayer2-derived) hacks.
2015-01-07 22:23:38 +01:00
wm4 f61b8b312d win32: request UTF-16 API variants, Vista+ APIs, and COM C macros
Put the Vista+ (_WIN32_WINNT) and the COM C (COBJMACROS) defines into
the build system, instead of defining them over and over in the code.
2015-01-07 21:42:44 +01:00
wm4 0f4bf347c5 player: print used number of threads in verbose mode
Also, don't use av_log() for mpv output.
2015-01-05 12:17:55 +01:00
wm4 fda44ecc92 af_volume: dump applied replaygain in verbose mode 2015-01-04 01:35:48 +01:00
Kevin Mitchell 6a6620a554 ao/wasapi: style/code formatting tweaks 2015-01-02 14:50:59 -08:00
Kevin Mitchell 155c8e20ef ao/wasapi: improve exclusive mode format search
fixes #1376
2015-01-02 14:08:47 -08:00
Kevin Mitchell 81948634ca ao/wasapi: revamp set_waveformatex
* bits instead of bytes
* add valid_bits argument
* just pass in the mp_chmap and get the number and wavext channel map from that
* indicate valid bits in waveformat_to_str
* make appropriate accomodations in try_format
2015-01-02 14:08:47 -08:00
Kevin Mitchell 121352cd95 ao/wasapi: add CO_E_NOTINITIALIZED to explain_err
someone on irc reported seeing this error
2015-01-02 14:08:47 -08:00
wm4 4075518011 ao_portaudio: remove this audio output
It's just completely useless. We have good native support for all 3
desktop platforms, and ao_sdl or ao_openal as fallbacks.
2014-12-29 18:53:12 +01:00
wm4 adeada149b ao_alsa: print channel map if setting it fails
This message is printed when the audio device advertised a channel map,
but couldn't set it - which is probably a dmix bug (we'll never know,
ALSA doesn't take bug reports).

Print the requested map, so that the user (maybe) can make a connection
when seeing the message and the actually used channel map, which might
be less confusing. Or at least less useless.
2014-12-29 18:49:11 +01:00
Stefano Pigozzi 21d93690cb ao: add debug log with the detected channel maps
This could be helpful with bug reports.
2014-12-29 17:56:53 +01:00
Stefano Pigozzi 54aea7d5de chmap_sel: add multichannel fallback heuristic
Instead of just failing during channel map selection, try to select a close
layout that makes most sense and upmix/downmix to that instead of failing AO
initialization. The heuristic is rather simple, and uses the following steps:

1) If mono is required always prefer stereo to a multichannel upmix.
2) Search for an upmix that is an exact superset of the required channel map.
3) Search for a downmix that is the exact subset of the required channel map.
4) Search for either an upmix or downmix that is the closest (minimum difference
   of channels) to the required channel map.
2014-12-29 17:56:53 +01:00
Stefano Pigozzi 461ba50ed6 chmap: add a 7.1(rear) layout name
This is common on Apple systems so it's handy to have a label for it.
2014-12-29 17:56:53 +01:00
Stefano Pigozzi 894b172a76 ao_coreaudio: remove useless guard
useless after 069016fd6c
2014-12-27 12:33:44 +01:00
Stefano Pigozzi 15e30e58b2 ao_coreaudio: fix some naming conventions 2014-12-27 12:33:44 +01:00
Stefano Pigozzi 069016fd6c ao_coreaudio: fix channel mapping
There where 3 major errors in the previous code:

1) The kAudioDevicePropertyPreferredChannelLayout selector returns a single
   layout not an array.
2) The check for AudioChannelLayout allocation size was wrong (didn't account
   for variable sized struct).
3) Didn't query the kAudioDevicePropertyPreferredChannelsForStereo selector
   since I didn't know about it's existence.

All of these are fixed.

Might help with #1367
2014-12-27 12:04:58 +01:00
Stefano Pigozzi 9aa7df3446 ao_coreaudio: fix typo 2014-12-27 00:29:21 +01:00
Stefano Pigozzi 4d99315730 ao_coreaudio: move some code to make output readable 2014-12-27 00:27:50 +01:00
Stefano Pigozzi 1391e765a2 ao_coreaudio: add more layout debug outputs
Should help remote debugging #1367 with --msg-level=ao=debug
2014-12-27 00:16:48 +01:00
wm4 3fdb6be316 win32: add mmap() emulation
Makes all of overlay_add work on windows/mingw.

Since we now don't explicitly check for mmap() anymore (it's always
present), this also requires us to make af_export.c compile, but I
haven't tested it.
2014-12-26 17:30:10 +01:00
Stefano Pigozzi 9317071bc3 ao_coreaudio: fix AudioChannelLayout allocations
AudioChannelLayout uses a trailing variable sized array so we need to
query CoreAudio for the size of the struct it is going to need (or the
conversion of that particular layout would fail).

Fixes #1366
2014-12-26 15:04:36 +01:00
wm4 759656d0ba ao_alsa: fix unpause path atfer previous commit
The resume code was accidentally fully removed from this code path.
2014-12-23 13:20:32 +01:00
wm4 d7b5484f51 ao_alsa: fix resuming from suspend mode
snd_pcm_prepare() was not always called, which could result in an
infinite loop.

Whether snd_pcm_prepare() was actually called depended on whether the
device was a hw device (or other characteristics; depending on
snd_pcm_hw_params_can_pause()), and required real suspend (annoying for
testing), so it was somewhat tricky to reproduce without knowing these
things.
2014-12-23 03:59:14 +01:00
wm4 a69f168dff ao_alsa: fix setting mono channel map
When setting the ALSA channel map, we never actually set the map we got
from ALSA directly, but convert it to mpv's, and then back to ALSA's.
mpv and ALSA use different conventions for mono, and there is already an
exception for ALSA->mpv, but not mpv->ALSA.
2014-12-20 17:18:50 +01:00
wm4 0dc455eb16 ao_alsa: remove some dead code
This was only added recently (c1e97161) as an attempt to minimize the
bad impact of channel layout device aliases. But use of these was
removed in commit 49df0132. Now this code does pretty much nothing, and
shouldn't be needed anymore. It does something when using spdif, but
this fallback won't work anyway.
2014-12-20 16:54:00 +01:00
wm4 5b32f30aa1 audio: fix previous commit
This would have always forced mono first (if supported by the AO),
instead of stereo.
2014-12-20 16:48:30 +01:00
wm4 d07c6566cd audio: fix fallback if audio API does not support mono
This makes it fallback to stereo properly.
2014-12-20 16:21:52 +01:00
Stefano Pigozzi 4b65bd5086 ao_coreaudio: fix mono/stereo channel mapping
Needed after af3bbb800d since now we use channel mapping all the time.

Fixes #1357
2014-12-16 13:04:29 +01:00
Stefano Pigozzi a7e48eca66 ao_coreaudio: add missing goto for error path 2014-12-16 13:04:28 +01:00
Kevin Mitchell 1e5f9d2673 ao/wasapi: use IsEqualGUID and IsEqualPropertyKey
before we were reinventing this wheel
2014-12-16 03:29:51 -08:00
wm4 49df01323e ao_alsa: remove old multichannel method
The "old" method (before the ALSA channel map API) used device aliases
like "surround51" to set the channel layout. The "interesting" part was
that these devices usually redirect to a hardware device. This means
playing stereo would lead you to the "default" device (dmix), while e.g.
5.1 to "surround51", which automatically takes care of the fact that
dmix can't do 5.1.

This is pretty much nonsense, though. It shouldn't depend on the damn
input media file whether the player is going to use shared access (dmix)
or exclusive access (direct hw device).

As a consequence, by default ao_alsa will do only what dmix can do. If
the user actually wants multichannel, he has to select a suitable hw
device with --audio-device. From there on, the correct speaker mapping
will be ensured via the channel mapping API.

The change is preparation for making multichannel output the default (as
far as supported by the audio output API). Of the common APIs, only ALSA
messes up beyond repair, so I feel like this change is needed.

On ancient alsa-lib versions, only stereo and mono can be played with
this branch.
2014-12-15 16:58:03 +01:00
wm4 ae5fd4a809 ao_alsa: add ridiculous hack to deal with braindead ALSA behavior
dmix reports channel layouts it doesn't support. The rest of the
technical part of the story is in the code comment.

This seems to be the only reasonable way to fallback from trying to
initialize certain devices (like dmix) with multichannel audio. We could
probably add support for such padding channels to our audio chain or to
ao_alsa itself, but this would probably be much more work than this
commit.

What dmix does is probably a bug. I've tried to report it to ALSA. Thay
have a link on their website to a bug tracker, but it's a dead link, and
has been for years. I've posted to alsa-devel, but received no reply.
I'm thus assuming this absolutely retarded behavior is by design, and
nothing will happen to improve upon it.

I'm considering sending Lennart Poettering a "thank you" email, because
with PulseAudio, multichannel audio just works (although some other
things just don't work).
2014-12-15 16:40:23 +01:00
Kevin Mitchell 4966a67f71 ao/wasapi: set the ao with the waveformat channelmap
hopefully this fixes #1350
2014-12-15 05:01:38 -08:00
reimar 13b4fb9d28 af_hrtf: Fix out-of-range read.
Based on patch by Yuriy Kaminskiy [yumkam gmail].

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@37330 b3059339-0415-0410-9bf9-f77b7e298cf2
Signed-off-by: wm4 <wm4@nowhere>
2014-12-06 17:09:57 +01:00
wm4 020897b5d3 ao_alsa: minor simplification
Whether we print it as warning or error doesn't really matter; we
continue anyway. (I don't actually know what the implications of running
in non-blocking mode are; for what's it worth, when I tested with
explicitly changing to non-blocking, it seemed to work fine anyway, so
don't change that part.)
2014-12-05 16:04:05 +01:00
wm4 c6deee3801 ao_alsa: hackfix mono playback
ALSA returns "FL" as channel layout when trying to play mono. mpv and
libavresample don't like this; in particular, using libavresample to
convert stereo to "FL" fails.
2014-12-05 16:04:05 +01:00
Stefano Pigozzi 254c60e608 coreaudio: don't output too many channel descriptions
for #1279 and #1249
2014-12-05 12:35:34 +01:00
Stefano Pigozzi f5ac80ea88 coreaudio: add missing \n in log line 2014-12-05 09:57:40 +01:00
Stefano Pigozzi 8e6f3bef36 coreaudio: don't print layout a second time
For #1279
2014-12-05 09:57:06 +01:00
wm4 d6606bcfff ao_alsa: simplify, remove no-block suboption
If no-block was given, the device would be opened with SND_PCM_NOBLOCK.
Also, after opening, blocking mode was unconditionally enabled anyway
with snd_pcm_nonblock(). Further, if opening with SND_PCM_NOBLOCK
failed, opening was retried without this flag.

This doesn't make any sense to me, and I've never heard of someone using
this suboption. I suspect it has to do with ancient ALSA bugs or API
caveats. Remove it and simplify the code.
2014-12-05 01:23:09 +01:00
wm4 c1e97161f4 ao_alsa: try to fallback to "default" device if device is busy
ALSA is crap. It's impossible to make multichannel playback just do the
right thing. dmix (the default on most distros) can do stereo only, and
will refuse to play multichannel. On the other hand, if you try like mpv
(and mplayer) to open a multichannel device (like "surround51" etc.),
this will actually open a hardware device, which will either fail if
dmix is active, or block out dmix if opening succeeds.

This commit falls back to "default" (i.e. dmix) if opening a
multichannel device fails, which is a tiny step towards the right
behavior. (Although fixing it fully is impossible.)
2014-12-04 22:42:07 +01:00
Stefano Pigozzi 9faf482d89 coreaudio: reject descriptions with too many channels
This is a fix attempt for #1279 and #1249.
2014-12-04 21:51:06 +01:00
Stefano Pigozzi c070d16093 coreaudio: fix more layout prints 2014-12-04 21:51:03 +01:00
Stefano Pigozzi 4db97d3303 coreaudio: fix prints of uint32_t in log_layout 2014-12-04 21:33:38 +01:00
wm4 4be7bdcc0f audio: fix one of the previous commits
Fixes commit 52c51149. It broke multichannel (or possibly everything)
for ao_alsa, ao_oss, ao_sndio.
2014-12-01 18:28:00 +01:00
Stefano Pigozzi 1c0920a8dd ao_coreaudio: initialize fetched properties to zeros
Should hopefully fix #1249 and #1279
2014-12-01 16:51:19 +01:00
wm4 b0ed93d87d audio: allow more than 20 channel map entries
This could trigger an assertion when using ao_alsa or ao_coreaudio. The
code was simply assuming the number of channel maps was bounded
statically (which was true at first in both AOs).

Fix by using dynamic memory allocation. It needs to be explicitly
enabled by the AOs by setting a temp context, because otherwise the
memory couldn't be freed. (Or at least this seems to be the most elegant
solution.)

Fixes #1306.
2014-12-01 15:28:06 +01:00
Kevin Mitchell 67c4117476 ao/wasapi: make set_ao_format EX/EXTENSIBLE agnostic
There is no guarantee that closestMatch returned by IsFormatSupported
is actually a WAVEFORMATEXTENSIBLE.

http://msdn.microsoft.com/en-us/library/windows/desktop/dd370876%28v=vs.85%29.aspx

We should therefore not blindly treat it as such.
2014-12-01 03:40:24 -08:00
Kevin Mitchell 146561cc91 ao/wasapi: fix set_ao_format
Before it used whatever was in ao->format and changed the bits even
though this might have nothing to do with the actual WAVEFORMAT
negotiated with WASAPI.

For example, if the initial ao->format was a float and we had set the
WAVEFORMAT to s24, this would create a non-existent float24 format.
Worse, it might put an u16 into ao->format when WAVEFORMAT described s16.
WASAPI doesn't support unsigned at all as far as I can tell.
2014-12-01 03:40:24 -08:00
Kevin Mitchell 524cdfc3f1 ao/wasapi: show actual waveformat tried
also remove bogus ao_format
2014-12-01 03:40:23 -08:00
Kevin Mitchell bd33fa7052 ao/wasapi: don't assume 32-bits == float
This was based on old WAVEFORMATEX restrictions
http://msdn.microsoft.com/en-us/library/windows/hardware/ff538799%28v=vs.85%29.aspx

With the new WAVEFORMATEXTENSIBLE, this is no longer a problem. and we
can have s32 or float32 so we need to actually check / set these correctly.

fixes #1287
2014-12-01 03:40:23 -08:00
Kevin Mitchell 2006069ca2 ao/format: add af_fmt_is_float 2014-12-01 03:40:23 -08:00
Kevin Mitchell 96fa3ebd1a ao/wasapi: make sure that < 16-bit pcm never happens
it just sucks. noone should have to listen to that.
2014-12-01 03:40:23 -08:00
Kevin Mitchell 9a0b97d214 ao/wasapi: get rid of WAVEFMT union
It only confused the issue. Replace it's functionality with
waveformat_copy function where needed.
2014-12-01 03:40:23 -08:00
Kevin Mitchell 77f675a151 ao/wasapi: handle VistaBlob failure more gracefully 2014-11-28 10:52:48 -08:00
Kevin Mitchell b83e447e2b ao/wasapi: remove unnecessary check of audio thread input
it would have caused a deadlock if it fired anyway.
2014-11-28 10:52:48 -08:00
Kevin Mitchell b0854bc42c ao/wasapi: more consistent/reliable method of computing extra WAVEFORMATEXTENSIBLE size 2014-11-28 10:52:48 -08:00
Kevin Mitchell 8908b80b77 ao/wasapi: more missed cleanup on failure 2014-11-28 10:52:43 -08:00
Kevin Mitchell 7b5baf3b53 ao/wasapi: check return values
Only issue a warning for failure of wasapi_enumerate_devices and
wasapi_fill_VistaBlob.
2014-11-28 10:52:12 -08:00
Kevin Mitchell 14f9719a65 ao/wasapi: make functions return bool that were acting like it
this involved inverting the logic of find_formats, enumerate_devies
and wasapi_fill_VistaBlob. The latter two were trivial as their return
values were not actually checked (to be fixed in a later
commit).
2014-11-28 10:48:36 -08:00
Kevin Mitchell 4f208e6f68 ao/wasapi: check full GUID of KSDATAFORMAT to determine float 2014-11-28 10:48:36 -08:00
Kevin Mitchell 239c880fe2 ao/wasapi: expose GUID and PKEY convenience functions
Give them the prefix mp_ and make them nonstatic.
2014-11-28 10:48:36 -08:00
Kevin Mitchell e2bc1c5f17 ao/wasapi: remove unused variable 2014-11-28 10:48:36 -08:00
Kevin Mitchell fb5d88a287 ao/wasapi: safely define PKEY constants
Before these definitions were incorrectly guarded by and #ifdef
but since they aren't macros, this would never be true so that
if they were ever added to mingw headers we would have problems.

rename KSDATAFORMAT constants with the same mp prefix for consistency.
also use DEFINE_GUID rather than defining the bare structure
2014-11-28 10:48:36 -08:00
Kevin Mitchell 81464780e9 ao/wasapi: avoid redundant passing of ao and wasapi_state as arguments
also drop some useless const declaraitons
2014-11-28 10:48:36 -08:00
Kevin Mitchell 3b0b89c0af ao/wasapi: just return 0 unconditionally from the thread
We weren't actually checking this value anyway. We only really
cared about init failure, which was checked another way.
2014-11-28 10:48:36 -08:00
Kevin Mitchell d40c0d4f90 ao/wasapi: fix unmatched CoUninitialize() on init failure 2014-11-28 10:48:36 -08:00
Kevin Mitchell d0c37f0731 ao/wasapi: more debugging messages 2014-11-28 10:48:07 -08:00
Kevin Mitchell ecb491fd95 ao/wasapi: simplify the init retry 2014-11-28 08:02:16 -08:00
Kevin Mitchell e4aaaf69df ao/wasapi: make get_device_delay return an error code 2014-11-28 08:02:16 -08:00
wm4 4a83f3df11 ao_wasapi: don't treat SetDisplayName() failure as fatal
Same for SetIconPath().
2014-11-27 20:05:29 +01:00
wm4 a98f88a12f mixer: don't show softvol neutral marker on OSD if not using softvol
Also fix the comment on the softvol field.
2014-11-27 10:11:55 +01:00
wm4 cc54377463 Do not call strerror()
...because everything is terrible.

strerror() is not documented as having to be thread-safe by POSIX and
C11. (Which is pretty much bullshit, because both mandate threads and
some form of thread-local storage - so there's no excuse why
implementation couldn't implement this in a thread-safe way. Especially
with C11 this is ridiculous, because there is no way to use threads and
convert error numbers to strings at the same time!)

Since we heavily use threads now, we should avoid unsafe functions like
strerror().

strerror_r() is in POSIX, but GNU/glibc deliberately fucks it up and
gives the function different semantics than the POSIX one. It's a bit of
work to convince this piece of shit to expose the POSIX standard
function, and not the messed up GNU one.

strerror_l() is also in POSIX, but only since the 2008 standard, and
thus is not widespread.

The solution is using avlibc (libavutil, by its official name), which
handles the unportable details for us, mostly. We avoid some pain.
2014-11-26 21:21:56 +01:00
wm4 5b69b76609 ao_alsa: fix channel map in pre-channel map API case
Forgotten in commit 5d5f5b09.
2014-11-25 18:34:24 +01:00
wm4 e1ae936e6b ao_alsa: always enable "plug" plugin for non-default device
This seems safer: otherwise, opening the AO could randomly fail if the
audio formats happens to be not float.

Unfortunately, this only works if the user does not select a device.
Since ALSA devices are arbitrary strings, including plugins with complex
parameters, it's not trivial or maybe even impossible to edit the string
in a way the "plug" plugin is added.

With --audio-device, it would be safe for users to select either
"default" or one of the "plughw" devices. Everything else seems
questionable.
2014-11-25 18:15:45 +01:00
wm4 5d5f5b094b ao_alsa: select and set channel maps via channel map API
Use the ALSA channel map API for querying and selecting supported
channel maps.

Since we (probably?) want to be compatible with ALSA versions before the
change, we still try to select the device name by channel map, and open
that device. There's no way to negotiate a channel map before opening,
so we're stuck with this approach. Fortunately, it seems these devices
allow selecting and setting any other supported channel layout, so maybe
this is not an issue at all. In particular, this avoids selecting the
default (dmix) device, which can only do stereo.

Most code is based on Martin Herkt <lachs0r@srsfckn.biz>'s alsa_ng
branch, with heavy modifications.
2014-11-25 18:09:36 +01:00
wm4 5fb54fa756 ao_alsa: minor fixes
Don't crash if no fallback channel layout could be found (caller can't
handle NULL return from select_chmap()). Apparently this could never
actually happen, though.

Don't treat snd_pcm_hw_params_set_periods_near() failure as fatal error.
Same deal as with snd_pcm_hw_params_set_buffer_time_near().

Actually free channel maps returned by snd_pcm_get_chmap().

Adjust some messages.
2014-11-25 17:27:19 +01:00
wm4 7d6e58471f audio: make mp_audio_config_to_str return a stack-allocated string
Simpler overall.
2014-11-25 11:11:31 +01:00
wm4 8a7b686597 ao_alsa: cleanups
No functional changes.

ALSA_PCM_NEW_HW_PARAMS_API was a pre-ALSA 1.0.0 thing and does nothing
with modern ALSA. It stopped being necessary about 10 years ago.

3 functions are moved to avoid forward references.
2014-11-25 11:10:44 +01:00
wm4 28b6ce39d3 audio: make mp_chmap_to_str() return a stack-allocated string
Simplifies memory management.
2014-11-24 19:56:01 +01:00
wm4 2228d47373 ao_alsa: try to use the channel map reported by ALSA
If ALSA reports a channel map, and it looks like it makes sense (i.e.
could be converted to mpv channel map, and the channel count matches),
then use that instead of the channel map we are assuming.

This is based on code written by lachs0r (alsa_ng branch).
2014-11-24 19:44:26 +01:00
wm4 df43e2d22a ao_pcm: simplify
Also shuts up Coverity.
2014-11-21 10:09:38 +01:00
wm4 9d2aef048d ao_oss: check whether setting samplerate succeeds
Independent from whether the samplerate was accepted or adjusted, errors
returned by the ioctl are fatal errors.

Found by Coverity.
2014-11-21 10:09:26 +01:00