vlc | branch: master | Jean-Baptiste Kempf <j...@videolan.org> | Sun Nov 17 15:02:03 2013 +0100| [fdd456ea6ef1984eedd1912ba2eb37a43e1ae08b] | committer: Jean-Baptiste Kempf
MMDevice: split OpenDevice, CloseDevice and ActivateDevice for WinRT The code wasn't common anymore :) This reduces the number of #if VLC_WINSTORE_APP and should help readability Maybe Open() and Close() should be splitted in a similar way... > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fdd456ea6ef1984eedd1912ba2eb37a43e1ae08b --- modules/audio_output/mmdevice.c | 71 ++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/modules/audio_output/mmdevice.c b/modules/audio_output/mmdevice.c index ad025e4..aee2615 100644 --- a/modules/audio_output/mmdevice.c +++ b/modules/audio_output/mmdevice.c @@ -546,7 +546,6 @@ static int DevicesEnum(audio_output_t *aout) IMMDeviceCollection_Release(devs); return n; } -#endif /* !VLC_WINSTORE_APP */ /** * Opens the selected audio output device. @@ -556,12 +555,6 @@ static HRESULT OpenDevice(audio_output_t *aout, const char *devid) aout_sys_t *sys = aout->sys; assert(sys->dev == NULL); -#if VLC_WINSTORE_APP - (void)devid; - assert(!devid); - sys->dev = var_InheritAddress(aout, "mmdevice-audioclient"); - return S_OK; -#else HRESULT hr; if (devid != NULL) /* Device selected explicitly */ { @@ -615,7 +608,6 @@ out: SetEvent(sys->device_changed); WaitForSingleObject(sys->device_ready, INFINITE); return hr; -#endif /* ! VLC_WINSTORE_APP */ } /** @@ -626,7 +618,6 @@ static void CloseDevice(audio_output_t *aout) aout_sys_t *sys = aout->sys; assert(sys->dev != NULL); -#if !VLC_WINSTORE_APP if (sys->manager != NULL) { IAudioSessionManager_Release(sys->manager); @@ -634,12 +625,53 @@ static void CloseDevice(audio_output_t *aout) } IMMDevice_Release(sys->dev); -#else + 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); +} + +#else /* VLC_WINSTORE_APP */ + +static HRESULT OpenDevice(audio_output_t *aout, const char *devid) +{ + aout_sys_t *sys = aout->sys; + assert(sys->dev == NULL); + + (void)devid; + assert(!devid); + sys->dev = var_InheritAddress(aout, "mmdevice-audioclient"); + return S_OK; +} + +static void CloseDevice(audio_output_t *aout) +{ + aout_sys_t *sys = aout->sys; + + assert(sys->dev != NULL); free(sys->dev); -#endif sys->dev = NULL; } +static HRESULT ActivateDevice(void *opaque, REFIID iid, PROPVARIANT *actparms, + void **restrict pv) +{ + IMMDevice *dev = opaque; + (void)iid; (void)actparms; + *pv = dev; + return S_OK; +} +#endif /* !VLC_WINSTORE_APP */ + + static int DeviceSelect(audio_output_t *aout, const char *id) { aout_sys_t *sys = aout->sys; @@ -662,23 +694,6 @@ static int DeviceSelect(audio_output_t *aout, const char *id) return FAILED(hr) ? -1 : 0; } -/** - * 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; -#if VLC_WINSTORE_APP - (void)iid; (void)actparms; - *pv = dev; - return S_OK; -#else - return IMMDevice_Activate(dev, iid, CLSCTX_ALL, actparms, pv); -#endif -} - static int Start(audio_output_t *aout, audio_sample_format_t *restrict fmt) { aout_sys_t *sys = aout->sys; _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits