Fix Windows warnings

This commit is contained in:
badaix 2020-04-10 13:27:08 +02:00
parent ade0ee7be3
commit e5047f1aff
12 changed files with 167 additions and 165 deletions

View file

@ -5,164 +5,164 @@ group: edge
matrix:
include:
- os: linux
compiler: gcc
env:
- COMPILER=g++-4.9
addons:
apt:
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- ubuntu-toolchain-r-test
packages:
- g++-4.9 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
# - os: linux
# compiler: gcc
# env:
# - COMPILER=g++-4.9
# addons:
# apt:
# sources:
# - sourceline: 'ppa:mhier/libboost-latest'
# - ubuntu-toolchain-r-test
# packages:
# - g++-4.9 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
- os: linux
compiler: gcc
env:
- COMPILER=g++-5
addons:
apt:
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- ubuntu-toolchain-r-test
packages:
- g++-5 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
# - os: linux
# compiler: gcc
# env:
# - COMPILER=g++-5
# addons:
# apt:
# sources:
# - sourceline: 'ppa:mhier/libboost-latest'
# - ubuntu-toolchain-r-test
# packages:
# - g++-5 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
- os: linux
compiler: gcc
env:
- COMPILER=g++-6
addons:
apt:
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- ubuntu-toolchain-r-test
packages:
- g++-6 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
# - os: linux
# compiler: gcc
# env:
# - COMPILER=g++-6
# addons:
# apt:
# sources:
# - sourceline: 'ppa:mhier/libboost-latest'
# - ubuntu-toolchain-r-test
# packages:
# - g++-6 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
- os: linux
compiler: gcc
env:
- COMPILER=g++-7
addons:
apt:
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- ubuntu-toolchain-r-test
packages:
- g++-7 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
# - os: linux
# compiler: gcc
# env:
# - COMPILER=g++-7
# addons:
# apt:
# sources:
# - sourceline: 'ppa:mhier/libboost-latest'
# - ubuntu-toolchain-r-test
# packages:
# - g++-7 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
- os: linux
compiler: gcc
env:
- COMPILER=g++-8
addons:
apt:
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- ubuntu-toolchain-r-test
packages:
- g++-8 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
# - os: linux
# compiler: gcc
# env:
# - COMPILER=g++-8
# addons:
# apt:
# sources:
# - sourceline: 'ppa:mhier/libboost-latest'
# - ubuntu-toolchain-r-test
# packages:
# - g++-8 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
- os: linux
compiler: gcc
env:
- COMPILER=g++-9
addons:
apt:
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- ubuntu-toolchain-r-test
packages:
- g++-9 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
# - os: linux
# compiler: gcc
# env:
# - COMPILER=g++-9
# addons:
# apt:
# sources:
# - sourceline: 'ppa:mhier/libboost-latest'
# - ubuntu-toolchain-r-test
# packages:
# - g++-9 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
- os: linux
compiler: clang
env:
- COMPILER=clang++-3.9
- CXXFLAGS=-stdlib=libc++
- CC=clang-3.9
addons:
apt:
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- llvm-toolchain-trusty-3.9
packages:
- clang-3.9 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
# - os: linux
# compiler: clang
# env:
# - COMPILER=clang++-3.9
# - CXXFLAGS=-stdlib=libc++
# - CC=clang-3.9
# addons:
# apt:
# sources:
# - sourceline: 'ppa:mhier/libboost-latest'
# - llvm-toolchain-trusty-3.9
# packages:
# - clang-3.9 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
- os: linux
compiler: clang
env:
- COMPILER=clang++-4.0
- CXXFLAGS=-stdlib=libc++
- CC=clang-4.0
addons:
apt:
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- llvm-toolchain-trusty-4.0
packages:
- clang-4.0 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
# - os: linux
# compiler: clang
# env:
# - COMPILER=clang++-4.0
# - CXXFLAGS=-stdlib=libc++
# - CC=clang-4.0
# addons:
# apt:
# sources:
# - sourceline: 'ppa:mhier/libboost-latest'
# - llvm-toolchain-trusty-4.0
# packages:
# - clang-4.0 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
- os: linux
compiler: clang
env:
- COMPILER=clang++-5.0
- CXXFLAGS=-stdlib=libc++
- CC=clang-5.0
addons:
apt:
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- llvm-toolchain-trusty-5.0
packages:
- clang-5.0 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
# - os: linux
# compiler: clang
# env:
# - COMPILER=clang++-5.0
# - CXXFLAGS=-stdlib=libc++
# - CC=clang-5.0
# addons:
# apt:
# sources:
# - sourceline: 'ppa:mhier/libboost-latest'
# - llvm-toolchain-trusty-5.0
# packages:
# - clang-5.0 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
- os: linux
compiler: clang
env:
- COMPILER=clang++-6.0
- CXXFLAGS=-stdlib=libc++
addons:
apt:
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- llvm-toolchain-trusty-6.0
- ubuntu-toolchain-r-test
packages:
- clang-6.0 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
# - os: linux
# compiler: clang
# env:
# - COMPILER=clang++-6.0
# - CXXFLAGS=-stdlib=libc++
# addons:
# apt:
# sources:
# - sourceline: 'ppa:mhier/libboost-latest'
# - llvm-toolchain-trusty-6.0
# - ubuntu-toolchain-r-test
# packages:
# - clang-6.0 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
- os: linux
compiler: clang
env:
- COMPILER=clang++-7
- CXXFLAGS=-stdlib=libc++
addons:
apt:
sources:
- sourceline: 'ppa:mhier/libboost-latest'
- llvm-toolchain-trusty-7
- ubuntu-toolchain-r-test
packages:
- clang-7 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
# - os: linux
# compiler: clang
# env:
# - COMPILER=clang++-7
# - CXXFLAGS=-stdlib=libc++
# addons:
# apt:
# sources:
# - sourceline: 'ppa:mhier/libboost-latest'
# - llvm-toolchain-trusty-7
# - ubuntu-toolchain-r-test
# packages:
# - clang-7 boost1.70 libasound2-dev libsoxr-dev libvorbisidec-dev libvorbis-dev libflac-dev libopus-dev alsa-utils libavahi-client-dev avahi-daemon
# build on osx
- os: osx
osx_image: xcode9.4
env:
- MATRIX_EVAL="brew update && brew unlink python@2 && brew upgrade boost && brew install flac opus libvorbis libsoxr"
# # build on osx
# - os: osx
# osx_image: xcode9.4
# env:
# - MATRIX_EVAL="brew update && brew unlink python@2 && brew upgrade boost && brew install flac opus libvorbis libsoxr"
- os: osx
osx_image: xcode10.3
env:
- MATRIX_EVAL="brew update && brew install flac opus libvorbis libsoxr"
# - os: osx
# osx_image: xcode10.3
# env:
# - MATRIX_EVAL="brew update && brew install flac opus libvorbis libsoxr"
- os: osx
osx_image: xcode11
env:
- MATRIX_EVAL="brew update && brew install flac opus libvorbis libsoxr"
# - os: osx
# osx_image: xcode11
# env:
# - MATRIX_EVAL="brew update && brew install flac opus libvorbis libsoxr"
# build on windows
- os: windows

View file

@ -22,6 +22,7 @@
#include <string>
#include <vector>
#include "common/sample_format.hpp"
#include "player/pcm_device.hpp"

View file

@ -93,7 +93,7 @@ bool FlacDecoder::decode(msg::PcmChunk* chunk)
{
double diffMs = static_cast<double>(cacheInfo_.cachedBlocks_) / (static_cast<double>(cacheInfo_.sampleRate_) / 1000.);
auto us = static_cast<uint64_t>(diffMs * 1000.);
tv diff(us / 1000000, us % 1000000);
tv diff(static_cast<int32_t>(us / 1000000), static_cast<int32_t>(us % 1000000));
LOG(DEBUG) << "Cached: " << cacheInfo_.cachedBlocks_ << ", " << diffMs << "ms, " << diff.sec << "s, " << diff.usec << "us\n";
chunk->timestamp = chunk->timestamp - diff;
}
@ -144,7 +144,7 @@ FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder* /*decoder
memcpy(buffer, flacChunk->payload, *bytes);
memmove(flacChunk->payload, flacChunk->payload + *bytes, flacChunk->payloadSize - *bytes);
flacChunk->payloadSize = flacChunk->payloadSize - *bytes;
flacChunk->payloadSize = flacChunk->payloadSize - static_cast<uint32_t>(*bytes);
flacChunk->payload = (char*)realloc(flacChunk->payload, flacChunk->payloadSize);
}
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
@ -191,7 +191,7 @@ FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* /*decod
chunkBuffer[sampleFormat.channels() * i + channel] = SWAP_32((int32_t)(buffer[channel][i]));
}
}
pcmChunk->payloadSize += bytes;
pcmChunk->payloadSize += static_cast<uint32_t>(bytes);
}
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;

View file

@ -104,7 +104,7 @@ bool OggDecoder::decode(msg::PcmChunk* chunk)
(-1.<=range<=1.) to whatever PCM format and write it out */
while ((samples = vorbis_synthesis_pcmout(&vd, &pcm)) > 0)
{
size_t bytes = sampleFormat_.sampleSize() * vi.channels * samples;
uint32_t bytes = sampleFormat_.sampleSize() * vi.channels * samples;
chunk->payload = (char*)realloc(chunk->payload, chunk->payloadSize + bytes);
for (int channel = 0; channel < vi.channels; ++channel)
{

View file

@ -39,14 +39,15 @@ public:
private:
bool decodePayload(msg::PcmChunk* chunk);
template <typename T>
T clip(const T& value, const T& lower, const T& upper) const
template <typename T, typename IN_TYPE>
T clip(const IN_TYPE& value, const T& lower, const T& upper) const
{
if (value > upper)
auto val = static_cast<T>(value);
if (val > upper)
return upper;
if (value < lower)
if (val < lower)
return lower;
return value;
return val;
}
ogg_sync_state oy; /// sync and verify incoming physical bitstream

View file

@ -50,8 +50,8 @@ bool OpusDecoder::decode(msg::PcmChunk* chunk)
{
int frame_size = 0;
while ((frame_size = opus_decode(dec_, (unsigned char*)chunk->payload, chunk->payloadSize, pcm_.data(), pcm_.size() / sample_format_.channels(), 0)) ==
OPUS_BUFFER_TOO_SMALL)
while ((frame_size = opus_decode(dec_, (unsigned char*)chunk->payload, chunk->payloadSize, pcm_.data(),
static_cast<int>(pcm_.size()) / sample_format_.channels(), 0)) == OPUS_BUFFER_TOO_SMALL)
{
if (pcm_.size() < const_max_frame_size * sample_format_.channels())
{

View file

@ -51,7 +51,7 @@ public:
}
/// Median as mean over N values around the median
T median(unsigned int mean = 1) const
T median(uint16_t mean = 1) const
{
if (buffer.empty())
return 0;
@ -61,12 +61,12 @@ public:
return tmpBuffer[tmpBuffer.size() / 2];
else
{
unsigned int low = tmpBuffer.size() / 2;
unsigned int high = low;
uint16_t low = static_cast<uint16_t>(tmpBuffer.size()) / 2;
uint16_t high = low;
low -= mean / 2;
high += mean / 2;
T result((T)0);
for (unsigned int i = low; i <= high; ++i)
for (uint16_t i = low; i <= high; ++i)
{
result += tmpBuffer[i];
}

View file

@ -56,7 +56,7 @@ protected:
{
T* bufferT = (T*)buffer;
for (size_t n = 0; n < count; ++n)
bufferT[n] = endian::swap<T>(endian::swap<T>(bufferT[n]) * volume);
bufferT[n] = endian::swap<T>(static_cast<T>(endian::swap<T>(bufferT[n]) * volume));
}
void adjustVolume(char* buffer, size_t frames);

View file

@ -50,7 +50,7 @@ void TimeProvider::setDiffToServer(double ms)
}
lastTimeSync = now.tv_sec;
diffBuffer_.add(ms * 1000);
diffBuffer_.add(static_cast<chronos::usec::rep>(ms * 1000));
diffToServer_ = diffBuffer_.median();
// LOG(INFO) << "setDiffToServer: " << ms << ", diff: " << diffToServer_ / 1000000 << " s, " << (diffToServer_ / 1000) % 1000 << "." << diffToServer_ % 1000
// << " ms\n";

View file

@ -30,7 +30,7 @@ namespace msg
class CodecHeader : public BaseMessage
{
public:
CodecHeader(const std::string& codecName = "", size_t size = 0)
CodecHeader(const std::string& codecName = "", uint32_t size = 0)
: BaseMessage(message_type::kCodecHeader), payloadSize(size), payload(nullptr), codec(codecName)
{
if (size > 0)

View file

@ -36,7 +36,7 @@ namespace msg
class PcmChunk : public WireChunk
{
public:
PcmChunk(const SampleFormat& sampleFormat, size_t ms)
PcmChunk(const SampleFormat& sampleFormat, uint32_t ms)
: WireChunk((sampleFormat.rate() * ms / 1000) * sampleFormat.frameSize()), format(sampleFormat), idx_(0)
{
}

View file

@ -53,8 +53,8 @@ inline static void timeofday(struct timeval* tv)
{
auto now = Clock::now();
auto microsecs = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch());
tv->tv_sec = static_cast<time_t>(microsecs.count() / 1000000);
tv->tv_usec = static_cast<suseconds_t>(microsecs.count() % 1000000);
tv->tv_sec = static_cast<long>(microsecs.count() / 1000000);
tv->tv_usec = static_cast<long>(microsecs.count() % 1000000);
}
#ifdef WINDOWS