rdpsnd/winmm: fix SetVolume when device is not opened.

This commit is contained in:
Vic Lee 2015-09-02 15:15:15 +08:00
parent 2d5e249eff
commit cc1bcb31b8

View File

@ -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;