From: Armin Novak Date: Tue, 17 Jul 2018 08:57:08 +0000 (+0200) Subject: Using dynamic logger again. X-Git-Tag: 2.0.0-rc3~5^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9645c9247cca769b684773c06fd7782970babb2;p=platform%2Fupstream%2Ffreerdp.git Using dynamic logger again. --- diff --git a/channels/audin/client/alsa/audin_alsa.c b/channels/audin/client/alsa/audin_alsa.c index fb6402c..2a61504 100644 --- a/channels/audin/client/alsa/audin_alsa.c +++ b/channels/audin/client/alsa/audin_alsa.c @@ -31,6 +31,7 @@ #include #include #include +#include #include @@ -54,6 +55,7 @@ typedef struct _AudinALSADevice void* user_data; rdpContext* rdpcontext; + wLog* log; } AudinALSADevice; static snd_pcm_format_t audin_alsa_format(UINT32 wFormatTag, UINT32 bitPerChannel) @@ -94,8 +96,8 @@ static BOOL audin_alsa_set_params(AudinALSADevice* alsa, if ((error = snd_pcm_hw_params_malloc(&hw_params)) < 0) { - WLog_ERR(TAG, "snd_pcm_hw_params_malloc (%s)", - snd_strerror(error)); + WLog_Print(alsa->log, WLOG_ERROR, "snd_pcm_hw_params_malloc (%s)", + snd_strerror(error)); return FALSE; } @@ -122,12 +124,12 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg) AudinALSADevice* alsa = (AudinALSADevice*) arg; const size_t rbytes_per_frame = alsa->aformat.nChannels * 4; DWORD status; - DEBUG_DVC("in"); + WLog_Print(alsa->log, WLOG_DEBUG, "in"); buffer = (BYTE*) calloc(alsa->frames_per_packet, rbytes_per_frame); if (!buffer) { - WLog_ERR(TAG, "calloc failed!"); + WLog_Print(alsa->log, WLOG_ERROR, "calloc failed!"); error = CHANNEL_RC_NO_MEMORY; goto out; } @@ -135,14 +137,14 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg) if ((error = snd_pcm_open(&capture_handle, alsa->device_name, SND_PCM_STREAM_CAPTURE, 0)) < 0) { - WLog_ERR(TAG, "snd_pcm_open (%s)", snd_strerror(error)); + WLog_Print(alsa->log, WLOG_ERROR, "snd_pcm_open (%s)", snd_strerror(error)); error = CHANNEL_RC_INITIALIZATION_ERROR; goto out; } if (!audin_alsa_set_params(alsa, capture_handle)) { - WLog_ERR(TAG, "audin_alsa_set_params failed"); + WLog_Print(alsa->log, WLOG_ERROR, "audin_alsa_set_params failed"); goto out; } @@ -153,7 +155,7 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg) if (status == WAIT_FAILED) { error = GetLastError(); - WLog_ERR(TAG, "WaitForSingleObject failed with error %ld!", error); + WLog_Print(alsa->log, WLOG_ERROR, "WaitForSingleObject failed with error %ld!", error); break; } @@ -169,7 +171,7 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg) } else if (error < 0) { - WLog_ERR(TAG, "snd_pcm_readi (%s)", snd_strerror(error)); + WLog_Print(alsa->log, WLOG_ERROR, "snd_pcm_readi (%s)", snd_strerror(error)); break; } @@ -178,7 +180,7 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg) if (error) { - WLog_ERR(TAG, "audin_alsa_thread_receive failed with error %ld", error); + WLog_Print(alsa->log, WLOG_ERROR, "audin_alsa_thread_receive failed with error %ld", error); break; } } @@ -189,7 +191,7 @@ static DWORD WINAPI audin_alsa_thread_func(LPVOID arg) snd_pcm_close(capture_handle); out: - DEBUG_DVC("out"); + WLog_Print(alsa->log, WLOG_DEBUG, "out"); if (error && alsa->rdpcontext) setChannelError(alsa->rdpcontext, error, @@ -271,14 +273,14 @@ static UINT audin_alsa_open(IAudinDevice* device, AudinReceive receive, if (!(alsa->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) { - WLog_ERR(TAG, "CreateEvent failed!"); + WLog_Print(alsa->log, WLOG_ERROR, "CreateEvent failed!"); goto error_out; } if (!(alsa->thread = CreateThread(NULL, 0, audin_alsa_thread_func, alsa, 0, NULL))) { - WLog_ERR(TAG, "CreateThread failed!"); + WLog_Print(alsa->log, WLOG_ERROR, "CreateThread failed!"); goto error_out; } @@ -306,7 +308,7 @@ static UINT audin_alsa_close(IAudinDevice* device) if (WaitForSingleObject(alsa->thread, INFINITE) == WAIT_FAILED) { error = GetLastError(); - WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"", error); + WLog_Print(alsa->log, WLOG_ERROR, "WaitForSingleObject failed with error %"PRIu32"", error); return error; } @@ -361,7 +363,7 @@ static UINT audin_alsa_parse_addin_args(AudinALSADevice* device, if (!alsa->device_name) { - WLog_ERR(TAG, "_strdup failed!"); + WLog_Print(alsa->log, WLOG_ERROR, "_strdup failed!"); return CHANNEL_RC_NO_MEMORY; } } @@ -397,6 +399,7 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS return CHANNEL_RC_NO_MEMORY; } + alsa->log = WLog_Get(TAG); alsa->iface.Open = audin_alsa_open; alsa->iface.FormatSupported = audin_alsa_format_supported; alsa->iface.SetFormat = audin_alsa_set_format; @@ -407,7 +410,8 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS if ((error = audin_alsa_parse_addin_args(alsa, args))) { - WLog_ERR(TAG, "audin_alsa_parse_addin_args failed with errorcode %"PRIu32"!", error); + WLog_Print(alsa->log, WLOG_ERROR, "audin_alsa_parse_addin_args failed with errorcode %"PRIu32"!", + error); goto error_out; } @@ -417,7 +421,7 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS if (!alsa->device_name) { - WLog_ERR(TAG, "_strdup failed!"); + WLog_Print(alsa->log, WLOG_ERROR, "_strdup failed!"); error = CHANNEL_RC_NO_MEMORY; goto error_out; } @@ -432,7 +436,7 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin, (IAudinDevice*) alsa))) { - WLog_ERR(TAG, "RegisterAudinDevice failed with error %"PRIu32"!", error); + WLog_Print(alsa->log, WLOG_ERROR, "RegisterAudinDevice failed with error %"PRIu32"!", error); goto error_out; } diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index 52eb4d3..4986db4 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -32,6 +32,7 @@ #include #include +#include #include @@ -100,6 +101,7 @@ struct _AUDIN_PLUGIN UINT32 FramesPerPacket; FREERDP_DSP_CONTEXT* dsp_context; + wLog* log; }; static BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args); @@ -132,23 +134,23 @@ static UINT audin_channel_write_and_free(AUDIN_CHANNEL_CALLBACK* callback, wStre * * @return 0 on success, otherwise a Win32 error code */ -static UINT audin_process_version(IWTSVirtualChannelCallback* pChannelCallback, wStream* s) +static UINT audin_process_version(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callback, wStream* s) { wStream* out; const UINT32 ClientVersion = 0x01; UINT32 ServerVersion; - AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; if (Stream_GetRemainingLength(s) < 4) return ERROR_INVALID_DATA; Stream_Read_UINT32(s, ServerVersion); - DEBUG_DVC("ServerVersion=%"PRIu32", ClientVersion=%"PRIu32, ServerVersion, ClientVersion); + WLog_Print(audin->log, WLOG_DEBUG, "ServerVersion=%"PRIu32", ClientVersion=%"PRIu32, ServerVersion, + ClientVersion); out = Stream_New(NULL, 5); if (!out) { - WLog_ERR(TAG, "Stream_New failed!"); + WLog_Print(audin->log, WLOG_ERROR, "Stream_New failed!"); return ERROR_OUTOFMEMORY; } @@ -162,11 +164,13 @@ static UINT audin_process_version(IWTSVirtualChannelCallback* pChannelCallback, * * @return 0 on success, otherwise a Win32 error code */ -static UINT audin_send_incoming_data_pdu(IWTSVirtualChannelCallback* pChannelCallback) +static UINT audin_send_incoming_data_pdu(AUDIN_CHANNEL_CALLBACK* callback) { - BYTE out_data[1]; - AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; - out_data[0] = MSG_SNDIN_DATA_INCOMING; + BYTE out_data[1] = { MSG_SNDIN_DATA_INCOMING }; + + if (!callback || !callback->channel || !callback->channel->Write) + return ERROR_INTERNAL_ERROR; + return callback->channel->Write(callback->channel, 1, out_data, NULL); } @@ -175,10 +179,8 @@ static UINT audin_send_incoming_data_pdu(IWTSVirtualChannelCallback* pChannelCal * * @return 0 on success, otherwise a Win32 error code */ -static UINT audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, wStream* s) +static UINT audin_process_formats(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callback, wStream* s) { - AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; - AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) callback->plugin; UINT32 i; UINT error; wStream* out; @@ -189,11 +191,11 @@ static UINT audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, return ERROR_INVALID_DATA; Stream_Read_UINT32(s, NumFormats); - DEBUG_DVC("NumFormats %"PRIu32"", NumFormats); + WLog_Print(audin->log, WLOG_DEBUG, "NumFormats %"PRIu32"", NumFormats); if ((NumFormats < 1) || (NumFormats > 1000)) { - WLog_ERR(TAG, "bad NumFormats %"PRIu32"", NumFormats); + WLog_Print(audin->log, WLOG_ERROR, "bad NumFormats %"PRIu32"", NumFormats); return ERROR_INVALID_DATA; } @@ -202,7 +204,7 @@ static UINT audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, if (!callback->formats) { - WLog_ERR(TAG, "calloc failed!"); + WLog_Print(audin->log, WLOG_ERROR, "calloc failed!"); return ERROR_INVALID_DATA; } @@ -211,7 +213,7 @@ static UINT audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, if (!out) { error = CHANNEL_RC_NO_MEMORY; - WLog_ERR(TAG, "Stream_New failed!"); + WLog_Print(audin->log, WLOG_ERROR, "Stream_New failed!"); goto out; } @@ -247,10 +249,11 @@ static UINT audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, Stream_Seek(s, format.cbSize); } - DEBUG_DVC("wFormatTag=%"PRIu16" nChannels=%"PRIu16" nSamplesPerSec=%"PRIu32" " - "nBlockAlign=%"PRIu16" wBitsPerSample=%"PRIu16" cbSize=%"PRIu16"", - format.wFormatTag, format.nChannels, format.nSamplesPerSec, - format.nBlockAlign, format.wBitsPerSample, format.cbSize); + WLog_Print(audin->log, WLOG_DEBUG, + "wFormatTag=%s nChannels=%"PRIu16" nSamplesPerSec=%"PRIu32" " + "nBlockAlign=%"PRIu16" wBitsPerSample=%"PRIu16" cbSize=%"PRIu16"", + rdpsnd_get_audio_tag_string(format.wFormatTag), format.nChannels, format.nSamplesPerSec, + format.nBlockAlign, format.wBitsPerSample, format.cbSize); if (audin->fixed_format > 0 && audin->fixed_format != format.wFormatTag) continue; @@ -271,7 +274,7 @@ static UINT audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, if (!Stream_EnsureRemainingCapacity(out, 18 + format.cbSize)) { error = CHANNEL_RC_NO_MEMORY; - WLog_ERR(TAG, "Stream_EnsureRemainingCapacity failed!"); + WLog_Print(audin->log, WLOG_ERROR, "Stream_EnsureRemainingCapacity failed!"); goto out; } @@ -284,9 +287,9 @@ static UINT audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, } } - if ((error = audin_send_incoming_data_pdu(pChannelCallback))) + if ((error = audin_send_incoming_data_pdu(callback))) { - WLog_ERR(TAG, "audin_send_incoming_data_pdu failed!"); + WLog_Print(audin->log, WLOG_ERROR, "audin_send_incoming_data_pdu failed!"); goto out; } @@ -321,16 +324,14 @@ out: * * @return 0 on success, otherwise a Win32 error code */ -static UINT audin_send_format_change_pdu(IWTSVirtualChannelCallback* pChannelCallback, +static UINT audin_send_format_change_pdu(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callback, UINT32 NewFormat) { - wStream* out; - AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; - out = Stream_New(NULL, 5); + wStream* out = Stream_New(NULL, 5); if (!out) { - WLog_ERR(TAG, "Stream_New failed!"); + WLog_Print(audin->log, WLOG_ERROR, "Stream_New failed!"); return CHANNEL_RC_OK; } @@ -344,15 +345,14 @@ static UINT audin_send_format_change_pdu(IWTSVirtualChannelCallback* pChannelCal * * @return 0 on success, otherwise a Win32 error code */ -static UINT audin_send_open_reply_pdu(IWTSVirtualChannelCallback* pChannelCallback, UINT32 Result) +static UINT audin_send_open_reply_pdu(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callback, + UINT32 Result) { - wStream* out; - AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; - out = Stream_New(NULL, 5); + wStream* out = Stream_New(NULL, 5); if (!out) { - WLog_ERR(TAG, "Stream_New failed!"); + WLog_Print(audin->log, WLOG_ERROR, "Stream_New failed!"); return CHANNEL_RC_NO_MEMORY; } @@ -384,7 +384,12 @@ static UINT audin_receive_wave_data(const AUDIO_FORMAT* format, if (!audin->attached) return CHANNEL_RC_OK; - Stream_SetPosition(audin->data, 0); + WLog_Print(audin->log, WLOG_TRACE, + "%s: nChannels: %"PRIu16" nSamplesPerSec: %"PRIu32" " + "nAvgBytesPerSec: %"PRIu32" nBlockAlign: %"PRIu16" wBitsPerSample: %"PRIu16" cbSize: %"PRIu16" [%"PRIdz"]", + rdpsnd_get_audio_tag_string(audin->format->wFormatTag), + audin->format->nChannels, audin->format->nSamplesPerSec, audin->format->nAvgBytesPerSec, + audin->format->nBlockAlign, audin->format->wBitsPerSample, audin->format->cbSize, size); if (!Stream_EnsureRemainingCapacity(audin->data, 1)) return CHANNEL_RC_NO_MEMORY; @@ -404,9 +409,9 @@ static UINT audin_receive_wave_data(const AUDIO_FORMAT* format, if (Stream_GetPosition(audin->data) <= 1) return CHANNEL_RC_OK; - if ((error = audin_send_incoming_data_pdu((IWTSVirtualChannelCallback*) callback))) + if ((error = audin_send_incoming_data_pdu(callback))) { - WLog_ERR(TAG, "audin_send_incoming_data_pdu failed!"); + WLog_Print(audin->log, WLOG_ERROR, "audin_send_incoming_data_pdu failed!"); return error; } @@ -424,8 +429,8 @@ static BOOL audin_open_device(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callb format = *audin->format; supported = IFCALLRESULT(FALSE, audin->device->FormatSupported, audin->device, &format); - WLog_DBG(TAG, "microphone uses %s codec", - rdpsnd_get_audio_tag_string(format.wFormatTag)); + WLog_Print(audin->log, WLOG_DEBUG, "microphone uses %s codec", + rdpsnd_get_audio_tag_string(format.wFormatTag)); if (!supported) { @@ -465,10 +470,8 @@ static BOOL audin_open_device(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callb * * @return 0 on success, otherwise a Win32 error code */ -static UINT audin_process_open(IWTSVirtualChannelCallback* pChannelCallback, wStream* s) +static UINT audin_process_open(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callback, wStream* s) { - AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; - AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) callback->plugin; UINT32 initialFormat; UINT32 FramesPerPacket; UINT error = CHANNEL_RC_OK; @@ -478,14 +481,14 @@ static UINT audin_process_open(IWTSVirtualChannelCallback* pChannelCallback, wSt Stream_Read_UINT32(s, FramesPerPacket); Stream_Read_UINT32(s, initialFormat); - DEBUG_DVC("FramesPerPacket=%"PRIu32" initialFormat=%"PRIu32"", - FramesPerPacket, initialFormat); + WLog_Print(audin->log, WLOG_DEBUG, "FramesPerPacket=%"PRIu32" initialFormat=%"PRIu32"", + FramesPerPacket, initialFormat); audin->FramesPerPacket = FramesPerPacket; if (initialFormat >= callback->formats_count) { - WLog_ERR(TAG, "invalid format index %"PRIu32" (total %d)", - initialFormat, callback->formats_count); + WLog_Print(audin->log, WLOG_ERROR, "invalid format index %"PRIu32" (total %d)", + initialFormat, callback->formats_count); return ERROR_INVALID_DATA; } @@ -494,14 +497,14 @@ static UINT audin_process_open(IWTSVirtualChannelCallback* pChannelCallback, wSt if (!audin_open_device(audin, callback)) return ERROR_INTERNAL_ERROR; - if ((error = audin_send_format_change_pdu(pChannelCallback, initialFormat))) + if ((error = audin_send_format_change_pdu(audin, callback, initialFormat))) { - WLog_ERR(TAG, "audin_send_format_change_pdu failed!"); + WLog_Print(audin->log, WLOG_ERROR, "audin_send_format_change_pdu failed!"); return error; } - if ((error = audin_send_open_reply_pdu(pChannelCallback, 0))) - WLog_ERR(TAG, "audin_send_open_reply_pdu failed!"); + if ((error = audin_send_open_reply_pdu(audin, callback, 0))) + WLog_Print(audin->log, WLOG_ERROR, "audin_send_open_reply_pdu failed!"); return error; } @@ -511,10 +514,9 @@ static UINT audin_process_open(IWTSVirtualChannelCallback* pChannelCallback, wSt * * @return 0 on success, otherwise a Win32 error code */ -static UINT audin_process_format_change(IWTSVirtualChannelCallback* pChannelCallback, wStream* s) +static UINT audin_process_format_change(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* callback, + wStream* s) { - AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; - AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) callback->plugin; UINT32 NewFormat; UINT error = CHANNEL_RC_OK; @@ -522,12 +524,12 @@ static UINT audin_process_format_change(IWTSVirtualChannelCallback* pChannelCall return ERROR_INVALID_DATA; Stream_Read_UINT32(s, NewFormat); - DEBUG_DVC("NewFormat=%"PRIu32"", NewFormat); + WLog_Print(audin->log, WLOG_DEBUG, "NewFormat=%"PRIu32"", NewFormat); if (NewFormat >= callback->formats_count) { - WLog_ERR(TAG, "invalid format index %"PRIu32" (total %d)", - NewFormat, callback->formats_count); + WLog_Print(audin->log, WLOG_ERROR, "invalid format index %"PRIu32" (total %d)", + NewFormat, callback->formats_count); return ERROR_INVALID_DATA; } @@ -547,7 +549,7 @@ static UINT audin_process_format_change(IWTSVirtualChannelCallback* pChannelCall if (!audin_open_device(audin, callback)) return ERROR_INTERNAL_ERROR; - if ((error = audin_send_format_change_pdu(pChannelCallback, NewFormat))) + if ((error = audin_send_format_change_pdu(audin, callback, NewFormat))) WLog_ERR(TAG, "audin_send_format_change_pdu failed!"); return error; @@ -562,33 +564,43 @@ static UINT audin_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, { UINT error; BYTE MessageId; + AUDIN_PLUGIN* audin; + AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; - if (Stream_GetRemainingLength(data) < 1) - return ERROR_INVALID_DATA; + if (!callback || !data) + return ERROR_INVALID_PARAMETER; + + audin = (AUDIN_PLUGIN*) callback->plugin; + + if (!audin) + return ERROR_INTERNAL_ERROR; + + if (Stream_GetRemainingCapacity(data) < 1) + return ERROR_NO_DATA; Stream_Read_UINT8(data, MessageId); - DEBUG_DVC("MessageId=0x%02"PRIx8"", MessageId); + WLog_Print(audin->log, WLOG_DEBUG, "MessageId=0x%02"PRIx8"", MessageId); switch (MessageId) { case MSG_SNDIN_VERSION: - error = audin_process_version(pChannelCallback, data); + error = audin_process_version(audin, callback, data); break; case MSG_SNDIN_FORMATS: - error = audin_process_formats(pChannelCallback, data); + error = audin_process_formats(audin, callback, data); break; case MSG_SNDIN_OPEN: - error = audin_process_open(pChannelCallback, data); + error = audin_process_open(audin, callback, data); break; case MSG_SNDIN_FORMATCHANGE: - error = audin_process_format_change(pChannelCallback, data); + error = audin_process_format_change(audin, callback, data); break; default: - WLog_ERR(TAG, "unknown MessageId=0x%02"PRIx8"", MessageId); + WLog_Print(audin->log, WLOG_ERROR, "unknown MessageId=0x%02"PRIx8"", MessageId); error = ERROR_INVALID_DATA; break; } @@ -607,14 +619,14 @@ static UINT audin_on_close(IWTSVirtualChannelCallback* pChannelCallback) AUDIN_CHANNEL_CALLBACK* callback = (AUDIN_CHANNEL_CALLBACK*) pChannelCallback; AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) callback->plugin; UINT error = CHANNEL_RC_OK; - DEBUG_DVC("..."); + WLog_Print(audin->log, WLOG_TRACE, "..."); if (audin->device) { IFCALLRET(audin->device->Close, error, audin->device); if (error != CHANNEL_RC_OK) - WLog_ERR(TAG, "Close failed with errorcode %"PRIu32"", error); + WLog_Print(audin->log, WLOG_ERROR, "Close failed with errorcode %"PRIu32"", error); } audin->format = NULL; @@ -644,13 +656,19 @@ static UINT audin_on_new_channel_connection(IWTSListenerCallback* pListenerCallb IWTSVirtualChannelCallback** ppCallback) { AUDIN_CHANNEL_CALLBACK* callback; + AUDIN_PLUGIN* audin; AUDIN_LISTENER_CALLBACK* listener_callback = (AUDIN_LISTENER_CALLBACK*) pListenerCallback; - DEBUG_DVC("..."); + + if (!listener_callback || !listener_callback->plugin) + return ERROR_INTERNAL_ERROR; + + audin = (AUDIN_PLUGIN*) listener_callback->plugin; + WLog_Print(audin->log, WLOG_TRACE, "..."); callback = (AUDIN_CHANNEL_CALLBACK*) calloc(1, sizeof(AUDIN_CHANNEL_CALLBACK)); if (!callback) { - WLog_ERR(TAG, "calloc failed!"); + WLog_Print(audin->log, WLOG_ERROR, "calloc failed!"); return CHANNEL_RC_NO_MEMORY; } @@ -671,12 +689,12 @@ static UINT audin_on_new_channel_connection(IWTSListenerCallback* pListenerCallb static UINT audin_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManager* pChannelMgr) { AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) pPlugin; - DEBUG_DVC("..."); + WLog_Print(audin->log, WLOG_TRACE, "..."); audin->listener_callback = (AUDIN_LISTENER_CALLBACK*) calloc(1, sizeof(AUDIN_LISTENER_CALLBACK)); if (!audin->listener_callback) { - WLog_ERR(TAG, "calloc failed!"); + WLog_Print(audin->log, WLOG_ERROR, "calloc failed!"); return CHANNEL_RC_NO_MEMORY; } @@ -696,7 +714,7 @@ static UINT audin_plugin_terminated(IWTSPlugin* pPlugin) { AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) pPlugin; UINT error = CHANNEL_RC_OK; - DEBUG_DVC("..."); + WLog_Print(audin->log, WLOG_TRACE, "..."); if (audin->device) { @@ -704,7 +722,7 @@ static UINT audin_plugin_terminated(IWTSPlugin* pPlugin) if (error != CHANNEL_RC_OK) { - WLog_ERR(TAG, "Free failed with errorcode %"PRIu32"", error); + WLog_Print(audin->log, WLOG_ERROR, "Free failed with errorcode %"PRIu32"", error); // dont stop on error } @@ -755,11 +773,11 @@ static UINT audin_register_device_plugin(IWTSPlugin* pPlugin, IAudinDevice* devi if (audin->device) { - WLog_ERR(TAG, "existing device, abort."); + WLog_Print(audin->log, WLOG_ERROR, "existing device, abort."); return ERROR_ALREADY_EXISTS; } - DEBUG_DVC("device registered."); + WLog_Print(audin->log, WLOG_DEBUG, "device registered."); audin->device = device; return CHANNEL_RC_OK; } @@ -769,7 +787,7 @@ static UINT audin_register_device_plugin(IWTSPlugin* pPlugin, IAudinDevice* devi * * @return 0 on success, otherwise a Win32 error code */ -static UINT audin_load_device_plugin(IWTSPlugin* pPlugin, const char* name, ADDIN_ARGV* args) +static UINT audin_load_device_plugin(AUDIN_PLUGIN* audin, char* name, ADDIN_ARGV* args) { PFREERDP_AUDIN_DEVICE_ENTRY entry; FREERDP_AUDIN_DEVICE_ENTRY_POINTS entryPoints; @@ -779,23 +797,24 @@ static UINT audin_load_device_plugin(IWTSPlugin* pPlugin, const char* name, ADDI if (entry == NULL) { - WLog_ERR(TAG, "freerdp_load_channel_addin_entry did not return any function pointers for %s ", - name); + WLog_Print(audin->log, WLOG_ERROR, + "freerdp_load_channel_addin_entry did not return any function pointers for %s ", + name); return ERROR_INVALID_FUNCTION; } - entryPoints.plugin = pPlugin; + entryPoints.plugin = (IWTSPlugin*) audin; entryPoints.pRegisterAudinDevice = audin_register_device_plugin; entryPoints.args = args; - entryPoints.rdpcontext = ((AUDIN_PLUGIN*)pPlugin)->rdpcontext; + entryPoints.rdpcontext = audin->rdpcontext; if ((error = entry(&entryPoints))) { - WLog_ERR(TAG, "%s entry returned error %"PRIu32".", name, error); + WLog_Print(audin->log, WLOG_ERROR, "%s entry returned error %"PRIu32".", name, error); return error; } - WLog_INFO(TAG, "Loaded %s backend for audin", name); + WLog_Print(audin->log, WLOG_INFO, "Loaded %s backend for audin", name); return CHANNEL_RC_OK; } @@ -811,7 +830,7 @@ static UINT audin_set_subsystem(AUDIN_PLUGIN* audin, const char* subsystem) if (!audin->subsystem) { - WLog_ERR(TAG, "_strdup failed!"); + WLog_Print(audin->log, WLOG_ERROR, "_strdup failed!"); return ERROR_NOT_ENOUGH_MEMORY; } @@ -830,7 +849,7 @@ static UINT audin_set_device_name(AUDIN_PLUGIN* audin, char* device_name) if (!audin->device_name) { - WLog_ERR(TAG, "_strdup failed!"); + WLog_Print(audin->log, WLOG_ERROR, "_strdup failed!"); return ERROR_NOT_ENOUGH_MEMORY; } @@ -877,7 +896,7 @@ BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args) { if ((error = audin_set_subsystem(audin, arg->Value))) { - WLog_ERR(TAG, "audin_set_subsystem failed with error %"PRIu32"!", error); + WLog_Print(audin->log, WLOG_ERROR, "audin_set_subsystem failed with error %"PRIu32"!", error); return FALSE; } } @@ -885,7 +904,7 @@ BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args) { if ((error = audin_set_device_name(audin, arg->Value))) { - WLog_ERR(TAG, "audin_set_device_name failed with error %"PRIu32"!", error); + WLog_Print(audin->log, WLOG_ERROR, "audin_set_device_name failed with error %"PRIu32"!", error); return FALSE; } } @@ -983,6 +1002,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) return CHANNEL_RC_NO_MEMORY; } + audin->log = WLog_Get(TAG); audin->data = Stream_New(NULL, 4096); if (!audin->data) @@ -1012,10 +1032,10 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) if (audin->subsystem) { - if ((error = audin_load_device_plugin((IWTSPlugin*) audin, audin->subsystem, args))) + if ((error = audin_load_device_plugin(audin, audin->subsystem, args))) { - WLog_ERR(TAG, "audin_load_device_plugin %s failed with error %"PRIu32"!", - audin->subsystem, error); + WLog_Print(audin->log, WLOG_ERROR, "audin_load_device_plugin %s failed with error %"PRIu32"!", + audin->subsystem, error); goto out; } } @@ -1025,18 +1045,18 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) { if ((error = audin_set_subsystem(audin, entry->subsystem))) { - WLog_ERR(TAG, "audin_set_subsystem for %s failed with error %"PRIu32"!", - entry->subsystem, error); + WLog_Print(audin->log, WLOG_ERROR, "audin_set_subsystem for %s failed with error %"PRIu32"!", + entry->subsystem, error); } else if ((error = audin_set_device_name(audin, entry->device))) { - WLog_ERR(TAG, "audin_set_device_name for %s failed with error %"PRIu32"!", - entry->subsystem, error); + WLog_Print(audin->log, WLOG_ERROR, "audin_set_device_name for %s failed with error %"PRIu32"!", + entry->subsystem, error); } - else if ((error = audin_load_device_plugin((IWTSPlugin*) audin, audin->subsystem, args))) + else if ((error = audin_load_device_plugin(audin, audin->subsystem, args))) { - WLog_ERR(TAG, "audin_load_device_plugin %s failed with error %"PRIu32"!", - entry->subsystem, error); + WLog_Print(audin->log, WLOG_ERROR, "audin_load_device_plugin %s failed with error %"PRIu32"!", + entry->subsystem, error); } entry++; @@ -1044,7 +1064,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) } if (audin->device == NULL) - WLog_ERR(TAG, "no sound device."); + WLog_Print(audin->log, WLOG_ERROR, "no sound device."); error = pEntryPoints->RegisterPlugin(pEntryPoints, "audin", (IWTSPlugin*) audin); out: diff --git a/channels/audin/client/audin_main.h b/channels/audin/client/audin_main.h index 419986c..83a75a4 100644 --- a/channels/audin/client/audin_main.h +++ b/channels/audin/client/audin_main.h @@ -32,11 +32,5 @@ #define TAG CHANNELS_TAG("audin.client") -#ifdef WITH_DEBUG_DVC -#define DEBUG_DVC(...) WLog_DBG(TAG, __VA_ARGS__) -#else -#define DEBUG_DVC(...) do { } while (0) -#endif - #endif /* FREERDP_CHANNEL_AUDIN_CLIENT_MAIN_H */ diff --git a/channels/audin/client/pulse/audin_pulse.c b/channels/audin/client/pulse/audin_pulse.c index fc683af..2ebb2f5 100644 --- a/channels/audin/client/pulse/audin_pulse.c +++ b/channels/audin/client/pulse/audin_pulse.c @@ -29,6 +29,7 @@ #include #include +#include #include @@ -58,6 +59,7 @@ typedef struct _AudinPulseDevice void* user_data; rdpContext* rdpcontext; + wLog* log; } AudinPulseDevice; static void audin_pulse_context_state_callback(pa_context* context, void* userdata) @@ -69,18 +71,18 @@ static void audin_pulse_context_state_callback(pa_context* context, void* userda switch (state) { case PA_CONTEXT_READY: - DEBUG_DVC("PA_CONTEXT_READY"); + WLog_Print(pulse->log, WLOG_DEBUG, "PA_CONTEXT_READY"); pa_threaded_mainloop_signal(pulse->mainloop, 0); break; case PA_CONTEXT_FAILED: case PA_CONTEXT_TERMINATED: - DEBUG_DVC("state %d", state); + WLog_Print(pulse->log, WLOG_DEBUG, "state %d", state); pa_threaded_mainloop_signal(pulse->mainloop, 0); break; default: - DEBUG_DVC("state %d", state); + WLog_Print(pulse->log, WLOG_DEBUG, "state %d", state); break; } } @@ -100,8 +102,8 @@ static UINT audin_pulse_connect(IAudinDevice* device) if (pa_context_connect(pulse->context, NULL, 0, NULL)) { - WLog_ERR(TAG, "pa_context_connect failed (%d)", - pa_context_errno(pulse->context)); + WLog_Print(pulse->log, WLOG_ERROR, "pa_context_connect failed (%d)", + pa_context_errno(pulse->context)); return ERROR_INTERNAL_ERROR; } @@ -110,8 +112,8 @@ static UINT audin_pulse_connect(IAudinDevice* device) if (pa_threaded_mainloop_start(pulse->mainloop) < 0) { pa_threaded_mainloop_unlock(pulse->mainloop); - WLog_ERR(TAG, "pa_threaded_mainloop_start failed (%d)", - pa_context_errno(pulse->context)); + WLog_Print(pulse->log, WLOG_ERROR, "pa_threaded_mainloop_start failed (%d)", + pa_context_errno(pulse->context)); return ERROR_INTERNAL_ERROR; } @@ -124,8 +126,8 @@ static UINT audin_pulse_connect(IAudinDevice* device) if (!PA_CONTEXT_IS_GOOD(state)) { - WLog_ERR(TAG, "bad context state (%d)", - pa_context_errno(pulse->context)); + WLog_Print(pulse->log, WLOG_ERROR, "bad context state (%d)", + pa_context_errno(pulse->context)); pa_context_disconnect(pulse->context); return ERROR_INVALID_STATE; } @@ -134,7 +136,7 @@ static UINT audin_pulse_connect(IAudinDevice* device) } pa_threaded_mainloop_unlock(pulse->mainloop); - DEBUG_DVC("connected"); + WLog_Print(pulse->log, WLOG_DEBUG, "connected"); return CHANNEL_RC_OK; } @@ -276,18 +278,18 @@ static void audin_pulse_stream_state_callback(pa_stream* stream, void* userdata) switch (state) { case PA_STREAM_READY: - DEBUG_DVC("PA_STREAM_READY"); + WLog_Print(pulse->log, WLOG_DEBUG, "PA_STREAM_READY"); pa_threaded_mainloop_signal(pulse->mainloop, 0); break; case PA_STREAM_FAILED: case PA_STREAM_TERMINATED: - DEBUG_DVC("state %d", state); + WLog_Print(pulse->log, WLOG_DEBUG, "state %d", state); pa_threaded_mainloop_signal(pulse->mainloop, 0); break; default: - DEBUG_DVC("state %d", state); + WLog_Print(pulse->log, WLOG_DEBUG, "state %d", state); break; } } @@ -355,8 +357,8 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u if (!pulse->stream) { pa_threaded_mainloop_unlock(pulse->mainloop); - DEBUG_DVC("pa_stream_new failed (%d)", - pa_context_errno(pulse->context)); + WLog_Print(pulse->log, WLOG_DEBUG, "pa_stream_new failed (%d)", + pa_context_errno(pulse->context)); return pa_context_errno(pulse->context); } @@ -377,8 +379,8 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u &buffer_attr, PA_STREAM_ADJUST_LATENCY) < 0) { pa_threaded_mainloop_unlock(pulse->mainloop); - WLog_ERR(TAG, "pa_stream_connect_playback failed (%d)", - pa_context_errno(pulse->context)); + WLog_Print(pulse->log, WLOG_ERROR, "pa_stream_connect_playback failed (%d)", + pa_context_errno(pulse->context)); return pa_context_errno(pulse->context); } @@ -392,8 +394,8 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u if (!PA_STREAM_IS_GOOD(state)) { audin_pulse_close(device); - WLog_ERR(TAG, "bad stream state (%d)", - pa_context_errno(pulse->context)); + WLog_Print(pulse->log, WLOG_ERROR, "bad stream state (%d)", + pa_context_errno(pulse->context)); pa_threaded_mainloop_unlock(pulse->mainloop); return pa_context_errno(pulse->context); } @@ -403,7 +405,7 @@ static UINT audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u pa_threaded_mainloop_unlock(pulse->mainloop); pulse->buffer_frames = 0; - DEBUG_DVC("connected"); + WLog_Print(pulse->log, WLOG_DEBUG, "connected"); return CHANNEL_RC_OK; } @@ -445,7 +447,7 @@ static UINT audin_pulse_parse_addin_args(AudinPulseDevice* device, ADDIN_ARGV* a if (!pulse->device_name) { - WLog_ERR(TAG, "_strdup failed!"); + WLog_Print(pulse->log, WLOG_ERROR, "_strdup failed!"); return CHANNEL_RC_NO_MEMORY; } } @@ -480,6 +482,7 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn return CHANNEL_RC_NO_MEMORY; } + pulse->log = WLog_Get(TAG); pulse->iface.Open = audin_pulse_open; pulse->iface.FormatSupported = audin_pulse_format_supported; pulse->iface.SetFormat = audin_pulse_set_format; @@ -490,7 +493,8 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn if ((error = audin_pulse_parse_addin_args(pulse, args))) { - WLog_ERR(TAG, "audin_pulse_parse_addin_args failed with error %"PRIu32"!", error); + WLog_Print(pulse->log, WLOG_ERROR, "audin_pulse_parse_addin_args failed with error %"PRIu32"!", + error); goto error_out; } @@ -498,7 +502,7 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn if (!pulse->mainloop) { - WLog_ERR(TAG, "pa_threaded_mainloop_new failed"); + WLog_Print(pulse->log, WLOG_ERROR, "pa_threaded_mainloop_new failed"); error = CHANNEL_RC_NO_MEMORY; goto error_out; } @@ -507,7 +511,7 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn if (!pulse->context) { - WLog_ERR(TAG, "pa_context_new failed"); + WLog_Print(pulse->log, WLOG_ERROR, "pa_context_new failed"); error = CHANNEL_RC_NO_MEMORY; goto error_out; } @@ -516,13 +520,13 @@ UINT freerdp_audin_client_subsystem_entry(PFREERDP_AUDIN_DEVICE_ENTRY_POINTS pEn if ((error = audin_pulse_connect((IAudinDevice*) pulse))) { - WLog_ERR(TAG, "audin_pulse_connect failed"); + WLog_Print(pulse->log, WLOG_ERROR, "audin_pulse_connect failed"); goto error_out; } if ((error = pEntryPoints->pRegisterAudinDevice(pEntryPoints->plugin, (IAudinDevice*) pulse))) { - WLog_ERR(TAG, "RegisterAudinDevice failed with error %"PRIu32"!", error); + WLog_Print(pulse->log, WLOG_ERROR, "RegisterAudinDevice failed with error %"PRIu32"!", error); goto error_out; }