mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 07:17:43 +02:00
removed debug code
This commit is contained in:
parent
7196814ec3
commit
e5d7d471e3
6 changed files with 10 additions and 49 deletions
|
@ -90,7 +90,6 @@ int AudioMixerClientData::parseData(const QByteArray& packet) {
|
||||||
// we don't have a matching injected audio ring buffer, so add it
|
// we don't have a matching injected audio ring buffer, so add it
|
||||||
matchingInjectedRingBuffer = new InjectedAudioRingBuffer(streamIdentifier);
|
matchingInjectedRingBuffer = new InjectedAudioRingBuffer(streamIdentifier);
|
||||||
_ringBuffers.push_back(matchingInjectedRingBuffer);
|
_ringBuffers.push_back(matchingInjectedRingBuffer);
|
||||||
printf("created InjectedRingBuffer %p\n", (void*)matchingInjectedRingBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
matchingInjectedRingBuffer->parseData(packet);
|
matchingInjectedRingBuffer->parseData(packet);
|
||||||
|
@ -133,7 +132,6 @@ void AudioMixerClientData::pushBuffersAfterFrameSend() {
|
||||||
&& audioBuffer->hasStarted() && audioBuffer->isStarved()) {
|
&& audioBuffer->hasStarted() && audioBuffer->isStarved()) {
|
||||||
// this is an empty audio buffer that has starved, safe to delete
|
// this is an empty audio buffer that has starved, safe to delete
|
||||||
delete audioBuffer;
|
delete audioBuffer;
|
||||||
printf("deleted injector %p\n", (void*)audioBuffer);
|
|
||||||
i = _ringBuffers.erase(i);
|
i = _ringBuffers.erase(i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -622,7 +622,6 @@ void Audio::handleAudioInput() {
|
||||||
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer);
|
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer);
|
||||||
|
|
||||||
if (audioMixer && audioMixer->getActiveSocket()) {
|
if (audioMixer && audioMixer->getActiveSocket()) {
|
||||||
|
|
||||||
MyAvatar* interfaceAvatar = Application::getInstance()->getAvatar();
|
MyAvatar* interfaceAvatar = Application::getInstance()->getAvatar();
|
||||||
glm::vec3 headPosition = interfaceAvatar->getHead()->getPosition();
|
glm::vec3 headPosition = interfaceAvatar->getHead()->getPosition();
|
||||||
glm::quat headOrientation = interfaceAvatar->getHead()->getFinalOrientationInWorldFrame();
|
glm::quat headOrientation = interfaceAvatar->getHead()->getFinalOrientationInWorldFrame();
|
||||||
|
@ -639,7 +638,6 @@ void Audio::handleAudioInput() {
|
||||||
numAudioBytes = sizeof(int16_t);
|
numAudioBytes = sizeof(int16_t);
|
||||||
} else {
|
} else {
|
||||||
numAudioBytes = numNetworkBytes;
|
numAudioBytes = numNetworkBytes;
|
||||||
//_isStereoInput ? NETWORK_BUFFER_LENGTH_BYTES_STEREO : NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL;
|
|
||||||
|
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::EchoServerAudio)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::EchoServerAudio)) {
|
||||||
packetType = PacketTypeMicrophoneAudioWithEcho;
|
packetType = PacketTypeMicrophoneAudioWithEcho;
|
||||||
|
|
|
@ -125,12 +125,7 @@ qint64 AudioRingBuffer::writeData(const char* data, qint64 maxSize) {
|
||||||
std::less<int16_t*> less;
|
std::less<int16_t*> less;
|
||||||
std::less_equal<int16_t*> lessEqual;
|
std::less_equal<int16_t*> lessEqual;
|
||||||
|
|
||||||
// TODO: why is less(_endOfLastWrite, _nextOutput) a condition here?
|
if (_hasStarted && samplesToCopy > _sampleCapacity - samplesAvailable()) {
|
||||||
if (_hasStarted
|
|
||||||
/*
|
|
||||||
&& (less(_endOfLastWrite, _nextOutput)
|
|
||||||
&& lessEqual(_nextOutput, shiftedPositionAccomodatingWrap(_endOfLastWrite, samplesToCopy)))*/
|
|
||||||
&& samplesToCopy > _sampleCapacity - samplesAvailable()) {
|
|
||||||
// this read will cross the next output, so call us starved and reset the buffer
|
// this read will cross the next output, so call us starved and reset the buffer
|
||||||
qDebug() << "Filled the ring buffer. Resetting.";
|
qDebug() << "Filled the ring buffer. Resetting.";
|
||||||
_endOfLastWrite = _buffer;
|
_endOfLastWrite = _buffer;
|
||||||
|
@ -148,7 +143,6 @@ qint64 AudioRingBuffer::writeData(const char* data, qint64 maxSize) {
|
||||||
|
|
||||||
_endOfLastWrite = shiftedPositionAccomodatingWrap(_endOfLastWrite, samplesToCopy);
|
_endOfLastWrite = shiftedPositionAccomodatingWrap(_endOfLastWrite, samplesToCopy);
|
||||||
|
|
||||||
printf("%p: writeData. %d samples available\n", (void*)this, samplesAvailable());
|
|
||||||
return samplesToCopy * sizeof(int16_t);
|
return samplesToCopy * sizeof(int16_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +156,6 @@ const int16_t& AudioRingBuffer::operator[] (const int index) const {
|
||||||
|
|
||||||
void AudioRingBuffer::shiftReadPosition(unsigned int numSamples) {
|
void AudioRingBuffer::shiftReadPosition(unsigned int numSamples) {
|
||||||
_nextOutput = shiftedPositionAccomodatingWrap(_nextOutput, numSamples);
|
_nextOutput = shiftedPositionAccomodatingWrap(_nextOutput, numSamples);
|
||||||
printf("%p: mixed. %d samples remaining\n", (void*)this, samplesAvailable());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int AudioRingBuffer::samplesAvailable() const {
|
unsigned int AudioRingBuffer::samplesAvailable() const {
|
||||||
|
|
|
@ -74,7 +74,6 @@ public:
|
||||||
bool hasStarted() const { return _hasStarted; }
|
bool hasStarted() const { return _hasStarted; }
|
||||||
|
|
||||||
void addSilentFrame(int numSilentSamples);
|
void addSilentFrame(int numSilentSamples);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// disallow copying of AudioRingBuffer objects
|
// disallow copying of AudioRingBuffer objects
|
||||||
AudioRingBuffer(const AudioRingBuffer&);
|
AudioRingBuffer(const AudioRingBuffer&);
|
||||||
|
|
|
@ -33,12 +33,9 @@ InterframeTimeGapHistory::InterframeTimeGapHistory()
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterframeTimeGapHistory::frameReceived() {
|
void InterframeTimeGapHistory::frameReceived() {
|
||||||
|
|
||||||
static quint64 gapsSum = 0;
|
|
||||||
|
|
||||||
quint64 now = usecTimestampNow();
|
quint64 now = usecTimestampNow();
|
||||||
|
|
||||||
// make sure this isn't the first time frameReceived() is called, meaning there's actually a gap to calculate.
|
// make sure this isn't the first time frameReceived() is called so can actually calculate a gap.
|
||||||
if (_lastFrameReceivedTime != 0) {
|
if (_lastFrameReceivedTime != 0) {
|
||||||
quint64 gap = now - _lastFrameReceivedTime;
|
quint64 gap = now - _lastFrameReceivedTime;
|
||||||
|
|
||||||
|
@ -123,7 +120,6 @@ int PositionalAudioRingBuffer::parseData(const QByteArray& packet) {
|
||||||
readBytes += sizeof(int16_t);
|
readBytes += sizeof(int16_t);
|
||||||
|
|
||||||
if (numSilentSamples > 0) {
|
if (numSilentSamples > 0) {
|
||||||
|
|
||||||
if (_currentJitterBufferFrames > _desiredJitterBufferFrames) {
|
if (_currentJitterBufferFrames > _desiredJitterBufferFrames) {
|
||||||
// our current jitter buffer size exceeds its desired value, so ignore some silent
|
// our current jitter buffer size exceeds its desired value, so ignore some silent
|
||||||
// frames to get that size as close to desired as possible
|
// frames to get that size as close to desired as possible
|
||||||
|
@ -140,7 +136,6 @@ int PositionalAudioRingBuffer::parseData(const QByteArray& packet) {
|
||||||
} else {
|
} else {
|
||||||
// we need to drop all frames to get the jitter buffer close as possible to its desired length
|
// we need to drop all frames to get the jitter buffer close as possible to its desired length
|
||||||
_currentJitterBufferFrames -= numSilentFrames;
|
_currentJitterBufferFrames -= numSilentFrames;
|
||||||
printf("dropped silent packet! jbuffer size is now %d ###############\n", _currentJitterBufferFrames);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
addSilentFrame(numSilentSamples);
|
addSilentFrame(numSilentSamples);
|
||||||
|
@ -148,8 +143,7 @@ int PositionalAudioRingBuffer::parseData(const QByteArray& packet) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// there is audio data to read
|
// there is audio data to read
|
||||||
int dataBytes = writeData(packet.data() + readBytes, packet.size() - readBytes);
|
readBytes += writeData(packet.data() + readBytes, packet.size() - readBytes);
|
||||||
readBytes += dataBytes;
|
|
||||||
}
|
}
|
||||||
return readBytes;
|
return readBytes;
|
||||||
}
|
}
|
||||||
|
@ -200,12 +194,7 @@ bool PositionalAudioRingBuffer::shouldBeAddedToMix() {
|
||||||
int samplesPerFrame = getSamplesPerFrame();
|
int samplesPerFrame = getSamplesPerFrame();
|
||||||
int desiredJitterBufferSamples = _desiredJitterBufferFrames * samplesPerFrame;
|
int desiredJitterBufferSamples = _desiredJitterBufferFrames * samplesPerFrame;
|
||||||
|
|
||||||
//printf("\nsamples available: %d frames available: %d\n", samplesAvailable(), samplesAvailable() / samplesPerFrame);
|
|
||||||
if (!isNotStarvedOrHasMinimumSamples(samplesPerFrame + desiredJitterBufferSamples)) {
|
if (!isNotStarvedOrHasMinimumSamples(samplesPerFrame + desiredJitterBufferSamples)) {
|
||||||
|
|
||||||
printf("\nMIXING DELAYED! waiting for jitter buffer to fill after being starved\n");
|
|
||||||
printf("samples available: %d frames available: %d\n", samplesAvailable(), samplesAvailable() / samplesPerFrame);
|
|
||||||
|
|
||||||
// if the buffer was starved, allow it to accrue at least the desired number of
|
// if the buffer was starved, allow it to accrue at least the desired number of
|
||||||
// jitter buffer frames before we start taking frames from it for mixing
|
// jitter buffer frames before we start taking frames from it for mixing
|
||||||
|
|
||||||
|
@ -214,12 +203,7 @@ printf("samples available: %d frames available: %d\n", samplesAvailable(), samp
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} else if (samplesAvailable() < samplesPerFrame) {
|
} else if (samplesAvailable() < samplesPerFrame) {
|
||||||
|
|
||||||
printf("\nMIXING DELAYED! jitter buffer is starved!!!\n");
|
|
||||||
printf("samples available: %d frames available: %d\n", samplesAvailable(), samplesAvailable() / samplesPerFrame);
|
|
||||||
|
|
||||||
// if the buffer doesn't have a full frame of samples to take for mixing, it is starved
|
// if the buffer doesn't have a full frame of samples to take for mixing, it is starved
|
||||||
_isStarved = true;
|
_isStarved = true;
|
||||||
|
|
||||||
|
@ -230,19 +214,13 @@ printf("samples available: %d frames available: %d\n", samplesAvailable(), samp
|
||||||
_shouldOutputStarveDebug = true;
|
_shouldOutputStarveDebug = true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
//printf("WILL MIX\n");
|
|
||||||
|
|
||||||
// good buffer, add this to the mix
|
// good buffer, add this to the mix
|
||||||
|
|
||||||
if (_isStarved) {
|
if (_isStarved) {
|
||||||
|
|
||||||
// if this buffer has just finished replenishing after being starved, the number of frames in it now
|
// if this buffer has just finished replenishing after being starved, the number of frames in it now
|
||||||
// minus one (since a frame will be read immediately after this) is the length of the jitter buffer
|
// minus one (since a frame will be read immediately after this) is the length of the jitter buffer
|
||||||
_currentJitterBufferFrames = samplesAvailable() / samplesPerFrame - 1;
|
_currentJitterBufferFrames = samplesAvailable() / samplesPerFrame - 1;
|
||||||
printf("jitter buffer length is now %d; desired: %d --------\n", _currentJitterBufferFrames, _desiredJitterBufferFrames);
|
|
||||||
|
|
||||||
_isStarved = false;
|
_isStarved = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +239,5 @@ void PositionalAudioRingBuffer::updateDesiredJitterBufferFrames() {
|
||||||
if (_desiredJitterBufferFrames < 1) {
|
if (_desiredJitterBufferFrames < 1) {
|
||||||
_desiredJitterBufferFrames = 1;
|
_desiredJitterBufferFrames = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" desired jbuffer size is now %d --------------------------------\n", _desiredJitterBufferFrames);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -43,7 +43,6 @@ private:
|
||||||
bool _newWindowMaxGapAvailable;
|
bool _newWindowMaxGapAvailable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class PositionalAudioRingBuffer : public AudioRingBuffer {
|
class PositionalAudioRingBuffer : public AudioRingBuffer {
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
|
@ -99,8 +98,6 @@ protected:
|
||||||
InterframeTimeGapHistory _interframeTimeGapHistory;
|
InterframeTimeGapHistory _interframeTimeGapHistory;
|
||||||
int _desiredJitterBufferFrames;
|
int _desiredJitterBufferFrames;
|
||||||
int _currentJitterBufferFrames;
|
int _currentJitterBufferFrames;
|
||||||
|
|
||||||
quint64 _lastMixTime;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_PositionalAudioRingBuffer_h
|
#endif // hifi_PositionalAudioRingBuffer_h
|
||||||
|
|
Loading…
Reference in a new issue