From aebd0a50d1981c92e4918923ac77c0ad95d167b7 Mon Sep 17 00:00:00 2001 From: Thomas Groman Date: Sun, 27 Oct 2019 00:20:29 -0700 Subject: added initial framework to hold jack code --- src/audio/audio_device.cpp | 9 +++++++++ src/audio/audio_device.h | 26 ++++++++++++++++++++++++++ src/sys_settings.cpp | 9 +++++++++ 3 files changed, 44 insertions(+) diff --git a/src/audio/audio_device.cpp b/src/audio/audio_device.cpp index dd61e8d..84aa2db 100644 --- a/src/audio/audio_device.cpp +++ b/src/audio/audio_device.cpp @@ -33,6 +33,10 @@ #include #endif +#ifdef HAVE_JACK +#include +#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; @@ -44,6 +48,11 @@ t_audio_io* t_audio_io::open(const t_audio_device& dev, bool playback, bool capt } else if (dev.type == t_audio_device::ALSA) { 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"); 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 bb07539..32d215d 100644 --- a/src/sys_settings.cpp +++ b/src/sys_settings.cpp @@ -153,6 +153,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; } @@ -170,6 +176,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); } -- cgit v1.2.3