mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-27 00:47:43 +01:00
stop resetting _jack to zero to avoid crashing stupidly
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3647 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
4a42a635e5
commit
d44c033d0f
1 changed files with 39 additions and 37 deletions
|
|
@ -86,6 +86,7 @@ AudioEngine::~AudioEngine ()
|
|||
|
||||
if (_running) {
|
||||
jack_client_close (_jack);
|
||||
_jack = 0;
|
||||
}
|
||||
|
||||
stop_metering_thread ();
|
||||
|
|
@ -105,6 +106,11 @@ _thread_init_callback (void *arg)
|
|||
int
|
||||
AudioEngine::start ()
|
||||
{
|
||||
if (!_jack) {
|
||||
error << _("AudioEngine::start() called while disconnected from JACK") << endmsg;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!_running) {
|
||||
|
||||
if (session) {
|
||||
|
|
@ -163,17 +169,13 @@ AudioEngine::start ()
|
|||
int
|
||||
AudioEngine::stop (bool forever)
|
||||
{
|
||||
if (_running) {
|
||||
_running = false;
|
||||
stop_metering_thread ();
|
||||
if (_jack) {
|
||||
if (forever) {
|
||||
jack_client_t* foo = _jack;
|
||||
_jack = 0;
|
||||
jack_client_close (foo);
|
||||
disconnect_from_jack ();
|
||||
} else {
|
||||
jack_deactivate (_jack);
|
||||
Stopped(); /* EMIT SIGNAL */
|
||||
}
|
||||
Stopped(); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
return _running ? -1 : 0;
|
||||
|
|
@ -188,11 +190,13 @@ AudioEngine::get_sync_offset (nframes_t& offset) const
|
|||
|
||||
jack_position_t pos;
|
||||
|
||||
(void) jack_transport_query (_jack, &pos);
|
||||
|
||||
if (pos.valid & JackVideoFrameOffset) {
|
||||
offset = pos.video_offset;
|
||||
return true;
|
||||
if (_jack) {
|
||||
(void) jack_transport_query (_jack, &pos);
|
||||
|
||||
if (pos.valid & JackVideoFrameOffset) {
|
||||
offset = pos.video_offset;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -236,7 +240,7 @@ int
|
|||
AudioEngine::_xrun_callback (void *arg)
|
||||
{
|
||||
AudioEngine* ae = static_cast<AudioEngine*> (arg);
|
||||
if (ae->jack()) {
|
||||
if (ae->connected()) {
|
||||
ae->Xrun (); /* EMIT SIGNAL */
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -246,7 +250,7 @@ int
|
|||
AudioEngine::_graph_order_callback (void *arg)
|
||||
{
|
||||
AudioEngine* ae = static_cast<AudioEngine*> (arg);
|
||||
if (ae->jack()) {
|
||||
if (ae->connected()) {
|
||||
ae->GraphReordered (); /* EMIT SIGNAL */
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -803,7 +807,8 @@ AudioEngine::halted (void *arg)
|
|||
ae->_running = false;
|
||||
ae->_buffer_size = 0;
|
||||
ae->_frame_rate = 0;
|
||||
ae->_jack = 0;
|
||||
|
||||
cerr << "!!! HALTED !!!\n";
|
||||
|
||||
if (was_running) {
|
||||
ae->Halted(); /* EMIT SIGNAL */
|
||||
|
|
@ -921,13 +926,9 @@ AudioEngine::get_nth_physical_audio (uint32_t n, int flag)
|
|||
uint32_t i;
|
||||
string ret;
|
||||
|
||||
if (!_running || !_jack) {
|
||||
if (!_has_run) {
|
||||
fatal << _("get_nth_physical called before engine was started") << endmsg;
|
||||
/*NOTREACHED*/
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
if (!_jack) {
|
||||
fatal << _("get_nth_physical called before engine was connected") << endmsg;
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
ports = jack_get_ports (_jack, NULL, JACK_DEFAULT_AUDIO_TYPE, JackPortIsPhysical|flag);
|
||||
|
|
@ -955,20 +956,12 @@ AudioEngine::get_port_total_latency (const Port& port)
|
|||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
if (!_running) {
|
||||
if (!_has_run) {
|
||||
fatal << _("get_port_total_latency() called before engine was started") << endmsg;
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
}
|
||||
|
||||
return jack_port_get_total_latency (_jack, port._port);
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngine::transport_stop ()
|
||||
{
|
||||
// cerr << "tell JACK to stop\n";
|
||||
if (_jack) {
|
||||
jack_transport_stop (_jack);
|
||||
}
|
||||
|
|
@ -1112,7 +1105,7 @@ AudioEngine::connect_to_jack (string client_name)
|
|||
{
|
||||
jack_client_name = client_name;
|
||||
|
||||
if ((_jack = jack_client_new (client_name.c_str())) == NULL) {
|
||||
if ((_jack = jack_client_new (client_name.c_str())) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1124,29 +1117,36 @@ AudioEngine::connect_to_jack (string client_name)
|
|||
int
|
||||
AudioEngine::disconnect_from_jack ()
|
||||
{
|
||||
if (_jack == 0) {
|
||||
if (!_jack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
jack_client_close (_jack);
|
||||
|
||||
if (_running) {
|
||||
stop_metering_thread ();
|
||||
}
|
||||
|
||||
{
|
||||
Glib::Mutex::Lock lm (_process_lock);
|
||||
jack_client_close (_jack);
|
||||
_jack = 0;
|
||||
}
|
||||
|
||||
_buffer_size = 0;
|
||||
_frame_rate = 0;
|
||||
|
||||
if (_running) {
|
||||
stop_metering_thread ();
|
||||
_running = false;
|
||||
Stopped(); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
_jack = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
AudioEngine::reconnect_to_jack ()
|
||||
{
|
||||
if (_jack) {
|
||||
if (_running) {
|
||||
disconnect_from_jack ();
|
||||
/* XXX give jackd a chance */
|
||||
Glib::usleep (250000);
|
||||
|
|
@ -1272,7 +1272,9 @@ void
|
|||
AudioEngine::update_total_latencies ()
|
||||
{
|
||||
#ifdef HAVE_JACK_RECOMPUTE_LATENCIES
|
||||
jack_recompute_total_latencies (_jack);
|
||||
if (_jack) {
|
||||
jack_recompute_total_latencies (_jack);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue