Browse Source

fix ordering of ALSA driver startup operations, drop driver detach from shutdown pathway

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@775 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.109.0
pbd 21 years ago
parent
commit
9e41b507e5
7 changed files with 76 additions and 64 deletions
  1. +1
    -1
      configure.in
  2. +34
    -35
      drivers/alsa/alsa_driver.c
  3. +7
    -7
      jackd/engine.c
  4. +9
    -3
      libjack/client.c
  5. +22
    -18
      libjack/driver.c
  6. +2
    -0
      libjack/port.c
  7. +1
    -0
      libjack/transclient.c

+ 1
- 1
configure.in View File

@@ -15,7 +15,7 @@ dnl changes are made
dnl ---
JACK_MAJOR_VERSION=0
JACK_MINOR_VERSION=99
JACK_MICRO_VERSION=7
JACK_MICRO_VERSION=8

dnl ---
dnl HOWTO: updating the jack protocol version


+ 34
- 35
drivers/alsa/alsa_driver.c View File

@@ -50,7 +50,7 @@ extern void show_work_times ();
#undef DEBUG_WAKEUP

/* Delay (in process calls) before jackd will report an xrun */
#define XRUN_REPORT_DELAY 64
#define XRUN_REPORT_DELAY 0


static void
@@ -923,10 +923,41 @@ alsa_driver_start (alsa_driver_t *driver)
}

if (driver->hw_monitoring) {
driver->hw->set_input_monitor_mask (driver->hw,
driver->input_monitor_mask);
if (driver->input_monitor_mask || driver->all_monitor_in) {
if (driver->all_monitor_in) {
driver->hw->set_input_monitor_mask (driver->hw, ~0U);
} else {
driver->hw->set_input_monitor_mask (
driver->hw, driver->input_monitor_mask);
}
} else {
driver->hw->set_input_monitor_mask (driver->hw,
driver->input_monitor_mask);
}
}

if (driver->playback_handle) {
driver->playback_nfds =
snd_pcm_poll_descriptors_count (driver->playback_handle);
} else {
driver->playback_nfds = 0;
}

if (driver->capture_handle) {
driver->capture_nfds =
snd_pcm_poll_descriptors_count (driver->capture_handle);
} else {
driver->capture_nfds = 0;
}

if (driver->pfd) {
free (driver->pfd);
}

driver->pfd = (struct pollfd *)
malloc (sizeof (struct pollfd) *
(driver->playback_nfds + driver->capture_nfds + 2));

if (driver->playback_handle) {
/* fill playback buffer with zeroes, and mark
all fragments as having data.
@@ -977,38 +1008,6 @@ alsa_driver_start (alsa_driver_t *driver)
}
}
if (driver->hw_monitoring &&
(driver->input_monitor_mask || driver->all_monitor_in)) {
if (driver->all_monitor_in) {
driver->hw->set_input_monitor_mask (driver->hw, ~0U);
} else {
driver->hw->set_input_monitor_mask (
driver->hw, driver->input_monitor_mask);
}
}

if (driver->playback_handle) {
driver->playback_nfds =
snd_pcm_poll_descriptors_count (driver->playback_handle);
} else {
driver->playback_nfds = 0;
}

if (driver->capture_handle) {
driver->capture_nfds =
snd_pcm_poll_descriptors_count (driver->capture_handle);
} else {
driver->capture_nfds = 0;
}

if (driver->pfd) {
free (driver->pfd);
}

driver->pfd = (struct pollfd *)
malloc (sizeof (struct pollfd) *
(driver->playback_nfds + driver->capture_nfds + 2));

return 0;
}



+ 7
- 7
jackd/engine.c View File

@@ -1958,8 +1958,7 @@ jack_server_thread (void *arg)
break;
}

if (pfd[0].revents & POLLIN) {
if (engine->control->engine_ok && pfd[0].revents & POLLIN) {
DEBUG ("pfd[0].revents & POLLIN");

memset (&client_addr, 0, sizeof (client_addr));
@@ -1986,7 +1985,7 @@ jack_server_thread (void *arg)
break;
}

if (pfd[1].revents & POLLIN) {
if (engine->control->engine_ok && pfd[1].revents & POLLIN) {
DEBUG ("pfd[1].revents & POLLIN");

memset (&client_addr, 0, sizeof (client_addr));
@@ -2005,8 +2004,6 @@ jack_server_thread (void *arg)
close (client_socket);
}
}

}

return 0;
@@ -2554,13 +2551,16 @@ jack_engine_delete (jack_engine_t *engine)

engine->control->engine_ok = 0; /* tell clients we're going away */

/* shutdown master socket to prevent new clients arriving */
// close (engine->fds[0]);

if (engine->driver) {
jack_driver_t* driver = engine->driver;

VERBOSE (engine, "stopping driver\n");
driver->stop (driver);
VERBOSE (engine, "detaching driver\n");
driver->detach (driver, engine);
// VERBOSE (engine, "detaching driver\n");
// driver->detach (driver, engine);
VERBOSE (engine, "unloading driver\n");
jack_driver_unload (driver);
engine->driver = NULL;


+ 9
- 3
libjack/client.c View File

@@ -123,8 +123,9 @@ oop_client_deliver_request (void *ptr, jack_request_t *req)
rok = (read (client->request_fd, req, sizeof (*req))
== sizeof (*req));

if (wok && rok) /* everything OK? */
if (wok && rok) { /* everything OK? */
return req->status;
}

req->status = -1; /* request failed */

@@ -606,8 +607,13 @@ jack_request_client (ClientType type, const char* client_name,
"(duplicate client name?)");
goto fail;
}

jack_error ("cannot read response from jack server (%s)",
if (errno == ECONNRESET) {
jack_error ("could not attach as jack client (server has exited)");
goto fail;
}
jack_error ("cannot read regsponse from jack server (%s)",
strerror (errno));
goto fail;
}


+ 22
- 18
libjack/driver.c View File

@@ -116,11 +116,10 @@ jack_driver_nt_thread (void * arg)

pthread_mutex_lock (&driver->nt_run_lock);

while ( (run = driver->nt_run) == DRIVER_NT_RUN) {
while ((run = driver->nt_run) == DRIVER_NT_RUN) {
pthread_mutex_unlock (&driver->nt_run_lock);

rc = driver->nt_run_cycle (driver);
if (rc) {
if ((rc = driver->nt_run_cycle (driver)) != 0) {
jack_error ("DRIVER NT: could not run driver cycle");
goto out;
}
@@ -142,23 +141,30 @@ jack_driver_nt_start (jack_driver_nt_t * driver)
{
int err;

err = driver->nt_start (driver);
if (err) {
jack_error ("DRIVER NT: could not start driver");
return err;
}

/* stop the new thread from really starting until the driver has
been started.
*/
pthread_mutex_lock (&driver->nt_run_lock);
driver->nt_run = DRIVER_NT_RUN;

err = jack_create_thread (&driver->nt_thread,
driver->engine->rtpriority,
driver->engine->control->real_time,
jack_driver_nt_thread, driver);
if (err) {
if ((err = jack_create_thread (&driver->nt_thread,
driver->engine->rtpriority,
driver->engine->control->real_time,
jack_driver_nt_thread, driver)) != 0) {
jack_error ("DRIVER NT: could not start driver thread!");
driver->nt_stop (driver);
return err;
}
if ((err = driver->nt_start (driver)) != 0) {
jack_error ("DRIVER NT: could not start driver");
return err;
}

/* let the thread run, since the underlying "device" has now been started */

pthread_mutex_unlock (&driver->nt_run_lock);

return 0;
}
@@ -172,15 +178,13 @@ jack_driver_nt_do_stop (jack_driver_nt_t * driver, int run)
driver->nt_run = run;
pthread_mutex_unlock (&driver->nt_run_lock);

err = pthread_join (driver->nt_thread, NULL);
if (err) {
if ((err = pthread_join (driver->nt_thread, NULL)) != 0) {
jack_error ("DRIVER NT: error waiting for driver thread: %s",
strerror (err));
return err;
}

err = driver->nt_stop (driver);
if (err) {
if ((err = driver->nt_stop (driver)) != 0) {
jack_error ("DRIVER NT: error stopping driver");
return err;
}


+ 2
- 0
libjack/port.c View File

@@ -139,11 +139,13 @@ jack_port_register (jack_client_t *client,
req.x.port_info.client_id = client->control->id;

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;
}



+ 1
- 0
libjack/transclient.c View File

@@ -226,6 +226,7 @@ jack_frame_time (const jack_client_t *client)
jack_read_frame_time (client, &current);
usecs = jack_get_microseconds() - current.stamp;

elapsed = (jack_nframes_t)
floor ((((float) ectl->current_time.frame_rate)
/ 1000000.0f) * usecs);


Loading…
Cancel
Save