Get C++11 constant types from the std:: namespace rather than the C one.
authorbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 22 Jan 2014 02:42:40 +0000 (02:42 +0000)
committerbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 22 Jan 2014 02:42:40 +0000 (02:42 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1387 01035d8c-6547-0410-b346-abe4f91aad63

freedv-server/source/audio_sink.cpp
freedv-server/source/blank_panel.cpp
freedv-server/source/codec_noop.cpp
freedv-server/source/drivers.h
freedv-server/source/keying_sink.cpp
freedv-server/source/modem_noop.cpp
freedv-server/source/ptt_constant.cpp
freedv-server/source/run.cpp
freedv-server/source/text_constant.cpp
freedv-server/source/tone.cpp
freedv-server/source/utility.cpp

index 560db6b04c197ba68a4df1cf4a2aede8fa1cdcc3..82c43a43d440052e20def3932aa71332e1e50a5b 100644 (file)
@@ -14,12 +14,12 @@ namespace FreeDV {
 
        /// Return the number of audio samples the device can handle in
        /// a write without blocking. This version always returns SIZE_MAX.
-        virtual size_t
+        virtual std::size_t
                ready();
 
         /// Write audio into the "short" type.
        virtual std::size_t
-               write16(const int16_t * array, std::size_t length);
+               write16(const std::int16_t * array, std::size_t length);
   };
 
   AudioSink::AudioSink(const char * p)
@@ -33,7 +33,7 @@ namespace FreeDV {
 
   // Write audio into the "short" type.
   std::size_t
-  AudioSink::write16(const int16_t * array, std::size_t length)
+  AudioSink::write16(const std::int16_t * array, std::size_t length)
   {
     return length;
   }
@@ -44,7 +44,7 @@ namespace FreeDV {
     return new ::FreeDV::AudioSink(parameter);
   }
 
-  size_t
+  std::size_t
   AudioSink::ready()
   {
     return SIZE_MAX;
index 9127a18165e966482d3c84638f7445259c435a2d..01eaecd221fa7fbe1677e1645f50d3074576f245 100644 (file)
@@ -13,7 +13,7 @@ namespace FreeDV {
     
     /// Return the amount of bytes ready for read. In this case, it always
     /// returns 0.
-    size_t     ready();
+    std::size_t        ready();
   };
 
   BlankPanel::BlankPanel(const char * parameter, Interfaces * interfaces)
@@ -25,7 +25,7 @@ namespace FreeDV {
   {
   }
 
-  size_t
+  std::size_t
   BlankPanel::ready()
   {
     return 0;
index 30a05d65690fe2e416b2ac49dcd35fc8d2fe0754..b4fa9dc728ad5a1c1f367042a3bf1b3b9df10fbd 100644 (file)
@@ -23,9 +23,9 @@ namespace FreeDV {
     /// \param o The array of audio samples after decoding, in an array
     /// of signed 16-bit integers.
     /// \param length The number of bytes of data to be decoded.
-    /// \return The number of int16_t elements in the decoded array.
+    /// \return The number of std::int16_t elements in the decoded array.
     virtual std::size_t
-                       decode16(const uint8_t * i, int16_t * o, \
+                       decode16(const std::uint8_t * i, std::int16_t * o, \
                         std::size_t length);
 
 
@@ -34,9 +34,9 @@ namespace FreeDV {
     /// of signed 16-bit integers.
     /// \param o The encoded data, in an array of unsigned 8-bit integers.
     /// \param length The number of audio samples to be encoded.
-    /// \return The number of uint8_t elements in the encoded array.
+    /// \return The number of std::uint8_t elements in the encoded array.
     virtual std::size_t
-                       encode16(const int16_t * i, uint8_t * o, \
+                       encode16(const std::int16_t * i, std::uint8_t * o, \
                         std::size_t length);
 
     /// Return the duration of a frame in milliseconds.
@@ -66,17 +66,17 @@ namespace FreeDV {
   std::size_t const
   CodecNoOp::bytes_per_frame() const
   {
-    return sizeof(int16_t);
+    return sizeof(std::int16_t);
   }
 
   std::size_t
-  CodecNoOp::decode16(const uint8_t * i, int16_t * o, std::size_t length)
+  CodecNoOp::decode16(const std::uint8_t * i, std::int16_t * o, std::size_t length)
   {
     return length;
   }
 
   std::size_t
-  CodecNoOp::encode16(const int16_t * i, uint8_t * o, std::size_t length)
+  CodecNoOp::encode16(const std::int16_t * i, std::uint8_t * o, std::size_t length)
   {
     return length;
   }
index 35d6495d588e4cdfc2c517b143cbcd9845d68d33..aa9cda85cc9aa0cd8c12bda3e0a107f454ae6a90 100644 (file)
@@ -19,6 +19,19 @@ namespace FreeDV {
   ///  or a memory leak will occurr.
   char *       copy_string(const char * s);
 
+  /// Simple C++ circular buffer class. 
+  /// Written to avoid STL templates, Boost, etc. in order to keep down the
+  /// size of the embedded version of this program. 
+  class CircularBuffer {
+  private:
+    char *     buffer;
+    std::size_t        length;
+    char *     in;
+    char *     out;
+
+  public:
+  };
+
   /// Set the real-time parameters in the scheduler before running our main
   /// loop.
   void         set_scheduler();
@@ -106,7 +119,7 @@ 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.
-    virtual size_t     ready() = 0;
+    virtual std::size_t        ready() = 0;
 
     virtual            ~IODevice() = 0;
   };
@@ -153,7 +166,7 @@ namespace FreeDV {
 
         /// Read audio into an array of the signed 16-bit integer type.
     virtual std::size_t
-                       read16(int16_t * array, std::size_t length) = 0;
+                       read16(std::int16_t * array, std::size_t length) = 0;
   };
 
   /// Virtual base class for audio output drivers.
@@ -171,7 +184,7 @@ namespace FreeDV {
 
         /// Write audio from an array of the signed 16-bit integer type.
     virtual std::size_t
-                       write16(const int16_t * array, std::size_t length) = 0;
+                       write16(const std::int16_t * array, std::size_t length) = 0;
   };
 
   /// Virtual base class for codecs.
@@ -199,9 +212,9 @@ namespace FreeDV {
     /// \param o The array of audio samples after decoding, in an array
     /// of signed 16-bit integers.
     /// \param length The number of bytes of data to be decoded.
-    /// \return The number of int16_t elements in the decoded array.
+    /// \return The number of std::int16_t elements in the decoded array.
     virtual std::size_t
-                       decode16(const uint8_t * i, int16_t * o, \
+                       decode16(const std::uint8_t * i, std::int16_t * o, \
                         std::size_t length) = 0;
 
 
@@ -210,9 +223,9 @@ namespace FreeDV {
     /// of signed 16-bit integers.
     /// \param o The encoded data, in an array of unsigned 8-bit integers.
     /// \param length The number of audio samples to be encoded.
-    /// \return The number of uint8_t elements in the encoded array.
+    /// \return The number of std::uint8_t elements in the encoded array.
     virtual std::size_t
-                       encode16(const int16_t * i, uint8_t * o, \
+                       encode16(const std::int16_t * i, std::uint8_t * o, \
                         std::size_t length) = 0;
 
     /// Return the duration of a frame in milliseconds.
@@ -333,7 +346,7 @@ namespace FreeDV {
     virtual void       key(bool value) = 0;
 
     /// Return the amount of bytes ready to write.
-    virtual size_t     ready() = 0;
+    virtual std::size_t        ready() = 0;
   };
 
   /// Softmodem driver.
@@ -360,9 +373,9 @@ namespace FreeDV {
     /// of signed 16-bit integers.
     /// \param o The demodulated data, in an array of unsigned 8-bit integers.
     /// \param length The number of audio samples to be demodulated.
-    /// \return The number of uint8_t elements in the demodulated array.
+    /// \return The number of std::uint8_t elements in the demodulated array.
     virtual std::size_t
-                       demodulate16(const int16_t * i, uint8_t * o, \
+                       demodulate16(const std::int16_t * i, std::uint8_t * o, \
                         std::size_t length) = 0;
 
     /// Modulate from data to audio samples.
@@ -370,9 +383,9 @@ namespace FreeDV {
     /// \param o The array of audio samples after modulation, in an array
     /// of signed 16-bit integers.
     /// \param length The number of bytes of data to be modulated.
-    /// \return The number of int16_t elements in the modulated array.
+    /// \return The number of std::int16_t elements in the modulated array.
     virtual std::size_t
-                       modulate16(const uint8_t * i, int16_t * o, \
+                       modulate16(const std::uint8_t * i, std::int16_t * o, \
                         std::size_t length) = 0;
 
     /// Return the duration of a frame in milliseconds.
@@ -419,7 +432,7 @@ namespace FreeDV {
 
   public:
     /// Read the text data.
-    virtual size_t     read(char * buffer, size_t length) = 0;
+    virtual std::size_t        read(char * buffer, std::size_t length) = 0;
 
     virtual            ~TextInput() = 0;
   };
index f2616c0cb41e815acf19984a4c2e7174a0328e1f..54007ef059984b60b3a9c424727f5002c2024468 100644 (file)
@@ -17,7 +17,7 @@ namespace FreeDV {
 
     /// Return the amount of bytes ready for read. In this case, it always
     /// returns SIZE_MAX.
-    size_t             ready();
+    std::size_t                ready();
   };
 
   KeyingSink::KeyingSink(const char * parameters)
@@ -38,7 +38,7 @@ namespace FreeDV {
       std::cerr << "keying: RECEIVE" << std::endl;
   }
 
-  size_t
+  std::size_t
   KeyingSink::ready()
   {
     return SIZE_MAX;
index c90b9a55b121707ea2c7f944a00abf71326be3fd..5d1a62c107643b49e895df7484616bd6cc20e042 100644 (file)
@@ -25,9 +25,9 @@ namespace FreeDV {
     /// of signed 16-bit integers.
     /// \param o The demodulated data, in an array of unsigned 8-bit integers.
     /// \param length The number of audio samples to be demodulated.
-    /// \return The number of uint8_t elements in the demodulated array.
+    /// \return The number of std::uint8_t elements in the demodulated array.
     virtual std::size_t
-                       demodulate16(const int16_t * i, uint8_t * o, \
+                       demodulate16(const std::int16_t * i, std::uint8_t * o, \
                         std::size_t length);
 
     /// Modulate from data to audio samples.
@@ -35,9 +35,9 @@ namespace FreeDV {
     /// \param o The array of audio samples after modulation, in an array
     /// of signed 16-bit integers.
     /// \param length The number of bytes of data to be modulated.
-    /// \return The number of int16_t elements in the modulated array.
+    /// \return The number of std::int16_t elements in the modulated array.
     virtual std::size_t
-                       modulate16(const uint8_t * i, int16_t * o, \
+                       modulate16(const std::uint8_t * i, std::int16_t * o, \
                         std::size_t length);
 
     /// Return the duration of a frame in milliseconds.
@@ -67,17 +67,17 @@ namespace FreeDV {
   std::size_t const
   ModemNoOp::bytes_per_frame() const
   {
-    return sizeof(int16_t);
+    return sizeof(std::int16_t);
   }
 
   std::size_t
-  ModemNoOp::demodulate16(const int16_t * i, uint8_t * o, std::size_t length)
+  ModemNoOp::demodulate16(const std::int16_t * i, std::uint8_t * o, std::size_t length)
   {
     return length;
   }
 
   std::size_t
-  ModemNoOp::modulate16(const uint8_t * i, int16_t * o, std::size_t length)
+  ModemNoOp::modulate16(const std::uint8_t * i, std::int16_t * o, std::size_t length)
   {
     return length;
   }
index 2a534d29b9bd3bc5f359ecd1119aa5d4c6dc9494..43d21f9d6c2c2cbde7d67985468a88e2ef809ce6 100644 (file)
@@ -17,7 +17,7 @@ namespace FreeDV {
     virtual            ~PTTConstant();
     
     /// Return the amount of bytes ready for read.
-    size_t     ready();
+    std::size_t        ready();
 
     /// Return true if the PTT input is pressed.
     bool       state();
@@ -41,7 +41,7 @@ namespace FreeDV {
   {
   }
 
-  size_t
+  std::size_t
   PTTConstant::ready()
   {
     if ( ready_one_shot )
index 10dbfa8d3f0f6c51ed9bb2dc0f148e4a6e0011b5..717d97e7a3f14ff787f5435ec0952df551f53171 100644 (file)
@@ -108,7 +108,7 @@ namespace FreeDV {
   static void
   receive(Interfaces * i)
   {
-    const size_t       samples_to_decode = i->receiver->ready()
+    const std::size_t  samples_to_decode = i->receiver->ready()
                         % i->modem->samples_per_frame();
   }
   
index df88db40dbb9b08da46d0f12a49efd4280ad3f74..4de3c8f6d681a016500531a82459cc4a052c6163 100644 (file)
@@ -8,8 +8,8 @@ namespace FreeDV {
   /// This driver provides constant text.
   class TextConstant : public TextInput {
   private:
-    const size_t       length;
-    size_t             index;
+    const std::size_t  length;
+    std::size_t                index;
 
   public:
     /// Instantiate the constant text driver.
@@ -17,10 +17,10 @@ namespace FreeDV {
     virtual            ~TextConstant();
     
     /// Read the text data.
-    size_t             read(char * buffer, size_t size);
+    std::size_t                read(char * buffer, std::size_t size);
 
     /// Return the amount of bytes ready for read.
-    size_t             ready();
+    std::size_t                ready();
   };
 
   TextConstant::TextConstant(const char * parameters)
@@ -32,10 +32,10 @@ namespace FreeDV {
   {
   }
 
-  size_t
-  TextConstant::read(char * buffer, size_t size)
+  std::size_t
+  TextConstant::read(char * buffer, std::size_t size)
   {
-    const size_t available = length - index;
+    const std::size_t available = length - index;
 
     if ( available == 0 ) {
       /// A real I/O device would block if this happened, so throw an error.
@@ -52,7 +52,7 @@ namespace FreeDV {
     return size;
   }
 
-  size_t
+  std::size_t
   TextConstant::ready()
   {
     return length - index;
index a8bb3305c68890b058b418acf9ab0a9c6044b84e..5b96b5b52771b42315ab94ef407c25cb9df53620 100644 (file)
@@ -20,7 +20,7 @@ namespace FreeDV {
 
     /// Return the amount of audio samples for read. In this case, it always
     /// returns SIZE_MAX.
-    size_t     ready();
+    std::size_t        ready();
 
     /// Generate a sine wave.
     float      sine_wave(float frequency, unsigned int step);
@@ -31,7 +31,7 @@ namespace FreeDV {
     virtual            ~Tone();
     
     // Read audio into the "short" type.
-    virtual std::size_t        read16(int16_t * array, std::size_t length);
+    virtual std::size_t        read16(std::int16_t * array, std::size_t length);
   };
 
   Tone::Tone(const char * parameters)
@@ -95,7 +95,7 @@ namespace FreeDV {
   }
 
   std::size_t
-  Tone::read16(int16_t * array, std::size_t length)
+  Tone::read16(std::int16_t * array, std::size_t length)
   {
     const unsigned int array_length = ((sizeof(tones) / sizeof(*tones)) - 1);
 
@@ -113,12 +113,12 @@ namespace FreeDV {
       // sum of amplitudes is 1.0.
       if ( sumOfAmplitudes > 1.0 )
         value /= sumOfAmplitudes;
-      array[i] = (int16_t)rint(value * master_amplitude * ((1 << 15) - 1));
+      array[i] = (std::int16_t)rint(value * master_amplitude * ((1 << 15) - 1));
     }
     clock = (clock + length) % SampleRate;
   }
 
-  size_t
+  std::size_t
   Tone::ready()
   {
     return SIZE_MAX;
index 079a85ac3275c75ce1ae223d2c6b649ee9f2c0b7..60e5b0e8c7b15b459c0263471d51f692d7df08cc 100644 (file)
@@ -5,7 +5,7 @@ namespace FreeDV {
   char *
   copy_string(const char * s)
   {
-    const size_t length(strlen(s) + 1);
+    const std::size_t length(strlen(s) + 1);
     char * copy = new char[length];
     memcpy(copy, s, length);
     return copy;