Start defining poll interface.
authorbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 14 Mar 2014 19:59:26 +0000 (19:59 +0000)
committerbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 14 Mar 2014 19:59:26 +0000 (19:59 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1442 01035d8c-6547-0410-b346-abe4f91aad63

freedv-server/source/drivers.h
freedv-server/source/platform/linux/audio_out_alsa.cpp

index 9b13440cd97caa4093e937c993af9d5d794aaf24..ae7ef72c3cf9e5353f6d603a7345c913225d0daf 100644 (file)
@@ -222,8 +222,13 @@ namespace FreeDV {
     /// All drivers present a unidirectional interface.
     /// If the underlying device is bidirectional that detail is hidden and
     /// we present one or more separate read and write drivers.
+    /// \return The number of audio samples or bytes that can be read or
+    /// written.
     virtual std::size_t        ready() = 0;
 
+    ///  
+    virtual int                poll_fds(struct pollfd * array, int space) = 0;
+
     virtual            ~IODevice() = 0;
   };
 
index 8600c5448087c7fa81e0ff01df3e781a11fbb475..dca77e804c43addaa263c9226368b802fed2d96a 100644 (file)
@@ -37,6 +37,14 @@ namespace FreeDV {
                AudioOutALSA(const char * parameters);
                ~AudioOutALSA();
 
+        /// Return file descriptors for poll()
+       /// \param size The address of a variable that will be written
+       /// with the number of file descriptors in the array.
+        /// \return The address of an array of integers containing the
+       /// file descriptors.
+       virtual int
+               poll_fds(struct pollfd * array, int space);
+
        /// Return the number of audio samples the device can handle in
        /// a write without blocking.
         virtual std::size_t
@@ -105,6 +113,19 @@ namespace FreeDV {
     return ALSAEnumerate(stream, SND_PCM_STREAM_PLAYBACK);
   }
 
+  int
+  AudioOutALSA::poll_fds(struct pollfd * array, int space)
+  {
+    const int size = snd_pcm_poll_descriptors_count(handle);
+    
+    snd_pcm_poll_descriptors(
+     handle,
+     array,
+     space);
+    
+    return size;
+  }
+
   std::size_t
   AudioOutALSA::ready()
   {