mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-28 21:01:16 +02:00
std::min() compiler error on windows
This commit is contained in:
parent
6bde55898d
commit
46c45da842
1 changed files with 17 additions and 17 deletions
|
@ -60,27 +60,27 @@ qint64 AudioRingBuffer::readSamples(int16_t* destination, qint64 maxSamples) {
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 AudioRingBuffer::readData(char *data, qint64 maxSize) {
|
qint64 AudioRingBuffer::readData(char *data, qint64 maxSize) {
|
||||||
|
|
||||||
// only copy up to the number of samples we have available
|
// only copy up to the number of samples we have available
|
||||||
int numReadSamples = std::min((unsigned) (maxSize / sizeof(int16_t)), samplesAvailable());
|
int numReadSamples = std::min((unsigned) (maxSize / sizeof(int16_t)), samplesAvailable());
|
||||||
|
|
||||||
if (_nextOutput + numReadSamples > _buffer + _sampleCapacity) {
|
if (_nextOutput + numReadSamples > _buffer + _sampleCapacity) {
|
||||||
// we're going to need to do two reads to get this data, it wraps around the edge
|
// we're going to need to do two reads to get this data, it wraps around the edge
|
||||||
|
|
||||||
// read to the end of the buffer
|
// read to the end of the buffer
|
||||||
int numSamplesToEnd = (_buffer + _sampleCapacity) - _nextOutput;
|
int numSamplesToEnd = (_buffer + _sampleCapacity) - _nextOutput;
|
||||||
memcpy(data, _nextOutput, numSamplesToEnd * sizeof(int16_t));
|
memcpy(data, _nextOutput, numSamplesToEnd * sizeof(int16_t));
|
||||||
|
|
||||||
// read the rest from the beginning of the buffer
|
// read the rest from the beginning of the buffer
|
||||||
memcpy(data + numSamplesToEnd, _buffer, (numReadSamples - numSamplesToEnd) * sizeof(int16_t));
|
memcpy(data + numSamplesToEnd, _buffer, (numReadSamples - numSamplesToEnd) * sizeof(int16_t));
|
||||||
} else {
|
} else {
|
||||||
// read the data
|
// read the data
|
||||||
memcpy(data, _nextOutput, numReadSamples * sizeof(int16_t));
|
memcpy(data, _nextOutput, numReadSamples * sizeof(int16_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
// push the position of _nextOutput by the number of samples read
|
// push the position of _nextOutput by the number of samples read
|
||||||
_nextOutput = shiftedPositionAccomodatingWrap(_nextOutput, numReadSamples);
|
_nextOutput = shiftedPositionAccomodatingWrap(_nextOutput, numReadSamples);
|
||||||
|
|
||||||
return numReadSamples * sizeof(int16_t);
|
return numReadSamples * sizeof(int16_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,12 +91,12 @@ qint64 AudioRingBuffer::writeSamples(const int16_t* source, qint64 maxSamples) {
|
||||||
qint64 AudioRingBuffer::writeData(const char* data, qint64 maxSize) {
|
qint64 AudioRingBuffer::writeData(const char* data, qint64 maxSize) {
|
||||||
// make sure we have enough bytes left for this to be the right amount of audio
|
// make sure we have enough bytes left for this to be the right amount of audio
|
||||||
// otherwise we should not copy that data, and leave the buffer pointers where they are
|
// otherwise we should not copy that data, and leave the buffer pointers where they are
|
||||||
|
|
||||||
int samplesToCopy = std::min(maxSize / sizeof(int16_t), (quint64) _sampleCapacity);
|
int samplesToCopy = std::min(maxSize / sizeof(int16_t), (qint64) _sampleCapacity);
|
||||||
|
|
||||||
std::less<int16_t*> less;
|
std::less<int16_t*> less;
|
||||||
std::less_equal<int16_t*> lessEqual;
|
std::less_equal<int16_t*> lessEqual;
|
||||||
|
|
||||||
if (_hasStarted
|
if (_hasStarted
|
||||||
&& (less(_endOfLastWrite, _nextOutput)
|
&& (less(_endOfLastWrite, _nextOutput)
|
||||||
&& lessEqual(_nextOutput, shiftedPositionAccomodatingWrap(_endOfLastWrite, samplesToCopy)))) {
|
&& lessEqual(_nextOutput, shiftedPositionAccomodatingWrap(_endOfLastWrite, samplesToCopy)))) {
|
||||||
|
@ -106,7 +106,7 @@ qint64 AudioRingBuffer::writeData(const char* data, qint64 maxSize) {
|
||||||
_nextOutput = _buffer;
|
_nextOutput = _buffer;
|
||||||
_isStarved = true;
|
_isStarved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_endOfLastWrite + samplesToCopy <= _buffer + _sampleCapacity) {
|
if (_endOfLastWrite + samplesToCopy <= _buffer + _sampleCapacity) {
|
||||||
memcpy(_endOfLastWrite, data, samplesToCopy * sizeof(int16_t));
|
memcpy(_endOfLastWrite, data, samplesToCopy * sizeof(int16_t));
|
||||||
} else {
|
} else {
|
||||||
|
@ -114,16 +114,16 @@ qint64 AudioRingBuffer::writeData(const char* data, qint64 maxSize) {
|
||||||
memcpy(_endOfLastWrite, data, numSamplesToEnd * sizeof(int16_t));
|
memcpy(_endOfLastWrite, data, numSamplesToEnd * sizeof(int16_t));
|
||||||
memcpy(_buffer, data + (numSamplesToEnd * sizeof(int16_t)), (samplesToCopy - numSamplesToEnd) * sizeof(int16_t));
|
memcpy(_buffer, data + (numSamplesToEnd * sizeof(int16_t)), (samplesToCopy - numSamplesToEnd) * sizeof(int16_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
_endOfLastWrite = shiftedPositionAccomodatingWrap(_endOfLastWrite, samplesToCopy);
|
_endOfLastWrite = shiftedPositionAccomodatingWrap(_endOfLastWrite, samplesToCopy);
|
||||||
|
|
||||||
return samplesToCopy * sizeof(int16_t);
|
return samplesToCopy * sizeof(int16_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t& AudioRingBuffer::operator[](const int index) {
|
int16_t& AudioRingBuffer::operator[](const int index) {
|
||||||
// make sure this is a valid index
|
// make sure this is a valid index
|
||||||
assert(index > -_sampleCapacity && index < _sampleCapacity);
|
assert(index > -_sampleCapacity && index < _sampleCapacity);
|
||||||
|
|
||||||
return *shiftedPositionAccomodatingWrap(_nextOutput, index);
|
return *shiftedPositionAccomodatingWrap(_nextOutput, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,11 +136,11 @@ unsigned int AudioRingBuffer::samplesAvailable() const {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
int sampleDifference = _endOfLastWrite - _nextOutput;
|
int sampleDifference = _endOfLastWrite - _nextOutput;
|
||||||
|
|
||||||
if (sampleDifference < 0) {
|
if (sampleDifference < 0) {
|
||||||
sampleDifference += _sampleCapacity;
|
sampleDifference += _sampleCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sampleDifference;
|
return sampleDifference;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ bool AudioRingBuffer::isNotStarvedOrHasMinimumSamples(unsigned int numRequiredSa
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t* AudioRingBuffer::shiftedPositionAccomodatingWrap(int16_t* position, int numSamplesShift) const {
|
int16_t* AudioRingBuffer::shiftedPositionAccomodatingWrap(int16_t* position, int numSamplesShift) const {
|
||||||
|
|
||||||
if (numSamplesShift > 0 && position + numSamplesShift >= _buffer + _sampleCapacity) {
|
if (numSamplesShift > 0 && position + numSamplesShift >= _buffer + _sampleCapacity) {
|
||||||
// this shift will wrap the position around to the beginning of the ring
|
// this shift will wrap the position around to the beginning of the ring
|
||||||
return position + numSamplesShift - _sampleCapacity;
|
return position + numSamplesShift - _sampleCapacity;
|
||||||
|
|
Loading…
Reference in a new issue