Let's try libevent instead of a POSIX event handler.
authorbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 17 Jan 2014 19:47:39 +0000 (19:47 +0000)
committerbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 17 Jan 2014 19:47:39 +0000 (19:47 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1369 01035d8c-6547-0410-b346-abe4f91aad63

freedv-server/CMakeLists.txt
freedv-server/source/drivers.h
freedv-server/source/event_posix.cpp [deleted file]
freedv-server/source/libevent.cpp [new file with mode: 0644]

index 7a4f492c625cc2df59a58f9ce8acfe3cbe23701e..1d7f491fb4080bb8b4ffa8acd89620a81810c701 100644 (file)
@@ -96,10 +96,10 @@ set(Compile.sources
   source/codec_noop.cpp
   source/driver_manager.cpp
   source/event_handler.cpp
-  source/event_posix.cpp
   source/interfaces.cpp
   source/keying.cpp
   source/keying_sink.cpp
+  source/libevent.cpp
   source/modem.cpp
   source/modem_noop.cpp
   source/ptt_constant.cpp
index e269feb5140c8122823500018b01ef1b6c207b8e..9ac02e2874e70f2d98ae2b31783aa0fe9b45caeb 100644 (file)
@@ -430,8 +430,8 @@ namespace FreeDV {
     AudioInput *       Tone(const char * parameter);
     AudioOutput *      AudioSink(const char * parameter);
     Codec *            CodecNoOp(const char * parameter);
-    EventHandler *     EventHandlerPOSIX(const char * parameter);
     Keying *           KeyingSink(const char * parameter);
+    EventHandler *     LibEvent(const char * parameter);
     Modem *            ModemNoOp(const char * parameter);
     PTTInput *         PTTConstant(const char * parameter);
     TextInput *                TextConstant(const char * parameter);
diff --git a/freedv-server/source/event_posix.cpp b/freedv-server/source/event_posix.cpp
deleted file mode 100644 (file)
index bb1c964..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/// The POSIX event handler, mainly for running without a GUI. 
-
-#include "drivers.h"
-
-namespace FreeDV {
-  /// Event handler class for POSIX.
-  class EventHandlerPOSIX : public EventHandler {
-  protected:
-       /// Run one iteration of the event handler.
-       void            iterate();
-
-  public:
-       /// Create an event handler instance.
-                       EventHandlerPOSIX(const char * parameters);
-
-       virtual         ~EventHandlerPOSIX();
-
-       /// Monitor a file descriptor in the event loop. Call a function if the
-       /// file descriptor is ready for I/O.
-       /// \param fd The file descriptor to monitor.
-       /// \param type A bit-field of values defined in this class,
-       ///  indicating the kinds of events to listen for.
-       /// \param private_data Private data to be passed to the event
-       ///  function.
-       /// \param event A coroutine to call when there is a status change
-       ///  on the file descriptor. The arguments of the coroutine are
-       ///  - fd: The file descriptor that has an event.
-       ///  - type: A bit-field of FDStatus values indicating the events
-       ///    received.
-       ///  - private: The address of opaque data to be passed to the driver.
-       virtual void    monitor(int fd, unsigned int type, void * private_data,
-                        void (*event)(int fd, unsigned int type, void * private_data)
-                        );
-
-       /// Remove all monitoring of the given file descriptor by the event
-       /// loop handler.
-       /// \param fd The file descriptor to be removed from monitoring.
-       virtual void    unmonitor(int fd);
-  };
-
-  EventHandlerPOSIX::EventHandlerPOSIX(const char * parameters)
-  : EventHandler("posix", parameters)
-  {
-  }
-
-  EventHandlerPOSIX::~EventHandlerPOSIX()
-  {
-  }
-
-  void
-  EventHandlerPOSIX::iterate()
-  {
-  }
-
-  EventHandler *
-  Driver::EventHandlerPOSIX(const char * parameter)
-  {
-    return new ::FreeDV::EventHandlerPOSIX(parameter);
-  }
-
-  void
-  EventHandlerPOSIX::monitor(int fd, unsigned int type, void * private_data,
-   void (*event)(int fd, unsigned int type, void * private_data))
-  {
-  }
-
-  void
-  EventHandlerPOSIX::unmonitor(int fd)
-  {
-  }
-
-#ifndef NO_INITIALIZERS
-  static bool
-  initializer()
-  {
-    init_driver_manager().register_codec("no-op", Driver::CodecNoOp);
-    return true;
-  }
-  static const bool initialized = initializer();
-#endif
-}
diff --git a/freedv-server/source/libevent.cpp b/freedv-server/source/libevent.cpp
new file mode 100644 (file)
index 0000000..20cd344
--- /dev/null
@@ -0,0 +1,81 @@
+/// The POSIX event handler, mainly for running without a GUI. 
+
+#include "drivers.h"
+
+namespace FreeDV {
+  /// Event handler class for POSIX.
+  class LibEvent : public EventHandler {
+  protected:
+       /// Run one iteration of the event handler.
+       void            iterate();
+
+  public:
+       /// Create an event handler instance.
+                       LibEvent(const char * parameters);
+
+       virtual         ~LibEvent();
+
+       /// Monitor a file descriptor in the event loop. Call a function if the
+       /// file descriptor is ready for I/O.
+       /// \param fd The file descriptor to monitor.
+       /// \param type A bit-field of values defined in this class,
+       ///  indicating the kinds of events to listen for.
+       /// \param private_data Private data to be passed to the event
+       ///  function.
+       /// \param event A coroutine to call when there is a status change
+       ///  on the file descriptor. The arguments of the coroutine are
+       ///  - fd: The file descriptor that has an event.
+       ///  - type: A bit-field of FDStatus values indicating the events
+       ///    received.
+       ///  - private: The address of opaque data to be passed to the driver.
+       virtual void    monitor(int fd, unsigned int type, void * private_data,
+                        void (*event)(int fd, unsigned int type, void * private_data)
+                        );
+
+       /// Remove all monitoring of the given file descriptor by the event
+       /// loop handler.
+       /// \param fd The file descriptor to be removed from monitoring.
+       virtual void    unmonitor(int fd);
+  };
+
+  LibEvent::LibEvent(const char * parameters)
+  : EventHandler("posix", parameters)
+  {
+  }
+
+  LibEvent::~LibEvent()
+  {
+  }
+
+  void
+  LibEvent::iterate()
+  {
+  }
+
+  EventHandler *
+  Driver::LibEvent(const char * parameter)
+  {
+    return new ::FreeDV::LibEvent(parameter);
+  }
+
+  void
+  LibEvent::monitor(int fd, unsigned int type, void * private_data,
+   void (*event)(int fd, unsigned int type, void * private_data))
+  {
+  }
+
+  void
+  LibEvent::unmonitor(int fd)
+  {
+  }
+
+#ifndef NO_INITIALIZERS
+  static bool
+  initializer()
+  {
+    init_driver_manager().register_codec("no-op", Driver::CodecNoOp);
+    return true;
+  }
+  static const bool initialized = initializer();
+#endif
+}