mirror of
https://github.com/overte-org/overte.git
synced 2025-04-26 12:16:18 +02:00
debugging new audio stream organization
This commit is contained in:
parent
172cd91f27
commit
3d22a11e28
4 changed files with 41 additions and 53 deletions
|
@ -98,15 +98,18 @@ void AudioMixer::addBufferToMixForListeningNodeWithBuffer(PositionalAudioRingBuf
|
||||||
// if the frame to be mixed is silent, don't mix it
|
// if the frame to be mixed is silent, don't mix it
|
||||||
if (bufferToAdd->getNextOutputTrailingLoudness() == 0.0f) {
|
if (bufferToAdd->getNextOutputTrailingLoudness() == 0.0f) {
|
||||||
bufferToAdd->popFrames(1);
|
bufferToAdd->popFrames(1);
|
||||||
|
printf("trailing loudness too soft: not mixing!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get pointer to frame to be mixed. If the stream cannot provide a frame (is starved), bail
|
// get pointer to frame to be mixed. If the stream cannot provide a frame (is starved), bail
|
||||||
AudioRingBuffer::ConstIterator nextOutputStart;
|
AudioRingBuffer::ConstIterator nextOutputStart;
|
||||||
if (!bufferToAdd->popFrames(&nextOutputStart, 1)) {
|
if (!bufferToAdd->popFrames(&nextOutputStart, 1)) {
|
||||||
|
printf("stream is starved! not mixing!\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("mixing stream\n");
|
||||||
|
|
||||||
float bearingRelativeAngleToSource = 0.0f;
|
float bearingRelativeAngleToSource = 0.0f;
|
||||||
float attenuationCoefficient = 1.0f;
|
float attenuationCoefficient = 1.0f;
|
||||||
|
|
|
@ -86,6 +86,7 @@ int InboundAudioStream::parseData(const QByteArray& packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isStarved && _ringBuffer.samplesAvailable() >= _desiredJitterBufferFrames * _ringBuffer.getNumFrameSamples()) {
|
if (_isStarved && _ringBuffer.samplesAvailable() >= _desiredJitterBufferFrames * _ringBuffer.getNumFrameSamples()) {
|
||||||
|
printf("\nstream refilled from starve!\n");
|
||||||
_isStarved = false;
|
_isStarved = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,79 +96,60 @@ int InboundAudioStream::parseData(const QByteArray& packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InboundAudioStream::popFrames(int numFrames, bool starveOnFail) {
|
bool InboundAudioStream::popFrames(int numFrames, bool starveOnFail) {
|
||||||
if (_isStarved) {
|
bool popped;
|
||||||
_consecutiveNotMixedCount++;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool popped = false;
|
|
||||||
|
|
||||||
int numSamplesRequested = numFrames * _ringBuffer.getNumFrameSamples();
|
int numSamplesRequested = numFrames * _ringBuffer.getNumFrameSamples();
|
||||||
if (_ringBuffer.samplesAvailable() >= numSamplesRequested) {
|
if (popped = shouldPop(numSamplesRequested, starveOnFail)) {
|
||||||
_ringBuffer.shiftReadPosition(numSamplesRequested);
|
_ringBuffer.shiftReadPosition(numSamplesRequested);
|
||||||
_hasStarted = true;
|
|
||||||
popped = true;
|
|
||||||
} else {
|
|
||||||
if (starveOnFail) {
|
|
||||||
setToStarved();
|
|
||||||
_consecutiveNotMixedCount++;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_framesAvailableStats.update(_ringBuffer.framesAvailable());
|
_framesAvailableStats.update(_ringBuffer.framesAvailable());
|
||||||
|
|
||||||
return popped;
|
return popped;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InboundAudioStream::popFrames(int16_t* dest, int numFrames, bool starveOnFail) {
|
bool InboundAudioStream::popFrames(int16_t* dest, int numFrames, bool starveOnFail) {
|
||||||
if (_isStarved) {
|
bool popped;
|
||||||
_consecutiveNotMixedCount++;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool popped = false;
|
|
||||||
|
|
||||||
int numSamplesRequested = numFrames * _ringBuffer.getNumFrameSamples();
|
int numSamplesRequested = numFrames * _ringBuffer.getNumFrameSamples();
|
||||||
if (_ringBuffer.samplesAvailable() >= numSamplesRequested) {
|
if (popped = shouldPop(numSamplesRequested, starveOnFail)) {
|
||||||
_ringBuffer.readSamples(dest, numSamplesRequested);
|
_ringBuffer.readSamples(dest, numSamplesRequested);
|
||||||
_hasStarted = true;
|
|
||||||
popped = true;
|
|
||||||
} else {
|
|
||||||
if (starveOnFail) {
|
|
||||||
setToStarved();
|
|
||||||
_consecutiveNotMixedCount++;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_framesAvailableStats.update(_ringBuffer.framesAvailable());
|
_framesAvailableStats.update(_ringBuffer.framesAvailable());
|
||||||
|
|
||||||
return popped;
|
return popped;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InboundAudioStream::popFrames(AudioRingBuffer::ConstIterator* nextOutput, int numFrames, bool starveOnFail) {
|
bool InboundAudioStream::popFrames(AudioRingBuffer::ConstIterator* nextOutput, int numFrames, bool starveOnFail) {
|
||||||
|
bool popped;
|
||||||
|
int numSamplesRequested = numFrames * _ringBuffer.getNumFrameSamples();
|
||||||
|
if (popped = shouldPop(numSamplesRequested, starveOnFail)) {
|
||||||
|
*nextOutput = _ringBuffer.nextOutput();
|
||||||
|
_ringBuffer.shiftReadPosition(numSamplesRequested);
|
||||||
|
}
|
||||||
|
_framesAvailableStats.update(_ringBuffer.framesAvailable());
|
||||||
|
|
||||||
|
return popped;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InboundAudioStream::shouldPop(int numSamples, bool starveOnFail) {
|
||||||
|
printf("\nshouldPop()\n");
|
||||||
|
|
||||||
if (_isStarved) {
|
if (_isStarved) {
|
||||||
|
printf("\t we're starved, not popping\n");
|
||||||
_consecutiveNotMixedCount++;
|
_consecutiveNotMixedCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool popped = false;
|
if (_ringBuffer.samplesAvailable() >= numSamples) {
|
||||||
|
printf("have requested samples and not starved, popping\n");
|
||||||
int numSamplesRequested = numFrames * _ringBuffer.getNumFrameSamples();
|
|
||||||
if (_ringBuffer.samplesAvailable() >= numSamplesRequested) {
|
|
||||||
*nextOutput = _ringBuffer.nextOutput();
|
|
||||||
_ringBuffer.shiftReadPosition(numSamplesRequested);
|
|
||||||
_hasStarted = true;
|
_hasStarted = true;
|
||||||
popped = true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (starveOnFail) {
|
if (starveOnFail) {
|
||||||
|
printf("don't have enough samples; starved!\n");
|
||||||
setToStarved();
|
setToStarved();
|
||||||
_consecutiveNotMixedCount++;
|
_consecutiveNotMixedCount++;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_framesAvailableStats.update(_ringBuffer.framesAvailable());
|
|
||||||
|
|
||||||
return popped;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InboundAudioStream::setToStarved() {
|
void InboundAudioStream::setToStarved() {
|
||||||
|
|
|
@ -79,6 +79,9 @@ public:
|
||||||
int getSilentFramesDropped() const { return _silentFramesDropped; }
|
int getSilentFramesDropped() const { return _silentFramesDropped; }
|
||||||
int getOverflowCount() const { return _ringBuffer.getOverflowCount(); }
|
int getOverflowCount() const { return _ringBuffer.getOverflowCount(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool shouldPop(int numSamples, bool starveOnFail);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// disallow copying of InboundAudioStream objects
|
// disallow copying of InboundAudioStream objects
|
||||||
InboundAudioStream(const InboundAudioStream&);
|
InboundAudioStream(const InboundAudioStream&);
|
||||||
|
|
Loading…
Reference in a new issue