From a8fde1144bf6423284cc70c9abaa57c443466a9e Mon Sep 17 00:00:00 2001 From: Vic Lee Date: Mon, 15 Aug 2011 16:58:07 +0800 Subject: [PATCH] rdpsnd: start playing immediately when a close signal received. --- channels/rdpsnd/alsa/rdpsnd_alsa.c | 11 +++++++++++ channels/rdpsnd/rdpsnd_main.c | 2 ++ channels/rdpsnd/rdpsnd_main.h | 2 ++ 3 files changed, 15 insertions(+) diff --git a/channels/rdpsnd/alsa/rdpsnd_alsa.c b/channels/rdpsnd/alsa/rdpsnd_alsa.c index e88e85a93..c9cb27cd0 100644 --- a/channels/rdpsnd/alsa/rdpsnd_alsa.c +++ b/channels/rdpsnd/alsa/rdpsnd_alsa.c @@ -298,6 +298,16 @@ static void rdpsnd_alsa_play(rdpsndDevicePlugin* device, uint8* data, int size) free(decoded_data); } +static void rdpsnd_alsa_start(rdpsndDevicePlugin* device) +{ + rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device; + + if (alsa->out_handle == 0) + return; + + snd_pcm_start(alsa->out_handle); +} + int FreeRDPRdpsndDeviceEntry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints) { rdpsndAlsaPlugin* alsa; @@ -310,6 +320,7 @@ int FreeRDPRdpsndDeviceEntry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints) alsa->device.SetFormat = rdpsnd_alsa_set_format; alsa->device.SetVolume = rdpsnd_alsa_set_volume; alsa->device.Play = rdpsnd_alsa_play; + alsa->device.Start = rdpsnd_alsa_start; alsa->device.Close = rdpsnd_alsa_close; alsa->device.Free = rdpsnd_alsa_free; diff --git a/channels/rdpsnd/rdpsnd_main.c b/channels/rdpsnd/rdpsnd_main.c index 1f17e8adf..4f2910aac 100644 --- a/channels/rdpsnd/rdpsnd_main.c +++ b/channels/rdpsnd/rdpsnd_main.c @@ -363,6 +363,8 @@ static void rdpsnd_process_message_wave(rdpsndPlugin* rdpsnd, STREAM* data_in) static void rdpsnd_process_message_close(rdpsndPlugin* rdpsnd) { DEBUG_SVC("server closes."); + if (rdpsnd->device) + IFCALL(rdpsnd->device->Start, rdpsnd->device); rdpsnd->close_timestamp = get_mstime() + 2000; rdpsnd->plugin.interval_ms = 10; } diff --git a/channels/rdpsnd/rdpsnd_main.h b/channels/rdpsnd/rdpsnd_main.h index ba391a09e..90e87e082 100644 --- a/channels/rdpsnd/rdpsnd_main.h +++ b/channels/rdpsnd/rdpsnd_main.h @@ -41,6 +41,7 @@ typedef void (*pcOpen) (rdpsndDevicePlugin* device, rdpsndFormat* format); typedef void (*pcSetFormat) (rdpsndDevicePlugin* device, rdpsndFormat* format); typedef void (*pcSetVolume) (rdpsndDevicePlugin* device, uint32 value); typedef void (*pcPlay) (rdpsndDevicePlugin* device, uint8* data, int size); +typedef void (*pcStart) (rdpsndDevicePlugin* device); typedef void (*pcClose) (rdpsndDevicePlugin* device); typedef void (*pcFree) (rdpsndDevicePlugin* device); @@ -51,6 +52,7 @@ struct rdpsnd_device_plugin pcSetFormat SetFormat; pcSetVolume SetVolume; pcPlay Play; + pcStart Start; pcClose Close; pcFree Free; };