fixes per code review comments

This commit is contained in:
Stephen Birarda 2013-05-09 13:30:11 -07:00
parent cd69297af2
commit 23f861f5e2
3 changed files with 16 additions and 16 deletions

View file

@ -72,7 +72,7 @@ void plateauAdditionOfSamples(int16_t &mixSample, int16_t sampleToAdd) {
}
void attachNewBufferToAgent(Agent *newAgent) {
if (newAgent->getLinkedData() == NULL) {
if (!newAgent->getLinkedData()) {
newAgent->setLinkedData(new AudioRingBuffer(RING_BUFFER_SAMPLES, BUFFER_LENGTH_SAMPLES_PER_CHANNEL));
}
}
@ -89,9 +89,9 @@ int main(int argc, const char* argv[]) {
agentList->startSilentAgentRemovalThread();
agentList->startDomainServerCheckInThread();
unsigned char *packetData = new unsigned char[MAX_PACKET_SIZE];
unsigned char* packetData = new unsigned char[MAX_PACKET_SIZE];
sockaddr *agentAddress = new sockaddr;
sockaddr* agentAddress = new sockaddr;
// make sure our agent socket is non-blocking
agentList->getAgentSocket().setBlocking(false);
@ -106,7 +106,7 @@ int main(int argc, const char* argv[]) {
for (AgentList::iterator agent = agentList->begin(); agent != agentList->end(); agent++) {
AudioRingBuffer* agentBuffer = (AudioRingBuffer*) agent->getLinkedData();
if (agentBuffer->getEndOfLastWrite() != NULL) {
if (agentBuffer->getEndOfLastWrite()) {
if (!agentBuffer->isStarted()
&& agentBuffer->diffLastWriteNextOutput() <= BUFFER_LENGTH_SAMPLES_PER_CHANNEL + JITTER_BUFFER_SAMPLES) {
printf("Held back buffer for agent with ID %d.\n", agent->getAgentId());
@ -217,15 +217,15 @@ int main(int argc, const char* argv[]) {
}
int16_t* goodChannel = bearingRelativeAngleToSource > 0.0f
? clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL
: clientMix;
? clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL
: clientMix;
int16_t* delayedChannel = bearingRelativeAngleToSource > 0.0f
? clientMix
: clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
? clientMix
: clientMix + BUFFER_LENGTH_SAMPLES_PER_CHANNEL;
int16_t* delaySamplePointer = otherAgentBuffer->getNextOutput() == otherAgentBuffer->getBuffer()
? otherAgentBuffer->getBuffer() + RING_BUFFER_SAMPLES - numSamplesDelay
: otherAgentBuffer->getNextOutput() - numSamplesDelay;
? otherAgentBuffer->getBuffer() + RING_BUFFER_SAMPLES - numSamplesDelay
: otherAgentBuffer->getNextOutput() - numSamplesDelay;
for (int s = 0; s < BUFFER_LENGTH_SAMPLES_PER_CHANNEL; s++) {

View file

@ -50,8 +50,8 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
unsigned char *dataPtr = sourceBuffer + 1;
memcpy(&_position, dataPtr, sizeof(_position.x) * 3);
dataPtr += (sizeof(_position.x) * 3);
memcpy(&_position, dataPtr, sizeof(_position));
dataPtr += (sizeof(_position));
unsigned int attenuationByte = *(dataPtr++);
_attenuationRatio = attenuationByte / 255.0f;
@ -74,7 +74,7 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
sourceBuffer = dataPtr;
}
if (_endOfLastWrite == NULL) {
if (!_endOfLastWrite) {
_endOfLastWrite = _buffer;
} else if (diffLastWriteNextOutput() > _ringBufferLengthSamples - _bufferLengthSamples) {
_endOfLastWrite = _buffer;
@ -94,7 +94,7 @@ int AudioRingBuffer::parseData(unsigned char* sourceBuffer, int numBytes) {
}
short AudioRingBuffer::diffLastWriteNextOutput() {
if (_endOfLastWrite == NULL) {
if (!_endOfLastWrite) {
return 0;
} else {
short sampleDifference = _endOfLastWrite - _nextOutput;

View file

@ -28,10 +28,10 @@ public:
AudioRingBuffer* clone() const;
int16_t* getNextOutput() const { return _nextOutput; }
void setNextOutput(int16_t *nextOutput) { _nextOutput = nextOutput; }
void setNextOutput(int16_t* nextOutput) { _nextOutput = nextOutput; }
int16_t* getEndOfLastWrite() const { return _endOfLastWrite; }
void setEndOfLastWrite(int16_t *endOfLastWrite) { _endOfLastWrite = endOfLastWrite; }
void setEndOfLastWrite(int16_t* endOfLastWrite) { _endOfLastWrite = endOfLastWrite; }
int16_t* getBuffer() const { return _buffer; }