aboutsummaryrefslogtreecommitdiffhomepage
path: root/audio/out/ao_wasapi_utils.c
Commit message (Collapse)AuthorAge
* ao_wasapi: remove old commentGravatar Kevin Mitchell2017-08-07
|
* ao_wasapi: reorganize wasapi.hGravatar Kevin Mitchell2017-08-07
| | | | | Remove dead declarations. Move macro only used in wasapi_utils.c closer to use. Rearrange declaration order.
* ao_wasapi: deduplicate wasapi sample format selectionGravatar Kevin Mitchell2017-08-07
|
* ao_wasapi: clean up find_formats logicGravatar Kevin Mitchell2017-08-07
| | | | | 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_initGravatar Kevin Mitchell2017-08-07
| | | | | | | | 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 commentGravatar Kevin Mitchell2017-07-10
| | | | | 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 errorsGravatar Kevin Mitchell2017-07-10
|
* ao_wasapi: don't repeat format negotiation on align hackGravatar Kevin Mitchell2017-07-10
| | | | | Even if it did return a different result, the bufferFrameCount from the align hack would be wrong anyway.
* ao_wasapi: fix leak on align hackGravatar Kevin Mitchell2017-07-10
|
* ao_wasapi: enable packed 24 bit outputGravatar Kevin Mitchell2017-07-09
|
* ao_wasapi: reorder channels and samplerates to speed up searchGravatar Kevin Mitchell2017-07-09
| | | | | | | 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 fixesGravatar Kevin Mitchell2017-07-09
|
* ao_wasapi: try correct initial formatGravatar Kevin Mitchell2017-07-09
| | | | | | | | | 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 mapGravatar wm42017-07-07
|
* ao_wasapi: drop use of AF_FORMAT_S24Gravatar wm42017-07-07
| | | | | | | | | | | 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 supportGravatar wm42017-06-29
| | | | | | | | | | | 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) supportGravatar Pedro Pombeiro2017-06-29
| | | | | | | | libmpv only. Some things are still missing. Heavily reworked. Signed-off-by: wm4 <wm4@nowhere>
* ao_wasapi: do not use deprecated wchar functionsGravatar Pedro Pombeiro2017-06-29
| | | | These break on UWP. Based on a patch by Pedro Pombeiro.
* ao_wasapi: remove subtly duplicated codeGravatar wm42017-06-28
| | | | Seems like this can be slightly simplified.
* ao_wasapi: remove duplicate code for creating IAudioClientGravatar wm42017-06-28
| | | | | | | | | | | | 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 doubleGravatar wm42017-03-29
| | | | | | | | | | | | | | | | | | | | | | 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.hGravatar James Ross-Gowan2017-01-30
| | | | | | | | | | | | | | | 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 formatsGravatar wm42016-11-30
| | | | | | | | | 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 variableGravatar pavelxdd2016-11-27
| | | | | Introduced in 1a2319f3e4cc42c680e2fd3ba30022c7a9adf3fe Produced a warning during compilation on Windows.
* options: remove deprecated sub-option handling for --vo and --aoGravatar wm42016-11-25
| | | | | | | | 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 -DINITGUIDGravatar James Ross-Gowan2016-09-28
| | | | | | | | | | | | 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 defaultGravatar wm42016-08-05
| | | | | | | | 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 functionGravatar Kevin Mitchell2016-03-17
| | | | It duplicates the logic that was previously used here.
* ao_wasapi: use MP_FATAL for stuff that leads to init failureGravatar Kevin Mitchell2016-02-26
|
* ao_wasapi: set buffer size to device period in exclusive modeGravatar Kevin Mitchell2016-02-26
| | | | | | | | | | | | | 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_queueGravatar Kevin Mitchell2016-02-26
| | | | | | | | | | 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 macrosGravatar Kevin Mitchell2016-02-26
|
* Initial Android supportGravatar Jan Ekström2016-02-10
| | | | | * 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 functionGravatar Kevin Mitchell2016-01-28
|
* ao_wasapi: correct check for specified device on default changeGravatar Kevin Mitchell2016-01-28
| | | | | | 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 deviceGravatar Kevin Mitchell2016-01-28
| | | | | 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 enumerationGravatar Kevin Mitchell2016-01-22
| | | | | | 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 foundGravatar Kevin Mitchell2016-01-22
| | | | | | | | 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 laterGravatar wm42016-01-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 functionsGravatar wm42016-01-11
| | | | | | 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 fileGravatar Kevin Mitchell2016-01-05
| | | | | 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 threadGravatar Kevin Mitchell2016-01-05
| | | | This is something else that has nothing to do with audio rendering.
* ao_wasapi: make find_deviceID read only wrt struct aoGravatar Kevin Mitchell2016-01-05
| | | | This makes it clearer that state->device is being allocated.
* ao_wasapi: move device selection to main threadGravatar Kevin Mitchell2016-01-05
| | | | In attempt to simplify the audio event thread, this can now be moved out.
* ao_wasapi: avoid some redundant error messages in device selectionGravatar Kevin Mitchell2016-01-05
| | | | | 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 errorGravatar Kevin Mitchell2016-01-05
| | | | | In get_device_desc, don't alloc the return value until we know there wasn't an error.
* ao_wasapi: remove +x flag from filesGravatar wm42016-01-04
|
* ao_wasapi: make persistent enumerator local to change_notifyGravatar Kevin Mitchell2016-01-04
| | | | This is no longer required by anything else
* ao_wasapi: rewrite device listing and selectionGravatar Kevin Mitchell2016-01-04
| | | | | | | | | | | | | 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 functionGravatar Kevin Mitchell2015-12-21
| | | | also make failure non-fatal