X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Faudio_backend.h;h=44525c83537015dcac77bcc52961a2ea87a14f5f;hb=b5239317d4657ad689ef7ef4d11c1fb6ae3e699b;hp=98f6c4d8a7782f054aa4d1517bbdc0a4df72d8bd;hpb=3d95822716d2e52b54a5bdbe7be4478ab034f8db;p=ardour.git diff --git a/libs/ardour/ardour/audio_backend.h b/libs/ardour/ardour/audio_backend.h index 98f6c4d8a7..44525c8353 100644 --- a/libs/ardour/ardour/audio_backend.h +++ b/libs/ardour/ardour/audio_backend.h @@ -17,8 +17,8 @@ */ -#ifndef __ardour_audiobackend_h__ -#define __ardour_audiobackend_h__ +#ifndef __libardour_audiobackend_h__ +#define __libardour_audiobackend_h__ #include #include @@ -26,30 +26,41 @@ #include #include +#include + +#include "ardour/types.h" + namespace ARDOUR { class AudioEngine; +class PortEngine; +class PortManager; class AudioBackend { public: - enum State { - Stopped = 0x1, - Running = 0x2, - Paused = 0x4, - Freewheeling = 0x8, - }; - - AudioBackend (AudioEngine& e) : engine (e), _state (Stopped) {} + AudioBackend (AudioEngine& e) : engine (e){} virtual ~AudioBackend () {} - /** return true if the underlying mechanism/API is still available + /** Return the name of this backend. + * + * Should use a well-known, unique term. Expected examples + * might include "JACK", "CoreAudio", "ASIO" etc. + */ + virtual std::string name() const = 0; + + /** Return a private, type-free pointer to any data + * that might be useful to a concrete implementation + */ + virtual void* private_handle() const = 0; + + /** Return true if the underlying mechanism/API is still available * for us to utilize. return false if some or all of the AudioBackend * API can no longer be effectively used. */ virtual bool connected() const = 0; - /** return true if the callback from the underlying mechanism/API + /** Return true if the callback from the underlying mechanism/API * (CoreAudio, JACK, ASIO etc.) occurs in a thread subject to realtime * constraints. Return false otherwise. */ @@ -96,13 +107,6 @@ class AudioBackend { */ virtual uint32_t available_output_channel_count (const std::string& device) const = 0; - enum SampleFormat { - Signed16bitInteger, - Signed24bitInteger, - Signed32bitInteger, - FloatingPoint - }; - /* Set the hardware parameters. * * If called when the current state is stopped or paused, @@ -161,15 +165,17 @@ class AudioBackend { */ virtual int set_systemic_output_latency (uint32_t) = 0; - virtual std::string get_device_name () const = 0; - virtual float get_sample_rate () const = 0; - virtual uint32_t get_buffer_size () const = 0; - virtual SampleFormat get_sample_format () const = 0; - virtual bool get_interleaved () const = 0; - virtual uint32_t get_input_channels () const = 0; - virtual uint32_t get_output_channels () const = 0; - virtual uint32_t get_systemic_input_latency () const = 0; - virtual uint32_t get_systemic_output_latency () const = 0; + /* Retrieving parameters */ + + virtual std::string device_name () const = 0; + virtual float sample_rate () const = 0; + virtual uint32_t buffer_size () const = 0; + virtual SampleFormat sample_format () const = 0; + virtual bool interleaved () const = 0; + virtual uint32_t input_channels () const = 0; + virtual uint32_t output_channels () const = 0; + virtual uint32_t systemic_input_latency () const = 0; + virtual uint32_t systemic_output_latency () const = 0; /* Basic state control */ @@ -244,7 +250,7 @@ class AudioBackend { * Implementations can feel free to smooth the values returned over * time (e.g. high pass filtering, or its equivalent). */ - virtual float get_cpu_load() const = 0; + virtual float cpu_load() const = 0; /* Transport Control (JACK is the only audio API that currently offers the concept of shared transport control) @@ -258,14 +264,14 @@ class AudioBackend { virtual void transport_stop () {} /** return the current transport state */ - virtual TransportState transport_state () { return TransportStopped; } + virtual TransportState transport_state () const { return TransportStopped; } /** Attempt to locate the transport to @param pos */ - virtual void transport_locate (framepos_t pos) {} + virtual void transport_locate (framepos_t /*pos*/) {} /** Return the current transport location, in samples measured * from the origin (defined by the transport time master) */ - virtual framepos_t transport_frame() { return 0; } + virtual framepos_t transport_frame() const { return 0; } /** If @param yn is true, become the time master for any inter-application transport * timebase, otherwise cease to be the time master for the same. @@ -275,11 +281,9 @@ class AudioBackend { * JACK is the only currently known audio API with the concept of a shared * transport timebase. */ - virtual int set_time_master (bool yn) { return 0; } + virtual int set_time_master (bool /*yn*/) { return 0; } - virtual framecnt_t sample_rate () const; - virtual pframes_t samples_per_cycle () const; - virtual int usecs_per_cycle () const { return _usecs_per_cycle; } + virtual int usecs_per_cycle () const { return 1000000 * (buffer_size() / sample_rate()); } virtual size_t raw_buffer_size (DataType t); /* Process time */ @@ -326,7 +330,7 @@ class AudioBackend { * Can ONLY be called from within a process() callback tree (which implies * that it can only be called by a process thread) */ - virtual bool get_sync_offset (pframes_t& offset) const { return 0; } + virtual bool get_sync_offset (pframes_t& /*offset*/) const { return false; } /** Create a new thread suitable for running part of the buffer process * cycle (i.e. Realtime scheduling, memory allocation, etc. etc are all @@ -336,22 +340,21 @@ class AudioBackend { */ virtual int create_process_thread (boost::function func, pthread_t*, size_t stacksize) = 0; - private: + protected: AudioEngine& engine; - State _state; - - std::string _target_device; - float _target_sample_rate; - uint32_t _target_buffer_size; - SampleFormat _target_sample_format; - bool _target_interleaved; - uint32_t _target_input_channels; - uint32_t _target_output_channels; - uin32_t _target_systemic_input_latency; - uin32_t _target_systemic_input_latency; }; -} +struct AudioBackendInfo { + const char* name; + + int (*instantiate) (const std::string& arg1, const std::string& arg2); + int (*deinstantiate) (void); + + boost::shared_ptr (*backend_factory) (AudioEngine&); + boost::shared_ptr (*portengine_factory) (PortManager&); +}; + +} // namespace -#endif /* __ardour_audiobackend_h__ */ +#endif /* __libardour_audiobackend_h__ */