summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_wasapi_utils.c
Commit message (Collapse)AuthorAgeFilesLines
* audio: fix annyoing af_get_best_sample_formats() definitionwm42018-01-251-1/+1
| | | | | | | | | | | | | | | | The af_get_best_sample_formats() function had an argument of int[AF_FORMAT_COUNT], which is slightly incorrect, because it's 0 terminated and should in theory have AF_FORMAT_COUNT+1 entries. It won't actually write this many formats (since some formats are fundamentally incompatible), but it still feels annoying and incorrect. So fix it, and require that callers pass an AF_FORMAT_COUNT+1 array. Note that the array size has no meaning in C function arguments (just another issue with C static arrays being weird and stupid), so get rid of it completely. Not changing the af_lavcac3enc use, since that is rewritten in another branch anyway.
* ao_wasapi: remove old commentKevin Mitchell2017-08-071-1/+1
|
* ao_wasapi: reorganize wasapi.hKevin Mitchell2017-08-071-0/+4
| | | | | Remove dead declarations. Move macro only used in wasapi_utils.c closer to use. Rearrange declaration order.
* ao_wasapi: deduplicate wasapi sample format selectionKevin Mitchell2017-08-071-49/+40
|
* ao_wasapi: clean up find_formats logicKevin Mitchell2017-08-071-75/+45
| | | | | There were too many functions within functions, too much going on in if clauses and duplicated code. Fix it.
* ao_wasapi: return bool instead of HRESULT from thread_initKevin Mitchell2017-08-071-32/+42
| | | | | | | | Any bad HRESULTs should have been printed already and lots of failure modes don't have an HRESULT leading to awkward hr = E_FAIL business. This also checks the exit status of GetBufferSize in the align hack. A final fatal message is added if either of the retry hacks fail.
* ao_wasapi: remove redundant / outdated commentKevin Mitchell2017-07-101-1/+0
| | | | | Where this was moved from, it made slightly more sense. Here what the comment is trying to say is already pretty obvious from the code.
* ao_waspi: use switch for handling fix_format errorsKevin Mitchell2017-07-101-5/+8
|
* ao_wasapi: don't repeat format negotiation on align hackKevin Mitchell2017-07-101-4/+7
| | | | | Even if it did return a different result, the bufferFrameCount from the align hack would be wrong anyway.
* ao_wasapi: fix leak on align hackKevin Mitchell2017-07-101-1/+1
|
* ao_wasapi: enable packed 24 bit outputKevin Mitchell2017-07-091-1/+1
|
* ao_wasapi: reorder channels and samplerates to speed up searchKevin Mitchell2017-07-091-4/+4
| | | | | | | This shouldn't affect which are chosen, but it should speed up the search by putting more common configurations earlier so that a working sample format and sample rates can be found sooner obviating the need to search them for each iteration of the outer loops.
* ao_wasapi: minor cosmetic fixesKevin Mitchell2017-07-091-3/+3
|
* ao_wasapi: try correct initial formatKevin Mitchell2017-07-091-1/+4
| | | | | | | | | The loop to select the native wasapi_format for the incoming audio was not breaking correctly when it found the most desirable format. It therefore executed completely leaving the least desirable format (u8) as the choice. fixes #4582
* ao_wasapi_utils: be slightly more clever when converting channel mapwm42017-07-071-0/+5
|
* ao_wasapi: drop use of AF_FORMAT_S24wm42017-07-071-115/+129
| | | | | | | | | | | Do conversion directly, using the infrastructure that was added before. This also rewrites part of format negotation, I guess. I couldn't test the format that was used for S24 - my hardware does not report support for it. So I commented it, as it could be buggy. Testing this with the wasapi_formats[] entry for 24/24 uncommented would be appreciated.
* ao_wasapi: UWP wrapper hack supportwm42017-06-291-6/+36
| | | | | | | | | | | UWP does not support the whole IMMDevice API. Instead, you need to use a new API (available starting from Windows 8), which is in addition not in MinGW, and extremely unpleasant to use. The wasapiuwp2.dll wrapper is a small custom MSVC DLL, which does this instead, and returns a normal IAudioClient. Before this, ao_wasapi did not initialize on UWP.
* Universal Windows Plaform (UWP) supportPedro Pombeiro2017-06-291-0/+4
| | | | | | | | libmpv only. Some things are still missing. Heavily reworked. Signed-off-by: wm4 <wm4@nowhere>
* ao_wasapi: do not use deprecated wchar functionsPedro Pombeiro2017-06-291-1/+1
| | | | These break on UWP. Based on a patch by Pedro Pombeiro.
* ao_wasapi: remove subtly duplicated codewm42017-06-281-7/+6
| | | | Seems like this can be slightly simplified.
* ao_wasapi: remove duplicate code for creating IAudioClientwm42017-06-281-34/+24
| | | | | | | | | | | | The code accounting for the terrible AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED semantics (which MSDN claims can happen "starting with Windows 7" - so probably on Windows 10 too) duplicated the call for creating the IAudioClient. That's not great, so get rid of it. Let wasapi_thread_init() handle this. It has a retry loop anyway. This redoes device lookup and format negotiation, but potential failures due to race conditions (what if the driver decides to change behavior) shouldn't be worse than before.
* ao_wasapi: do not pass nonsense to drivers with doublewm42017-03-291-5/+23
| | | | | | | | | | | | | | | | | | | | | | This tried to use AF_FORMAT_DOUBLE as KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, with wBitsPerSample==64. This is probably not allowed, and drivers appear to react inconsistently to it. (With one user, the format was accepted during format negotiation, but then rejected on actual init.) Remove it, which essentially forces it to fall back to some other format. (Looks like it'll use af_select_best_samplerate(), which would probably make it try S32 next.) The af_fmt_from_planar() is so that we don't have to care about AF_FORMAT_FLOATP. Wasapi always requires packed data anyway. This should actually handle other potentially unknown sample formats better. This changes that set_waveformat() always set the exact format. Now it might set a "close" format instead. But all callers seem to deal with this well. Although in theory, callers should probably handle the fallback. The next cleanup (if ever) can take care of this.
* win32: add COM-specific SAFE_RELEASE to windows_utils.hJames Ross-Gowan2017-01-301-22/+19
| | | | | | | | | | | | | | | See: https://msdn.microsoft.com/en-us/library/windows/desktop/dd743946.aspx Microsoft example code often uses a SAFE_RELEASE macro like the one in the above link. This makes it easier to avoid errors when releasing COM interfaces. It also reduces noise in COM-heavy code. ao_wasapi.h also had a macro called SAFE_RELEASE, though unlike the version above, its SAFE_RELEASE macro accepted a second parameter which allowed it to destroy arbitrary objects other than just COM interfaces. This renames ao_wasapi's SAFE_RELEASE to SAFE_DESTROY, which should more accurately reflect what it does and prevent confusion with the Microsoft version.
* ao_wasapi: log return code when probing audio formatswm42016-11-301-13/+5
| | | | | | | | | We log a large number of formats, but we rarely log the result of the probing. Change this. The logic in try_format_exclusive() changes slightly, but should be equivalent. EXIT_ON_ERROR() checks for FAILED(), which should be exclusive to SUCCEEDED().
* ao_wasapi_utils: remove unused variablepavelxdd2016-11-271-1/+0
| | | | | Introduced in 1a2319f3e4cc42c680e2fd3ba30022c7a9adf3fe Produced a warning during compilation on Windows.
* options: remove deprecated sub-option handling for --vo and --aowm42016-11-251-4/+1
| | | | | | | | Long planned. Leads to some sanity. There still are some rather gross things. Especially g_groups is ugly, and a hack that can hopefully be removed. (There is a plan for it, but whether it's implemented depends on how much energy is left.)
* win32: build with -DINITGUIDJames Ross-Gowan2016-09-281-1/+0
| | | | | | | | | | | | We always want to use __declspec(selectany) to declare GUIDs, but manually including <initguid.h> in every file that used GUIDs was error-prone. Since all <initguid.h> does is define INITGUID and include <guiddef.h>, we can remove all references to <initguid.h> and just compile with -DINITGUID to get the same effect. Also, this partially reverts 622bcb0 by re-adding libuuid.a to the build, since apparently some GUIDs (such as GUID_NULL) are not declared in the source file, even when INITGUID is set.
* ao_wasapi: in exclusive mode do not output multichannel by defaultwm42016-08-051-1/+1
| | | | | | | | Exactly the same situation as with ao_alsa in commit 0b144eac (except that we can detect the situation better under wasapi). Essentially, wasapi will allow us to output any sample format, and not just the one configured by the user in the audio system settings.
* 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. F