Commit cf1cf045 authored by sletz's avatar sletz
Browse files

Correct ressource leak in JackCoreMidiOutputPort.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4615 0c269be4-1314-0410-8aa9-9f06e86f4224
parent a35832d2
......@@ -875,66 +875,72 @@ jackctl_server_open(
jackctl_server *server_ptr,
jackctl_driver *driver_ptr)
{
if (!server_ptr || !driver_ptr) {
return false;
}
try {
int rc = jack_register_server(server_ptr->name.str, server_ptr->replace_registry.b);
switch (rc)
{
case EEXIST:
jack_error("`%s' server already active", server_ptr->name.str);
goto fail;
case ENOSPC:
jack_error("too many servers already active");
goto fail;
case ENOMEM:
jack_error("no access to shm registry");
goto fail;
}
if (!server_ptr || !driver_ptr) {
return false;
}
jack_log("server `%s' registered", server_ptr->name.str);
int rc = jack_register_server(server_ptr->name.str, server_ptr->replace_registry.b);
switch (rc)
{
case EEXIST:
jack_error("`%s' server already active", server_ptr->name.str);
goto fail;
case ENOSPC:
jack_error("too many servers already active");
goto fail;
case ENOMEM:
jack_error("no access to shm registry");
goto fail;
}
/* clean up shared memory and files from any previous
* instance of this server name */
jack_cleanup_shm();
JackTools::CleanupFiles(server_ptr->name.str);
jack_log("server `%s' registered", server_ptr->name.str);
if (!server_ptr->realtime.b && server_ptr->client_timeout.i == 0) {
server_ptr->client_timeout.i = 500; /* 0.5 sec; usable when non realtime. */
}
/* clean up shared memory and files from any previous
* instance of this server name */
jack_cleanup_shm();
JackTools::CleanupFiles(server_ptr->name.str);
/* check port max value before allocating server */
if (server_ptr->port_max.ui > PORT_NUM_MAX) {
jack_error("JACK server started with too much ports %d (when port max can be %d)", server_ptr->port_max.ui, PORT_NUM_MAX);
goto fail;
}
if (!server_ptr->realtime.b && server_ptr->client_timeout.i == 0) {
server_ptr->client_timeout.i = 500; /* 0.5 sec; usable when non realtime. */
}
/* get the engine/driver started */
server_ptr->engine = new JackServer(
server_ptr->sync.b,
server_ptr->temporary.b,
server_ptr->client_timeout.i,
server_ptr->realtime.b,
server_ptr->realtime_priority.i,
server_ptr->port_max.ui,
server_ptr->verbose.b,
(jack_timer_type_t)server_ptr->clock_source.ui,
server_ptr->name.str);
if (server_ptr->engine == NULL)
{
jack_error("Failed to create new JackServer object");
goto fail_unregister;
}
/* check port max value before allocating server */
if (server_ptr->port_max.ui > PORT_NUM_MAX) {
jack_error("JACK server started with too much ports %d (when port max can be %d)", server_ptr->port_max.ui, PORT_NUM_MAX);
goto fail;
}
rc = server_ptr->engine->Open(driver_ptr->desc_ptr, driver_ptr->set_parameters);
if (rc < 0)
{
jack_error("JackServer::Open() failed with %d", rc);
goto fail_delete;
}
/* get the engine/driver started */
server_ptr->engine = new JackServer(
server_ptr->sync.b,
server_ptr->temporary.b,
server_ptr->client_timeout.i,
server_ptr->realtime.b,
server_ptr->realtime_priority.i,
server_ptr->port_max.ui,
server_ptr->verbose.b,
(jack_timer_type_t)server_ptr->clock_source.ui,
server_ptr->name.str);
if (server_ptr->engine == NULL)
{
jack_error("Failed to create new JackServer object");
goto fail_unregister;
}
return true;
rc = server_ptr->engine->Open(driver_ptr->desc_ptr, driver_ptr->set_parameters);
if (rc < 0)
{
jack_error("JackServer::Open() failed with %d", rc);
goto fail_delete;
}
return true;
} catch (std::exception e) {
jack_error("jackctl_server_open error...");
}
fail_delete:
delete server_ptr->engine;
......
......@@ -187,6 +187,7 @@ destroy_semaphore(semaphore_t semaphore, int id)
{
char name[128];
sprintf(name, "midi_sem_%d", id);
sem_close(semaphore);
sem_unlink(name);
}
#else
......
......@@ -54,7 +54,7 @@ JackCoreMidiOutputPort::JackCoreMidiOutputPort(double time_ratio,
JackCoreMidiOutputPort::~JackCoreMidiOutputPort()
{
delete thread;
sem_destroy(thread_queue_semaphore);
sem_close(thread_queue_semaphore);
sem_unlink(semaphore_name);
delete read_queue;
delete thread_queue;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment