#include <winpr/synch.h>
#include <winpr/thread.h>
#include <winpr/cmdline.h>
+#include <winpr/wlog.h>
#include <alsa/asoundlib.h>
void* user_data;
rdpContext* rdpcontext;
+ wLog* log;
} AudinALSADevice;
static snd_pcm_format_t audin_alsa_format(UINT32 wFormatTag, UINT32 bitPerChannel)
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;
}
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;
}
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;
}
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;
}
}
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;
}
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;
}
}
snd_pcm_close(capture_handle);
out:
- DEBUG_DVC("out");
+ WLog_Print(alsa->log, WLOG_DEBUG, "out");
if (error && alsa->rdpcontext)
setChannelError(alsa->rdpcontext, error,
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;
}
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;
}
if (!alsa->device_name)
{
- WLog_ERR(TAG, "_strdup failed!");
+ WLog_Print(alsa->log, WLOG_ERROR, "_strdup failed!");
return CHANNEL_RC_NO_MEMORY;
}
}
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;
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;
}
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;
}
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;
}
#include <winpr/crt.h>
#include <winpr/cmdline.h>
+#include <winpr/wlog.h>
#include <freerdp/addin.h>
UINT32 FramesPerPacket;
FREERDP_DSP_CONTEXT* dsp_context;
+ wLog* log;
};
static BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args);
*
* @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;
}
*
* @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);
}
*
* @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;
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;
}
if (!callback->formats)
{
- WLog_ERR(TAG, "calloc failed!");
+ WLog_Print(audin->log, WLOG_ERROR, "calloc failed!");
return ERROR_INVALID_DATA;
}
if (!out)
{
error = CHANNEL_RC_NO_MEMORY;
- WLog_ERR(TAG, "Stream_New failed!");
+ WLog_Print(audin->log, WLOG_ERROR, "Stream_New failed!");
goto out;
}
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;
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;
}
}
}
- 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;
}
*
* @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;
}
*
* @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;
}
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;
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;
}
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)
{
*
* @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;
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;
}
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;
}
*
* @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;
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;
}
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;
{
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;
}
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;
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;
}
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;
}
{
AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) pPlugin;
UINT error = CHANNEL_RC_OK;
- DEBUG_DVC("...");
+ WLog_Print(audin->log, WLOG_TRACE, "...");
if (audin->device)
{
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
}
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;
}
*
* @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;
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;
}
if (!audin->subsystem)
{
- WLog_ERR(TAG, "_strdup failed!");
+ WLog_Print(audin->log, WLOG_ERROR, "_strdup failed!");
return ERROR_NOT_ENOUGH_MEMORY;
}
if (!audin->device_name)
{
- WLog_ERR(TAG, "_strdup failed!");
+ WLog_Print(audin->log, WLOG_ERROR, "_strdup failed!");
return ERROR_NOT_ENOUGH_MEMORY;
}
{
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;
}
}
{
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;
}
}
return CHANNEL_RC_NO_MEMORY;
}
+ audin->log = WLog_Get(TAG);
audin->data = Stream_New(NULL, 4096);
if (!audin->data)
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;
}
}
{
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++;
}
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:
#include <winpr/crt.h>
#include <winpr/cmdline.h>
+#include <winpr/wlog.h>
#include <pulse/pulseaudio.h>
void* user_data;
rdpContext* rdpcontext;
+ wLog* log;
} AudinPulseDevice;
static void audin_pulse_context_state_callback(pa_context* context, void* userdata)
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;
}
}
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;
}
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;
}
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;
}
}
pa_threaded_mainloop_unlock(pulse->mainloop);
- DEBUG_DVC("connected");
+ WLog_Print(pulse->log, WLOG_DEBUG, "connected");
return CHANNEL_RC_OK;
}
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;
}
}
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);
}
&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);
}
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);
}
pa_threaded_mainloop_unlock(pulse->mainloop);
pulse->buffer_frames = 0;
- DEBUG_DVC("connected");
+ WLog_Print(pulse->log, WLOG_DEBUG, "connected");
return CHANNEL_RC_OK;
}
if (!pulse->device_name)
{
- WLog_ERR(TAG, "_strdup failed!");
+ WLog_Print(pulse->log, WLOG_ERROR, "_strdup failed!");
return CHANNEL_RC_NO_MEMORY;
}
}
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;
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;
}
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;
}
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;
}
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;
}