1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 3 /* 4 Sonic Visualiser 5 An audio file viewer and annotation editor. 6 Centre for Digital Music, Queen Mary, University of London. 7 8 This program is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public License as 10 published by the Free Software Foundation; either version 2 of the 11 License, or (at your option) any later version. See the file 12 COPYING included with this distribution for more information. 13 */ 14 15 /* 16 This is a modified version of a source file from the 17 Rosegarden MIDI and audio sequencer and notation editor. 18 This file copyright 2000-2006 Chris Cannam and QMUL. 19 */ 20 21 #ifndef SV_OSC_QUEUE_H 22 #define SV_OSC_QUEUE_H 23 24 #include "OSCMessage.h" 25 26 #include "base/RingBuffer.h" 27 28 #include <QObject> 29 30 #ifdef HAVE_LIBLO 31 #include <lo/lo.h> 32 #endif 33 34 class OSCQueue : public QObject 35 { 36 Q_OBJECT 37 38 public: 39 OSCQueue(bool withNetworkPort); 40 virtual ~OSCQueue(); 41 42 bool isOK() const; 43 44 bool isEmpty() const { return getMessagesAvailable() == 0; } 45 int getMessagesAvailable() const; 46 void postMessage(OSCMessage); 47 OSCMessage readMessage(); 48 49 QString getOSCURL() const; 50 51 bool hasPort() const { return m_withPort; } 52 53 signals: 54 void messagesAvailable(); 55 56 protected: 57 #ifdef HAVE_LIBLO 58 lo_server_thread m_thread; 59 60 static void oscError(int, const char *, const char *); 61 static int oscMessageHandler(const char *, const char *, lo_arg **, 62 int, lo_message, void *); 63 #endif 64 65 bool parseOSCPath(QString path, int &target, int &targetData, QString &method); 66 67 bool m_withPort; 68 RingBuffer<OSCMessage *> m_buffer; 69 }; 70 71 #endif 72 73