Merge pull request #821 from awakecoding/master

rdpsnd + tsmf fix
This commit is contained in:
Marc-André Moreau 2012-11-25 22:35:44 -08:00
commit f22ad7948f
16 changed files with 102 additions and 31 deletions

View File

@ -477,6 +477,9 @@ int freerdp_rdpsnd_client_subsystem_entry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pE
args = pEntryPoints->args;
rdpsnd_alsa_parse_addin_args((rdpsndDevicePlugin*) alsa, args);
if (!alsa->device_name)
alsa->device_name = _strdup("default");
alsa->out_handle = 0;
alsa->source_rate = 22050;
alsa->actual_rate = 22050;

View File

@ -319,20 +319,27 @@ static void rdpsnd_process_message_wave_info(rdpsndPlugin* rdpsnd, STREAM* data_
DEBUG_SVC("waveDataSize %d wFormatNo %d", rdpsnd->waveDataSize, wFormatNo);
rdpsnd->close_timestamp = 0;
if (!rdpsnd->is_open)
{
rdpsnd->current_format = wFormatNo;
rdpsnd->is_open = TRUE;
if (rdpsnd->device)
{
IFCALL(rdpsnd->device->Open, rdpsnd->device, &rdpsnd->supported_formats[wFormatNo],
rdpsnd->latency);
}
}
else if (wFormatNo != rdpsnd->current_format)
{
rdpsnd->current_format = wFormatNo;
if (rdpsnd->device)
{
IFCALL(rdpsnd->device->SetFormat, rdpsnd->device, &rdpsnd->supported_formats[wFormatNo],
rdpsnd->latency);
}
}
}
@ -345,14 +352,19 @@ static void rdpsnd_process_message_wave(rdpsndPlugin* rdpsnd, STREAM* data_in)
struct data_out_item* item;
rdpsnd->expectingWave = 0;
memcpy(stream_get_head(data_in), rdpsnd->waveData, 4);
if (stream_get_size(data_in) != rdpsnd->waveDataSize)
{
DEBUG_WARN("size error");
return;
}
if (rdpsnd->device)
{
IFCALL(rdpsnd->device->Play, rdpsnd->device, stream_get_head(data_in), stream_get_size(data_in));
}
process_ms = get_mstime() - rdpsnd->wave_timestamp;
delay_ms = 250;
@ -380,8 +392,12 @@ 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;
}
@ -392,8 +408,11 @@ static void rdpsnd_process_message_setvolume(rdpsndPlugin* rdpsnd, STREAM* data_
stream_read_UINT32(data_in, dwVolume);
DEBUG_SVC("dwVolume 0x%X", dwVolume);
if (rdpsnd->device)
{
IFCALL(rdpsnd->device->SetVolume, rdpsnd->device, dwVolume);
}
}
static void rdpsnd_process_receive(rdpSvcPlugin* plugin, STREAM* data_in)
@ -420,18 +439,23 @@ static void rdpsnd_process_receive(rdpSvcPlugin* plugin, STREAM* data_in)
case SNDC_FORMATS:
rdpsnd_process_message_formats(rdpsnd, data_in);
break;
case SNDC_TRAINING:
rdpsnd_process_message_training(rdpsnd, data_in);
break;
case SNDC_WAVE:
rdpsnd_process_message_wave_info(rdpsnd, data_in, BodySize);
break;
case SNDC_CLOSE:
rdpsnd_process_message_close(rdpsnd);
break;
case SNDC_SETVOLUME:
rdpsnd_process_message_setvolume(rdpsnd, data_in);
break;
default:
DEBUG_WARN("unknown msgType %d", msgType);
break;

View File

@ -49,13 +49,14 @@ typedef struct _TSMFALSAAudioDevice
UINT32 bytes_per_sample;
FREERDP_DSP_CONTEXT* dsp_context;
} TSMFALSAAudioDevice;
} TSMFAlsaAudioDevice;
static BOOL tsmf_alsa_open_device(TSMFALSAAudioDevice* alsa)
static BOOL tsmf_alsa_open_device(TSMFAlsaAudioDevice* alsa)
{
int error;
error = snd_pcm_open(&alsa->out_handle, alsa->device, SND_PCM_STREAM_PLAYBACK, 0);
if (error < 0)
{
DEBUG_WARN("failed to open device %s", alsa->device);
@ -68,7 +69,7 @@ static BOOL tsmf_alsa_open_device(TSMFALSAAudioDevice* alsa)
static BOOL tsmf_alsa_open(ITSMFAudioDevice* audio, const char* device)
{
TSMFALSAAudioDevice* alsa = (TSMFALSAAudioDevice*) audio;
TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*) audio;
if (!device)
{
@ -90,7 +91,7 @@ static BOOL tsmf_alsa_set_format(ITSMFAudioDevice* audio,
snd_pcm_uframes_t frames;
snd_pcm_hw_params_t* hw_params;
snd_pcm_sw_params_t* sw_params;
TSMFALSAAudioDevice* alsa = (TSMFALSAAudioDevice*) audio;
TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*) audio;
if (!alsa->out_handle)
return FALSE;
@ -102,11 +103,13 @@ static BOOL tsmf_alsa_set_format(ITSMFAudioDevice* audio,
alsa->bytes_per_sample = bits_per_sample / 8;
error = snd_pcm_hw_params_malloc(&hw_params);
if (error < 0)
{
DEBUG_WARN("snd_pcm_hw_params_malloc failed");
return FALSE;
}
snd_pcm_hw_params_any(alsa->out_handle, hw_params);
snd_pcm_hw_params_set_access(alsa->out_handle, hw_params,
SND_PCM_ACCESS_RW_INTERLEAVED);
@ -123,11 +126,13 @@ static BOOL tsmf_alsa_set_format(ITSMFAudioDevice* audio,
snd_pcm_hw_params_free(hw_params);
error = snd_pcm_sw_params_malloc(&sw_params);
if (error < 0)
{
DEBUG_WARN("snd_pcm_sw_params_malloc");
return FALSE;
}
snd_pcm_sw_params_current(alsa->out_handle, sw_params);
snd_pcm_sw_params_set_start_threshold(alsa->out_handle, sw_params,
frames / 2);
@ -139,6 +144,7 @@ static BOOL tsmf_alsa_set_format(ITSMFAudioDevice* audio,
DEBUG_DVC("sample_rate %d channels %d bits_per_sample %d",
sample_rate, channels, bits_per_sample);
DEBUG_DVC("hardware buffer %d frames", (int)frames);
if ((alsa->actual_rate != alsa->source_rate) ||
(alsa->actual_channels != alsa->source_channels))
{
@ -147,6 +153,7 @@ static BOOL tsmf_alsa_set_format(ITSMFAudioDevice* audio,
alsa->actual_rate, alsa->actual_channels,
alsa->source_rate, alsa->source_channels);
}
return TRUE;
}
@ -160,7 +167,7 @@ static BOOL tsmf_alsa_play(ITSMFAudioDevice* audio, BYTE* data, UINT32 data_size
BYTE* pindex;
int rbytes_per_frame;
int sbytes_per_frame;
TSMFALSAAudioDevice* alsa = (TSMFALSAAudioDevice*) audio;
TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*) audio;
DEBUG_DVC("data_size %d", data_size);
@ -193,6 +200,7 @@ static BOOL tsmf_alsa_play(ITSMFAudioDevice* audio, BYTE* data, UINT32 data_size
len = end - pindex;
frames = len / rbytes_per_frame;
error = snd_pcm_writei(alsa->out_handle, pindex, frames);
if (error == -EPIPE)
{
snd_pcm_recover(alsa->out_handle, error, 0);
@ -206,9 +214,12 @@ static BOOL tsmf_alsa_play(ITSMFAudioDevice* audio, BYTE* data, UINT32 data_size
tsmf_alsa_open_device(alsa);
break;
}
DEBUG_DVC("%d frames played.", error);
if (error == 0)
break;
pindex += error * rbytes_per_frame;
}
}
@ -221,14 +232,15 @@ static UINT64 tsmf_alsa_get_latency(ITSMFAudioDevice* audio)
{
UINT64 latency = 0;
snd_pcm_sframes_t frames = 0;
TSMFALSAAudioDevice* alsa = (TSMFALSAAudioDevice*) audio;
TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*) audio;
if (alsa->out_handle && alsa->actual_rate > 0 &&
snd_pcm_delay(alsa->out_handle, &frames) == 0 &&
frames > 0)
{
latency = ((UINT64)frames) * 10000000LL / (UINT64)alsa->actual_rate;
latency = ((UINT64)frames) * 10000000LL / (UINT64) alsa->actual_rate;
}
return latency;
}
@ -238,7 +250,7 @@ static void tsmf_alsa_flush(ITSMFAudioDevice* audio)
static void tsmf_alsa_free(ITSMFAudioDevice* audio)
{
TSMFALSAAudioDevice* alsa = (TSMFALSAAudioDevice*) audio;
TSMFAlsaAudioDevice* alsa = (TSMFAlsaAudioDevice*) audio;
DEBUG_DVC("");
@ -247,6 +259,7 @@ static void tsmf_alsa_free(ITSMFAudioDevice* audio)
snd_pcm_drain(alsa->out_handle);
snd_pcm_close(alsa->out_handle);
}
freerdp_dsp_context_free(alsa->dsp_context);
free(alsa);
}
@ -257,10 +270,10 @@ static void tsmf_alsa_free(ITSMFAudioDevice* audio)
ITSMFAudioDevice* freerdp_tsmf_client_audio_subsystem_entry(void)
{
TSMFALSAAudioDevice* alsa;
TSMFAlsaAudioDevice* alsa;
alsa = (TSMFALSAAudioDevice*) malloc(sizeof(TSMFALSAAudioDevice));
ZeroMemory(alsa, sizeof(TSMFALSAAudioDevice));
alsa = (TSMFAlsaAudioDevice*) malloc(sizeof(TSMFAlsaAudioDevice));
ZeroMemory(alsa, sizeof(TSMFAlsaAudioDevice));
alsa->iface.Open = tsmf_alsa_open;
alsa->iface.SetFormat = tsmf_alsa_set_format;

View File

@ -16,7 +16,8 @@
#import "freerdp/graphics.h"
#import "freerdp/utils/event.h"
#import "freerdp/client/cliprdr.h"
#import "freerdp/utils/args.h"
#import "freerdp/client/file.h"
#import "freerdp/client/cmdline.h"
#import "freerdp/rail/rail.h"
#import "freerdp/rail.h"
#import "freerdp/utils/rail.h"

View File

@ -1016,6 +1016,7 @@ int rdp_connect()
BOOL mac_pre_connect(freerdp *inst)
{
int status;
char *cptr;
int len;
int i;
@ -1213,12 +1214,28 @@ BOOL mac_pre_connect(freerdp *inst)
}
}
#endif
freerdp_parse_args(inst->settings, g_mrdpview->argc, g_mrdpview->argv, process_plugin_args, inst->context->channels, NULL, NULL);
if ((strcmp(g_mrdpview->argv[1], "-h") == 0) || (strcmp(g_mrdpview->argv[1], "--help") == 0)) {
[NSApp terminate:nil];
return TRUE;
}
if (freerdp_detect_old_command_line_syntax(inst->context->argc, inst->context->argv))
{
printf("warning: deprecated command-line syntax detected!\n");
freerdp_client_print_command_line_help(inst->context->argc, inst->context->argv);
[NSApp terminate:nil];
return TRUE;
}
inst->context->argc = g_mrdpview->argc;
inst->context->argv = g_mrdpview->argv;
status = freerdp_client_parse_command_line_arguments(inst->context->argc, inst->context->argv, inst->settings);
if (status < 0)
{
[NSApp terminate:nil];
return TRUE;
}
freerdp_client_load_addins(inst->context->channels, inst->settings);
[g_mrdpview setViewSize:inst->settings->DesktopWidth :inst->settings->DesktopHeight];

View File

@ -883,6 +883,12 @@ int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
int index;
ADDIN_ARGV* args;
if ((freerdp_static_channel_collection_find(settings, "rdpsnd")) ||
(freerdp_dynamic_channel_collection_find(settings, "tsmf")))
{
settings->AudioPlayback = TRUE; /* Both rdpsnd and tsmf require this flag to be set */
}
if (settings->DeviceRedirection)
{
freerdp_client_load_static_channel_addin(channels, settings, "rdpdr", settings);

View File

@ -99,6 +99,8 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MODULE freerdp
MODULES freerdp-utils)
message(STATUS "libfreerdp-codec libs: ${${MODULE_PREFIX}_LIBS}")
if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()

View File

@ -772,7 +772,7 @@ BOOL compress_rdp_5(struct rdp_mppc_enc* enc, BYTE* srcData, int len)
/* encode copy_offset and insert into output buffer */
if ((copy_offset >= 0) && (copy_offset <= 63))
if (copy_offset <= 63) /* (copy_offset >= 0) is always true */
{
/* insert binary header */
data = 0x1f;

View File

@ -113,7 +113,7 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${OPENSSL_LIBRARIES})
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL
MODULE freerdp
MODULES freerdp-core freerdp-crypto freerdp-codec freerdp-locale freerdp-utils)
MODULES freerdp-crypto freerdp-codec freerdp-locale freerdp-utils)
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD}

View File

@ -809,6 +809,12 @@ int rpc_in_write(rdpRpc* rpc, BYTE* data, int length)
{
int status;
#ifdef WITH_DEBUG_TSG
rpc_pdu_header_print((rpcconn_hdr_t*) data);
printf("Sending PDU (length: %d)\n", length);
freerdp_hexdump(data, length);
#endif
status = tls_write_all(rpc->TlsIn, data, length);
return status;
@ -871,6 +877,8 @@ int rpc_recv_pdu(rdpRpc* rpc)
header = (rpcconn_hdr_t*) rpc->buffer;
bytesRead += status;
rpc_pdu_header_print(header);
if (header->common.frag_length > rpc->length)
{
rpc->length = header->common.frag_length;

View File

@ -59,7 +59,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD}
MODULE winpr
MODULES winpr-crt)
MODULES winpr-crt winpr-library)
if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)

View File

@ -183,7 +183,8 @@ void* freerdp_keyboard_xkb_init()
UINT32 freerdp_keyboard_init_xkbfile(UINT32 keyboardLayoutId, RDP_SCANCODE x11_keycode_to_rdp_scancode[256])
{
void* display;
memset(x11_keycode_to_rdp_scancode, 0, sizeof(x11_keycode_to_rdp_scancode));
ZeroMemory(x11_keycode_to_rdp_scancode, sizeof(RDP_SCANCODE) * 256);
display = freerdp_keyboard_xkb_init();

View File

@ -65,15 +65,10 @@ if(${CMAKE_SYSTEM_NAME} MATCHES SunOS)
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} rt)
endif()
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL
MODULE freerdp
MODULES freerdp-common)
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD}
MODULE winpr
MODULES winpr-crt winpr-synch)
MODULES winpr-crt winpr-synch winpr-thread)
if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)

View File

@ -90,7 +90,7 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${X11_LIBRARIES})
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD}
MODULE freerdp
MODULES freerdp-core freerdp-codec freerdp-utils freerdp-gdi freerdp-crypto freerdp-locale)
MODULES freerdp-core freerdp-common freerdp-codec freerdp-utils freerdp-gdi freerdp-crypto freerdp-locale)
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD}
@ -101,3 +101,4 @@ target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "Server/X11")

View File

@ -300,7 +300,7 @@ HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
struct stat fileStat;
WIN32_FILE_SEARCH* pFileSearch;
ZeroMemory(lpFindFileData, sizeof(LPWIN32_FIND_DATAA));
ZeroMemory(lpFindFileData, sizeof(WIN32_FIND_DATAA));
pFileSearch = (WIN32_FILE_SEARCH*) malloc(sizeof(WIN32_FILE_SEARCH));
ZeroMemory(pFileSearch, sizeof(WIN32_FILE_SEARCH));

View File

@ -582,7 +582,7 @@ RPC_STATUS UuidToStringA(UUID* Uuid, RPC_CSTR* StringUuid)
* xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
*/
sprintf_s((char*) *StringUuid, 36 + 1, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
sprintf_s((char*) *StringUuid, 36 + 1, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
Uuid->Data1, Uuid->Data2, Uuid->Data3,
Uuid->Data4[0], Uuid->Data4[1],
Uuid->Data4[2], Uuid->Data4[3], Uuid->Data4[4],