Skip to content

Commit

Permalink
[yarphear] use std::deque rather than ACE class, fixes robotology#82
Browse files Browse the repository at this point in the history
…[thanks @mdtux89]
  • Loading branch information
paulfitz authored and apaikan committed Oct 25, 2013
1 parent f6c655f commit b64bf04
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/yarphear/yarphear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*/


#include <ace/config.h>
#include <ace/Unbounded_Queue.h>
#include <deque>

#include <stdio.h>
#include <math.h>
Expand All @@ -22,7 +21,6 @@
#include <yarp/sig/SoundFile.h>

using namespace yarp::os;
using namespace yarp::os::impl; // yarphear uses something from the impl namespace, is this correct?
using namespace yarp::sig;
using namespace yarp::sig::file;
using namespace yarp::dev;
Expand All @@ -37,7 +35,7 @@ class Echo : public TypedReaderCallback<Sound> {
Semaphore mutex;
bool muted;
bool saving;
ACE_Unbounded_Queue<Sound> sounds;
std::deque<Sound> sounds;
int samples;
int channels;

Expand Down Expand Up @@ -133,7 +131,7 @@ class Echo : public TypedReaderCallback<Sound> {
}

void saveFrame(Sound& sound) {
sounds.enqueue_tail(sound);
sounds.push_back(sound);
samples += sound.getSamples();
channels = sound.getChannels();
printf(" %ld sound frames buffered in memory (%ld samples)\n",
Expand All @@ -148,16 +146,16 @@ class Echo : public TypedReaderCallback<Sound> {
Sound total;
total.resize(samples,channels);
long int at = 0;
while (!sounds.is_empty()) {
Sound tmp;
sounds.dequeue_head(tmp);
while (!sounds.empty()) {
Sound& tmp = sounds.front();
for (int i=0; i<channels; i++) {
for (int j=0; j<tmp.getSamples(); j++) {
total.set(tmp.get(j,i),at+j,i);
}
}
total.setFrequency(tmp.getFrequency());
at += tmp.getSamples();
sounds.pop_front();
}
mutex.post();
bool ok = write(total,name);
Expand Down

0 comments on commit b64bf04

Please sign in to comment.