示例#1
0
char *
jack_get_internal_client_name (jack_client_t *client,
			       jack_intclient_t intclient)
{
	jack_request_t req;
	char *name;

	memset (&req, 0, sizeof (req));
	req.type = IntClientName;
	req.x.intclient.options = JackNullOption;
	jack_uuid_copy (req.x.intclient.uuid, intclient);

	jack_client_deliver_request (client, &req);

	if (req.status & JackFailure) {
		return NULL;
	}

	/* allocate storage for returning the name */
	if ((name = strdup (req.x.intclient.name)) == NULL) {
		return NULL;
	}

	return name;
}
示例#2
0
int
jack_internal_client_handle (jack_client_t *client,
			     const char *client_name,
			     jack_status_t *status,
                             jack_intclient_t handle)
{
	jack_request_t req;
	jack_status_t my_status;

	if (status == NULL)		/* no status from caller? */
		status = &my_status;	/* use local status word */
	*status = 0;

	memset (&req, 0, sizeof (req));
	req.type = IntClientHandle;
	req.x.intclient.options = JackNullOption;
	strncpy (req.x.intclient.name, client_name,
		 sizeof (req.x.intclient.name));

	*status = jack_client_deliver_request (client, &req);

        if (!jack_uuid_empty (req.x.intclient.uuid)) {
                jack_uuid_copy (handle, req.x.intclient.uuid);
                return 0;
        }

        return -1;
}
示例#3
0
static int
jack_intclient_request(RequestType type, jack_client_t *client,
                       const char* client_name, jack_options_t options,
                       jack_status_t *status, jack_intclient_t uuid, jack_varargs_t *va)
{
	jack_request_t req;

	memset (&req, 0, sizeof (req));

	if (strlen (client_name) >= sizeof (req.x.intclient.name)) {
		jack_error ("\"%s\" is too long for a JACK client name.\n"
			    "Please use %lu characters or less.",
			    client_name, sizeof (req.x.intclient.name));
		return -1;
	}

	if (va->load_name
	    && (strlen (va->load_name) > sizeof (req.x.intclient.path) - 1)) {
		jack_error ("\"%s\" is too long for a shared object name.\n"
			     "Please use %lu characters or less.",
			    va->load_name, sizeof (req.x.intclient.path) - 1);
		*status |= (JackFailure|JackInvalidOption);
		return -1;
	}

	if (va->load_init
	    && (strlen (va->load_init) > sizeof (req.x.intclient.init) - 1)) {
		jack_error ("\"%s\" is too long for internal client init "
			    "string.\nPlease use %lu characters or less.",
			    va->load_init, sizeof (req.x.intclient.init) - 1);
		*status |= (JackFailure|JackInvalidOption);
		return -1;
	}

	req.type = type;
	req.x.intclient.options = options;
	strncpy (req.x.intclient.name, client_name,
		 sizeof (req.x.intclient.name));
	if (va->load_name)
		strncpy (req.x.intclient.path, va->load_name,
			 sizeof (req.x.intclient.path));
	if (va->load_init)
		strncpy (req.x.intclient.init, va->load_init,
			 sizeof (req.x.intclient.init));

	jack_client_deliver_request (client, &req);

	*status |= req.status;

	if (*status & JackFailure)
		return -1;

	jack_uuid_copy (uuid, req.x.intclient.uuid);
        return 0;
}
示例#4
0
文件: port.c 项目: josh-helpert/jack1
jack_port_t *
jack_port_register (jack_client_t *client, 
		    const char *port_name,
		    const char *port_type,
		    unsigned long flags,
		    unsigned long buffer_size)
{
	jack_request_t req;
	jack_port_t *port = 0;
	int length ;

        VALGRIND_MEMSET (&req, 0, sizeof (req));

	req.type = RegisterPort;

	length = strlen ((const char *) client->control->name)
		+ 1 + strlen (port_name);
	if ( length >= sizeof (req.x.port_info.name) ) {
	  jack_error ("\"%s:%s\" is too long to be used as a JACK port name.\n"
		      "Please use %lu characters or less.",
		      client->control->name , 
		      port_name,
		      sizeof (req.x.port_info.name) - 1);
	  return NULL ;
	}

	strcpy ((char *) req.x.port_info.name,
		(const char *) client->control->name);
	strcat ((char *) req.x.port_info.name, ":");
	strcat ((char *) req.x.port_info.name, port_name);

	snprintf (req.x.port_info.type, sizeof (req.x.port_info.type),
		  "%s", port_type);
	req.x.port_info.flags = flags;
	req.x.port_info.buffer_size = buffer_size;
	jack_uuid_copy (req.x.port_info.client_id, client->control->uuid);

	if (jack_client_deliver_request (client, &req)) {
		jack_error ("cannot deliver port registration request");
		return NULL;
	}

	if ((port = jack_port_new (client, req.x.port_info.port_id,
				   client->engine)) == NULL) {
		jack_error ("cannot allocate client side port structure");
		return NULL;
	}

	client->ports = jack_slist_prepend (client->ports, port);

	return port;
}
示例#5
0
文件: port.c 项目: josh-helpert/jack1
int 
jack_port_unregister (jack_client_t *client, jack_port_t *port)
{
	jack_request_t req;
        
        VALGRIND_MEMSET (&req, 0, sizeof (req));


	req.type = UnRegisterPort;
	req.x.port_info.port_id = port->shared->id;
	jack_uuid_copy (req.x.port_info.client_id, client->control->uuid);

	return jack_client_deliver_request (client, &req);
}
示例#6
0
static int
jack_property_change_notify (jack_client_t* client, jack_uuid_t uuid, const char* key, jack_property_change_t change)
{
        jack_request_t req;

        /* the engine passes in a NULL client when it removes metadata during port or client removal
         */

        if (client == NULL) {
                return 0;
        }

        req.type = PropertyChangeNotify;
        req.x.property.change = change;
        jack_uuid_copy (req.x.property.uuid, uuid);
        req.x.property.keylen = key ? strlen (key) + 1 : 0;
        req.x.property.key = key;
        return jack_client_deliver_request (client, &req);
}
示例#7
0
文件: thread.c 项目: Llefjord/jack1
static void
maybe_get_capabilities (jack_client_t* client)
{
#ifdef USE_CAPABILITIES

	if (client != 0) {
		
		jack_request_t req;

		if (client->engine->has_capabilities != 0) {
			
			/* we need to ask the engine for realtime capabilities
			   before trying to run the thread work function
			*/
			
                        VALGRIND_MEMSET (&req, 0, sizeof (req));
		
			req.type = SetClientCapabilities;
			req.x.cap_pid = getpid();
			
			jack_client_deliver_request (client, &req);
			
			if (req.status) {
				
				/* what to do? engine is running realtime, it
				   is using capabilities and has them
				   (otherwise we would not get an error
				   return) but for some reason it could not
				   give the client the required capabilities.
				   for now, allow the client to run, albeit
				   non-realtime.
				*/
				
				jack_error ("could not receive realtime capabilities, "
					    "client will run non-realtime");
				
			}
		}
	}
#endif /* USE_CAPABILITIES */
}	
示例#8
0
jack_status_t
jack_internal_client_unload (jack_client_t *client,
			     jack_intclient_t intclient)
{
	jack_request_t req;
	jack_status_t status;

	if (intclient) {

		memset (&req, 0, sizeof (req));
		req.type = IntClientUnload;
		req.x.intclient.options = JackNullOption;
		jack_uuid_copy (req.x.intclient.uuid, intclient);
		jack_client_deliver_request (client, &req);
		status = req.status;

	} else {			/* intclient is null */
		status = (JackNoSuchClient|JackFailure);
	}

	return status;
}
示例#9
0
文件: port.c 项目: DrAndromeda/jack1
int
jack_port_rename (jack_client_t* client, jack_port_t *port, const char *new_name)
{
	int ret;
	char* old_name = strdup (port->shared->name);

	if ((ret = jack_port_set_name (port, new_name)) == 0) {

		/* tell server about name change */
		jack_request_t req;

		req.type = PortNameChanged;

		/* re-purpose an appropriate part of the request union to convey the names */
		snprintf ((char*)req.x.connect.source_port, JACK_PORT_NAME_SIZE - 1, "%s", old_name);
		snprintf ((char*)req.x.connect.destination_port, JACK_PORT_NAME_SIZE - 1, "%s", new_name);

		(void)jack_client_deliver_request (client, &req);
	}

	free (old_name);

	return ret;
}