#include <freerdp/freerdp.h>
#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
rdpContext* rdpcontext;
};
+static BOOL audin_process_addin_args(AUDIN_PLUGIN* audin, ADDIN_ARGV* args);
+
/**
* Function description
*
{
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)
return error;
}
+ WLog_INFO(TAG, "Loaded %s backend for audin", name);
return CHANNEL_RC_OK;
}
{ 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;
char *device;
};
- UINT error = CHANNEL_RC_OK;
+ UINT error = CHANNEL_RC_INITIALIZATION_ERROR;
ADDIN_ARGV* args;
AUDIN_PLUGIN* audin;
struct SubsystemEntry entries[] =
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;
}