summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt12
-rw-r--r--cmake/FindJack.cmake18
-rw-r--r--src/audio/audio_device.cpp44
-rw-r--r--src/audio/audio_device.h26
-rw-r--r--src/sys_settings.cpp9
6 files changed, 110 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index ecce011..d53551c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,7 @@ src/parser/scanner.cxx
src/sdp/sdp_parser.cxx
src/sdp/sdp_parser.hxx
src/sdp/sdp_scanner.cxx
+build/
# Qt Creator files
CMakeLists.txt.user*
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7e3fde0..a3f4e93 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,6 +16,7 @@ OPTION(WITH_ZRTP "Enable ZRTP encrypted calls" OFF)
OPTION(WITH_SPEEX "Enable the Speex codec" OFF)
OPTION(WITH_ILBC "Enable the iLBC codec" OFF)
OPTION(WITH_ALSA "Enable ALSA support" ON)
+OPTION(WITH_JACK "Enable JackAudio support" ON)
OPTION(WITH_DIAMONDCARD "Enable Diamondcard integration" OFF)
OPTION(WITH_QT5 "Enable Qt 5 GUI" ON)
CMAKE_DEPENDENT_OPTION(WITH_DBUS "Enable use of QtDBus (GUI only)" ON "WITH_QT5" OFF)
@@ -68,6 +69,17 @@ if (WITH_ALSA)
endif (ALSA_FOUND)
endif (WITH_ALSA)
+if (WITH_JACK)
+ find_package(Jack)
+
+ if (JACK_FOUND)
+ message(STATUS "jack OK")
+ set(HAVE_JACK TRUE)
+ else (JACK_FOUND)
+ message(FATAL_ERROR "jack not found!")
+ endif (JACK_FOUND)
+endif (WITH_JACK)
+
if (WITH_ZRTP)
find_package(Zrtpcpp)
diff --git a/cmake/FindJack.cmake b/cmake/FindJack.cmake
new file mode 100644
index 0000000..1391d98
--- /dev/null
+++ b/cmake/FindJack.cmake
@@ -0,0 +1,18 @@
+FIND_PATH(JACK_INCLUDE_DIR jack/jack.h)
+FIND_LIBRARY(JACK_LIBRARY NAMES jack)
+
+IF(JACK_INCLUDE_DIR AND JACK_LIBRARY)
+ SET(JACK_FOUND TRUE)
+ SET(JACK_LIBRARIES ${JACK_LIBRARY})
+ENDIF(JACK_INCLUDE_DIR AND JACK_LIBRARY)
+
+IF(JACK_FOUND)
+ IF (NOT Jack_FIND_QUIETLY)
+ MESSAGE(STATUS "Found jack includes: ${JACK_INCLUDE_DIR}/jack/jack.h")
+ MESSAGE(STATUS "Found jack library: ${JACK_LIBRARIES}")
+ ENDIF (NOT Jack_FIND_QUIETLY)
+ELSE(JACK_FOUND)
+ IF (Jack_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could NOT find jack development files")
+ ENDIF (Jack_FIND_REQUIRED)
+ENDIF(JACK_FOUND)
diff --git a/src/audio/audio_device.cpp b/src/audio/audio_device.cpp
index dd61e8d..df43c45 100644
--- a/src/audio/audio_device.cpp
+++ b/src/audio/audio_device.cpp
@@ -33,6 +33,10 @@
#include <alsa/asoundlib.h>
#endif
+#ifdef HAVE_JACK
+#include <jack/jack.h>
+#endif
+
t_audio_io* t_audio_io::open(const t_audio_device& dev, bool playback, bool capture, bool blocking, int channels, t_audio_sampleformat format, int sample_rate, bool short_latency)
{
t_audio_io* aio;
@@ -45,6 +49,11 @@ t_audio_io* t_audio_io::open(const t_audio_device& dev, bool playback, bool capt
aio = new t_alsa_io();
MEMMAN_NEW(aio);
#endif
+#ifdef HAVE_JACK
+ } elseif (dev.type == t_audio_device::JACK) {
+ aio = new t_jack_io();
+ MEMMAN_NEW(aio);
+#endif
} else {
string msg("Audio device not implemented");
log_file->write_report(msg, "t_audio_io::open",
@@ -350,6 +359,41 @@ int t_oss_io::write(const unsigned char* buf, int len) {
return ::write(fd, buf, len);
}
+#ifdef HAVE_JACK
+// Constructor
+t_jack_io::t_jack_io() : client(nullptr) {
+}
+
+// Opener
+bool t_jack_io::open(
+ const string& device,
+ bool playback,
+ bool capture,
+ bool blocking,
+ int channels, t_audio_sampleformat format,
+ int sample_rate,
+ bool short_latency
+ ) {
+ t_audio_io::open(
+ device,
+ playback,
+ capture,
+ blocking,
+ channels,
+ format,
+ sample_rate,
+ short_latency
+ );
+ int mode = 0;
+ string msg = "";
+
+
+// Destructor
+t_jack_io::~t_jack_io() {
+ jack_client_close(client);
+}
+#endif
+
#ifdef HAVE_LIBASOUND
t_alsa_io::t_alsa_io() : pcm_play_ptr(0), pcm_rec_ptr(0), play_framesize(1), rec_framesize(1),
diff --git a/src/audio/audio_device.h b/src/audio/audio_device.h
index 5adc1bb..ec81996 100644
--- a/src/audio/audio_device.h
+++ b/src/audio/audio_device.h
@@ -122,4 +122,30 @@ private:
};
#endif
+#ifdef HAVE_JACK
+class t_jack_io : public t_audio_io {
+public:
+ t_jack_io();
+ virtual ~t_jack_io();
+ void enable(bool enable_playback, bool enable_recording);
+ void flush(bool playback_buffer, bool recording_buffer);
+ int get_buffer_space(bool is_recording_buffer);
+ int get_buffer_size(bool is_recording_buffer);
+ bool play_buffer_underrun(void);
+ int read(unsigned char* buf, int len);
+ int write(const unsigned char* buf, int len);
+protected:
+ bool open(const string& device,
+ bool playback,
+ bool capture,
+ bool blocking,
+ int channels, t_audio_sampleformat format,
+ int sample_rate,
+ bool short_latency);
+private:
+ int fd;
+ int play_buffersize, rec_buffersize;
+};
+#endif
+
#endif
diff --git a/src/sys_settings.cpp b/src/sys_settings.cpp
index 475fa25..b4d6bf1 100644
--- a/src/sys_settings.cpp
+++ b/src/sys_settings.cpp
@@ -157,6 +157,12 @@ string t_audio_device::get_description(void) const {
s += ": ";
s += name;
}
+ } else if (type == JACK) {
+ s = "JACK: " +s;
+ if (!name.empty()) {
+ s += ": ";
+ s += name;
+ }
} else {
s = "Unknown: " + s;
}
@@ -174,6 +180,9 @@ string t_audio_device::get_settings_value(void) const {
case ALSA:
s = PFX_ALSA;
break;
+ case JACK:
+ s = PFX_JACK;
+ break;
default:
assert(false);
}