git-svn-id: svn+ssh://jackaudio.org/trunk/jack@1188 0c269be4-1314-0410-8aa9-9f06e86f4224tags/0.115.6
| @@ -76,7 +76,7 @@ struct _jack_engine { | |||||
| /* engine serialization -- use precedence for deadlock avoidance */ | /* engine serialization -- use precedence for deadlock avoidance */ | ||||
| pthread_mutex_t request_lock; /* precedes client_lock */ | pthread_mutex_t request_lock; /* precedes client_lock */ | ||||
| pthread_mutex_t client_lock; | |||||
| pthread_rwlock_t client_lock; | |||||
| pthread_mutex_t port_lock; | pthread_mutex_t port_lock; | ||||
| int process_errors; | int process_errors; | ||||
| int period_msecs; | int period_msecs; | ||||
| @@ -184,21 +184,26 @@ extern jack_timer_type_t clock_source; | |||||
| extern jack_client_internal_t * | extern jack_client_internal_t * | ||||
| jack_client_internal_by_id (jack_engine_t *engine, jack_client_id_t id); | jack_client_internal_by_id (jack_engine_t *engine, jack_client_id_t id); | ||||
| static inline void jack_rdlock_graph (jack_engine_t* engine) { | |||||
| DEBUG ("acquiring graph read lock"); | |||||
| pthread_rwlock_rdlock (&engine->client_lock); | |||||
| } | |||||
| static inline void jack_lock_graph (jack_engine_t* engine) { | static inline void jack_lock_graph (jack_engine_t* engine) { | ||||
| DEBUG ("acquiring graph lock"); | DEBUG ("acquiring graph lock"); | ||||
| pthread_mutex_lock (&engine->client_lock); | |||||
| pthread_rwlock_wrlock (&engine->client_lock); | |||||
| } | } | ||||
| static inline int jack_try_lock_graph (jack_engine_t *engine) | |||||
| static inline int jack_try_rdlock_graph (jack_engine_t *engine) | |||||
| { | { | ||||
| DEBUG ("TRYING to acquiring graph lock"); | |||||
| return pthread_mutex_trylock (&engine->client_lock); | |||||
| DEBUG ("TRYING to acquiring graph read lock"); | |||||
| return pthread_rwlock_tryrdlock (&engine->client_lock); | |||||
| } | } | ||||
| static inline void jack_unlock_graph (jack_engine_t* engine) | static inline void jack_unlock_graph (jack_engine_t* engine) | ||||
| { | { | ||||
| DEBUG ("releasing graph lock"); | DEBUG ("releasing graph lock"); | ||||
| pthread_mutex_unlock (&engine->client_lock); | |||||
| pthread_rwlock_unlock (&engine->client_lock); | |||||
| } | } | ||||
| static inline unsigned int jack_power_of_two (unsigned int n) | static inline unsigned int jack_power_of_two (unsigned int n) | ||||
| @@ -292,7 +292,7 @@ jack_client_by_name (jack_engine_t *engine, const char *name) | |||||
| jack_client_internal_t *client = NULL; | jack_client_internal_t *client = NULL; | ||||
| JSList *node; | JSList *node; | ||||
| jack_lock_graph (engine); | |||||
| jack_rdlock_graph (engine); | |||||
| for (node = engine->clients; node; node = jack_slist_next (node)) { | for (node = engine->clients; node; node = jack_slist_next (node)) { | ||||
| if (strcmp ((const char *) ((jack_client_internal_t *) | if (strcmp ((const char *) ((jack_client_internal_t *) | ||||
| @@ -313,7 +313,7 @@ jack_client_id_by_name (jack_engine_t *engine, const char *name) | |||||
| jack_client_id_t id = 0; /* NULL client ID */ | jack_client_id_t id = 0; /* NULL client ID */ | ||||
| JSList *node; | JSList *node; | ||||
| jack_lock_graph (engine); | |||||
| jack_rdlock_graph (engine); | |||||
| for (node = engine->clients; node; node = jack_slist_next (node)) { | for (node = engine->clients; node; node = jack_slist_next (node)) { | ||||
| if (strcmp ((const char *) ((jack_client_internal_t *) | if (strcmp ((const char *) ((jack_client_internal_t *) | ||||
| @@ -948,7 +948,7 @@ jack_intclient_name_request (jack_engine_t *engine, jack_request_t *req) | |||||
| { | { | ||||
| jack_client_internal_t *client; | jack_client_internal_t *client; | ||||
| jack_lock_graph (engine); | |||||
| jack_rdlock_graph (engine); | |||||
| if ((client = jack_client_internal_by_id (engine, | if ((client = jack_client_internal_by_id (engine, | ||||
| req->x.intclient.id))) { | req->x.intclient.id))) { | ||||
| strncpy ((char *) req->x.intclient.name, | strncpy ((char *) req->x.intclient.name, | ||||
| @@ -1392,7 +1392,7 @@ handle_external_client_request (jack_engine_t *engine, int fd) | |||||
| DEBUG ("HIT: before lock"); | DEBUG ("HIT: before lock"); | ||||
| jack_lock_graph (engine); | |||||
| jack_rdlock_graph (engine); | |||||
| DEBUG ("HIT: before for"); | DEBUG ("HIT: before for"); | ||||
| @@ -1694,7 +1694,7 @@ jack_engine_new (int realtime, int rtpriority, int do_mlock, int do_unlock, | |||||
| jack_engine_reset_rolling_usecs (engine); | jack_engine_reset_rolling_usecs (engine); | ||||
| engine->max_usecs = 0.0f; | engine->max_usecs = 0.0f; | ||||
| pthread_mutex_init (&engine->client_lock, 0); | |||||
| pthread_rwlock_init (&engine->client_lock, 0); | |||||
| pthread_mutex_init (&engine->port_lock, 0); | pthread_mutex_init (&engine->port_lock, 0); | ||||
| pthread_mutex_init (&engine->request_lock, 0); | pthread_mutex_init (&engine->request_lock, 0); | ||||
| @@ -2051,7 +2051,7 @@ jack_run_one_cycle (jack_engine_t *engine, jack_nframes_t nframes, | |||||
| consecutive_excessive_delays = 0; | consecutive_excessive_delays = 0; | ||||
| } | } | ||||
| if (jack_try_lock_graph (engine)) { | |||||
| if (jack_try_rdlock_graph (engine)) { | |||||
| /* engine can't run. just throw away an entire cycle */ | /* engine can't run. just throw away an entire cycle */ | ||||
| driver->null_cycle (driver, nframes); | driver->null_cycle (driver, nframes); | ||||
| return 0; | return 0; | ||||
| @@ -3514,10 +3514,11 @@ jack_use_driver (jack_engine_t *engine, jack_driver_t *driver) | |||||
| engine->driver = 0; | engine->driver = 0; | ||||
| } | } | ||||
| engine->driver = driver; | |||||
| if (driver) { | if (driver) { | ||||
| engine->driver = driver; | |||||
| if (driver->attach (driver, engine)) { | if (driver->attach (driver, engine)) { | ||||
| engine->driver = 0; | |||||
| return -1; | return -1; | ||||
| } | } | ||||
| @@ -3773,7 +3774,7 @@ jack_do_get_port_connections (jack_engine_t *engine, jack_request_t *req, | |||||
| int ret = -1; | int ret = -1; | ||||
| int internal = FALSE; | int internal = FALSE; | ||||
| jack_lock_graph (engine); | |||||
| jack_rdlock_graph (engine); | |||||
| port = &engine->internal_ports[req->x.port_info.port_id]; | port = &engine->internal_ports[req->x.port_info.port_id]; | ||||