28 #ifndef AUDIO_DEBUGGER_INCLUDED
29 #define AUDIO_DEBUGGER_INCLUDED
126 const std::string& name=
"AudioDebugger")
127 : name(name), sample_count(0)
129 gettimeofday(&start_time, 0);
135 src->unregisterSink();
151 void setName(std::string debug_name) { name = debug_name; }
169 float max_samp = 0.0f;
170 for (
int i=0; i<count; ++i)
172 if (samples[i] > max_samp)
174 max_samp = samples[i];
176 if (-samples[i] > max_samp)
178 max_samp = -samples[i];
182 struct timeval time, diff;
183 gettimeofday(&time, 0);
185 timersub(&time, &start_time, &diff);
186 uint64_t diff_ms = diff.tv_sec * 1000 + diff.tv_usec / 1000;
188 std::cout << name <<
"::writeSamples: count=" << count
189 <<
" ret=" << ret <<
" sample_rate=";
192 std::cout << sample_count * 1000 / diff_ms;
198 std::cout <<
" max=" << max_samp;
199 std::cout << std::endl;
213 std::cout << name <<
"::flushSamples\n";
226 std::cout << name <<
"::resumeOutput\n";
239 std::cout << name <<
"::allSamplesFlushed\n";
247 struct timeval start_time;
248 uint64_t sample_count;
AudioSink * sink(void) const
Get the registered audio sink.
AudioDebugger(Async::AudioSource *src=0, const std::string &name="AudioDebugger")
Default constuctor.
void sinkFlushSamples(void)
void setName(std::string debug_name)
Set the name that is displayed before debug messages.
virtual void flushSamples(void)
Tell the sink to flush the previously written samples.
This file contains the base class for an audio source.
virtual int writeSamples(const float *samples, int count)
Write samples into this audio sink.
bool registerSink(AudioSink *sink, bool managed=false)
Register an audio sink to provide samples to.
This file contains the base class for an audio sink.
int sinkWriteSamples(const float *samples, int len)
The base class for an audio sink.
Namespace for the asynchronous programming classes.
bool registerSource(AudioSource *source)
Register an audio source to provide samples to this sink.
void sourceResumeOutput(void)
Tell the source that we are ready to accept more samples.
void sourceAllSamplesFlushed(void)
Tell the source that all samples have been flushed.
The base class for an audio source.
virtual void resumeOutput(void)
Resume audio output to the sink.
virtual void allSamplesFlushed(void)
The registered sink has flushed all samples.
This class is used to debug an audio stream.
virtual ~AudioDebugger(void)
Destructor.