From 71bea3e1d0998ce26ee757aa63bb200181f69b33 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Sun, 28 Feb 2016 19:56:57 +0100 Subject: [PATCH] Fixed argument parsing for audin. --- channels/audin/client/audin_main.c | 84 ++++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index 373ae86..d72e155 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -38,13 +38,13 @@ #include #include "audin_main.h" -#define MSG_SNDIN_VERSION 0x01 -#define MSG_SNDIN_FORMATS 0x02 -#define MSG_SNDIN_OPEN 0x03 -#define MSG_SNDIN_OPEN_REPLY 0x04 -#define MSG_SNDIN_DATA_INCOMING 0x05 -#define MSG_SNDIN_DATA 0x06 -#define MSG_SNDIN_FORMATCHANGE 0x07 +#define MSG_SNDIN_VERSION 0x01 +#define MSG_SNDIN_FORMATS 0x02 +#define MSG_SNDIN_OPEN 0x03 +#define MSG_SNDIN_OPEN_REPLY 0x04 +#define MSG_SNDIN_DATA_INCOMING 0x05 +#define MSG_SNDIN_DATA 0x06 +#define MSG_SNDIN_FORMATCHANGE 0x07 typedef struct _AUDIN_LISTENER_CALLBACK AUDIN_LISTENER_CALLBACK; struct _AUDIN_LISTENER_CALLBACK @@ -93,6 +93,8 @@ struct _AUDIN_PLUGIN rdpContext* rdpcontext; }; +static BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args); + /** * Function description * @@ -639,8 +641,12 @@ static UINT audin_load_device_plugin(IWTSPlugin* pPlugin, const char* name, ADDI { PFREERDP_AUDIN_DEVICE_ENTRY entry; FREERDP_AUDIN_DEVICE_ENTRY_POINTS entryPoints; + AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*)pPlugin; UINT error; + if (!audin_process_addin_args(audin, args)) + return CHANNEL_RC_INITIALIZATION_ERROR; + entry = (PFREERDP_AUDIN_DEVICE_ENTRY) freerdp_load_channel_addin_entry("audin", (LPSTR) name, NULL, 0); if (entry == NULL) @@ -660,6 +666,7 @@ static UINT audin_load_device_plugin(IWTSPlugin* pPlugin, const char* name, ADDI return error; } + WLog_INFO(TAG, "Loaded %s backend for audin", name); return CHANNEL_RC_OK; } @@ -707,18 +714,19 @@ static COMMAND_LINE_ARGUMENT_A audin_args[] = { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } }; -static BOOL audin_process_addin_args(IWTSPlugin* pPlugin, ADDIN_ARGV* args) +BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args) { int status; DWORD flags; COMMAND_LINE_ARGUMENT_A* arg; - AUDIN_PLUGIN* audin = (AUDIN_PLUGIN*) pPlugin; UINT error; - flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON; + flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_IGN_UNKNOWN_KEYWORD; status = CommandLineParseArgumentsA(args->argc, (const char**) args->argv, audin_args, flags, audin, NULL, NULL); + if (status != 0) + return FALSE; arg = audin_args; @@ -786,7 +794,7 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) char *device; }; - UINT error = CHANNEL_RC_OK; + UINT error = CHANNEL_RC_INITIALIZATION_ERROR; ADDIN_ARGV* args; AUDIN_PLUGIN* audin; struct SubsystemEntry entries[] = @@ -837,31 +845,53 @@ UINT DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints) args = pEntryPoints->GetPluginData(pEntryPoints); audin->rdpcontext = ((freerdp*)((rdpSettings*) pEntryPoints->GetRdpSettings(pEntryPoints))->instance)->context; - while (entry && entry->subsystem && !audin->device) + if (args) { - if ((error = audin_set_subsystem(audin, entry->subsystem))) - { - WLog_ERR(TAG, "audin_set_subsystem for %s failed with error %lu!", - 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 %lu!", - entry->subsystem, error); - } - else if ((error = audin_load_device_plugin((IWTSPlugin*) audin, audin->subsystem, args))) + if (!audin_process_addin_args(audin, args)) + goto out; + } + + if (audin->subsystem) + { + if ((error = audin_load_device_plugin((IWTSPlugin*) audin, audin->subsystem, args))) { WLog_ERR(TAG, "audin_load_device_plugin %s failed with error %lu!", - entry->subsystem, error); + audin->subsystem, error); + goto out; } + } + else + { + while (entry && entry->subsystem && !audin->device) + { + if ((error = audin_set_subsystem(audin, entry->subsystem))) + { + WLog_ERR(TAG, "audin_set_subsystem for %s failed with error %lu!", + 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 %lu!", + entry->subsystem, error); + } + else if ((error = audin_load_device_plugin((IWTSPlugin*) audin, audin->subsystem, args))) + { + WLog_ERR(TAG, "audin_load_device_plugin %s failed with error %lu!", + entry->subsystem, error); + } - entry++; + entry++; + } } if (audin->device == NULL) - { WLog_ERR(TAG, "no sound device."); - } + + error = CHANNEL_RC_OK; + +out: + if (error != CHANNEL_RC_OK) + audin_plugin_terminated((IWTSPlugin*)audin); return error; } -- 2.7.4