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

wasapi: split as separate module

parent 0c3e5519
...@@ -57,11 +57,12 @@ if HAVE_JACK ...@@ -57,11 +57,12 @@ if HAVE_JACK
aout_LTLIBRARIES += libjack_plugin.la aout_LTLIBRARIES += libjack_plugin.la
endif endif
libmmdevice_plugin_la_SOURCES = audio_output/mmdevice.c audio_output/mmdevice.h \ libmmdevice_plugin_la_SOURCES = audio_output/mmdevice.c audio_output/mmdevice.h
audio_output/wasapi.c libmmdevice_plugin_la_LIBADD = -lole32
libmmdevice_plugin_la_LIBADD = -lole32 -lksuser libwasapi_plugin_la_SOURCES = audio_output/wasapi.c
libwasapi_plugin_la_LIBADD = -lole32 -lksuser
if HAVE_WASAPI if HAVE_WASAPI
aout_LTLIBRARIES += libmmdevice_plugin.la aout_LTLIBRARIES += libmmdevice_plugin.la libwasapi_plugin.la
endif endif
libdirectsound_plugin_la_SOURCES = audio_output/directsound.c \ libdirectsound_plugin_la_SOURCES = audio_output/directsound.c \
......
...@@ -40,6 +40,7 @@ DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, ...@@ -40,6 +40,7 @@ DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd,
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_aout.h> #include <vlc_aout.h>
#include <vlc_charset.h> #include <vlc_charset.h>
#include <vlc_modules.h>
#include "audio_output/mmdevice.h" #include "audio_output/mmdevice.h"
DEFINE_GUID (GUID_VLC_AUD_OUT, 0x4533f59d, 0x59ee, 0x00c6, DEFINE_GUID (GUID_VLC_AUD_OUT, 0x4533f59d, 0x59ee, 0x00c6,
...@@ -74,6 +75,7 @@ static wchar_t default_device[1] = L""; ...@@ -74,6 +75,7 @@ static wchar_t default_device[1] = L"";
struct aout_sys_t struct aout_sys_t
{ {
aout_stream_t *stream; /**< Underlying audio output stream */ aout_stream_t *stream; /**< Underlying audio output stream */
module_t *module;
#if !VLC_WINSTORE_APP #if !VLC_WINSTORE_APP
audio_output_t *aout; audio_output_t *aout;
IMMDeviceEnumerator *it; /**< Device enumerator, NULL when exiting */ IMMDeviceEnumerator *it; /**< Device enumerator, NULL when exiting */
...@@ -858,10 +860,27 @@ static HRESULT ActivateDevice(void *opaque, REFIID iid, PROPVARIANT *actparms, ...@@ -858,10 +860,27 @@ static HRESULT ActivateDevice(void *opaque, REFIID iid, PROPVARIANT *actparms,
} }
#endif /* VLC_WINSTORE_APP */ #endif /* VLC_WINSTORE_APP */
static int aout_stream_Start(void *func, va_list ap)
{
aout_stream_start_t start = func;
aout_stream_t *s = va_arg(ap, aout_stream_t *);
audio_sample_format_t *fmt = va_arg(ap, audio_sample_format_t *);
return SUCCEEDED(start(s, fmt, &GUID_VLC_AUD_OUT))
? VLC_SUCCESS : VLC_EGENERIC;
}
static void aout_stream_Stop(void *func, va_list ap)
{
aout_stream_stop_t stop = func;
aout_stream_t *s = va_arg(ap, aout_stream_t *);
stop(s);
}
static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt) static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
{ {
aout_sys_t *sys = aout->sys; aout_sys_t *sys = aout->sys;
HRESULT hr;
assert (sys->stream == NULL); assert (sys->stream == NULL);
#if !VLC_WINSTORE_APP #if !VLC_WINSTORE_APP
...@@ -882,14 +901,18 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt) ...@@ -882,14 +901,18 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
s->owner.activate = ActivateDevice; s->owner.activate = ActivateDevice;
EnterMTA(); EnterMTA();
hr = aout_stream_Start(s, fmt, &GUID_VLC_AUD_OUT); sys->module = vlc_module_load(s, "aout stream", NULL, false,
if (SUCCEEDED(hr)) aout_stream_Start, s, fmt);
sys->stream = s;
else
vlc_object_release(s);
LeaveMTA(); LeaveMTA();
return vlc_FromHR(aout, hr); if (sys->module == NULL)
{
vlc_object_release(s);
return -1;
}
sys->stream = s;
return 0;
} }
static void Stop(audio_output_t *aout) static void Stop(audio_output_t *aout)
...@@ -899,7 +922,7 @@ static void Stop(audio_output_t *aout) ...@@ -899,7 +922,7 @@ static void Stop(audio_output_t *aout)
assert (sys->stream != NULL); assert (sys->stream != NULL);
EnterMTA(); EnterMTA();
aout_stream_Stop(sys->stream); vlc_module_unload(sys->module, aout_stream_Stop, sys->stream);
LeaveMTA(); LeaveMTA();
vlc_object_release(sys->stream); vlc_object_release(sys->stream);
......
...@@ -49,13 +49,13 @@ struct aout_stream ...@@ -49,13 +49,13 @@ struct aout_stream
* \param fmt audio output sample format [IN/OUT] * \param fmt audio output sample format [IN/OUT]
* \param sid audio output session GUID [IN] * \param sid audio output session GUID [IN]
*/ */
HRESULT aout_stream_Start(aout_stream_t *s, audio_sample_format_t *fmt, typedef HRESULT (*aout_stream_start_t)(aout_stream_t *s,
const GUID *sid); audio_sample_format_t *fmt, const GUID *sid);
/** /**
* Destroys an audio output stream. * Destroys an audio output stream.
*/ */
void aout_stream_Stop(aout_stream_t *); typedef HRESULT (*aout_stream_stop_t)(aout_stream_t *);
static inline HRESULT aout_stream_TimeGet(aout_stream_t *s, mtime_t *delay) static inline HRESULT aout_stream_TimeGet(aout_stream_t *s, mtime_t *delay)
{ {
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_aout.h> #include <vlc_aout.h>
#include <vlc_plugin.h>
#include "audio_output/mmdevice.h" #include "audio_output/mmdevice.h"
static LARGE_INTEGER freq; /* performance counters frequency */ static LARGE_INTEGER freq; /* performance counters frequency */
...@@ -399,13 +400,11 @@ static void Stop(aout_stream_t *s) ...@@ -399,13 +400,11 @@ static void Stop(aout_stream_t *s)
IAudioClient_Release(sys->client); IAudioClient_Release(sys->client);
} }
HRESULT aout_stream_Start(aout_stream_t *s, vlc_module_begin()
audio_sample_format_t *restrict fmt, const GUID *sid) set_shortname("WASAPI")
{ set_description(N_("Windows Audio Session API output"))
return Start(s, fmt, sid); set_capability("aout stream", /*50*/0)
} set_category(CAT_AUDIO)
set_subcategory(SUBCAT_AUDIO_AOUT)
void aout_stream_Stop(aout_stream_t *s) set_callbacks(Start, Stop)
{ vlc_module_end()
Stop(s);
}
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