diff --git a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c index cb43e4680..0edc08d93 100644 --- a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c +++ b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c @@ -115,9 +115,7 @@ static int rdpsnd_alsa_set_hw_params(rdpsndAlsaPlugin* alsa) status = snd_pcm_hw_params_set_buffer_size_near(alsa->pcm_handle, hw_params, &alsa->buffer_size); SND_PCM_CHECK("snd_pcm_hw_params_set_buffer_size_near", status); - /* Get period size */ - status = snd_pcm_hw_params_get_period_size_min(hw_params, &alsa->period_size, NULL); - SND_PCM_CHECK("snd_pcm_hw_params_get_period_size_min", status); + alsa->period_size = alsa->buffer_size / 2; /* Set period size */ status = snd_pcm_hw_params_set_period_size_near(alsa->pcm_handle, hw_params, &alsa->period_size, NULL); @@ -191,12 +189,12 @@ static int rdpsnd_alsa_set_params(rdpsndAlsaPlugin* alsa) * It is also possible for the buffer size to not be an integer multiple of the period size. */ + int interrupts_per_sec_near = 20; + int bytes_per_sec = alsa->actual_rate * alsa->bytes_per_channel * alsa->actual_channels; + snd_pcm_drop(alsa->pcm_handle); - if (alsa->latency < 0) - alsa->latency = 400; - - alsa->buffer_size = alsa->latency * (alsa->actual_rate / 1000); + alsa->buffer_size = bytes_per_sec / (interrupts_per_sec_near / 2); if (rdpsnd_alsa_set_hw_params(alsa) < 0) return -1; @@ -225,11 +223,6 @@ static void rdpsnd_alsa_set_format(rdpsndDevicePlugin* device, AUDIO_FORMAT* for case WAVE_FORMAT_PCM: switch (format->wBitsPerSample) { - case 4: - alsa->format = SND_PCM_FORMAT_S16_LE; - alsa->bytes_per_channel = 2; - break; - case 8: alsa->format = SND_PCM_FORMAT_S8; alsa->bytes_per_channel = 1; diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index ceaa47d73..4211e0bc4 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -275,14 +275,14 @@ void rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, wStream* s) UINT16 wVersion; AUDIO_FORMAT* format; UINT16 wNumberOfFormats; - UINT32 dwVolume; rdpsnd_free_audio_formats(rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats); rdpsnd->NumberOfServerFormats = 0; rdpsnd->ServerFormats = NULL; + /* http://msdn.microsoft.com/en-us/library/cc240956.aspx */ Stream_Seek_UINT32(s); /* dwFlags */ - Stream_Read_UINT32(s, dwVolume); /* dwVolume */ + Stream_Seek_UINT32(s); /* dwVolume */ Stream_Seek_UINT32(s); /* dwPitch */ Stream_Seek_UINT16(s); /* wDGramPort */ Stream_Read_UINT16(s, wNumberOfFormats); @@ -324,9 +324,6 @@ void rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, wStream* s) if (wVersion >= 6) rdpsnd_send_quality_mode_pdu(rdpsnd); - - if (rdpsnd->device) - IFCALL(rdpsnd->device->SetVolume, rdpsnd->device, dwVolume); } void rdpsnd_send_training_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp, UINT16 wPackSize) diff --git a/client/Windows/wf_event.c b/client/Windows/wf_event.c index dfd17411f..cc54df906 100644 --- a/client/Windows/wf_event.c +++ b/client/Windows/wf_event.c @@ -41,6 +41,15 @@ static HWND g_focus_hWnd; BOOL wf_scale_blt(wfContext* wfc, HDC hdc, int x, int y, int w, int h, HDC hdcSrc, int x1, int y1, DWORD rop); void wf_scale_mouse_event(wfContext* wfc, rdpInput* input, UINT16 flags, UINT16 x, UINT16 y); +static BOOL g_flipping_in; +static BOOL g_flipping_out; + +static BOOL alt_ctrl_down() +{ + return ((GetAsyncKeyState(VK_CONTROL) & 0x8000) || + (GetAsyncKeyState(VK_MENU) & 0x8000)); +} + LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam) { wfContext* wfc; @@ -50,6 +59,13 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam) DEBUG_KBD("Low-level keyboard hook, hWnd %X nCode %X wParam %X", g_focus_hWnd, nCode, wParam); + if (g_flipping_in) + { + if (!alt_ctrl_down()) + g_flipping_in = FALSE; + return CallNextHookEx(NULL, nCode, wParam, lParam); + } + if (g_focus_hWnd && (nCode == HC_ACTION)) { switch (wParam) @@ -124,6 +140,15 @@ LRESULT CALLBACK wf_ll_kbd_proc(int nCode, WPARAM wParam, LPARAM lParam) } } + if (g_flipping_out) + { + if (!alt_ctrl_down()) + { + g_flipping_out = FALSE; + g_focus_hWnd = NULL; + } + } + return CallNextHookEx(NULL, nCode, wParam, lParam); } @@ -505,6 +530,8 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam case WM_SETFOCUS: DEBUG_KBD("getting focus %X", hWnd); + if (alt_ctrl_down()) + g_flipping_in = TRUE; g_focus_hWnd = hWnd; break; @@ -512,7 +539,10 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam if (g_focus_hWnd == hWnd && wfc && !wfc->fullscreen) { DEBUG_KBD("loosing focus %X", hWnd); - g_focus_hWnd = NULL; + if (alt_ctrl_down()) + g_flipping_out = TRUE; + else + g_focus_hWnd = NULL; } break; @@ -521,11 +551,16 @@ LRESULT CALLBACK wf_event_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam int activate = (int)(short) LOWORD(wParam); if (activate != WA_INACTIVE) { + if (alt_ctrl_down()) + g_flipping_in = TRUE; g_focus_hWnd = hWnd; } else { - g_focus_hWnd = NULL; + if (alt_ctrl_down()) + g_flipping_out = TRUE; + else + g_focus_hWnd = NULL; } } diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 974a85bdb..675419b92 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -303,16 +303,16 @@ BOOL rdp_client_redirect(rdpRdp* rdp) } else { - if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESS) - { - free(settings->ServerHostname); - settings->ServerHostname = _strdup(settings->TargetNetAddress); - } - else if (settings->RedirectionFlags & LB_TARGET_FQDN) + if (settings->RedirectionFlags & LB_TARGET_FQDN) { free(settings->ServerHostname); settings->ServerHostname = _strdup(settings->RedirectionTargetFQDN); } + else if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESS) + { + free(settings->ServerHostname); + settings->ServerHostname = _strdup(settings->TargetNetAddress); + } else if (settings->RedirectionFlags & LB_TARGET_NETBIOS_NAME) { free(settings->ServerHostname); diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 5bd5171e0..dfa5b20fb 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -1050,7 +1050,7 @@ static int rdp_recv_tpkt_pdu(rdpRdp* rdp, wStream* s) Stream_SetPosition(s, nextPosition); } } - else if (channelId == rdp->mcs->messageChannelId) + else if (rdp->mcs->messageChannelId && channelId == rdp->mcs->messageChannelId) { return rdp_recv_message_channel_pdu(rdp, s); } diff --git a/libfreerdp/core/redirection.c b/libfreerdp/core/redirection.c index d7f7e9ec0..0613e4d42 100644 --- a/libfreerdp/core/redirection.c +++ b/libfreerdp/core/redirection.c @@ -103,16 +103,16 @@ int rdp_redirection_apply_settings(rdpRdp* rdp) } else { - if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESS) - { - free(settings->TargetNetAddress); - settings->TargetNetAddress = _strdup(redirection->TargetNetAddress); - } - else if (settings->RedirectionFlags & LB_TARGET_FQDN) + if (settings->RedirectionFlags & LB_TARGET_FQDN) { free(settings->RedirectionTargetFQDN); settings->RedirectionTargetFQDN = _strdup(redirection->TargetFQDN); } + else if (settings->RedirectionFlags & LB_TARGET_NET_ADDRESS) + { + free(settings->TargetNetAddress); + settings->TargetNetAddress = _strdup(redirection->TargetNetAddress); + } else if (settings->RedirectionFlags & LB_TARGET_NETBIOS_NAME) { free(settings->RedirectionTargetNetBiosName);