diff options
author | David Robillard <d@drobilla.net> | 2010-01-05 21:55:24 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-01-05 21:55:24 +0000 |
commit | 566479a3ac4c8c6c9d190d6b4e8ecd104402180c (patch) | |
tree | 345297b440e7ba20f03d2cca70810c0e653f665c /src/engine/JackAudioDriver.hpp | |
parent | 534b3d2248884d5a8352c2239c668e632ab16b41 (diff) | |
download | ingen-566479a3ac4c8c6c9d190d6b4e8ecd104402180c.tar.gz ingen-566479a3ac4c8c6c9d190d6b4e8ecd104402180c.tar.bz2 ingen-566479a3ac4c8c6c9d190d6b4e8ecd104402180c.zip |
JackAudioDriver.[ch]pp -> JackDriver.[ch]pp
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2344 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/JackAudioDriver.hpp')
-rw-r--r-- | src/engine/JackAudioDriver.hpp | 173 |
1 files changed, 0 insertions, 173 deletions
diff --git a/src/engine/JackAudioDriver.hpp b/src/engine/JackAudioDriver.hpp deleted file mode 100644 index 5ff6bf64..00000000 --- a/src/engine/JackAudioDriver.hpp +++ /dev/null @@ -1,173 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007-2009 Dave Robillard <http://drobilla.net> - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef JACKAUDIODRIVER_H -#define JACKAUDIODRIVER_H - -#include <jack/jack.h> -#include <jack/transport.h> -#include "raul/AtomicInt.hpp" -#include "raul/List.hpp" -#include "raul/Semaphore.hpp" -#include "raul/Thread.hpp" -#include "Driver.hpp" -#include "Buffer.hpp" -#include "ProcessContext.hpp" - -namespace Raul { class Path; } - -namespace Ingen { - -class Engine; -class PatchImpl; -class PortImpl; -class DuplexPort; -class JackAudioDriver; -typedef jack_default_audio_sample_t jack_sample_t; - - -/** Used internally by JackAudioDriver to represent a Jack port. - * - * A Jack port always has a one-to-one association with a Patch port. - */ -class JackAudioPort : public DriverPort, public Raul::List<JackAudioPort*>::Node -{ -public: - JackAudioPort(JackAudioDriver* driver, DuplexPort* patch_port); - ~JackAudioPort(); - - void create(); - void destroy(); - - void move(const Raul::Path& path); - - void pre_process(ProcessContext& context); - void post_process(ProcessContext& context); - - jack_port_t* jack_port() const { return _jack_port; } - -private: - JackAudioDriver* _driver; - jack_port_t* _jack_port; -}; - - - -/** The Jack Driver. - * - * The process callback here drives the entire audio thread by "pulling" - * events from queues, processing them, running the patches, and passing - * events along to the PostProcessor. - * - * \ingroup engine - */ -class JackAudioDriver : public Driver -{ -public: - JackAudioDriver(Engine& engine); - ~JackAudioDriver(); - - bool supports(Shared::PortType port_type, Shared::EventType event_type); - - bool attach(const std::string& server_name, - const std::string& client_name, - void* jack_client); - - void activate(); - void deactivate(); - void enable(); - void disable(); - - DriverPort* port(const Raul::Path& path); - DriverPort* create_port(DuplexPort* patch_port); - - void add_port(DriverPort* port); - DriverPort* driver_port(const Raul::Path& path); - - Raul::List<DriverPort*>::Node* remove_port(const Raul::Path& path); - - PatchImpl* root_patch() { return _root_patch; } - void set_root_patch(PatchImpl* patch) { _root_patch = patch; } - - ProcessContext& context() { return _process_context; } - - /** Transport state for this frame. - * Intended to only be called from the audio thread. */ - inline const jack_position_t* position() { return &_position; } - inline jack_transport_state_t transport_state() { return _transport_state; } - - bool is_realtime() const { return jack_is_realtime(_client); } - - jack_client_t* jack_client() const { return _client; } - SampleCount buffer_size() const { return _buffer_size; } - SampleCount sample_rate() const { return _sample_rate; } - bool is_activated() const { return _is_activated; } - - inline SampleCount frame_time() const { return _client ? jack_frame_time(_client) : 0; } - - class PortRegistrationFailedException : public std::exception {}; - -private: - friend class JackAudioPort; - - // Static JACK callbacks which call the non-static callbacks (methods) - inline static void thread_init_cb(void* const jack_driver) { - return ((JackAudioDriver*)jack_driver)->_thread_init_cb(); - } - inline static void shutdown_cb(void* const jack_driver) { - return ((JackAudioDriver*)jack_driver)->_shutdown_cb(); - } - inline static int process_cb(jack_nframes_t nframes, void* const jack_driver) { - return ((JackAudioDriver*)jack_driver)->_process_cb(nframes); - } - inline static int buffer_size_cb(jack_nframes_t nframes, void* const jack_driver) { - return ((JackAudioDriver*)jack_driver)->_buffer_size_cb(nframes); - } - inline static int sample_rate_cb(jack_nframes_t nframes, void* const jack_driver) { - return ((JackAudioDriver*)jack_driver)->_sample_rate_cb(nframes); - } - - // Non static callbacks (methods) - void _thread_init_cb(); - void _shutdown_cb(); - int _process_cb(jack_nframes_t nframes); - int _buffer_size_cb(jack_nframes_t nframes); - int _sample_rate_cb(jack_nframes_t nframes); - - Engine& _engine; - Raul::Thread* _jack_thread; - Raul::Semaphore _sem; - Raul::AtomicInt _flag; - jack_client_t* _client; - jack_nframes_t _buffer_size; - jack_nframes_t _sample_rate; - uint32_t _midi_event_type; - bool _is_activated; - bool _local_client; ///< Whether _client should be closed on destruction - jack_position_t _position; - jack_transport_state_t _transport_state; - - Raul::List<JackAudioPort*> _ports; - ProcessContext _process_context; - - PatchImpl* _root_patch; -}; - - -} // namespace Ingen - -#endif // JACKAUDIODRIVER_H |