diff options
Diffstat (limited to 'audio/out/ao_wasapi0.c')
-rw-r--r-- | audio/out/ao_wasapi0.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/audio/out/ao_wasapi0.c b/audio/out/ao_wasapi0.c index a45ca829e5..11303ddde1 100644 --- a/audio/out/ao_wasapi0.c +++ b/audio/out/ao_wasapi0.c @@ -19,6 +19,7 @@ #define _WIN32_WINNT 0x600 #include <stdlib.h> +#include <inttypes.h> #include <process.h> #include <initguid.h> #include <audioclient.h> @@ -33,6 +34,10 @@ #include "core/mp_ring.h" #include "ao.h" +#ifndef BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE +#define BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE 0x00000001 +#endif + #define RING_BUFFER_COUNT 64 /* 20 millisecond buffer? */ @@ -236,7 +241,7 @@ static HRESULT check_support(struct wasapi0_state *state, EnterCriticalSection(&state->print_lock); mp_msg( MSGT_AO, MSGL_ERR, - "IAudioClient::IsFormatSupported failed with %s (%d at %ldHz %dchannels, channelmask = %lx)\n", + "IAudioClient::IsFormatSupported failed with %s (%d at %"PRId32"Hz %dchannels, channelmask = %"PRIx32")\n", explain_err( hr), wformat->Format.wBitsPerSample, wformat->Format.nSamplesPerSec, @@ -366,7 +371,7 @@ reinit: EnterCriticalSection(&state->print_lock); mp_msg(MSGT_AO, MSGL_V, "ao-wasapi: fix_format OK, using %lld byte buffer block size!\n", - state->buffer_block_size); + (long long) state->buffer_block_size); LeaveCriticalSection(&state->print_lock); return 0; exit_label: @@ -425,15 +430,10 @@ exit_label: static void thread_pause(wasapi0_state *state) { + state->is_playing = 0; IAudioClient_Stop(state->pAudioClient); } -static void thread_reset(wasapi0_state *state) -{ - IAudioClient_Stop(state->pAudioClient); - IAudioClient_Reset(state->pAudioClient); -} - /* force_feed - feed in even if available data is smaller than required buffer, to clear the buffer */ static void thread_feed(wasapi0_state *state,int force_feed) { @@ -456,6 +456,7 @@ static void thread_feed(wasapi0_state *state,int force_feed) state->bufferFrameCount, AUDCLNT_BUFFERFLAGS_SILENT); EXIT_ON_ERROR(hr) + return; } hr = IAudioRenderClient_ReleaseBuffer(state->pRenderClient, state->bufferFrameCount, 0); @@ -463,7 +464,7 @@ static void thread_feed(wasapi0_state *state,int force_feed) return; exit_label: EnterCriticalSection(&state->print_lock); - mp_msg(MSGT_AO, MSGL_ERR, "ao-wasapi: thread_feed fails with %lx!\n", hr); + mp_msg(MSGT_AO, MSGL_ERR, "ao-wasapi: thread_feed fails with %"PRIx32"!\n", hr); LeaveCriticalSection(&state->print_lock); return; } @@ -471,10 +472,20 @@ exit_label: static void thread_play(wasapi0_state *state) { thread_feed(state, 0); + state->is_playing = 1; IAudioClient_Start(state->pAudioClient); return; } +static void thread_reset(wasapi0_state *state) +{ + IAudioClient_Stop(state->pAudioClient); + IAudioClient_Reset(state->pAudioClient); + if (state->is_playing) { + thread_play(state); + } +} + static void thread_getVol(wasapi0_state *state) { IAudioEndpointVolume_GetMasterVolumeLevelScalar(state->pEndpointVolume, @@ -515,7 +526,7 @@ static void thread_uninit(wasapi0_state *state) if (state->hTask) state->VistaBlob.pAvRevertMmThreadCharacteristics(state->hTask); CoUninitialize(); - _endthreadex(0); + ExitThread(0); } static unsigned int __stdcall ThreadLoop(void *lpParameter) @@ -670,7 +681,7 @@ static int init(struct ao *ao, char *params) return -1; } state->init_ret = -1; - state->threadLoop = (HANDLE)_beginthreadex(NULL, 0, &ThreadLoop, ao, 0, NULL); + state->threadLoop = (HANDLE)CreateThread(NULL, 0, &ThreadLoop, ao, 0, NULL); if (!state->threadLoop) { /* failed to init thread */ mp_msg(MSGT_AO, MSGL_ERR, "ao-wasapi0: fail to create thread!\n"); |