summaryrefslogtreecommitdiffstats
path: root/audio/out
Commit message (Collapse)AuthorAgeFilesLines
* ao_pulse: plug a memory leakBen Boeckel2015-01-261-0/+3
|
* ao_wasapi: fix try_format logic in shared modeJames Ross-Gowan2015-01-251-2/+1
| | | | | | | | | | | | | | | | | The MSDN documentation for IsFormatSupported says a return code of AUDCLNT_E_UNSUPPORTED_FORMAT means the function "succeeded but the specified format is not supported in exclusive mode." This seems to imply that the format is supported in shared mode, and that's what the old code assumed, however try_format would incorrectly return success with some drivers. The remarks section of the documentation contradicts that assumption. It says that in shared mode, if the audio engine does not support the caller-specified format or any similar format, ppClosestMatch is set to NULL and the function returns AUDCLNT_E_UNSUPPORTED_FORMAT. This is the same as in exclusive mode, so treat AUDCLNT_E_UNSUPPORTED_FORMAT the same regardless of opt_exclusive. In shared mode, the format selection code will fall back to the mix format, which should always be supported.
* ao_alsa: reinitialize if device got brokenwm42015-01-251-0/+3
| | | | | | | | | Apparently, physically disconnecting the audio device (consider USB audio) breaks the ALSA device handle forever. It will signal ENODEV. Fortunately, it's easy for us to handle this, and we can just use existing mechanisms that will make the playback core close and reopen the AO. Whether the immediate reopening will actually succeeds really is ALSA's problem, though.
* ao_coreaudio: reset possibly random errno valuewm42015-01-251-1/+2
| | | | | | | | | | In general, you need to check errno when using strtol(), but as far as I know, strtol() won't reset errno on success. This has to be done manually. The code could have failed sporadically if strtol() succeeded, and errno was already set to one of the checked values. (This strtol() still isn't fully error checked, but I don't know if it's intentional, e.g. for parsing a numeric prefix only.)
* ao_alsa: fix a small memory leakwm42015-01-251-0/+2
|
* ao_alsa: fix dtshd passthroughwm42015-01-251-2/+6
| | | | | | | 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.
* ao_pulse: disable latency calculation hacks by defaultwm42015-01-251-1/+0
| | | | | | | | | | | | | | 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.
* win32: request UTF-16 API variants, Vista+ APIs, and COM C macroswm42015-01-255-13/+1
| | | | | | | | | 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. Conflicts: video/out/w32_common.c waftools/checks/custom.py
* ao/wasapi: style/code formatting tweaksKevin Mitchell2015-01-253-64/+63
|
* ao/wasapi: use IsEqualGUID and IsEqualPropertyKeyKevin Mitchell2015-01-253-30/+9
| | | | before we were reinventing this wheel
* ao/wasapi: set the ao with the waveformat channelmapKevin Mitchell2015-01-251-1/+10
| | | | hopefully this fixes #1350
* ao/wasapi: improve exclusive mode format searchKevin Mitchell2015-01-251-46/+36
| | | | fixes #1376
* ao/wasapi: revamp set_waveformatexKevin Mitchell2015-01-251-27/+43
| | | | | | | | * 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
* ao/wasapi: add CO_E_NOTINITIALIZED to explain_errKevin Mitchell2015-01-251-0/+1
| | | | someone on irc reported seeing this error
* ao_alsa: print channel map if setting it failswm42015-01-251-1/+2
| | | | | | | | | | 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.
* ao: add debug log with the detected channel mapsStefano Pigozzi2015-01-251-0/+6
| | | | This could be helpful with bug reports.
* ao_coreaudio: remove useless guardStefano Pigozzi2015-01-251-6/+0
| | | | useless after 069016fd6c
* ao_coreaudio: fix some naming conventionsStefano Pigozzi2015-01-251-5/+5
|
* ao_coreaudio: fix channel mappingStefano Pigozzi2015-01-251-19/+70
| | | | | | | | | | | | | | | 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
* ao_coreaudio: fix typoStefano Pigozzi2015-01-251-1/+1
|
* ao_coreaudio: move some code to make output readableStefano Pigozzi2015-01-251-1/+1
|
* ao_coreaudio: add more layout debug outputsStefano Pigozzi2015-01-251-19/+25
| | | | Should help remote debugging #1367 with --msg-level=ao=debug
* ao_coreaudio: fix AudioChannelLayout allocationsStefano Pigozzi2015-01-251-34/+46
| | | | | | | | 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
* ao_coreaudio: fix mono/stereo channel mappingStefano Pigozzi2015-01-251-9/+7
| | | | | | Needed after af3bbb800d since now we use channel mapping all the time. Fixes #1357
* Do not call strerror()wm42015-01-251-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | ...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.
* ao/wasapi: make set_ao_format EX/EXTENSIBLE agnosticKevin Mitchell2015-01-251-14/+28
| | | | | | | | | 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.
* ao/wasapi: fix set_ao_formatKevin Mitchell2015-01-251-23/+10
| | | | | | | | | | | 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.
* ao/wasapi: show actual waveformat triedKevin Mitchell2015-01-251-8/+30
| | | | also remove bogus ao_format
* ao/wasapi: don't assume 32-bits == floatKevin Mitchell2015-01-251-45/+43
| | | | | | | | | | 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
* ao/wasapi: make sure that < 16-bit pcm never happensKevin Mitchell2015-01-251-6/+16
| | | | it just sucks. noone should have to listen to that.
* ao/wasapi: get rid of WAVEFMT unionKevin Mitchell2015-01-251-29/+13
| | | | | It only confused the issue. Replace it's functionality with waveformat_copy function where needed.
* ao/wasapi: handle VistaBlob failure more gracefullyKevin Mitchell2015-01-252-6/+21
|
* ao/wasapi: remove unnecessary check of audio thread inputKevin Mitchell2015-01-251-2/+0
| | | | it would have caused a deadlock if it fired anyway.
* ao/wasapi: more consistent/reliable method of computing extra ↵Kevin Mitchell2015-01-251-2/+1
| | | | WAVEFORMATEXTENSIBLE size
* ao/wasapi: more missed cleanup on failureKevin Mitchell2015-01-251-3/+5
|
* ao/wasapi: check return valuesKevin Mitchell2015-01-251-3/+6
| | | | | Only issue a warning for failure of wasapi_enumerate_devices and wasapi_fill_VistaBlob.
* ao/wasapi: make functions return bool that were acting like itKevin Mitchell2015-01-252-37/+37
| | | | | | | 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).
* ao/wasapi: check full GUID of KSDATAFORMAT to determine floatKevin Mitchell2015-01-252-8/+9
|
* ao/wasapi: expose GUID and PKEY convenience functionsKevin Mitchell2015-01-253-45/+49
| | | | Give them the prefix mp_ and make them nonstatic.
* ao/wasapi: remove unused variableKevin Mitchell2015-01-251-3/+0
|
* ao/wasapi: safely define PKEY constantsKevin Mitchell2015-01-251-16/+13
| | | | | | | | | 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
* ao/wasapi: avoid redundant passing of ao and wasapi_state as argumentsKevin Mitchell2015-01-251-19/+19
| | | | also drop some useless const declaraitons
* ao/wasapi: just return 0 unconditionally from the threadKevin Mitchell2015-01-251-10/+4
| | | | | We weren't actually checking this value anyway. We only really cared about init failure, which was checked another way.
* ao/wasapi: fix unmatched CoUninitialize() on init failureKevin Mitchell2015-01-252-8/+5
|
* ao/wasapi: more debugging messagesKevin Mitchell2015-01-252-14/+27
|
* ao/wasapi: simplify the init retryKevin Mitchell2015-01-251-10/+8
|
* ao/wasapi: make get_device_delay return an error codeKevin Mitchell2015-01-251-12/+21
|
* ao_wasapi: don't treat SetDisplayName() failure as fatalwm42015-01-251-1/+2
| | | | Same for SetIconPath().
* ao_pulse: exit AO if stream failswm42015-01-251-1/+5
| | | | | | This can for example reproduced by killing the pulseaudio server. If this happens, just try to reload the AO, instead of breaking everything forever.
* ao: remove coreaudio_exclusive from autoprobing listwm42015-01-251-2/+2
| | | | Apparently this was a mistake.
* ao_alsa: fix unpause path atfer previous commitwm42015-01-141-0/+2
| | | | The resume code was accidentally fully removed from this code path.
* ao_alsa: fix resuming from suspend modewm42015-01-141-4/+12
| | | | | | | | | | | 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.
* ao_alsa: fix setting mono channel mapwm42015-01-141-0/+5
| | | | | | | 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.
* ao_coreaudio: add missing goto for error pathStefano Pigozzi2014-12-171-0/+1
|
* ao_alsa: hackfix mono playbackwm42014-12-081-0/+3
| | | | | | 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.
* coreaudio: don't output too many channel descriptionsStefano Pigozzi2014-12-071-0/+6
| | | | for #1279 and #1249
* coreaudio: add missing \n in log lineStefano Pigozzi2014-12-071-1/+1
|
* coreaudio: don't print layout a second timeStefano Pigozzi2014-12-071-1/+1
| | | | For #1279
* ao_alsa: try to fallback to "default" device if device is busywm42014-12-071-1/+6
| | | | | | | | | | | | | 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.)
* coreaudio: reject descriptions with too many channelsStefano Pigozzi2014-12-071-0/+7
| | | | This is a fix attempt for #1279 and #1249.
* coreaudio: fix more layout printsStefano Pigozzi2014-12-071-2/+2
|
* coreaudio: fix prints of uint32_t in log_layoutStefano Pigozzi2014-12-071-10/+10
|
* ao_coreaudio: initialize fetched properties to zerosStefano Pigozzi2014-12-011-2/+2
| | | | Should hopefully fix #1249 and #1279
* audio: allow more than 20 channel map entrieswm42014-12-012-2/+2
| | | | | | | | | | | | | 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.
* ao_alsa: fix channel map in pre-channel map API casewm42014-11-251-0/+1
| | | | Forgotten in commit 5d5f5b09.
* ao_alsa: always enable "plug" plugin for non-default devicewm42014-11-251-3/+2
| | | | | | | | | | | | | | 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.
* ao_alsa: select and set channel maps via channel map APIwm42014-11-251-28/+125
| | | | | | | | | | | | | | | | 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.
* ao_alsa: minor fixeswm42014-11-251-4/+6
| | | | | | | | | | | | | 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.
* ao_alsa: cleanupswm42014-11-251-97/+57
| | | | | | | | | 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.
* audio: make mp_chmap_to_str() return a stack-allocated stringwm42014-11-242-9/+4
| | | | Simplifies memory management.
* ao_alsa: try to use the channel map reported by ALSAwm42014-11-241-0/+64
| | | | | | | | If ALSA reports a channel map, and it looks like it makes sense (i.e. could be converted to mpv