Skip to content

Commit

Permalink
static_cast<int> to fix windows compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
m0dB authored and m0dB committed Nov 11, 2024
1 parent 0c9db44 commit da7919d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 46 deletions.
4 changes: 2 additions & 2 deletions src/encoder/encoderfdkaac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,9 @@ void EncoderFdkAac::encodeBuffer(const CSAMPLE* samples, const int sampleCount)
(void)m_pInputFifo->aquireWriteRegions(writeCount, &dataPtr1, &size1, &dataPtr2, &size2);
// fdk-aac doesn't support float samples, so convert
// to integers instead
SampleUtil::convertFloat32ToS16(dataPtr1, samples, size1);
SampleUtil::convertFloat32ToS16(dataPtr1, samples, static_cast<int>(size1));
if (size2 > 0) {
SampleUtil::convertFloat32ToS16(dataPtr2, samples + size1, size2);
SampleUtil::convertFloat32ToS16(dataPtr2, samples + size1, static_cast<int>(size2));
}
m_pInputFifo->releaseWriteRegions(writeCount);
}
Expand Down
4 changes: 2 additions & 2 deletions src/engine/sidechain/shoutconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,9 +1050,9 @@ void ShoutConnection::run() {
&dataPtr2, &size2);

// Push frames to the encoder.
process(dataPtr1, size1);
process(dataPtr1, static_cast<int>(size1));
if (size2 > 0) {
process(dataPtr2, size2);
process(dataPtr2, static_cast<int>(size2));
}

m_pOutputFifo->releaseReadRegions(readAvailable);
Expand Down
35 changes: 19 additions & 16 deletions src/soundio/sounddevicenetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ void SoundDeviceNetwork::readProcess(SINT framesPerBuffer) {
&dataPtr1, &size1, &dataPtr2, &size2);
// Fetch fresh samples and write to the the input buffer
m_pNetworkStream->read(dataPtr1,
size1 / m_numInputChannels);
static_cast<int>(size1) / m_numInputChannels);
CSAMPLE* lastFrame = &dataPtr1[size1 - m_numInputChannels];
if (size2 > 0) {
if (size2 != 0) {
m_pNetworkStream->read(dataPtr2,
size2 / m_numInputChannels);
static_cast<int>(size2) / m_numInputChannels);
lastFrame = &dataPtr2[size2 - m_numInputChannels];
}
m_inputFifo->releaseWriteRegions(copyCount);
Expand All @@ -181,7 +181,7 @@ void SoundDeviceNetwork::readProcess(SINT framesPerBuffer) {
(void)m_inputFifo->aquireWriteRegions(
m_numInputChannels, &dataPtr1, &size1, &dataPtr2, &size2);
if (size1) {
SampleUtil::copy(dataPtr1, lastFrame, size1);
SampleUtil::copy(dataPtr1, lastFrame, static_cast<int>(size1));
m_inputFifo->releaseWriteRegions(size1);
}
} else {
Expand Down Expand Up @@ -209,13 +209,13 @@ void SoundDeviceNetwork::readProcess(SINT framesPerBuffer) {
&dataPtr2, &size2);
// Fetch fresh samples and write to the the output buffer
composeInputBuffer(dataPtr1,
size1 / m_numInputChannels,
static_cast<int>(size1) / m_numInputChannels,
0,
m_numInputChannels);
if (size2 > 0) {
if (size2 != 0) {
composeInputBuffer(dataPtr2,
size2 / m_numInputChannels,
size1 / m_numInputChannels,
static_cast<int>(size2) / m_numInputChannels,
static_cast<int>(size1) / m_numInputChannels,
m_numInputChannels);
}
m_inputFifo->releaseReadRegions(readCount);
Expand Down Expand Up @@ -253,10 +253,10 @@ void SoundDeviceNetwork::writeProcess(SINT framesPerBuffer) {
&size1, &dataPtr2, &size2);
// Fetch fresh samples and write to the the output buffer
composeOutputBuffer(dataPtr1, size1 / m_numOutputChannels, 0, m_numOutputChannels);
if (size2 > 0) {
if (size2 != 0) {
composeOutputBuffer(dataPtr2,
size2 / m_numOutputChannels,
size1 / m_numOutputChannels,
static_cast<int>(size2) / m_numOutputChannels,
static_cast<int>(size1) / m_numOutputChannels,
m_numOutputChannels);
}
m_outputFifo->releaseWriteRegions(writeCount);
Expand All @@ -282,9 +282,12 @@ void SoundDeviceNetwork::writeProcess(SINT framesPerBuffer) {
}

workerWriteProcess(pWorker,
outChunkSize, readAvailable,
dataPtr1, size1,
dataPtr2, size2);
outChunkSize,
readAvailable,
dataPtr1,
static_cast<int>(size1),
dataPtr2,
static_cast<int>(size2));
}

m_outputFifo->releaseReadRegions(readAvailable);
Expand Down Expand Up @@ -417,8 +420,8 @@ void SoundDeviceNetwork::workerWriteSilence(NetworkOutputStreamWorkerPtr pWorker
(void)pFifo->aquireWriteRegions(clearCount,
&dataPtr1, &size1, &dataPtr2, &size2);
SampleUtil::clear(dataPtr1, size1);
if (size2 > 0) {
SampleUtil::clear(dataPtr2, size2);
if (size2 != 0) {
SampleUtil::clear(dataPtr2, static_cast<int>(size2));
}
pFifo->releaseWriteRegions(clearCount);

Expand Down
61 changes: 35 additions & 26 deletions src/soundio/sounddeviceportaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ SoundDeviceStatus SoundDevicePortAudio::open(bool isClkRefDevice, int syncBuffer
ring_buffer_size_t size2;
(void)m_outputFifo->aquireWriteRegions(writeCount, &dataPtr1,
&size1, &dataPtr2, &size2);
SampleUtil::clear(dataPtr1, size1);
SampleUtil::clear(dataPtr2, size2);
SampleUtil::clear(dataPtr1, static_cast<int>(size1));
SampleUtil::clear(dataPtr2, static_cast<int>(size2));
m_outputFifo->releaseWriteRegions(writeCount);
}
if (m_inputParams.channelCount > 0) {
Expand All @@ -306,8 +306,8 @@ SoundDeviceStatus SoundDevicePortAudio::open(bool isClkRefDevice, int syncBuffer
ring_buffer_size_t size2;
(void)m_inputFifo->aquireWriteRegions(writeCount, &dataPtr1,
&size1, &dataPtr2, &size2);
SampleUtil::clear(dataPtr1, size1);
SampleUtil::clear(dataPtr2, size2);
SampleUtil::clear(dataPtr1, static_cast<int>(size1));
SampleUtil::clear(dataPtr2, static_cast<int>(size2));
m_inputFifo->releaseWriteRegions(writeCount);
}
} else if (m_syncBuffers == 1) { // "Disabled (short delay)"
Expand Down Expand Up @@ -470,9 +470,9 @@ void SoundDevicePortAudio::readProcess(SINT framesPerBuffer) {
(void)m_inputFifo->aquireWriteRegions(inChunkSize,
&dataPtr1, &size1, &dataPtr2, &size2);
// Fetch fresh samples and write to the the input buffer
SampleUtil::clear(dataPtr1, size1);
if (size2 > 0) {
SampleUtil::clear(dataPtr2, size2);
SampleUtil::clear(dataPtr1, static_cast<int>(size1));
if (size2 != 0) {
SampleUtil::clear(dataPtr2, static_cast<int>(size2));
}
m_inputFifo->releaseWriteRegions(inChunkSize);
}
Expand All @@ -490,16 +490,19 @@ void SoundDevicePortAudio::readProcess(SINT framesPerBuffer) {
(void)m_inputFifo->aquireWriteRegions(copyCount,
&dataPtr1, &size1, &dataPtr2, &size2);
// Fetch fresh samples and write to the the input buffer
PaError err = Pa_ReadStream(pStream, dataPtr1,
size1 / m_inputParams.channelCount);
PaError err = Pa_ReadStream(pStream,
dataPtr1,
static_cast<int>(size1) / m_inputParams.channelCount);
CSAMPLE* lastFrame = &dataPtr1[size1 - m_inputParams.channelCount];
if (err == paInputOverflowed) {
//qDebug() << "SoundDevicePortAudio::readProcess() Pa_ReadStream paInputOverflowed" << m_deviceId;
m_pSoundManager->underflowHappened(12);
}
if (size2 > 0) {
PaError err = Pa_ReadStream(pStream, dataPtr2,
size2 / m_inputParams.channelCount);
if (size2 != 0) {
PaError err = Pa_ReadStream(pStream,
dataPtr2,
static_cast<int>(size2) /
m_inputParams.channelCount);
lastFrame = &dataPtr2[size2 - m_inputParams.channelCount];
if (err == paInputOverflowed) {
//qDebug() << "SoundDevicePortAudio::readProcess() Pa_ReadStream paInputOverflowed" << m_deviceId;
Expand Down Expand Up @@ -536,7 +539,7 @@ void SoundDevicePortAudio::readProcess(SINT framesPerBuffer) {
m_inputParams.channelCount, &dataPtr1, &size1,
&dataPtr2, &size2);
if (size1) {
SampleUtil::copy(dataPtr1, lastFrame, size1);
SampleUtil::copy(dataPtr1, lastFrame, static_cast<int>(size1));
m_inputFifo->releaseWriteRegions(size1);
}
} else {
Expand Down Expand Up @@ -566,12 +569,13 @@ void SoundDevicePortAudio::readProcess(SINT framesPerBuffer) {
&dataPtr2, &size2);
// Fetch fresh samples and write to the the output buffer
composeInputBuffer(dataPtr1,
size1 / m_inputParams.channelCount, 0,
static_cast<int>(size1) / m_inputParams.channelCount,
0,
m_inputParams.channelCount);
if (size2 > 0) {
if (size2 != 0) {
composeInputBuffer(dataPtr2,
size2 / m_inputParams.channelCount,
size1 / m_inputParams.channelCount,
static_cast<int>(size2) / m_inputParams.channelCount,
static_cast<int>(size1) / m_inputParams.channelCount,
m_inputParams.channelCount);
}
m_inputFifo->releaseReadRegions(readCount);
Expand Down Expand Up @@ -606,12 +610,14 @@ void SoundDevicePortAudio::writeProcess(SINT framesPerBuffer) {
(void) m_outputFifo->aquireWriteRegions(writeCount, &dataPtr1,
&size1, &dataPtr2, &size2);
// Fetch fresh samples and write to the the output buffer
composeOutputBuffer(dataPtr1, size1 / m_outputParams.channelCount, 0,
m_outputParams.channelCount);
composeOutputBuffer(dataPtr1,
static_cast<int>(size1) / m_outputParams.channelCount,
0,
m_outputParams.channelCount);
if (size2 > 0) {
composeOutputBuffer(dataPtr2,
size2 / m_outputParams.channelCount,
size1 / m_outputParams.channelCount,
static_cast<int>(size2) / m_outputParams.channelCount,
static_cast<int>(size1) / m_outputParams.channelCount,
m_outputParams.channelCount);
}
m_outputFifo->releaseWriteRegions(writeCount);
Expand Down Expand Up @@ -670,15 +676,18 @@ void SoundDevicePortAudio::writeProcess(SINT framesPerBuffer) {
} else {
m_outputDrift = false;
}
PaError err = Pa_WriteStream(pStream, dataPtr1,
size1 / m_outputParams.channelCount);
PaError err = Pa_WriteStream(pStream,
dataPtr1,
static_cast<int>(size1) / m_outputParams.channelCount);
if (err == paOutputUnderflowed) {
//qDebug() << "SoundDevicePortAudio::writeProcess() Pa_ReadStream paOutputUnderflowed" << m_deviceId;
m_pSoundManager->underflowHappened(19);
}
if (size2 > 0) {
PaError err = Pa_WriteStream(pStream, dataPtr2,
size2 / m_outputParams.channelCount);
if (size2 != 0) {
PaError err = Pa_WriteStream(pStream,
dataPtr2,
static_cast<int>(size2) /
m_outputParams.channelCount);
if (err == paOutputUnderflowed) {
//qDebug() << "SoundDevicePortAudio::writeProcess() Pa_WriteStream paOutputUnderflowed" << m_deviceId;
m_pSoundManager->underflowHappened(20);
Expand Down

0 comments on commit da7919d

Please sign in to comment.