[vlc-commits] wasapi: split as separate module
Rémi Denis-Courmont
git at videolan.org
Tue Feb 4 23:06:30 CET 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Feb 3 23:21:54 2014 +0200| [bdaac334537accbb4b9fbf91f90fb6acd4967fe0] | committer: Rémi Denis-Courmont
wasapi: split as separate module
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bdaac334537accbb4b9fbf91f90fb6acd4967fe0
---
modules/audio_output/Makefile.am | 9 +++++----
modules/audio_output/mmdevice.c | 39 ++++++++++++++++++++++++++++++--------
modules/audio_output/mmdevice.h | 6 +++---
modules/audio_output/wasapi.c | 19 +++++++++----------
4 files changed, 48 insertions(+), 25 deletions(-)
diff --git a/modules/audio_output/Makefile.am b/modules/audio_output/Makefile.am
index 242b52b..9fb4700 100644
--- a/modules/audio_output/Makefile.am
+++ b/modules/audio_output/Makefile.am
@@ -57,11 +57,12 @@ if HAVE_JACK
aout_LTLIBRARIES += libjack_plugin.la
endif
-libmmdevice_plugin_la_SOURCES = audio_output/mmdevice.c audio_output/mmdevice.h \
- audio_output/wasapi.c
-libmmdevice_plugin_la_LIBADD = -lole32 -lksuser
+libmmdevice_plugin_la_SOURCES = audio_output/mmdevice.c audio_output/mmdevice.h
+libmmdevice_plugin_la_LIBADD = -lole32
+libwasapi_plugin_la_SOURCES = audio_output/wasapi.c
+libwasapi_plugin_la_LIBADD = -lole32 -lksuser
if HAVE_WASAPI
-aout_LTLIBRARIES += libmmdevice_plugin.la
+aout_LTLIBRARIES += libmmdevice_plugin.la libwasapi_plugin.la
endif
libdirectsound_plugin_la_SOURCES = audio_output/directsound.c \
diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index f4cecb5..757481e 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -40,6 +40,7 @@ DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd,
#include <vlc_plugin.h>
#include <vlc_aout.h>
#include <vlc_charset.h>
+#include <vlc_modules.h>
#include "audio_output/mmdevice.h"
DEFINE_GUID (GUID_VLC_AUD_OUT, 0x4533f59d, 0x59ee, 0x00c6,
@@ -74,6 +75,7 @@ static wchar_t default_device[1] = L"";
struct aout_sys_t
{
aout_stream_t *stream; /**< Underlying audio output stream */
+ module_t *module;
#if !VLC_WINSTORE_APP
audio_output_t *aout;
IMMDeviceEnumerator *it; /**< Device enumerator, NULL when exiting */
@@ -858,10 +860,27 @@ static HRESULT ActivateDevice(void *opaque, REFIID iid, PROPVARIANT *actparms,
}
#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)
{
aout_sys_t *sys = aout->sys;
- HRESULT hr;
assert (sys->stream == NULL);
#if !VLC_WINSTORE_APP
@@ -882,14 +901,18 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
s->owner.activate = ActivateDevice;
EnterMTA();
- hr = aout_stream_Start(s, fmt, &GUID_VLC_AUD_OUT);
- if (SUCCEEDED(hr))
- sys->stream = s;
- else
- vlc_object_release(s);
+ sys->module = vlc_module_load(s, "aout stream", NULL, false,
+ aout_stream_Start, s, fmt);
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)
@@ -899,7 +922,7 @@ static void Stop(audio_output_t *aout)
assert (sys->stream != NULL);
EnterMTA();
- aout_stream_Stop(sys->stream);
+ vlc_module_unload(sys->module, aout_stream_Stop, sys->stream);
LeaveMTA();
vlc_object_release(sys->stream);
diff --git a/modules/audio_output/mmdevice.h b/modules/audio_output/mmdevice.h
index cb24282..0f4d2b2 100644
--- a/modules/audio_output/mmdevice.h
+++ b/modules/audio_output/mmdevice.h
@@ -49,13 +49,13 @@ struct aout_stream
* \param fmt audio output sample format [IN/OUT]
* \param sid audio output session GUID [IN]
*/
-HRESULT aout_stream_Start(aout_stream_t *s, audio_sample_format_t *fmt,
- const GUID *sid);
+typedef HRESULT (*aout_stream_start_t)(aout_stream_t *s,
+ audio_sample_format_t *fmt, const GUID *sid);
/**
* 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)
{
diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
index cbdcd62..1bce4da 100644
--- a/modules/audio_output/wasapi.c
+++ b/modules/audio_output/wasapi.c
@@ -32,6 +32,7 @@
#include <vlc_common.h>
#include <vlc_aout.h>
+#include <vlc_plugin.h>
#include "audio_output/mmdevice.h"
static LARGE_INTEGER freq; /* performance counters frequency */
@@ -399,13 +400,11 @@ static void Stop(aout_stream_t *s)
IAudioClient_Release(sys->client);
}
-HRESULT aout_stream_Start(aout_stream_t *s,
- audio_sample_format_t *restrict fmt, const GUID *sid)
-{
- return Start(s, fmt, sid);
-}
-
-void aout_stream_Stop(aout_stream_t *s)
-{
- Stop(s);
-}
+vlc_module_begin()
+ set_shortname("WASAPI")
+ set_description(N_("Windows Audio Session API output"))
+ set_capability("aout stream", /*50*/0)
+ set_category(CAT_AUDIO)
+ set_subcategory(SUBCAT_AUDIO_AOUT)
+ set_callbacks(Start, Stop)
+vlc_module_end()
More information about the vlc-commits
mailing list