28#ifndef AUDIO_DEBUGGER_INCLUDED
29#define AUDIO_DEBUGGER_INCLUDED
126 : name(
"AudioDebugger"), sample_count(0)
128 gettimeofday(&start_time, 0);
134 src->unregisterSink();
150 void setName(std::string debug_name) { name = debug_name; }
168 float max_samp = 0.0f;
169 for (
int i=0; i<count; ++i)
171 if (samples[i] > max_samp)
173 max_samp = samples[i];
175 if (-samples[i] > max_samp)
177 max_samp = -samples[i];
181 struct timeval time, diff;
182 gettimeofday(&time, 0);
184 timersub(&time, &start_time, &diff);
185 uint64_t diff_ms = diff.tv_sec * 1000 + diff.tv_usec / 1000;
187 std::cout << name <<
"::writeSamples: count=" << count
188 <<
" ret=" << ret <<
" sample_rate=";
191 std::cout << sample_count * 1000 / diff_ms;
197 std::cout <<
" max=" << max_samp;
198 std::cout << std::endl;
212 std::cout << name <<
"::flushSamples\n";
225 std::cout << name <<
"::resumeOutput\n";
238 std::cout << name <<
"::allSamplesFlushed\n";
246 struct timeval start_time;
247 uint64_t sample_count;
This file contains the base class for an audio sink.
This file contains the base class for an audio source.
This class is used to debug an audio stream.
virtual void resumeOutput(void)
Resume audio output to the sink.
void setName(std::string debug_name)
Set the name that is displayed before debug messages.
virtual ~AudioDebugger(void)
Destructor.
AudioDebugger(Async::AudioSource *src=0)
Default constuctor.
virtual void allSamplesFlushed(void)
The registered sink has flushed all samples.
virtual void flushSamples(void)
Tell the sink to flush the previously written samples.
virtual int writeSamples(const float *samples, int count)
Write samples into this audio sink.
The base class for an audio sink.
void sourceAllSamplesFlushed(void)
Tell the source that all samples have been flushed.
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.
The base class for an audio source.
bool registerSink(AudioSink *sink, bool managed=false)
Register an audio sink to provide samples to.
AudioSink * sink(void) const
Get the registered audio sink.
void sinkFlushSamples(void)
int sinkWriteSamples(const float *samples, int len)
Namespace for the asynchronous programming classes.