Add some documentation for doxygen. Add modem_codec2_reverse.cpp, for testing.
authorbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 30 May 2014 00:46:39 +0000 (00:46 +0000)
committerbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 30 May 2014 00:46:39 +0000 (00:46 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1610 01035d8c-6547-0410-b346-abe4f91aad63

12 files changed:
freedv-server/source/codec2.cpp
freedv-server/source/driver_manager.cpp
freedv-server/source/drivers.h
freedv-server/source/global.cpp
freedv-server/source/hid/hid.cpp
freedv-server/source/keying_sink.cpp
freedv-server/source/modem_fdmdv2.cpp
freedv-server/source/modem_noop.cpp
freedv-server/source/platform/linux/alsa.cpp
freedv-server/source/platform/linux/audio_out_alsa.cpp
freedv-server/source/platform/linux/evdev.h
freedv-server/source/run.cpp

index e1b0bd12913f34d72ffeb772f932b1b18cada271..c58e9dcaf2a1c4655db22d48db8f827627ec5eba 100644 (file)
@@ -25,7 +25,7 @@ namespace FreeDV {
 
   public:
 
-    /// Instantiate the no-op codec.
+    /// Instantiate the codec.
                        Codec2(const char *);
                        ~Codec2();
 
@@ -65,7 +65,7 @@ namespace FreeDV {
   };
 
   Codec2::Codec2(const char * _parameters)
-  : Codec("no-op", _parameters), c(0), samples_per(0), bytes_per(0)
+  : Codec("codec2", _parameters), c(0), samples_per(0), bytes_per(0)
   {
     int        mode = CODEC2_MODE_1600;
 
@@ -112,7 +112,7 @@ namespace FreeDV {
     std::size_t        bytes_read = 0;
     std::size_t        samples_read = 0;
 
-    while ( *data_length >= bytes_per || sample_length >= samples_per ) {
+    while ( *data_length >= bytes_per && sample_length >= samples_per ) {
       codec2_decode(c, o, i);
 
       *data_length -= bytes_per;
@@ -134,7 +134,7 @@ namespace FreeDV {
     std::size_t        bytes_read = 0;
     std::size_t        samples_read = 0;
 
-    while ( data_length >= bytes_per || *sample_length >= samples_per ) {
+    while ( data_length >= bytes_per && *sample_length >= samples_per ) {
       // FIX: Const cast away. Remove if we can get const correctness in
       // libcodec2.
       codec2_encode(c, o, (std::int16_t *)i);
index a66865828b2a6a3b71ba580a5e4e958d094dd177..0b778d54c42811497d599b094c5e0f163eca6fb0 100644 (file)
@@ -254,6 +254,11 @@ namespace FreeDV {
     place(key, (base_creator)creator, enumerator, &user_interface_drivers);
   }
 
+  /// Return the address of the global driver manager.
+  /// This function is used to avoid the C++ static initialization order fiasco.
+  /// Any static initialization function that registers a driver calls it,
+  /// and thus it initializes the driver manager regardless of static
+  /// initialization order.
   DriverManager *
   driver_manager()
   {
index 6d262583d7127b463087b11ea80f9b08c6e84078..567af728e1041116e25f108098f50c909a50867b 100644 (file)
@@ -414,7 +414,8 @@ public:
     /// \param i The array of audio samples to be encoded, in an array
     /// of signed 16-bit integers.
     /// \param o The encoded data, in an array of unsigned 8-bit integers.
-    /// \param sample_length On call: The number of audio samples to be
+    /// \param data_length The number of bytes which may be encoded.
+    /// \param sample_length On call: The number of audio samples which may be
     /// encoded. On return: The number of 16-bit audio samples that were
     /// consumed.
     /// \return The number of std::uint8_t elements in the encoded array.
@@ -802,6 +803,12 @@ Framer *   FramerNoOp(const char * parameter);
 ///
 KeyingOutput * KeyingSink(const char * parameter);
 
+/// Opens the Reverse Codec2 modem, for debugging.
+/// \param parameter
+/// \return A pointer to the Modem instance.
+///
+Modem *                Codec2_Reverse(const char * parameter);
+
 /// Opens the FDMDV2 modem.
 /// \param parameter
 /// \return A pointer to the Modem instance.
index f35f1eec705584bb42982dcc97ab0ea84df0b88a..61b67e7c01e5b8ebd487b4f46b811554ce2ca627 100644 (file)
@@ -1,6 +1,9 @@
 #include "drivers.h"
 
 namespace FreeDV {
+  /// Global name of the program, for error messages.
   const char * program_name = 0;
+
+  /// Global driver manager object.
   DriverManager * _globalDriverManager = 0;
 }
index 85f1f9d77026ff6baf3fd925566e05e3436a74ab..706f15b054b011b0c66a164e825fe2a80e1f02c2 100644 (file)
 #define        INTEGER_64
 #endif
 
+/// Structure for parsing USB Human Interface Device reports.
 struct HIDRaw {
 public:
+  /// Type field of a Collection object in a HID report.
   enum CollectionType {
     Physical = 0,
     Application = 1,   // Mouse or keyboard.
@@ -28,6 +30,7 @@ public:
     VendorEnd = 0xff
   };
  
+  /// Type field of a Generic Desktop Usage Page in a HID report.
   enum GenericDesktop {
     Undefined = 0x00,
     Pointer = 0x01,
@@ -78,6 +81,7 @@ public:
     D_pad_Left = 0x93
   };
 
+  /// Type field of a Global object in a HID report.
   enum GlobalType {
     UsagePage = 0,
     LogicalMinimum = 1,
@@ -93,6 +97,7 @@ public:
     Pop = 11
   };
 
+  /// Type field of a Local object in a HID report.
   enum LocalType {
     Usage = 0,
     UsageMinimum = 1,
@@ -105,6 +110,8 @@ public:
     StringMaximum = 9,
     Delimiter = 10
   };
+
+  /// Type field of a Main object in a HID report.
   enum MainType {
     Input = 0x8,
     Output = 0x9,
@@ -114,12 +121,14 @@ public:
     LongItem = 0x0f,
   };
   
+  /// Type of a top-level object in a HID report.
   enum Type {
     Main = 0,
     Global = 1,
     Local = 2
   };
   
+  /// Type of Usage Page in a HID report.
   enum UsagePageTypes {
     GenericDesktop = 1,
     Button = 9
index 75436ecd6de8278202020f8458f1e54cef98ac57..dca9e9ab3c43b7da83b0eec8f706328194a1668e 100644 (file)
@@ -25,7 +25,7 @@ namespace FreeDV {
     /// \param space The maximum number of file descriptors that may be
     /// stored in the array.
     /// \return The number of file descriptors written to the array.
-    int                        poll_fds(PollType *, int);
+    int                        poll_fds(PollType * array, int space);
 
     /// If the value is true, transmit. Otherwise receive.
     ///
index a657d2cd318f214f2e1d57c3b6f666da6aa1efef..c8b187ef5202a7996c242c7d64e4b64bca8c8b6f 100644 (file)
@@ -14,6 +14,7 @@ namespace FreeDV {
   /// Modem "FDMDV2".
   class ModemFDMDV2 : public Modem {
   public:
+    /// Modem operation mode. These are given as bit-rate + attributes.
     enum Mode {
       M_Invalid = -1,
       M_1400_V0_91_Legacy = 0, // Broken, and hopefully off-the-air by now.
@@ -69,6 +70,8 @@ namespace FreeDV {
     /// of signed 16-bit integers.
     /// \param data_length On call: The number of bytes of data to be
     /// modulated. On return: The number of bytes consumed.
+    /// \param sample_length The number of audio samples which may be
+    /// modulated.
     /// \return The number of 16-bit audio samples in the modulated array.
     virtual std::size_t
                        modulate16(
index 79af2139d99cf4912d9f24cf2c84dc4a39c604b5..b12e9c1348b2618526d7834802f915d8c7017876 100644 (file)
@@ -47,6 +47,8 @@ namespace FreeDV {
     /// of signed 16-bit integers.
     /// \param data_length On call: The number of bytes of data to be
     /// modulated. On return: The number of bytes consumed.
+    /// \param sample_length The number of audio samples which may be
+    /// modulated.
     /// \return The number of 16-bit audio samples in the modulated array.
     virtual std::size_t
                        modulate16(
index 738a6ffe85070d3307caf1b69963e2462a16d9b2..e38c46a8c8bccaab2e47320bab9f33a195230898 100644 (file)
@@ -303,11 +303,13 @@ namespace FreeDV {
       if ((error = snd_pcm_sw_params(handle, sw_params)) < 0)
         do_throw(error, name, stream, "ALSA set software parameters");
       
+#if 0
       // Dump sound parameters, for debugging.
       snd_output_t * output = 0;
       snd_output_stdio_attach(&output, stderr, 0);
       fprintf(stderr, "%s\n", name);
       snd_pcm_dump_setup(handle, output);
+#endif
 
       snd_pcm_sw_params_free(sw_params);
 
index 9d9144626cacb813d5826f7de33604e798deb392..73db6912de9f18639e97b087e32e1b91226b9b85 100644 (file)
 namespace FreeDV {
   std::ostream & ALSAEnumerate(std::ostream & stream, snd_pcm_stream_t mode);
 
-  // If more than this number of frames are queued for audio output, the
-  // latency is too high. Flush the output and print an overlong-delay message.
+  /// Maximum frames that an audio stream may be delayed.
+  /// If more than this number of frames are queued for audio output, the
+  /// latency is too high. Flush the output and print an overlong-delay message.
   const unsigned int   MaximumDelayFrames = 4;
 
-  // At the start of playback, preload the audio output with this many
-  // frames of zero data. This delays the output enough to avoid later
-  // buffer-overrun problems.
+  /// Number of zeroed frames with which to prime an audio output device.
+  /// At the start of playback, preload the audio output with this many
+  /// frames of zero data. This delays the output enough to avoid later
+  /// buffer-overrun problems.
   const unsigned int   FillFrames = 2;
 
   /// Audio output "ALSA", Uses the Linux ALSA Audio API.
index 6b98c32deedc94be78b87e17733af3186d6f2703..6bb2632b48f8156e3aada2c77b26b910e5bf6969 100644 (file)
@@ -8,8 +8,10 @@
 #include "drivers.h"
 
 namespace FreeDV {
+  /// Class used to access Linux event devices.
   class EvDev {
   public:
+    /// Structure used to enumerate Linux event devices.
     struct device_enumeration {
       char *   special_file;
       char *   name;
index 5834b488046c03b7a722f2db15bf918219b58079..72b59f9f16ed1a2e189edf1bae18d355526e7272 100644 (file)
@@ -28,7 +28,9 @@ namespace FreeDV {
   ///
   class Run {
   private:
-    const std::size_t  FIFOSize = MaximumFrameSamples * sizeof(int16_t) * 2;
+    const std::size_t  AudioFIFOSize =
+     MaximumFrameSamples * sizeof(int16_t) * 2;
+    const std::size_t  CodecFIFOSize = 1024;
     Interfaces * const i;
     int                        poll_fd_count;
     int                        poll_fd_base;
@@ -70,8 +72,8 @@ namespace FreeDV {
   
   Run::Run(Interfaces * interfaces)
   : i(interfaces), poll_fd_count(0), poll_fd_base(0), output_fd_base(-1),
-    codec_fifo(FIFOSize), in_fifo(FIFOSize),
-    out_fifo(FIFOSize)
+    codec_fifo(CodecFIFOSize), in_fifo(AudioFIFOSize),
+    out_fifo(AudioFIFOSize)
   {
     reset();
   }