Commit 6c8ed420 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

wasapi: fixes and simplifications

parent fda36eca
...@@ -100,7 +100,6 @@ static HRESULT TimeGet(aout_api_t *api, mtime_t *restrict delay) ...@@ -100,7 +100,6 @@ static HRESULT TimeGet(aout_api_t *api, mtime_t *restrict delay)
UINT64 pos, qpcpos; UINT64 pos, qpcpos;
HRESULT hr; HRESULT hr;
Enter();
hr = IAudioClient_GetService(sys->client, &IID_IAudioClock, &pv); hr = IAudioClient_GetService(sys->client, &IID_IAudioClock, &pv);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
...@@ -113,7 +112,6 @@ static HRESULT TimeGet(aout_api_t *api, mtime_t *restrict delay) ...@@ -113,7 +112,6 @@ static HRESULT TimeGet(aout_api_t *api, mtime_t *restrict delay)
} }
else else
msg_Err(api, "cannot get clock (error 0x%lx)", hr); msg_Err(api, "cannot get clock (error 0x%lx)", hr);
Leave();
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
...@@ -142,7 +140,6 @@ static HRESULT Play(aout_api_t *api, block_t *block) ...@@ -142,7 +140,6 @@ static HRESULT Play(aout_api_t *api, block_t *block)
aout_ChannelReorder(block->p_buffer, block->i_buffer, aout_ChannelReorder(block->p_buffer, block->i_buffer,
sys->chans_to_reorder, sys->chans_table, sys->bits); sys->chans_to_reorder, sys->chans_table, sys->bits);
Enter();
hr = IAudioClient_GetService(sys->client, &IID_IAudioRenderClient, &pv); hr = IAudioClient_GetService(sys->client, &IID_IAudioRenderClient, &pv);
if (FAILED(hr)) if (FAILED(hr))
{ {
...@@ -198,7 +195,6 @@ static HRESULT Play(aout_api_t *api, block_t *block) ...@@ -198,7 +195,6 @@ static HRESULT Play(aout_api_t *api, block_t *block)
} }
IAudioRenderClient_Release(render); IAudioRenderClient_Release(render);
out: out:
Leave();
block_Release(block); block_Release(block);
return hr; return hr;
...@@ -209,7 +205,6 @@ static HRESULT Pause(aout_api_t *api, bool paused) ...@@ -209,7 +205,6 @@ static HRESULT Pause(aout_api_t *api, bool paused)
aout_api_sys_t *sys = api->sys; aout_api_sys_t *sys = api->sys;
HRESULT hr; HRESULT hr;
Enter();
if (paused) if (paused)
hr = IAudioClient_Stop(sys->client); hr = IAudioClient_Stop(sys->client);
else else
...@@ -217,7 +212,6 @@ static HRESULT Pause(aout_api_t *api, bool paused) ...@@ -217,7 +212,6 @@ static HRESULT Pause(aout_api_t *api, bool paused)
if (FAILED(hr)) if (FAILED(hr))
msg_Warn(api, "cannot %s stream (error 0x%lx)", msg_Warn(api, "cannot %s stream (error 0x%lx)",
paused ? "stop" : "start", hr); paused ? "stop" : "start", hr);
Leave();
return hr; return hr;
} }
...@@ -226,11 +220,9 @@ static HRESULT Flush(aout_api_t *api) ...@@ -226,11 +220,9 @@ static HRESULT Flush(aout_api_t *api)
aout_api_sys_t *sys = api->sys; aout_api_sys_t *sys = api->sys;
HRESULT hr; HRESULT hr;
Enter();
IAudioClient_Stop(sys->client); IAudioClient_Stop(sys->client);
hr = IAudioClient_Reset(sys->client);
Leave();
hr = IAudioClient_Reset(sys->client);
if (FAILED(hr)) if (FAILED(hr))
msg_Warn(api, "cannot reset stream (error 0x%lx)", hr); msg_Warn(api, "cannot reset stream (error 0x%lx)", hr);
else else
...@@ -339,11 +331,12 @@ static HRESULT Start(aout_api_t *api, audio_sample_format_t *restrict fmt, ...@@ -339,11 +331,12 @@ static HRESULT Start(aout_api_t *api, audio_sample_format_t *restrict fmt,
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
sys->client = NULL; sys->client = NULL;
void *pv;
HRESULT hr; HRESULT hr;
Enter(); Enter();
void *pv;
hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_ALL, NULL, &pv); hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_ALL, NULL, &pv);
Leave();
if (FAILED(hr)) if (FAILED(hr))
{ {
msg_Err(api, "cannot activate client (error 0x%lx)", hr); msg_Err(api, "cannot activate client (error 0x%lx)", hr);
...@@ -400,8 +393,6 @@ static HRESULT Start(aout_api_t *api, audio_sample_format_t *restrict fmt, ...@@ -400,8 +393,6 @@ static HRESULT Start(aout_api_t *api, audio_sample_format_t *restrict fmt,
goto error; goto error;
} }
Leave();
sys->rate = fmt->i_rate; sys->rate = fmt->i_rate;
sys->bytes_per_frame = fmt->i_bytes_per_frame; sys->bytes_per_frame = fmt->i_bytes_per_frame;
sys->written = 0; sys->written = 0;
...@@ -410,11 +401,11 @@ static HRESULT Start(aout_api_t *api, audio_sample_format_t *restrict fmt, ...@@ -410,11 +401,11 @@ static HRESULT Start(aout_api_t *api, audio_sample_format_t *restrict fmt,
api->play = Play; api->play = Play;
api->pause = Pause; api->pause = Pause;
api->flush = Flush; api->flush = Flush;
return VLC_SUCCESS; return S_OK;
error: error:
if (sys->client != NULL) if (sys->client != NULL)
IAudioClient_Release(sys->client); IAudioClient_Release(sys->client);
Leave(); free(sys);
return hr; return hr;
} }
...@@ -422,10 +413,8 @@ static void Stop(aout_api_t *api) ...@@ -422,10 +413,8 @@ static void Stop(aout_api_t *api)
{ {
aout_api_sys_t *sys = api->sys; aout_api_sys_t *sys = api->sys;
Enter();
IAudioClient_Stop(sys->client); /* should not be needed */ IAudioClient_Stop(sys->client); /* should not be needed */
IAudioClient_Release(sys->client); IAudioClient_Release(sys->client);
Leave();
} }
#undef aout_api_Start #undef aout_api_Start
...@@ -442,7 +431,7 @@ aout_api_t *aout_api_Start(vlc_object_t *parent, audio_sample_format_t *fmt, ...@@ -442,7 +431,7 @@ aout_api_t *aout_api_Start(vlc_object_t *parent, audio_sample_format_t *fmt,
vlc_object_release(api); vlc_object_release(api);
api = NULL; api = NULL;
} }
return NULL; return api;
} }
void aout_api_Stop(aout_api_t *api) void aout_api_Stop(aout_api_t *api)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment