/* configuration */
const char *address;
const char *binary;
+ const char *log;
/* asm-bridge management */
pid_t pid;
enum {
ARG_ASM_BRIDGE,
+ ARG_ASM_BRIDGE_LOG,
ARG_ASM_ZONE,
ARG_ASM_TPORT_ADDRESS,
ARG_ASM_PLAYBACK_RESOURCE,
static asm_to_lib_t *process_msg(lib_to_asm_t *msg, asm_data_t *ctx)
{
pid_t pid = msg->instance_id;
+ mrp_attr_t attrs[2];
+ char pidbuf[32];
asm_to_lib_t *reply;
goto error;
}
+ snprintf(pidbuf, sizeof(pidbuf), "%u", d->pid);
+ attrs[0].type = mqi_string;
+ attrs[0].name = "pid";
+ attrs[0].value.string = pidbuf;
+ attrs[1].name = NULL;
+
if (mrp_resource_set_add_resource(d->rset,
- ctx->playback_resource, rset_data->shared, NULL,
+ ctx->playback_resource, rset_data->shared,
+ &attrs[0],
rset_data->mandatory) < 0) {
mrp_log_error("Failed to add playback resource!");
mrp_resource_set_destroy(d->rset);
ctx->address = args[ARG_ASM_TPORT_ADDRESS].str;
ctx->binary = args[ARG_ASM_BRIDGE].str;
ctx->zone = args[ARG_ASM_ZONE].str;
+ ctx->log = args[ARG_ASM_BRIDGE_LOG].str;
ctx->playback_resource = args[ARG_ASM_PLAYBACK_RESOURCE].str;
ctx->recording_resource = args[ARG_ASM_RECORDING_RESOURCE].str;
mrp_log_error("close_fds() failed");
exit(1);
}
+ if (ctx->log != NULL)
+ setenv(ASM_BRIDGE_LOG_ENVVAR, ctx->log, 1);
execl(ctx->binary, ctx->binary, ctx->address, NULL);
exit(1);
}
static mrp_plugin_arg_t args[] = {
MRP_PLUGIN_ARGIDX(ARG_ASM_BRIDGE, STRING, "asm_bridge", "/usr/sbin/asm-bridge"),
+ MRP_PLUGIN_ARGIDX(ARG_ASM_BRIDGE_LOG, STRING, "asm_bridge_log", NULL),
MRP_PLUGIN_ARGIDX(ARG_ASM_ZONE, STRING, "zone", "default"),
MRP_PLUGIN_ARGIDX(ARG_ASM_TPORT_ADDRESS, STRING, "tport_address", "unxs:/tmp/murphy/asm"),
MRP_PLUGIN_ARGIDX(ARG_ASM_PLAYBACK_RESOURCE, STRING, "playback_resource", "audio_playback"),
static int log_init(const char *filename)
{
- logfile = fopen(filename, "w");
+ if (filename != NULL) {
+ logfile = fopen(filename, "w");
- if (!logfile)
- return -1;
+ if (!logfile)
+ return -1;
+ }
+ else
+ logfile = NULL;
return 0;
}
ctx_t ctx;
ctx.watched_files = NULL;
-#if 0
- log_init("/tmp/asm-bridge-log");
-#else
- logfile = NULL;
-#endif
+ log_init(getenv(ASM_BRIDGE_LOG_ENVVAR));
/* set up the signal handling */