Beispiel #1
0
int
jack_uuid_empty (const jack_uuid_t u)
{
        jack_uuid_t empty;
        VALGRIND_MEMSET(&empty, 0, sizeof(empty));
        uuid_clear (empty);
        if (jack_uuid_compare (u, empty) == 0) {
                return 1;
        }
        return 0;
}
Beispiel #2
0
jack_port_t *
jack_port_new (const jack_client_t *client, jack_port_id_t port_id,
	       jack_control_t *control)
{
	jack_port_shared_t *shared = &control->ports[port_id];
	jack_port_type_id_t ptid = shared->ptype_id;
	jack_port_t *port;

	if ((port = (jack_port_t*)malloc (sizeof(jack_port_t))) == NULL) {
		return NULL;
	}

	port->mix_buffer = NULL;
	port->client_segment_base = NULL;
	port->shared = shared;
	port->type_info = &client->engine->port_types[ptid];
	pthread_mutex_init (&port->connection_lock, NULL);
	port->connections = 0;
	port->tied = NULL;

	if (jack_uuid_compare (client->control->uuid, port->shared->client_id) == 0) {

		/* It's our port, so initialize the pointers to port
		 * functions within this address space.  These builtin
		 * definitions can be overridden by the client.
		 */
		jack_port_functions_t *port_functions = jack_get_port_functions (ptid);
		if (port_functions == NULL) {
			port_functions = &jack_builtin_NULL_functions;
		}
		port->fptr = *port_functions;
		port->shared->has_mixdown = (port->fptr.mixdown ? TRUE : FALSE);
	}

	/* set up a base address so that port->offset can be used to
	   compute the correct location. we don't store the location
	   directly, because port->client_segment_base and/or
	   port->offset can change if the buffer size or port counts
	   are changed.
	 */

	port->client_segment_base =
		(void**)&client->port_segment[ptid].attached_at;

	return port;
}
Beispiel #3
0
int 
jack_port_is_mine (const jack_client_t *client, const jack_port_t *port)
{
	return jack_uuid_compare (port->shared->client_id, client->control->uuid) == 0;
}
Beispiel #4
0
int
jack_get_all_properties (jack_description_t** descriptions)
{
        DBT key;
        DBT data;
        DBC* cursor;
        int ret;
        size_t dcnt = 0;
        size_t dsize = 0;
        size_t n = 0;
        jack_description_t* desc = NULL;
        jack_uuid_t uuid;
        jack_description_t* current_desc = NULL;
        jack_property_t* current_prop = NULL;
        size_t len1, len2;

        if (jack_property_init (NULL)) {
                return -1;
        }

        if ((ret = db->cursor (db, NULL, &cursor, 0)) != 0) {
                jack_error ("Cannot create cursor for metadata search (%s)", db_strerror (ret));
                return -1;
        }

        memset(&key, 0, sizeof(key));
	memset(&data, 0, sizeof(data));
        data.flags = DB_DBT_MALLOC;

        dsize = 8; /* initial guess at number of descriptions we need */
        dcnt = 0;
        desc = (jack_description_t*) malloc (dsize * sizeof (jack_description_t));

        while ((ret = cursor->get(cursor, &key, &data, DB_NEXT)) == 0) {

                /* require 2 extra chars (data+null) for key,
                   which is composed of UUID str plus a key name
                */

                if (key.size < JACK_UUID_STRING_SIZE + 2) {
                        if (data.size > 0) {
                                free (data.data);
                        }
                        continue;
                }

                if (jack_uuid_parse (key.data, uuid) != 0) {
                        continue;
                }
                
                /* do we have an existing description for this UUID */

                for (n = 0; n < dcnt ; ++n) {
                        if (jack_uuid_compare (uuid, desc[n].subject) == 0) {
                                break;
                        }
                }
                
                if (n == dcnt) {
                        /* we do not have an existing description, so grow the array */

                        if (dcnt == dsize) {
                                dsize *= 2;
                                desc = (jack_description_t*) realloc (desc, sizeof (jack_description_t) * dsize);
                        } 

                        /* initialize */

                        desc[n].property_size = 0;
                        desc[n].property_cnt = 0;
                        desc[n].properties = NULL;
                        
                        /* set up UUID */

                        jack_uuid_copy (desc[n].subject, uuid);
                        dcnt++;
                }

                current_desc = &desc[n];

                /* see if there is room for the new property or if we need to realloc 
                 */

                if (current_desc->property_cnt == current_desc->property_size) {
                        if (current_desc->property_size == 0) {
                                current_desc->property_size = 8;
                        } else {
                                current_desc->property_size *= 2;
                        }

                        current_desc->properties = (jack_property_t*) realloc (current_desc->properties, sizeof (jack_property_t) * current_desc->property_size);
                }
                
                current_prop = &current_desc->properties[current_desc->property_cnt++];
                
                /* copy key (without leading UUID) */

                len1 = key.size - JACK_UUID_STRING_SIZE;
                current_prop->key = malloc (len1);
                memcpy ((char*) current_prop->key, key.data + JACK_UUID_STRING_SIZE, len1);
                
                /* copy data (which contains 1 or 2 null terminated strings, the value
                   and optionally a MIME type.
                 */

                len1 = strlen (data.data) + 1;
                current_prop->data = (char *) malloc (len1);
                memcpy ((char*) current_prop->data, data.data, len1);
                
                if (len1 < data.size) {
                        len2 = strlen (data.data+len1) + 1;
                        
                        current_prop->type= (char *) malloc (len2);
                        memcpy ((char*) current_prop->type, data.data+len1, len2);
                } else {
                        /* no type specified, assume default */
                        current_prop->type = NULL;
                }
                
                if (data.size) {
                        free (data.data);
                }
        }
        
        cursor->close (cursor);

        (*descriptions) = desc;

        return dcnt;
}