From: bruceperens Date: Tue, 25 Mar 2014 05:16:38 +0000 (+0000) Subject: Fix some too-large inlines. X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=5b90d8aac7b5249d671d618fe63437e090e1d975;p=freetel-svn-tracking.git Fix some too-large inlines. git-svn-id: https://svn.code.sf.net/p/freetel/code@1479 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/freedv-server/source/drivers.h b/freedv-server/source/drivers.h index ac3b205e..14946088 100644 --- a/freedv-server/source/drivers.h +++ b/freedv-server/source/drivers.h @@ -120,29 +120,18 @@ public: /// \param length The amount of data requested. This must be smaller /// than or equal to the amount returned by get_available(). /// \return The address of the data to be read. - inline const uint8_t * - get(std::size_t length) { - assert(length % 2 == 0); - if ( length > (std::size_t)(in - out) ) - get_overrun(); - return out; - } + const uint8_t * + get(std::size_t length); /// Finish the I/O after get(). /// \param length The amount of data, in bytes, actually read. /// This must be smaller than or equal to the amount passed to /// get(). - inline void get_done(std::size_t length) { - assert(length % 2 == 0); - out += length; - assert(out >= buffer && out <= buffer_end); - if ( out == in ) - out = in = buffer; - } + void get_done(std::size_t length); /// Returns the amount of space available for incoming data. /// \return The amount of space, in bytes, available for incoming data. - inline std::size_t put_space() const { + std::size_t put_space() const { return (buffer_end) - in + (out - buffer); } @@ -155,24 +144,12 @@ public: /// to the length passed to put(). /// \param length The size of buffer in chars requested. /// \return The address of the buffer for incoming data. - inline uint8_t * put(std::size_t length) { - assert(length % 2 == 0); - const uint8_t * io_end = in + length; - - if ( io_end > buffer_end ) - return reorder(length); - else - return in; - } + uint8_t * put(std::size_t length); /// Complete the I/O after put(). /// \param length The amount of data actually written. This must be /// smaller than or equal to the length passed to put(). - inline void put_done(std::size_t length) { - assert(length % 2 == 0); - in += length; - assert(in >= buffer && in <= buffer_end); - } + void put_done(std::size_t length); /// Discard any buffered data. /// @@ -650,18 +627,11 @@ public: class Interfaces { private: // Copy constructor and operator=() disabled. - Interfaces(const Interfaces &); - Interfaces & operator=(const Interfaces &); + Interfaces(const Interfaces &); + Interfaces & operator=(const Interfaces &); public: - Interfaces() : codec(0), - framer(0), keying_output(0), loudspeaker(0), - microphone(0), modem(0), ptt_input_digital(0), - ptt_input_ssb(0), receiver(0), text_input(0), - transmitter(0), user_interface(0) - { - } - - virtual ~Interfaces() final; + Interfaces(); + virtual ~Interfaces() final; /// The voice codec in use. /// diff --git a/freedv-server/source/fifo.cpp b/freedv-server/source/fifo.cpp index b136ecfe..5ade19b1 100644 --- a/freedv-server/source/fifo.cpp +++ b/freedv-server/source/fifo.cpp @@ -20,12 +20,47 @@ namespace FreeDV { delete buffer; } + const uint8_t * + FIFO::get(std::size_t length) { + assert(length % 2 == 0); + if ( length > (std::size_t)(in - out) ) + get_overrun(); + return out; + } + + void + FIFO::get_done(std::size_t length) { + assert(length % 2 == 0); + out += length; + assert(out >= buffer && out <= buffer_end); + if ( out == in ) + out = in = buffer; + } + void FIFO::get_overrun() const { throw std::runtime_error("FIFO outgoing data overrun."); } + uint8_t * + FIFO::put(std::size_t length) { + assert(length % 2 == 0); + const uint8_t * io_end = in + length; + + if ( io_end > buffer_end ) + return reorder(length); + else + return in; + } + + void + FIFO::put_done(std::size_t length) { + assert(length % 2 == 0); + in += length; + assert(in >= buffer && in <= buffer_end); + } + uint8_t * FIFO::reorder(std::size_t size) { diff --git a/freedv-server/source/interfaces.cpp b/freedv-server/source/interfaces.cpp index f93f0632..f730365d 100644 --- a/freedv-server/source/interfaces.cpp +++ b/freedv-server/source/interfaces.cpp @@ -10,6 +10,15 @@ static const char empty[1] = { '\0' }; namespace FreeDV { + Interfaces::Interfaces() + : codec(0), + framer(0), keying_output(0), loudspeaker(0), + microphone(0), modem(0), ptt_input_digital(0), + ptt_input_ssb(0), receiver(0), text_input(0), + transmitter(0), user_interface(0) + { + } + Interfaces::~Interfaces() { } diff --git a/freedv-server/source/platform/linux/audio_in_alsa.cpp b/freedv-server/source/platform/linux/audio_in_alsa.cpp index 4d2ff48c..78abee62 100644 --- a/freedv-server/source/platform/linux/audio_in_alsa.cpp +++ b/freedv-server/source/platform/linux/audio_in_alsa.cpp @@ -34,16 +34,7 @@ namespace FreeDV { AudioInALSA & operator=(const AudioInALSA &); NORETURN void - do_throw(const int error, const char * message = 0) - { - std::ostringstream str; - - str << "Error on ALSA audio input \"" << parameters << "\": "; - if ( message ) - str << message << ": "; - str << snd_strerror(error) << '.'; - throw std::runtime_error(str.str().c_str()); - } + do_throw(const int error, const char * message = 0); public: /// Instantiate the audio input. @@ -96,6 +87,18 @@ namespace FreeDV { free(parameters); } + NORETURN void + AudioInALSA::do_throw(const int error, const char * message) + { + std::ostringstream str; + + str << "Error on ALSA audio input \"" << parameters << "\": "; + if ( message ) + str << message << ": "; + str << snd_strerror(error) << '.'; + throw std::runtime_error(str.str().c_str()); + } + // Read audio into the "short" type. std::size_t AudioInALSA::read16(std::int16_t * array, std::size_t length) diff --git a/freedv-server/source/platform/linux/audio_out_alsa.cpp b/freedv-server/source/platform/linux/audio_out_alsa.cpp index 8f7d4a60..b22607fc 100644 --- a/freedv-server/source/platform/linux/audio_out_alsa.cpp +++ b/freedv-server/source/platform/linux/audio_out_alsa.cpp @@ -33,16 +33,7 @@ namespace FreeDV { AudioOutALSA & operator=(const AudioOutALSA &); NORETURN void - do_throw(const int error, const char * message = 0) - { - std::ostringstream str; - - str << "Error on ALSA audio output \"" << parameters << "\": "; - if ( message ) - str << message << ": "; - str << snd_strerror(error) << '.'; - throw std::runtime_error(str.str().c_str()); - } + do_throw(const int error, const char * message = 0); public: /// Instantiate the audio output. @@ -93,6 +84,18 @@ namespace FreeDV { free(parameters); } + NORETURN void + AudioOutALSA::do_throw(const int error, const char * message) + { + std::ostringstream str; + + str << "Error on ALSA audio output \"" << parameters << "\": "; + if ( message ) + str << message << ": "; + str << snd_strerror(error) << '.'; + throw std::runtime_error(str.str().c_str()); + } + // Write audio into the "short" type. std::size_t AudioOutALSA::write16(const std::int16_t * array, std::size_t length) @@ -201,5 +204,5 @@ namespace FreeDV { AudioOutALSAEnumerator); return true; } - static const bool initialized = initializer(); + static const bool UNUSED initialized = initializer(); }