From 3527ad1ab8f1c6758d958dac21101a368c653155 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Mon, 26 Aug 2013 08:40:52 -0400 Subject: [PATCH] JACK: let Init do the cleanup on failure Previously, if Init failed, we were calling jack_client_close twice and segfaulting. --- src/arch/Sound/RageSoundDriver_JACK.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/arch/Sound/RageSoundDriver_JACK.cpp b/src/arch/Sound/RageSoundDriver_JACK.cpp index 770dcf528f..11a7f5e111 100644 --- a/src/arch/Sound/RageSoundDriver_JACK.cpp +++ b/src/arch/Sound/RageSoundDriver_JACK.cpp @@ -17,7 +17,14 @@ RageSoundDriver_JACK::RageSoundDriver_JACK() : RageSoundDriver_JACK::~RageSoundDriver_JACK() { - // Shut down client + // If Init failed, it cleaned up already and set client to NULL + if (client == NULL) + return; + + // Clean up and shut down client + jack_deactivate(client); + jack_port_unregister(client, port_r); + jack_port_unregister(client, port_l); jack_client_close(client); } @@ -99,6 +106,7 @@ out_unreg_l: jack_port_unregister(client, port_l); out_close: jack_client_close(client); + client = NULL; return error; }