Separate template/callback code from method code.

...for more small reductions in code size.
This commit is contained in:
Jared Boone 2016-01-04 11:45:33 -08:00
parent cd3a5afdb1
commit 6d3cdb9bbf
2 changed files with 15 additions and 4 deletions

View File

@ -58,3 +58,13 @@ bool AudioStatsCollector::update_stats(const size_t sample_count, const size_t s
return false;
}
}
bool AudioStatsCollector::feed(const buffer_s16_t& src) {
consume_audio_buffer(src);
return update_stats(src.count, src.sampling_rate);
}
bool AudioStatsCollector::mute(const size_t sample_count, const size_t sampling_rate) {
return update_stats(sample_count, sampling_rate);
}

View File

@ -32,16 +32,14 @@ class AudioStatsCollector {
public:
template<typename Callback>
void feed(const buffer_s16_t& src, Callback callback) {
consume_audio_buffer(src);
if( update_stats(src.count, src.sampling_rate) ) {
if( feed(src) ) {
callback(statistics);
}
}
template<typename Callback>
void mute(const size_t sample_count, const size_t sampling_rate, Callback callback) {
if( update_stats(sample_count, sampling_rate) ) {
if( mute(sample_count, sampling_rate) ) {
callback(statistics);
}
}
@ -57,6 +55,9 @@ private:
void consume_audio_buffer(const buffer_s16_t& src);
bool update_stats(const size_t sample_count, const size_t sampling_rate);
bool feed(const buffer_s16_t& src);
bool mute(const size_t sample_count, const size_t sampling_rate);
};
#endif/*__AUDIO_STATS_COLLECTOR_H__*/