From cc1bcb31b8fe4e5b55c9a96c15a93bcb11483e5a Mon Sep 17 00:00:00 2001 From: Vic Lee Date: Wed, 2 Sep 2015 15:15:15 +0800 Subject: [PATCH] rdpsnd/winmm: fix SetVolume when device is not opened. --- channels/rdpsnd/client/winmm/rdpsnd_winmm.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/channels/rdpsnd/client/winmm/rdpsnd_winmm.c b/channels/rdpsnd/client/winmm/rdpsnd_winmm.c index a9d54f441..5e143635a 100644 --- a/channels/rdpsnd/client/winmm/rdpsnd_winmm.c +++ b/channels/rdpsnd/client/winmm/rdpsnd_winmm.c @@ -50,6 +50,7 @@ struct rdpsnd_winmm_plugin WAVEFORMATEX format; int wformat; int block_size; + UINT32 volume; FREERDP_DSP_CONTEXT* dsp_context; }; @@ -162,6 +163,14 @@ static BOOL rdpsnd_winmm_open(rdpsndDevicePlugin* device, AUDIO_FORMAT* format, return FALSE; } + mmResult = waveOutSetVolume(winmm->hWaveOut, winmm->volume); + + if (mmResult != MMSYSERR_NOERROR) + { + WLog_ERR(TAG, "waveOutSetVolume failed: %d", mmResult); + return FALSE; + } + return TRUE; } @@ -239,13 +248,15 @@ static BOOL rdpsnd_winmm_set_volume(rdpsndDevicePlugin* device, UINT32 value) { rdpsndWinmmPlugin* winmm = (rdpsndWinmmPlugin*) device; + winmm->volume = value; + if (!winmm->hWaveOut) - return FALSE; + return TRUE; return (waveOutSetVolume(winmm->hWaveOut, value) == MMSYSERR_NOERROR); } -static void rdpsnd_winmm_wave_decode(rdpsndDevicePlugin* device, RDPSND_WAVE* wave) +static BOOL rdpsnd_winmm_wave_decode(rdpsndDevicePlugin* device, RDPSND_WAVE* wave) { int length; BYTE* data; @@ -375,6 +386,8 @@ UINT freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS p return CHANNEL_RC_NO_MEMORY; } + winmm->volume = 0xFFFFFFFF; + pEntryPoints->pRegisterRdpsndDevice(pEntryPoints->rdpsnd, (rdpsndDevicePlugin*) winmm); return CHANNEL_RC_OK;