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));
}
}
@ -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());

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;