Fix CodeQL complaints
- Multiplication result converted to larger type - Convert a lot of size variables from int to size_t
This commit is contained in:
parent
1aae84a195
commit
3de0a4f56c
|
|
@ -112,9 +112,9 @@ using namespace Async;
|
|||
|
||||
map<string, AudioDevice*> 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<channels; ch++)
|
||||
for (size_t ch=0; ch<channels; ch++)
|
||||
{
|
||||
for (int i=0; i<frame_cnt; i++)
|
||||
for (size_t i=0; i<frame_cnt; i++)
|
||||
{
|
||||
// no divisions in index calculation (embedded system performance !!!)
|
||||
samples[i] = static_cast<float>(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<samples_read; ++i)
|
||||
assert(samples_read >= 0);
|
||||
for (size_t i=0; i<static_cast<size_t>(samples_read); ++i)
|
||||
{
|
||||
int buf_pos = i * channels + channel;
|
||||
float sample = 32767.0 * tmp[i] + buf[buf_pos];
|
||||
|
|
|
|||
|
|
@ -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<std::string, AudioDevice*> devices;
|
||||
|
||||
|
||||
Mode current_mode;
|
||||
int use_count;
|
||||
size_t use_count;
|
||||
std::list<AudioIO*> aios;
|
||||
|
||||
}; /* class AudioDevice */
|
||||
|
|
|
|||
|
|
@ -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<size_t>(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<size_t>(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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<int>(log2(size));
|
||||
arg = (block_count_hint << 16) | frag_size_log2;
|
||||
arg = static_cast<int>((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<int>(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<int>(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<size_t>(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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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.size(); ++i)
|
||||
{
|
||||
dev += g[i].magnitudeSquared();
|
||||
|
|
@ -384,7 +384,7 @@ class DevPrinter : public AudioSink
|
|||
vector<Goertzel> g;
|
||||
int samp_cnt;
|
||||
float max_dev;
|
||||
float headroom;
|
||||
double headroom;
|
||||
double adj_level;
|
||||
double dev_est;
|
||||
size_t block_cnt;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ class PowerPlotter : public Async::AudioPassthrough
|
|||
double power = 0.0;
|
||||
for (int i=0; i<count; ++i)
|
||||
{
|
||||
power += samples[i] * samples[i];
|
||||
power += static_cast<double>(samples[i]) * samples[i];
|
||||
}
|
||||
power /= count;
|
||||
power = ALPHA * power + (1-ALPHA) * prev_power;
|
||||
|
|
|
|||
|
|
@ -294,8 +294,7 @@ int SigLevDetNoise::processSamples(float *samples, int count)
|
|||
for (int i=0; i<count; ++i)
|
||||
{
|
||||
const float &sample = samples[i];
|
||||
const double square = sample * sample;
|
||||
ss += square;
|
||||
ss += static_cast<double>(sample) * sample;
|
||||
if (++ss_cnt >= block_len)
|
||||
{
|
||||
SsSetIter it = ss_values.insert(ss);
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ void SvxSwDtmfDecoder::processBlock(void)
|
|||
for (size_t i=0; i<BLOCK_SIZE; ++i)
|
||||
{
|
||||
float sample = block[i] * win[i];
|
||||
block_energy += sample * sample;
|
||||
block_energy += static_cast<double>(sample) * sample;
|
||||
row[0].calc(sample);
|
||||
row[1].calc(sample);
|
||||
row[2].calc(sample);
|
||||
|
|
|
|||
|
|
@ -465,7 +465,7 @@ int ToneDetector::writeSamples(const float *buf, int len)
|
|||
famp *= *(win++);
|
||||
}
|
||||
|
||||
passband_energy += famp * famp;
|
||||
passband_energy += static_cast<double>(famp) * famp;
|
||||
|
||||
// Run the recursive Goertzel stage for the center frequency
|
||||
par->center.calc(famp);
|
||||
|
|
|
|||
12
src/versions
12
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue