diff options
Diffstat (limited to 'src/dabInput.h')
-rw-r--r-- | src/dabInput.h | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/src/dabInput.h b/src/dabInput.h index 685f7b2..12823b8 100644 --- a/src/dabInput.h +++ b/src/dabInput.h @@ -26,8 +26,10 @@ # include "config.h" #endif #include "Log.h" -extern Logger etiLog; +#include "RemoteControl.h" +#include <string> +extern Logger etiLog; struct dabInputOperations { int (*init)(void** args); @@ -44,6 +46,68 @@ struct dabInputOperations { bool operator==(const dabInputOperations&); }; +/* New input object base */ +class DabInputBase { + public: + virtual int open(const std::string name) = 0; + virtual int readFrame(void* buffer, int size) = 0; + virtual int setBitrate(int bitrate) = 0; + virtual int close() = 0; + + virtual ~DabInputBase() {}; + protected: + DabInputBase() {}; +}; + +/* Wrapper class for old-style dabInputOperations inputs */ +class DabInputCompatible : public DabInputBase { + public: + DabInputCompatible(dabInputOperations ops) + : m_ops(ops) + { m_ops.init(&args); } + + virtual ~DabInputCompatible() + { m_ops.clean(&args); } + + virtual int open(const std::string name) + { return m_ops.open(args, name.c_str()); } + + virtual int setbuf(int size) + { return m_ops.setbuf(args, size); } + + virtual int readFrame(void* buffer, int size) + { + if (m_ops.lock) { + m_ops.lock(args); + } + int result = m_ops.readFrame(&m_ops, args, buffer, size); + if (m_ops.unlock) { + m_ops.unlock(args); + } + return result; + } + + virtual int setBitrate(int bitrate) + { return m_ops.setBitrate(&m_ops, args, bitrate); } + + virtual int close() + { return m_ops.close(args); } + + virtual int rewind() + { return m_ops.rewind(args); } + + virtual int read(void* buffer, int size) + { return m_ops.read(args, buffer, size); } + + virtual dabInputOperations getOpts() { return m_ops; } + + private: + DabInputCompatible& operator=(const DabInputCompatible& other); + DabInputCompatible(const DabInputCompatible& other); + + dabInputOperations m_ops; + void* args; +}; int dabInputSetbuf(void* args, int size); int dabInputSetbitrate(dabInputOperations* ops, void* args, int bitrate); |