From 16531e14372558cd4cc4e76ebc3e00528e1692d7 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 25 Sep 2018 16:25:35 +0200 Subject: [PATCH] Fixed server audin callback, provide more information. --- channels/audin/server/audin.c | 6 +++++- include/freerdp/server/audin.h | 5 +++-- include/freerdp/server/shadow.h | 6 +++--- server/shadow/shadow_audin.c | 8 +++++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index 57b7a61..44d66db 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -335,11 +335,15 @@ static UINT audin_server_recv_data(audin_server* audin, wStream* s, if (freerdp_dsp_decode(audin->dsp_context, format, Stream_Pointer(s), length, out)) { + AUDIO_FORMAT dformat = *format; + dformat.wFormatTag = WAVE_FORMAT_PCM; + dformat.wBitsPerSample = 16; Stream_SealLength(out); + Stream_SetPosition(out, 0); sbytes_per_sample = format->wBitsPerSample / 8; sbytes_per_frame = format->nChannels * sbytes_per_sample; frames = Stream_Length(out) / sbytes_per_frame; - IFCALLRET(audin->context.ReceiveSamples, success, &audin->context, Stream_Buffer(out), frames); + IFCALLRET(audin->context.ReceiveSamples, success, &audin->context, &dformat, out, frames); if (success) WLog_ERR(TAG, "context.ReceiveSamples failed with error %"PRIu32"", success); diff --git a/include/freerdp/server/audin.h b/include/freerdp/server/audin.h index 7e13d89..ac49551 100644 --- a/include/freerdp/server/audin.h +++ b/include/freerdp/server/audin.h @@ -35,8 +35,9 @@ typedef BOOL (*psAudinServerClose)(audin_server_context* context); typedef UINT(*psAudinServerOpening)(audin_server_context* context); typedef UINT(*psAudinServerOpenResult)(audin_server_context* context, UINT32 result); -typedef UINT(*psAudinServerReceiveSamples)(audin_server_context* context, const void* buf, - int nframes); +typedef UINT(*psAudinServerReceiveSamples)(audin_server_context* context, + const AUDIO_FORMAT* format, wStream* buf, + size_t nframes); struct _audin_server_context { diff --git a/include/freerdp/server/shadow.h b/include/freerdp/server/shadow.h index 0eddae6..bc249fb 100644 --- a/include/freerdp/server/shadow.h +++ b/include/freerdp/server/shadow.h @@ -86,9 +86,9 @@ typedef BOOL (*pfnShadowMouseEvent)(rdpShadowSubsystem* subsystem, typedef BOOL (*pfnShadowExtendedMouseEvent)(rdpShadowSubsystem* subsystem, rdpShadowClient* client, UINT16 flags, UINT16 x, UINT16 y); -typedef void (*pfnShadowChannelAudinServerReceiveSamples)( - rdpShadowSubsystem* subsystem, rdpShadowClient* client, const void* buf, - int nframes); +typedef BOOL (*pfnShadowChannelAudinServerReceiveSamples)( + rdpShadowSubsystem* subsystem, rdpShadowClient* client, + const AUDIO_FORMAT* format, wStream* buf, size_t nframes); struct rdp_shadow_client { diff --git a/server/shadow/shadow_audin.c b/server/shadow/shadow_audin.c index 2d494b5..85a38af 100644 --- a/server/shadow/shadow_audin.c +++ b/server/shadow/shadow_audin.c @@ -78,7 +78,8 @@ static UINT AudinServerOpenResult(audin_server_context* context, UINT32 result) * * @return 0 on success, otherwise a Win32 error code */ -static UINT AudinServerReceiveSamples(audin_server_context* context, const void* buf, int nframes) +static UINT AudinServerReceiveSamples(audin_server_context* context, const AUDIO_FORMAT* format, + wStream* buf, size_t nframes) { rdpShadowClient* client = (rdpShadowClient*)context->data; rdpShadowSubsystem* subsystem = client->server->subsystem; @@ -86,8 +87,9 @@ static UINT AudinServerReceiveSamples(audin_server_context* context, const void* if (!client->mayInteract) return CHANNEL_RC_OK; - if (subsystem->AudinServerReceiveSamples) - subsystem->AudinServerReceiveSamples(subsystem, client, buf, nframes); + if (!IFCALLRESULT(TRUE, subsystem->AudinServerReceiveSamples, subsystem, client, format, buf, + nframes)) + return ERROR_INTERNAL_ERROR; return CHANNEL_RC_OK; } -- 2.7.4