[vlc-commits] wasapi: remove direct dependency on desktop-only IMMDevice
Rémi Denis-Courmont
git at videolan.org
Thu Dec 6 12:09:46 CET 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Dec 6 13:08:52 2012 +0200| [f8c07e70635f15bdd2d71adf2f90a0d5f3b445a5] | committer: Rémi Denis-Courmont
wasapi: remove direct dependency on desktop-only IMMDevice
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f8c07e70635f15bdd2d71adf2f90a0d5f3b445a5
---
modules/audio_output/mmdevice.c | 17 ++++++++++++++++-
modules/audio_output/mmdevice.h | 16 ++++++++++++++--
modules/audio_output/wasapi.c | 12 ++++--------
3 files changed, 34 insertions(+), 11 deletions(-)
diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c
index 8b8e9e2..8368a67 100644
--- a/modules/audio_output/mmdevice.c
+++ b/modules/audio_output/mmdevice.c
@@ -618,6 +618,18 @@ static void CloseDevice(audio_output_t *aout)
sys->dev = NULL;
}
+/**
+ * Callback for aout_stream_t to create a stream on the device.
+ * This can instantiate an IAudioClient or IDirectSound(8) object.
+ */
+static HRESULT ActivateDevice(void *opaque, REFIID iid, PROPVARIANT *actparms,
+ void **restrict pv)
+{
+ IMMDevice *dev = opaque;
+
+ return IMMDevice_Activate(dev, iid, CLSCTX_ALL, actparms, pv);
+}
+
static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
{
aout_sys_t *sys = aout->sys;
@@ -631,8 +643,11 @@ static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt)
if (unlikely(s == NULL))
return -1;
+ s->owner.device = sys->dev;
+ s->owner.activate = ActivateDevice;
+
EnterMTA();
- hr = aout_stream_Start(s, fmt, sys->dev, &GUID_VLC_AUD_OUT);
+ hr = aout_stream_Start(s, fmt, &GUID_VLC_AUD_OUT);
if (SUCCEEDED(hr))
sys->stream = s;
else
diff --git a/modules/audio_output/mmdevice.h b/modules/audio_output/mmdevice.h
index 0ba36f1..cb24282 100644
--- a/modules/audio_output/mmdevice.h
+++ b/modules/audio_output/mmdevice.h
@@ -35,17 +35,22 @@ struct aout_stream
HRESULT (*play)(aout_stream_t *, block_t *);
HRESULT (*pause)(aout_stream_t *, bool);
HRESULT (*flush)(aout_stream_t *);
+
+ struct
+ {
+ void *device;
+ HRESULT (*activate)(void *device, REFIID, PROPVARIANT *, void **);
+ } owner;
};
/**
* Creates an audio output stream on a given Windows multimedia device.
* \param s audio output stream object to be initialized
* \param fmt audio output sample format [IN/OUT]
- * \param dev MMDevice API output device
* \param sid audio output session GUID [IN]
*/
HRESULT aout_stream_Start(aout_stream_t *s, audio_sample_format_t *fmt,
- IMMDevice *dev, const GUID *sid);
+ const GUID *sid);
/**
* Destroys an audio output stream.
@@ -71,4 +76,11 @@ static inline HRESULT aout_stream_Flush(aout_stream_t *s)
{
return (s->flush)(s);
}
+
+static inline
+HRESULT aout_stream_Activate(aout_stream_t *s, REFIID iid,
+ PROPVARIANT *actparms, void **pv)
+{
+ return s->owner.activate(s->owner.device, iid, actparms, pv);
+}
#endif
diff --git a/modules/audio_output/wasapi.c b/modules/audio_output/wasapi.c
index 14672be..2e290fb 100644
--- a/modules/audio_output/wasapi.c
+++ b/modules/audio_output/wasapi.c
@@ -29,7 +29,6 @@
#include <stdlib.h>
#include <assert.h>
#include <audioclient.h>
-#include <mmdeviceapi.h>
#include <vlc_common.h>
#include <vlc_aout.h>
@@ -312,7 +311,7 @@ static unsigned vlc_CheckWaveOrder (const WAVEFORMATEX *restrict wf,
}
static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict fmt,
- IMMDevice *dev, const GUID *sid)
+ const GUID *sid)
{
aout_stream_sys_t *sys = malloc(sizeof (*sys));
if (unlikely(sys == NULL))
@@ -320,9 +319,7 @@ static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict fmt,
sys->client = NULL;
void *pv;
- HRESULT hr;
-
- hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_ALL, NULL, &pv);
+ HRESULT hr = aout_stream_Activate(s, &IID_IAudioClient, NULL, &pv);
if (FAILED(hr))
{
msg_Err(s, "cannot activate client (error 0x%lx)", hr);
@@ -404,10 +401,9 @@ static void Stop(aout_stream_t *s)
}
HRESULT aout_stream_Start(aout_stream_t *s,
- audio_sample_format_t *restrict fmt,
- IMMDevice *dev, const GUID *sid)
+ audio_sample_format_t *restrict fmt, const GUID *sid)
{
- return Start(s, fmt, dev, sid);
+ return Start(s, fmt, sid);
}
void aout_stream_Stop(aout_stream_t *s)
More information about the vlc-commits
mailing list