summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_wasapi_utils.c
Commit message (Collapse)AuthorAgeFilesLines
* ao_wasapi: use new af_select_best_samplerate functionKevin Mitchell2016-03-171-11/+3
| | | | It duplicates the logic that was previously used here.
* ao_wasapi: use MP_FATAL for stuff that leads to init failureKevin Mitchell2016-02-261-1/+1
|
* ao_wasapi: set buffer size to device period in exclusive modeKevin Mitchell2016-02-261-7/+12
| | | | | | | | | | | | | This eliminates some intermittent pops heard in a HRT MicroStreamer DAC uncorrelated with user interaction. As a bonus, this resolves #1773 which I can o longer reproduce as of this commit. Leave the 50ms buffer for shared mode since that seems to be working quite well. This is also the way exclusive mode is done in the MSDN example code: https://msdn.microsoft.com/en-us/library/windows/desktop/dd370844%28v=vs.85%29.aspx This was originally increased in c545c40 to mitigate glitches that subsequent refactorings have eliminated.
* ao_wasapi: replace laggy COM messaging with mp_dispatch_queueKevin Mitchell2016-02-261-93/+0
| | | | | | | | | | A COM message loop is apparently totally inappropriate for a low latency thread. It leads to audio glitches because the thread doesn't wake up fast enough when it should. It also causes mysterious correlations between the vo and ao thread (i.e., toggling fullscreen delays audio feed events). Instead use an mp_dispatch_queue to set/get volume/mute/session display name from the audio thread. This has the added benefit of obviating the need to marshal the associated interfaces from the audio thread.
* ao_wasapi: use SUCCEEDED/FAILED macrosKevin Mitchell2016-02-261-1/+1
|
* Initial Android supportJan Ekström2016-02-101-0/+1
| | | | | * Adds an 'android' feature, which is automatically detected. * Android has a broken strnlen, so a wrapper is added from FreeBSD.
* ao_wasapi: add "wasapi" prefix to non-static find_deviceID functionKevin Mitchell2016-01-281-1/+1
|
* ao_wasapi: correct check for specified device on default changeKevin Mitchell2016-01-281-2/+7
| | | | | | Correctly avoid a reload if the current device was specified by the user through --audio-device. Previously, we only recognized if the user had specified --ao=wasapi:device=.
* ao_wasapi: fix check for already found deviceKevin Mitchell2016-01-281-1/+1
| | | | | oops, forgot to change this when I made get_deviceID a more proper function. state->deviceID is not set or read here - that's for the caller to do.
* ao_wasapi: use correct UINT type for device enumerationKevin Mitchell2016-01-221-5/+5
| | | | | | Notably, the address of the enumerator->count member is passed to IMMDeviceCollection::GetCount(), which expects a UINT variable, not an int. How did this ever work?
* ao_wasapi: exit earlier if there are zero playback devices foundKevin Mitchell2016-01-221-0/+5
| | | | | | | | Previously, if the enumerator found no devices, attempting to get the default device with IMMDeviceEnumerator::GetDefaultAudioEndpoint would result in the cryptic (and undocumented) E_PROP_ID_UNSUPPORTED. This way, the user is given a better indication of what exactly is wrong and isolates any other possible triggers for this error.
* Relicense some non-MPlayer source files to LGPL 2.1 or laterwm42016-01-191-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This covers source files which were added in mplayer2 and mpv times only, and where all code is covered by LGPL relicensing agreements. There are probably more files to which this applies, but I'm being conservative here. A file named ao_sdl.c exists in MPlayer too, but the mpv one is a complete rewrite, and was added some time after the original ao_sdl.c was removed. The same applies to vo_sdl.c, for which the SDL2 API is radically different in addition (MPlayer supports SDL 1.2 only). common.c contains only code written by me. But common.h is a strange case: although it originally was named mp_common.h and exists in MPlayer too, by now it contains only definitions written by uau and me. The exceptions are the CONTROL_ defines - thus not changing the license of common.h yet. codec_tags.c contained once large tables generated from MPlayer's codecs.conf, but all of these tables were removed. From demux_playlist.c I'm removing a code fragment from someone who was not asked; this probably could be done later (see commit 15dccc37). misc.c is a bit complicated to reason about (it was split off mplayer.c and thus contains random functions out of this file), but actually all functions have been added post-MPlayer. Except get_relative_time(), which was written by uau, but looks similar to 3 different versions of something similar in each of the Unix/win32/OSX timer source files. I'm not sure what that means in regards to copyright, so I've just moved it into another still-GPL source file for now. screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but they're all gone.
* ao_wasapi: move out some utility functionswm42016-01-111-71/+0
| | | | | | Note that hresult_to_str() (coming from wasapi_explain_err()) is mostly wasapi-specific, but since HRESULT error codes are unique, it can be extended for any other use.
* ao_wasapi: remove unnecessary header fileKevin Mitchell2016-01-051-7/+4
| | | | | All the wasapi files were including both ao_wasapi.h and ao_wasapi_utils.h. Just merge them into a single file.
* ao_wasapi: initialize change notify in main threadKevin Mitchell2016-01-051-3/+0
| | | | This is something else that has nothing to do with audio rendering.
* ao_wasapi: make find_deviceID read only wrt struct aoKevin Mitchell2016-01-051-17/+17
| | | | This makes it clearer that state->device is being allocated.
* ao_wasapi: move device selection to main threadKevin Mitchell2016-01-051-7/+3
| | | | In attempt to simplify the audio event thread, this can now be moved out.
* ao_wasapi: avoid some redundant error messages in device selectionKevin Mitchell2016-01-051-15/+7
| | | | | If these error conditions are triggered, the called function will have already output a sufficiently informantive error message.
* ao_wasapi: alloc later to avoid free on errorKevin Mitchell2016-01-051-2/+1
| | | | | In get_device_desc, don't alloc the return value until we know there wasn't an error.
* ao_wasapi: remove +x flag from fileswm42016-01-041-0/+0
|
* ao_wasapi: make persistent enumerator local to change_notifyKevin Mitchell2016-01-041-8/+1
| | | | This is no longer required by anything else
* ao_wasapi: rewrite device listing and selectionKevin Mitchell2016-01-041-225/+185
| | | | | | | | | | | | | Unify and clean up listing and selection. Use common enumerator code for both operations to avoid duplication or inconsistencies. Maintain, but significatnly simplify manual device selection by id, name or number. This actually fixes loading by name which didn't really work before since the "name" displayed by --audio-device=help differed from that used to match the selection, which used the device "description" instead. Save the selected deviceID in the private structure for later loading. This will permit moving the device selection into the main thread in a future commit.
* ao_wasapi: move volume control init to it's own functionKevin Mitchell2015-12-211-21/+34
| | | | also make failure non-fatal
* ao_wasapi: correctly handle audio session display failureKevin Mitchell2015-12-211-10/+14
| | | | | In particular, try and release/null the interface so that it won't be marshalled.
* ao_wasapi: non-fatal error handling for COM marshallingKevin Mitchell2015-12-211-53/+63
| | | | | Also make sure that CoReleaseMarshalData is called if errors occur before unmarshalling.
* ao_wasapi: wrap long lines and use only c99 comment styleKevin Mitchell2015-12-211-69/+108
| | | | | also remove a log message in AOCONTROL_UPDATE_STREAM_TITLE since none of the other controls have one.
* ao_wasapi: remove useless buffer_block_sizeKevin Mitchell2015-12-211-6/+0
| | | | this was only ever used for a verbose message
* ao_wasapi: call the class-specific release functionsKevin Mitchell2015-12-201-6/+6
| | | | | IUnknown_Release() might be alright, but stay on the safe side.
* ao_wasapi: actually use hw volume support information for exclusive modeKevin Mitchell2015-12-201-0/+1
| | | | | | | | | Do not try and set/get master volume in exclusive if there is no hardware support. This would just uselessly change the master slider, but have no effect on the actual volume. Furthermore if getting hardware volume support information fails, then assume it has none.
* ao_wasapi: remove volume "restore" on exitKevin Mitchell2015-12-201-17/+1
| | | | | | It was complicated and not even very intuitive to the user. If you are controlling the master volume, you just have to be prepared to deal with the consequences.
* ao_wasapi: add E_NOINTERFACE to error listKevin Mitchell2015-12-201-0/+1
| | | | this is encountered trying to set up COM proxies in wine
* ao_wasapi: get rid of Vistablob hackKevin Mitchell2015-11-241-36/+5
| | | | | This was required to work around XP linking issues and is no longer required.
* ao_wasapi: work around DTS passthrough failurewm42015-11-191-1/+18
| | | | | | | | | | Apparently, some audio drivers do not support the DTS subtype, but passthrough works anyway if the AC3 subtype is set. Just retry with AC3 if the proper format doesn't work. The audio device which exposed this behavior reported itself as "M601d-A3/A3R (Intel(R) Display Audio)". xbmc/kodi even always passes DTS as AC3.
* audio: always log channel maps before determining final mapwm42015-10-261-3/+1
| | | | | Until now, this was done only in debug verbosity, while some AOs logged equivalent information in verbose mode. Clean this up.
* win32: revert wchar_t changeswm42015-08-011-5/+5
| | | | | | | | | | | Revert "win32: more wchar_t -> WCHAR replacements" Revert "win32: replace wchar_t with WCHAR" Doing a "partial" port of this makes no sense anymore from my perspective. Revert the changes, as they're confusing without context, maintenance, and progress. These changes were a bit premature anyway, and might actually cause other issues (locale neutrality etc. as it was pointed out).
* win32: more wchar_t -> WCHAR replacementswm42015-07-301-4/+4
| | | | | | | | | | | | | This was essentially missing from commit 0b52ac8a. Since L"..." string literals have the type wchar_t[], we can't use them for UTF-16 strings. Use C11 u"..." string literals instead. These have the type char16_t[], but we simply assume char16_t is the same underlying type as WCHAR. In practice, they're both unsigned short. For this reason use -std=c11 on Windows. Since Windows is a "special" environment (we require either MinGW or Cygwin), we don't need to worry too much about compiler compatibility.
* win32: replace wchar_t with WCHARwm42015-07-291-1/+1
| | | | | | | | | | | | | WCHAR is more portable. While at least MinGW, Cygwin, and MSVC actually use 16 bit wchar_t, Midipix will have 32 bit wchar_t. In that context, using WCHAR instead is more portable. This affects only non-MinGW parts, so not all uses of wchar_t need to be changed. For example, terminal-win.c won't be used on Midipix at all. (Most of io.c won't either, so the search & replace here is more than necessary, but also not harmful.) (Midipix is not useable yet, so this is just preparation.)
* ao_wasapi: fix regressionwm42015-06-271-1/+1
| | | | This probably fixes the regression introduced with commit 6147bcce.
* audio: fix format function consistency issueswm42015-06-261-7/+9
| | | | | | | | | | | Replace all the check macros with function calls. Give them all the same case and naming schema. Drop af_fmt2bits(). Only af_fmt2bps() survives as af_fmt_to_bytes(). Introduce af_fmt_is_pcm(), and use it in situations that used !AF_FORMAT_IS_SPECIAL. Nobody really knew what a "special" format was. It simply meant "not PCM".
* ao/wasapi: use atomic state variable instead of different eventsKevin Mitchell2015-04-041-4/+5
| | | | | | | | | 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
* ao_wasapi: code formatting and alignmentKevin Mitchell2015-04-031-9/+8
|
* audio: make all format query shortcuts macrosKevin Mitchell2015-04-031-1/+1
| | | | | af_fmt_is_float and af_fmt_is_planar were previously inconsistent with AF_FORAMT_IS_SPECIAL/AF_FORMAT_IS_IEC61937
* ao_wasapi: passthrough reworkKevin Mitchell2015-04-031-155/+152
| | | | | | | | | | | | | | | * 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
* ao_wasapi: abstract HRESULT_to_strKevin Mitchell2015-04-011-54/+53
|
* ao_wasapi: remove redundant castsKevin Mitchell2015-03-311-25/+20
|
* ao_wasapi: simplify hotplugKevin Mitchell2015-03-311-37/+5
| | | | | | | | | 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.
* ao_wasapi: fix device listingKevin Mitchell2015-03-311-77/+25
| | | | | remove depricated and convoluted validation. refer instead to the --audio-device option.
* ao/wasapi: add ao hotplugKevin Mitchell2015-03-311-1/+25
| | | | | | | 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.
* ao/wasapi: use built in KSDATAFORMATsKevin Mitchell2015-03-271-13/+8
| | | | | Rather than defining them ourselves. Thanks to rossy for figuring out the headers.
* ao/wasapi: add missing "if" bracesKevin Mitchell2015-03-261-33/+29
|
* ao/wasapi: rewrite format searchKevin Mitchell2015-03-261-175/+300
| | | | | | | More clearly separate the exclusive and shared mode format discovery. Make the exclusive mode search more systematic in particular about channel maps (i.e., use chmap_sel). Assume that the same sample format / sample rates work for all channels to narrow the search space.
* ao/wasapi: move resume to audio threadKevin Mitchell2015-02-231-4/+0
| | | | | | | | | | | | | | This echanges the two events hForceFeed/hFeedDone for hResume. This like the last commit makes things more deterministic. Importantly, the forcefeed is only done if there is not already a full buffer yet to be played by the device. This should fix some of the problems with exclusive mode. This commit also removes the necessity to have a proxy to the AudioClient object in the main thread. fixes #1529
* ao_wasapi: fix try_format logic in shared modeJames Ross-Gowan2015-01-231-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.
* win32: request UTF-16 API variants, Vista+ APIs, and COM C macroswm42015-01-071-3/+0
| | | | | 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.
* ao/wasapi: style/code formatting tweaksKevin Mitchell2015-01-021-47/+47
|
* ao/wasapi: improve exclusive mode format searchKevin Mitchell2015-01-021-46/+36
| | | | fixes #1376
* ao/wasapi: revamp set_waveformatexKevin Mitchell2015-01-021-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-021-0/+1
| | | | someone on irc reported seeing this error
* ao/wasapi: use IsEqualGUID and IsEqualPropertyKeyKevin Mitchell2014-12-161-25/+6
| | | | before we were reinventing this wheel
* ao/wasapi: set the ao with the waveformat channelmapKevin Mitchell2014-12-151-1/+10
| | | | hopefully this fixes #1350
* ao/wasapi: make set_ao_format EX/EXTENSIBLE agnosticKevin Mitchell2014-12-011-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 Mitchell2014-12-011-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 Mitchell2014-12-011-8/+30
| | | | also remove bogus ao_format
* ao/wasapi: don't assume 32-bits == floatKevin Mitchell2014-12-011-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 Mitchell2014-12-011-6/+16
| |