summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2024-10-11 18:40:02 -0400
committerDavid Robillard <d@drobilla.net>2024-10-11 18:40:02 -0400
commit1ef508b8259f91015570d28ccd47139fe6ddbfcc (patch)
treef46b3d7b4304f81a19cb2a361746786069f6f41a /src
parent3bcdeb14bb048f46e1e9ba03e17db5b01b6ebb51 (diff)
downloadpatchage-1ef508b8259f91015570d28ccd47139fe6ddbfcc.tar.gz
patchage-1ef508b8259f91015570d28ccd47139fe6ddbfcc.tar.bz2
patchage-1ef508b8259f91015570d28ccd47139fe6ddbfcc.zip
Avoid virtual calls in destructors
Diffstat (limited to 'src')
-rw-r--r--src/AlsaDriver.cpp5
-rw-r--r--src/Drivers.cpp11
-rw-r--r--src/Drivers.hpp4
-rw-r--r--src/JackLibDriver.cpp5
4 files changed, 15 insertions, 10 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp
index 7671402..20f86f6 100644
--- a/src/AlsaDriver.cpp
+++ b/src/AlsaDriver.cpp
@@ -133,10 +133,7 @@ AlsaDriver::AlsaDriver(ILog& log, EventSink emit_event)
, _log(log)
{}
-AlsaDriver::~AlsaDriver()
-{
- detach();
-}
+AlsaDriver::~AlsaDriver() = default;
void
AlsaDriver::attach(bool /*launch_daemon*/)
diff --git a/src/Drivers.cpp b/src/Drivers.cpp
index 94efd14..7104b00 100644
--- a/src/Drivers.cpp
+++ b/src/Drivers.cpp
@@ -27,6 +27,17 @@ Drivers::Drivers(ILog& log, Driver::EventSink emit_event)
})}
{}
+Drivers::~Drivers()
+{
+ if (_alsa_driver) {
+ _alsa_driver->detach();
+ }
+
+ if (_jack_driver) {
+ _jack_driver->detach();
+ }
+}
+
void
Drivers::refresh()
{
diff --git a/src/Drivers.hpp b/src/Drivers.hpp
index 6bb9eb4..a281d2e 100644
--- a/src/Drivers.hpp
+++ b/src/Drivers.hpp
@@ -4,13 +4,13 @@
#ifndef PATCHAGE_DRIVERS_HPP
#define PATCHAGE_DRIVERS_HPP
-#include "AudioDriver.hpp"
#include "Driver.hpp"
#include <memory>
namespace patchage {
+class AudioDriver;
class ILog;
enum class ClientType;
@@ -26,7 +26,7 @@ public:
Drivers(Drivers&&) = delete;
Drivers& operator=(Drivers&&) = delete;
- ~Drivers() = default;
+ ~Drivers();
/// Refresh all drivers and emit results to the event sink
void refresh();
diff --git a/src/JackLibDriver.cpp b/src/JackLibDriver.cpp
index 6df5b02..b540347 100644
--- a/src/JackLibDriver.cpp
+++ b/src/JackLibDriver.cpp
@@ -104,10 +104,7 @@ JackLibDriver::JackLibDriver(ILog& log, EventSink emit_event)
, _log{log}
{}
-JackLibDriver::~JackLibDriver()
-{
- detach();
-}
+JackLibDriver::~JackLibDriver() = default;
void
JackLibDriver::attach(const bool launch_daemon)