From 3de0a4f56c4baa48664cbcc3d8a033974acd47ec Mon Sep 17 00:00:00 2001 From: Tobias Blomberg Date: Sun, 31 Jan 2021 18:19:39 +0100 Subject: [PATCH] Fix CodeQL complaints - Multiplication result converted to larger type - Convert a lot of size variables from int to size_t --- src/async/audio/AsyncAudioDevice.cpp | 25 ++++----- src/async/audio/AsyncAudioDevice.h | 69 +++++++++++++++++------- src/async/audio/AsyncAudioDeviceAlsa.cpp | 18 ++++--- src/async/audio/AsyncAudioDeviceAlsa.h | 16 +++--- src/async/audio/AsyncAudioDeviceOSS.cpp | 28 +++++----- src/async/audio/AsyncAudioDeviceOSS.h | 6 +-- src/async/audio/AsyncAudioDeviceUDP.cpp | 9 ++-- src/async/audio/AsyncAudioDeviceUDP.h | 8 +-- src/async/audio/AsyncAudioIO.cpp | 12 ++--- src/async/audio/AsyncAudioIO.h | 16 +++--- src/async/audio/AsyncAudioReader.cpp | 8 ++- src/svxlink/devcal/devcal.cpp | 6 +-- src/svxlink/remotetrx/remotetrx.cpp | 2 +- src/svxlink/svxlink/svxlink.cpp | 2 +- src/svxlink/trx/DtmfDecoderTest.cpp | 2 +- src/svxlink/trx/SigLevDetNoise.cpp | 3 +- src/svxlink/trx/SvxSwDtmfDecoder.cpp | 2 +- src/svxlink/trx/ToneDetector.cpp | 2 +- src/versions | 12 ++--- 19 files changed, 139 insertions(+), 107 deletions(-) diff --git a/src/async/audio/AsyncAudioDevice.cpp b/src/async/audio/AsyncAudioDevice.cpp index 65a5a09a..0ab9fdf3 100644 --- a/src/async/audio/AsyncAudioDevice.cpp +++ b/src/async/audio/AsyncAudioDevice.cpp @@ -112,9 +112,9 @@ using namespace Async; map AudioDevice::devices; int AudioDevice::sample_rate = DEFAULT_SAMPLE_RATE; -int AudioDevice::block_size_hint = DEFAULT_BLOCK_SIZE_HINT; -int AudioDevice::block_count_hint = DEFAULT_BLOCK_COUNT_HINT; -int AudioDevice::channels = DEFAULT_CHANNELS; +size_t AudioDevice::block_size_hint = DEFAULT_BLOCK_SIZE_HINT; +size_t AudioDevice::block_count_hint = DEFAULT_BLOCK_COUNT_HINT; +size_t AudioDevice::channels = DEFAULT_CHANNELS; @@ -263,13 +263,13 @@ AudioDevice::~AudioDevice(void) } /* AudioDevice::~AudioDevice */ -void AudioDevice::putBlocks(int16_t *buf, int frame_cnt) +void AudioDevice::putBlocks(int16_t *buf, size_t frame_cnt) { - //printf("putBlocks: frame_cnt=%d\n", frame_cnt); + //printf("putBlocks: frame_cnt=%zu\n", frame_cnt); float samples[frame_cnt]; - for (int ch=0; ch(buf[i * channels + ch]) / 32768.0; @@ -286,10 +286,10 @@ void AudioDevice::putBlocks(int16_t *buf, int frame_cnt) } /* AudioDevice::putBlocks */ -int AudioDevice::getBlocks(int16_t *buf, int block_cnt) +size_t AudioDevice::getBlocks(int16_t *buf, size_t block_cnt) { - unsigned block_size = writeBlocksize(); - unsigned frames_to_write = block_cnt * block_size; + size_t block_size = writeBlocksize(); + size_t frames_to_write = block_cnt * block_size; memset(buf, 0, channels * frames_to_write * sizeof(*buf)); // Loop through all AudioIO objects and find out if they have any @@ -350,10 +350,11 @@ int AudioDevice::getBlocks(int16_t *buf, int block_cnt) { if (!(*it)->isIdle()) { - int channel = (*it)->channel(); + size_t channel = (*it)->channel(); float tmp[frames_to_write]; int samples_read = (*it)->readSamples(tmp, frames_to_write); - for (int i=0; i= 0); + for (size_t i=0; i(samples_read); ++i) { int buf_pos = i * channels + channel; float sample = 32767.0 * tmp[i] + buf[buf_pos]; diff --git a/src/async/audio/AsyncAudioDevice.h b/src/async/audio/AsyncAudioDevice.h index 854451fd..2f8a79af 100644 --- a/src/async/audio/AsyncAudioDevice.h +++ b/src/async/audio/AsyncAudioDevice.h @@ -178,7 +178,7 @@ class AudioDevice : public sigc::trackable * This is a global setting so all sound cards will be affected. Already * opened sound cards will not be affected. */ - static void setBlocksize(int size) + static void setBlocksize(size_t size) { block_size_hint = size; } @@ -187,13 +187,13 @@ class AudioDevice : public sigc::trackable * @brief Find out what the read (recording) blocksize is set to * @return Returns the currently set blocksize in samples per channel */ - virtual int readBlocksize(void) = 0; + virtual size_t readBlocksize(void) = 0; /** * @brief Find out what the write (playback) blocksize is set to * @return Returns the currently set blocksize in samples per channel */ - virtual int writeBlocksize(void) = 0; + virtual size_t writeBlocksize(void) = 0; /** * @brief Set the buffer count used when opening audio devices @@ -208,7 +208,7 @@ class AudioDevice : public sigc::trackable * This is a global setting so all sound cards will be affected. Already * opened sound cards will not be affected. */ - static void setBlockCount(int count) + static void setBlockCount(size_t count) { block_count_hint = (count <= 0) ? 0 : count; } @@ -222,12 +222,16 @@ class AudioDevice : public sigc::trackable * This is a global setting so all sound cards will be affected. Already * opened sound cards will not be affected. */ - static void setChannels(int channels) + static void setChannels(size_t channels) { AudioDevice::channels = channels; } - static int getChannels(void) { return channels; } + /** + * @brief Get the number of channels used for future opens + * @return Returns the number of channels used for future opens + */ + static size_t getChannels(void) { return channels; } /** * @brief Check if the audio device has full duplex capability @@ -292,9 +296,9 @@ class AudioDevice : public sigc::trackable protected: static int sample_rate; - static int block_size_hint; - static int block_count_hint; - static int channels; + static size_t block_size_hint; + static size_t block_count_hint; + static size_t channels; std::string dev_name; @@ -321,20 +325,45 @@ class AudioDevice : public sigc::trackable */ virtual void closeDevice(void) = 0; - void putBlocks(int16_t *buf, int frame_cnt); - int getBlocks(int16_t *buf, int block_cnt); - - + /** + * @brief Write samples read from audio device to upper layers + * @param buf Buffer containing frames of samples to write + * @param frame_cnt The number of frames of samples in the buffer + * + * This function is used by an audio device implementation to write audio + * samples recorded from the actual audio device to the upper software + * layers, for further processing. The number of samples is given as + * frames. A frame contains one sample per channel starting with channel 0. + * Frames are put in the buffer one after the other. Thus, the sample + * buffer should contain frame_cnt * channels samples. + */ + void putBlocks(int16_t *buf, size_t frame_cnt); + + /** + * @brief Read samples from upper layers to write to audio device + * @brief buf Buffer which will be filled with frames of samples + * @brief block_cnt The size of the buffer counted in blocks + * @return The number of blocks actually stored in the buffer + * + * This function is used by an audio device implementation to get samples + * from upper layers to write to the actual audio device. The count is + * given in blocks. The buffer must be able to store the number given in + * block_cnt. Fewer blocks may be returned if the requested block count is + * not available. The number of samples a block contain is + * ret_blocks * writeBlocksize() * channels. + */ + size_t getBlocks(int16_t *buf, size_t block_cnt); + private: - static const int DEFAULT_SAMPLE_RATE = INTERNAL_SAMPLE_RATE; - static const int DEFAULT_CHANNELS = 2; - static const int DEFAULT_BLOCK_COUNT_HINT = 4; - static const int DEFAULT_BLOCK_SIZE_HINT = 256; // Samples/channel/block - + static const int DEFAULT_SAMPLE_RATE = INTERNAL_SAMPLE_RATE; + static const size_t DEFAULT_CHANNELS = 2; + static const size_t DEFAULT_BLOCK_COUNT_HINT = 4; + static const size_t DEFAULT_BLOCK_SIZE_HINT = 256; // Samples/channel/block + static std::map devices; - + Mode current_mode; - int use_count; + size_t use_count; std::list aios; }; /* class AudioDevice */ diff --git a/src/async/audio/AsyncAudioDeviceAlsa.cpp b/src/async/audio/AsyncAudioDeviceAlsa.cpp index f3cefff5..5669081f 100644 --- a/src/async/audio/AsyncAudioDeviceAlsa.cpp +++ b/src/async/audio/AsyncAudioDeviceAlsa.cpp @@ -230,13 +230,13 @@ AudioDeviceAlsa::~AudioDeviceAlsa(void) } /* AudioDeviceAlsa::~AudioDeviceAlsa */ -int AudioDeviceAlsa::readBlocksize(void) +size_t AudioDeviceAlsa::readBlocksize(void) { return rec_block_size; } /* AudioDeviceAlsa::readBlocksize */ -int AudioDeviceAlsa::writeBlocksize(void) +size_t AudioDeviceAlsa::writeBlocksize(void) { return play_block_size; } /* AudioDeviceAlsa::writeBlocksize */ @@ -416,7 +416,7 @@ void AudioDeviceAlsa::audioReadHandler(FdWatch *watch, unsigned short revents) return; } - int frames_avail = snd_pcm_avail_update(rec_handle); + snd_pcm_sframes_t frames_avail = snd_pcm_avail_update(rec_handle); if (frames_avail < 0) { if (!startCapture(rec_handle)) @@ -428,7 +428,7 @@ void AudioDeviceAlsa::audioReadHandler(FdWatch *watch, unsigned short revents) //printf("frames_avail=%d\n", frames_avail); - if (frames_avail >= rec_block_size) + if (static_cast(frames_avail) >= rec_block_size) { frames_avail /= rec_block_size; frames_avail *= rec_block_size; @@ -436,7 +436,8 @@ void AudioDeviceAlsa::audioReadHandler(FdWatch *watch, unsigned short revents) int16_t buf[frames_avail * channels]; memset(buf, 0, sizeof(buf)); - int frames_read = snd_pcm_readi(rec_handle, buf, frames_avail); + snd_pcm_sframes_t frames_read = snd_pcm_readi(rec_handle, buf, + frames_avail); if (frames_read < 0) { if (!startCapture(rec_handle)) @@ -466,7 +467,7 @@ void AudioDeviceAlsa::writeSpaceAvailable(FdWatch *watch, unsigned short revents while (1) { - int space_avail = snd_pcm_avail_update(play_handle); + snd_pcm_sframes_t space_avail = snd_pcm_avail_update(play_handle); // Bail out if there's an error if (space_avail < 0) @@ -479,7 +480,7 @@ void AudioDeviceAlsa::writeSpaceAvailable(FdWatch *watch, unsigned short revents continue; } - int blocks_to_read = space_avail / play_block_size; + size_t blocks_to_read = static_cast(space_avail) / play_block_size; if (blocks_to_read == 0) { //printf("No free blocks available in sound card buffer\n"); @@ -712,7 +713,8 @@ bool AudioDeviceAlsa::initParams(snd_pcm_t *pcm_handle) bool AudioDeviceAlsa::getBlockAttributes(snd_pcm_t *pcm_handle, - int &block_size, int &block_count) + size_t &block_size, + size_t &block_count) { snd_pcm_hw_params_t *hw_params; int err = snd_pcm_hw_params_malloc (&hw_params); diff --git a/src/async/audio/AsyncAudioDeviceAlsa.h b/src/async/audio/AsyncAudioDeviceAlsa.h index d8b9d32e..fc539f05 100644 --- a/src/async/audio/AsyncAudioDeviceAlsa.h +++ b/src/async/audio/AsyncAudioDeviceAlsa.h @@ -132,13 +132,13 @@ class AudioDeviceAlsa : public AudioDevice * @brief Find out what the read (recording) blocksize is set to * @return Returns the currently set blocksize in samples per channel */ - virtual int readBlocksize(void); + virtual size_t readBlocksize(void); /** * @brief Find out what the write (playback) blocksize is set to * @return Returns the currently set blocksize in samples per channel */ - virtual int writeBlocksize(void); + virtual size_t writeBlocksize(void); /** * @brief Check if the audio device has full duplex capability @@ -187,10 +187,10 @@ class AudioDeviceAlsa : public AudioDevice private: class AlsaWatch; - int play_block_size; - int play_block_count; - int rec_block_size; - int rec_block_count; + size_t play_block_size; + size_t play_block_count; + size_t rec_block_size; + size_t rec_block_count; snd_pcm_t *play_handle; snd_pcm_t *rec_handle; AlsaWatch *play_watch; @@ -203,8 +203,8 @@ class AudioDeviceAlsa : public AudioDevice void audioReadHandler(FdWatch *watch, unsigned short revents); void writeSpaceAvailable(FdWatch *watch, unsigned short revents); bool initParams(snd_pcm_t *pcm_handle); - bool getBlockAttributes(snd_pcm_t *pcm_handle, int &block_size, - int &period_size); + bool getBlockAttributes(snd_pcm_t *pcm_handle, size_t &block_size, + size_t &period_size); bool startPlayback(snd_pcm_t *pcm_handle); bool startCapture(snd_pcm_t *pcm_handle); diff --git a/src/async/audio/AsyncAudioDeviceOSS.cpp b/src/async/audio/AsyncAudioDeviceOSS.cpp index ec21fad4..8f561681 100644 --- a/src/async/audio/AsyncAudioDeviceOSS.cpp +++ b/src/async/audio/AsyncAudioDeviceOSS.cpp @@ -130,14 +130,14 @@ REGISTER_AUDIO_DEVICE_TYPE("oss", AudioDeviceOSS); * ****************************************************************************/ -int AudioDeviceOSS::readBlocksize(void) +size_t AudioDeviceOSS::readBlocksize(void) { assert(fd != -1); return frag_size / (channels * sizeof(int16_t)); } /* AudioDeviceOSS::readBlocksize */ -int AudioDeviceOSS::writeBlocksize(void) +size_t AudioDeviceOSS::writeBlocksize(void) { assert(fd != -1); return frag_size / (channels * sizeof(int16_t)); @@ -284,10 +284,10 @@ bool AudioDeviceOSS::openDevice(Mode mode) } } - int size = (block_size_hint <= 0) ? 1 : - block_size_hint * channels * sizeof(int16_t); + size_t size = (block_size_hint == 0) ? 1 : + block_size_hint * channels * sizeof(int16_t); int frag_size_log2 = static_cast(log2(size)); - arg = (block_count_hint << 16) | frag_size_log2; + arg = static_cast((block_count_hint << 16) | frag_size_log2); if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &arg) == -1) { perror("SNDCTL_DSP_SETFRAGMENT ioctl failed"); @@ -310,16 +310,16 @@ bool AudioDeviceOSS::openDevice(Mode mode) return false; } - arg = channels; + arg = static_cast(channels); if(ioctl(fd, SNDCTL_DSP_CHANNELS, &arg) == -1) { perror("SNDCTL_DSP_CHANNELS ioctl failed"); close(); return false; } - if(arg != channels) + if(arg != static_cast(channels)) { - fprintf(stderr, "*** error: Unable to set number of channels to %d. The " + fprintf(stderr, "*** error: Unable to set number of channels to %zu. The " "driver suggested %d channels\n", channels, arg); close(); @@ -372,13 +372,15 @@ bool AudioDeviceOSS::openDevice(Mode mode) } } - frag_size = 0; - if (ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) + arg = 0; + if (ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &arg) == -1) { perror("SNDCTL_DSP_GETBLKSIZE ioctl failed"); close(); return false; } + assert(arg >= 0); + frag_size = static_cast(arg); return true; @@ -448,7 +450,7 @@ void AudioDeviceOSS::writeSpaceAvailable(FdWatch *watch) audio_buf_info info; //unsigned fragsize; // The frag (block) size in frames unsigned fragments; - unsigned frags_read; + size_t frags_read; do { // Find out how many frags we can write to the sound card @@ -468,7 +470,7 @@ void AudioDeviceOSS::writeSpaceAvailable(FdWatch *watch) int16_t buf[32768]; frags_read = getBlocks(buf, fragments); - //printf("fragments=%u frags_read=%u\n", fragments, frags_read); + //printf("fragments=%u frags_read=%zu\n", fragments, frags_read); if (frags_read == 0) { watch->setEnabled(false); @@ -476,7 +478,7 @@ void AudioDeviceOSS::writeSpaceAvailable(FdWatch *watch) } // Write the samples to the sound card - //printf("Writing %d fragments\n", frags_read); + //printf("Writing %zu fragments\n", frags_read); int written = ::write(fd, buf, frags_read * frag_size); if (written < 0) { diff --git a/src/async/audio/AsyncAudioDeviceOSS.h b/src/async/audio/AsyncAudioDeviceOSS.h index d3b58cf9..76b59476 100644 --- a/src/async/audio/AsyncAudioDeviceOSS.h +++ b/src/async/audio/AsyncAudioDeviceOSS.h @@ -134,13 +134,13 @@ class AudioDeviceOSS : public Async::AudioDevice * @brief Find out what the read (recording) blocksize is set to * @return Returns the currently set blocksize in samples per channel */ - virtual int readBlocksize(void); + virtual size_t readBlocksize(void); /** * @brief Find out what the write (playback) blocksize is set to * @return Returns the currently set blocksize in samples per channel */ - virtual int writeBlocksize(void); + virtual size_t writeBlocksize(void); /** * @brief Check if the audio device has full duplex capability @@ -195,7 +195,7 @@ class AudioDeviceOSS : public Async::AudioDevice FdWatch *write_watch; int device_caps; bool use_trigger; - int frag_size; + size_t frag_size; void audioReadHandler(FdWatch *watch); void writeSpaceAvailable(FdWatch *watch); diff --git a/src/async/audio/AsyncAudioDeviceUDP.cpp b/src/async/audio/AsyncAudioDeviceUDP.cpp index 7fd43f55..133e8a19 100644 --- a/src/async/audio/AsyncAudioDeviceUDP.cpp +++ b/src/async/audio/AsyncAudioDeviceUDP.cpp @@ -125,13 +125,13 @@ REGISTER_AUDIO_DEVICE_TYPE("udp", AudioDeviceUDP); * ****************************************************************************/ -int AudioDeviceUDP::readBlocksize(void) +size_t AudioDeviceUDP::readBlocksize(void) { return block_size; } /* AudioDeviceUDP::readBlocksize */ -int AudioDeviceUDP::writeBlocksize(void) +size_t AudioDeviceUDP::writeBlocksize(void) { return block_size; } /* AudioDeviceUDP::writeBlocksize */ @@ -193,7 +193,8 @@ AudioDeviceUDP::AudioDeviceUDP(const string& dev_name) read_buf_pos(0), port(0) { assert(AudioDeviceUDP_creator_registered); - int pace_interval = 1000 * block_size_hint / sampleRate(); + assert(sampleRate() > 0); + size_t pace_interval = 1000 * block_size_hint / sampleRate(); block_size = pace_interval * sampleRate() / 1000; read_buf = new int16_t[block_size * channels]; @@ -321,7 +322,7 @@ void AudioDeviceUDP::audioReadHandler(const IpAddress &ip, uint16_t port, { for (unsigned i=0; i < count / (channels * sizeof(int16_t)); ++i) { - for (int ch=0; ch < channels; ++ch) + for (size_t ch=0; ch < channels; ++ch) { read_buf[read_buf_pos * channels + ch] = ((int16_t *)buf)[i * channels + ch]; diff --git a/src/async/audio/AsyncAudioDeviceUDP.h b/src/async/audio/AsyncAudioDeviceUDP.h index aa363945..a552f859 100644 --- a/src/async/audio/AsyncAudioDeviceUDP.h +++ b/src/async/audio/AsyncAudioDeviceUDP.h @@ -138,13 +138,13 @@ class AudioDeviceUDP : public Async::AudioDevice * @brief Find out what the read (recording) blocksize is set to * @return Returns the currently set blocksize in samples per channel */ - virtual int readBlocksize(void); + virtual size_t readBlocksize(void); /** * @brief Find out what the write (playback) blocksize is set to * @return Returns the currently set blocksize in samples per channel */ - virtual int writeBlocksize(void); + virtual size_t writeBlocksize(void); /** * @brief Check if the audio device has full duplex capability @@ -192,10 +192,10 @@ class AudioDeviceUDP : public Async::AudioDevice private: - int block_size; + size_t block_size; Async::UdpSocket *sock; int16_t *read_buf; - int read_buf_pos; + size_t read_buf_pos; IpAddress ip_addr; uint16_t port; Async::Timer *pace_timer; diff --git a/src/async/audio/AsyncAudioIO.cpp b/src/async/audio/AsyncAudioIO.cpp index 215ed955..606107b1 100644 --- a/src/async/audio/AsyncAudioIO.cpp +++ b/src/async/audio/AsyncAudioIO.cpp @@ -238,38 +238,38 @@ void AudioIO::setSampleRate(int rate) } /* AudioIO::setSampleRate */ -void AudioIO::setBlocksize(int size) +void AudioIO::setBlocksize(size_t size) { AudioDevice::setBlocksize(size); } /* AudioIO::setBlocksize */ -int AudioIO::readBlocksize(void) +size_t AudioIO::readBlocksize(void) { return audio_dev->readBlocksize(); } /* AudioIO::readBlocksize */ -int AudioIO::writeBlocksize(void) +size_t AudioIO::writeBlocksize(void) { return audio_dev->writeBlocksize(); } /* AudioIO::writeBlocksize */ -void AudioIO::setBlockCount(int count) +void AudioIO::setBlockCount(size_t count) { AudioDevice::setBlockCount(count); } /* AudioIO::setBlockCount */ -void AudioIO::setChannels(int channels) +void AudioIO::setChannels(size_t channels) { return AudioDevice::setChannels(channels); } /* AudioIO::setBufferCount */ -AudioIO::AudioIO(const string& dev_name, int channel) +AudioIO::AudioIO(const string& dev_name, size_t channel) : io_mode(MODE_NONE), audio_dev(0), /* lead_in_pos(0), */ m_gain(1.0), sample_rate(-1), m_channel(channel), input_valve(0), input_fifo(0), audio_reader(0) diff --git a/src/async/audio/AsyncAudioIO.h b/src/async/audio/AsyncAudioIO.h index b22bcf44..1884be5f 100644 --- a/src/async/audio/AsyncAudioIO.h +++ b/src/async/audio/AsyncAudioIO.h @@ -169,19 +169,19 @@ class AudioIO : public Async::AudioSource, public Async::AudioSink * This is a global setting so all sound cards will be affected. Already * opened sound cards will not be affected. */ - static void setBlocksize(int size); + static void setBlocksize(size_t size); /** * @brief Find out what the read (recording) blocksize is set to * @return Returns the currently set blocksize in samples per channel */ - int readBlocksize(void); + size_t readBlocksize(void); /** * @brief Find out what the write (playback) blocksize is set to * @return Returns the currently set blocksize in samples per channel */ - int writeBlocksize(void); + size_t writeBlocksize(void); /** * @brief Set the block count used when opening audio devices @@ -195,7 +195,7 @@ class AudioIO : public Async::AudioSource, public Async::AudioSink * This is a global setting so all sound cards will be affected. Already * opened sound cards will not be affected. */ - static void setBlockCount(int count); + static void setBlockCount(size_t count); /** * @brief Set the number of channels used when doing future opens @@ -206,14 +206,14 @@ class AudioIO : public Async::AudioSource, public Async::AudioSink * This is a global setting so all sound cards will be affected. Already * opened sound cards will not be affected. */ - static void setChannels(int channels); + static void setChannels(size_t channels); /** * @brief Constructor * @param dev_name The name of the device to use * @param channel The channel number (zero is the first channel) */ - AudioIO(const std::string& dev_name, int channel); + AudioIO(const std::string& dev_name, size_t channel); /** * @brief Destructor @@ -301,7 +301,7 @@ class AudioIO : public Async::AudioSource, public Async::AudioSink * @brief Return the audio channel used * @return Returns the audio channel that was given to the constructor */ - int channel(void) const { return m_channel; } + size_t channel(void) const { return m_channel; } /** * @brief Resume audio output to the sink @@ -351,7 +351,7 @@ class AudioIO : public Async::AudioSource, public Async::AudioSink AudioDevice *audio_dev; float m_gain; int sample_rate; - int m_channel; + size_t m_channel; AudioValve *input_valve; InputFifo *input_fifo; DelayedFlushAudioReader *audio_reader; diff --git a/src/async/audio/AsyncAudioReader.cpp b/src/async/audio/AsyncAudioReader.cpp index d5e5a9ba..f36230b2 100644 --- a/src/async/audio/AsyncAudioReader.cpp +++ b/src/async/audio/AsyncAudioReader.cpp @@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include #include +#include /**************************************************************************** @@ -127,11 +128,8 @@ AudioReader::~AudioReader(void) int AudioReader::readSamples(float *samples, int count) { - if (count == 0) - { - return 0; - } - + assert(count > 0); + buf = samples; buf_size = count; samples_in_buf = 0; diff --git a/src/svxlink/devcal/devcal.cpp b/src/svxlink/devcal/devcal.cpp index 2a915d86..59f83115 100644 --- a/src/svxlink/devcal/devcal.cpp +++ b/src/svxlink/devcal/devcal.cpp @@ -324,13 +324,13 @@ class DevPrinter : public AudioSink if (++samp_cnt >= block_size) { double avg_power = pwr_sum / block_size; - float tot_dev = sqrt(avg_power) * sqrt(2); + double tot_dev = sqrt(avg_power) * sqrt(2); tot_dev *= adj_level; tot_dev *= headroom * max_dev; tot_dev_est = (1.0-ALPHA) * tot_dev + ALPHA * tot_dev_est; pwr_sum = 0.0; - float dev = 0.0f; + double dev = 0.0; for (size_t i=0; i g; int samp_cnt; float max_dev; - float headroom; + double headroom; double adj_level; double dev_est; size_t block_cnt; diff --git a/src/svxlink/remotetrx/remotetrx.cpp b/src/svxlink/remotetrx/remotetrx.cpp index 832b9190..8c4995c4 100644 --- a/src/svxlink/remotetrx/remotetrx.cpp +++ b/src/svxlink/remotetrx/remotetrx.cpp @@ -518,7 +518,7 @@ int main(int argc, char **argv) cout << "--- Using sample rate " << rate << "Hz\n"; } - int card_channels = 2; + size_t card_channels = 2; cfg.getValue("GLOBAL", "CARD_CHANNELS", card_channels); AudioIO::setChannels(card_channels); diff --git a/src/svxlink/svxlink/svxlink.cpp b/src/svxlink/svxlink/svxlink.cpp index 7aef63c0..f946b156 100644 --- a/src/svxlink/svxlink/svxlink.cpp +++ b/src/svxlink/svxlink/svxlink.cpp @@ -479,7 +479,7 @@ int main(int argc, char **argv) cout << "--- Using sample rate " << rate << "Hz\n"; } - int card_channels = 2; + size_t card_channels = 2; cfg.getValue("GLOBAL", "CARD_CHANNELS", card_channels); AudioIO::setChannels(card_channels); diff --git a/src/svxlink/trx/DtmfDecoderTest.cpp b/src/svxlink/trx/DtmfDecoderTest.cpp index 009a6e68..7c298d5e 100644 --- a/src/svxlink/trx/DtmfDecoderTest.cpp +++ b/src/svxlink/trx/DtmfDecoderTest.cpp @@ -162,7 +162,7 @@ class PowerPlotter : public Async::AudioPassthrough double power = 0.0; for (int i=0; i(samples[i]) * samples[i]; } power /= count; power = ALPHA * power + (1-ALPHA) * prev_power; diff --git a/src/svxlink/trx/SigLevDetNoise.cpp b/src/svxlink/trx/SigLevDetNoise.cpp index 54db297f..d3a78b6f 100644 --- a/src/svxlink/trx/SigLevDetNoise.cpp +++ b/src/svxlink/trx/SigLevDetNoise.cpp @@ -294,8 +294,7 @@ int SigLevDetNoise::processSamples(float *samples, int count) for (int i=0; i(sample) * sample; if (++ss_cnt >= block_len) { SsSetIter it = ss_values.insert(ss); diff --git a/src/svxlink/trx/SvxSwDtmfDecoder.cpp b/src/svxlink/trx/SvxSwDtmfDecoder.cpp index f3c3d72e..c102a997 100644 --- a/src/svxlink/trx/SvxSwDtmfDecoder.cpp +++ b/src/svxlink/trx/SvxSwDtmfDecoder.cpp @@ -259,7 +259,7 @@ void SvxSwDtmfDecoder::processBlock(void) for (size_t i=0; i(sample) * sample; row[0].calc(sample); row[1].calc(sample); row[2].calc(sample); diff --git a/src/svxlink/trx/ToneDetector.cpp b/src/svxlink/trx/ToneDetector.cpp index 274ce471..a905b083 100644 --- a/src/svxlink/trx/ToneDetector.cpp +++ b/src/svxlink/trx/ToneDetector.cpp @@ -465,7 +465,7 @@ int ToneDetector::writeSamples(const float *buf, int len) famp *= *(win++); } - passband_energy += famp * famp; + passband_energy += static_cast(famp) * famp; // Run the recursive Goertzel stage for the center frequency par->center.calc(famp); diff --git a/src/versions b/src/versions index 0d5702d4..c92150bd 100644 --- a/src/versions +++ b/src/versions @@ -2,16 +2,16 @@ PROJECT=master # Version for the Qtel application -QTEL=1.2.4.99.0 +QTEL=1.2.4.99.1 # Version for the EchoLib library LIBECHOLIB=1.3.3.99.0 # Version for the Async library -LIBASYNC=1.6.99.13 +LIBASYNC=1.6.99.14 # SvxLink versions -SVXLINK=1.7.99.46 +SVXLINK=1.7.99.47 MODULE_HELP=1.0.0 MODULE_PARROT=1.1.1 MODULE_ECHO_LINK=1.5.99.1 @@ -25,13 +25,13 @@ MODULE_FRN=1.1.0 MODULE_TRX=1.0.0 # Version for the RemoteTrx application -REMOTE_TRX=1.3.99.3 +REMOTE_TRX=1.3.99.4 # Version for the signal level calibration utility -SIGLEV_DET_CAL=1.0.7.99.0 +SIGLEV_DET_CAL=1.0.7.99.1 # Version for the deviation calibration utility -DEVCAL=1.0.2.99.0 +DEVCAL=1.0.2.99.1 # Version for svxserver SVXSERVER=0.0.6