Fix warnings on Windows

This commit is contained in:
badaix 2020-04-10 12:19:27 +02:00
parent 30753f9f61
commit ade0ee7be3
13 changed files with 67 additions and 63 deletions

View file

@ -78,7 +78,7 @@ x = 1,000016667 / (1,000016667 - 1)
soxr_ = nullptr;
}
// initialize the buffer with 20ms (~latency of the reampler)
resample_buffer_.resize(format_.frameSize() * ceil(format_.msRate()) * 20);
resample_buffer_.resize(format_.frameSize() * static_cast<uint16_t>(ceil(format_.msRate() * 20)));
}
#endif
}
@ -101,7 +101,7 @@ void Stream::setRealSampleRate(double sampleRate)
}
else
{
correctAfterXFrames_ = round((format_.rate() / sampleRate) / (format_.rate() / sampleRate - 1.));
correctAfterXFrames_ = static_cast<int32_t>(round((format_.rate() / sampleRate) / (format_.rate() / sampleRate - 1.)));
// LOG(TRACE, LOG_TAG) << "Correct after X: " << correctAfterXFrames_ << " (Real rate: " << sampleRate << ", rate: " << format_.rate() << ")\n";
}
}
@ -170,11 +170,11 @@ void Stream::addChunk(unique_ptr<msg::PcmChunk> chunk)
auto resampled_chunk = new msg::PcmChunk(format_, 0);
auto us = chrono::duration_cast<chrono::microseconds>(resampled_start.time_since_epoch()).count();
resampled_chunk->timestamp.sec = us / 1000000;
resampled_chunk->timestamp.usec = us % 1000000;
resampled_chunk->timestamp.sec = static_cast<int32_t>(us / 1000000);
resampled_chunk->timestamp.usec = static_cast<int32_t>(us % 1000000);
// copy from the resample_buffer to the resampled chunk
resampled_chunk->payloadSize = odone * format_.frameSize();
resampled_chunk->payloadSize = static_cast<uint32_t>(odone * format_.frameSize());
resampled_chunk->payload = (char*)realloc(resampled_chunk->payload, resampled_chunk->payloadSize);
memcpy(resampled_chunk->payload, resample_buffer_.data(), resampled_chunk->payloadSize);
@ -196,7 +196,7 @@ void Stream::addChunk(unique_ptr<msg::PcmChunk> chunk)
if (odone == resample_buffer_framesize)
{
// buffer for resampled data too small, add space for 5ms
resample_buffer_.resize(resample_buffer_.size() + format_.frameSize() * ceil(format_.msRate()) * 5);
resample_buffer_.resize(resample_buffer_.size() + format_.frameSize() * static_cast<uint16_t>(ceil(format_.msRate() * 5)));
LOG(DEBUG, LOG_TAG) << "Resample buffer completely filled, adding space for 5ms; new buffer size: " << resample_buffer_.size()
<< " bytes\n";
}
@ -247,7 +247,7 @@ cs::time_point_clk Stream::getNextPlayerChunk(void* outputBuffer, uint32_t frame
if (framesCorrection < 0 && frames + framesCorrection <= 0)
{
// Avoid underflow in new char[] constructor.
framesCorrection = -frames + 1;
framesCorrection = -static_cast<int32_t>(frames) + 1;
}
if (framesCorrection == 0)
@ -272,7 +272,7 @@ cs::time_point_clk Stream::getNextPlayerChunk(void* outputBuffer, uint32_t frame
slices = max;
}
// Size of each slice. The last slice may be bigger.
int size = max / slices;
auto size = max / slices;
// LOG(TRACE, LOG_TAG) << "getNextPlayerChunk, frames: " << frames << ", correction: " << framesCorrection << " (" << toRead << "), slices: " << slices
// << "\n";
@ -307,7 +307,7 @@ cs::time_point_clk Stream::getNextPlayerChunk(void* outputBuffer, uint32_t frame
}
void Stream::updateBuffers(int age)
void Stream::updateBuffers(chronos::usec::rep age)
{
buffer_.add(age);
miniBuffer_.add(age);
@ -390,7 +390,7 @@ bool Stream::getPlayerChunk(void* outputBuffer, const cs::usec& outputBufferDacT
// e.g. age = -20ms (=> should be played in 20ms)
// and the current chunk duration is 50ms, so we need to play 20ms silence (as we don't have data)
// and can play 30ms of the stream
uint32_t silent_frames = static_cast<size_t>(-chunk_->format.nsRate() * std::chrono::duration_cast<cs::nsec>(age).count());
uint32_t silent_frames = static_cast<uint32_t>(-chunk_->format.nsRate() * std::chrono::duration_cast<cs::nsec>(age).count());
bool result = (silent_frames <= frames);
silent_frames = std::min(silent_frames, frames);
LOG(DEBUG, LOG_TAG) << "Silent frames: " << silent_frames << ", frames: " << frames
@ -474,7 +474,7 @@ bool Stream::getPlayerChunk(void* outputBuffer, const cs::usec& outputBufferDacT
updateBuffers(age.count());
// print sync stats
// update median_ and shortMedian_ and print sync stats
if (now != lastUpdate_)
{
lastUpdate_ = now;
@ -488,7 +488,7 @@ bool Stream::getPlayerChunk(void* outputBuffer, const cs::usec& outputBufferDacT
}
catch (int e)
{
LOG(INFO) << "Exception\n";
LOG(INFO, LOG_TAG) << "Exception: " << e << "\n";
hard_sync_ = true;
return false;
}