From 0e9ad32bcbcc4a87badd7479b76df88729fe6ba8 Mon Sep 17 00:00:00 2001 From: Anthony Tong Date: Wed, 19 Oct 2011 10:55:54 -0400 Subject: [PATCH] port of llyzs patch from freerdp-old, issue #26 --- channels/drdynvc/audin/alsa/audin_alsa.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/channels/drdynvc/audin/alsa/audin_alsa.c b/channels/drdynvc/audin/alsa/audin_alsa.c index 1fea07e3a..feb048c1c 100644 --- a/channels/drdynvc/audin/alsa/audin_alsa.c +++ b/channels/drdynvc/audin/alsa/audin_alsa.c @@ -120,6 +120,9 @@ static boolean audin_alsa_thread_receive(AudinALSADevice* alsa, uint8* src, int while (frames > 0) { + if (freerdp_thread_is_stopped(alsa->thread)) + break; + cframes = alsa->frames_per_packet - alsa->buffer_frames; if (cframes > frames) cframes = frames; @@ -142,7 +145,13 @@ static boolean audin_alsa_thread_receive(AudinALSADevice* alsa, uint8* src, int encoded_size = alsa->buffer_frames * tbytes_per_frame; } - ret = alsa->receive(encoded_data, encoded_size, alsa->user_data); + if (freerdp_thread_is_stopped(alsa->thread)) + { + ret = 0; + frames = 0; + } + else + ret = alsa->receive(encoded_data, encoded_size, alsa->user_data); alsa->buffer_frames = 0; if (encoded_data != alsa->buffer) xfree(encoded_data);