Commit b4bc7ab8 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #29632: audiobuffer: make buffer size an explicit parameter

parent 6ad0780e
...@@ -42,7 +42,7 @@ class AudioBuffer { ...@@ -42,7 +42,7 @@ class AudioBuffer {
/** /**
* Default constructor. * Default constructor.
*/ */
AudioBuffer(size_t sample_num = 0, unsigned channel_num = 1, int sample_rate = 8000); AudioBuffer(size_t sample_num, unsigned channel_num = 1, int sample_rate = 8000);
/** /**
* Construtor from existing interleaved data (copied into the buffer). * Construtor from existing interleaved data (copied into the buffer).
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
AudioLoop::AudioLoop(unsigned int sampleRate) : buffer_(0), pos_(0) AudioLoop::AudioLoop(unsigned int sampleRate) : buffer_(0), pos_(0)
{ {
buffer_ = new AudioBuffer; buffer_ = new AudioBuffer(0);
buffer_->setSampleRate(sampleRate); buffer_->setSampleRate(sampleRate);
} }
......
...@@ -100,7 +100,7 @@ AudioRtpRecord::AudioRtpRecord() : ...@@ -100,7 +100,7 @@ AudioRtpRecord::AudioRtpRecord() :
, decoderPayloadType_(0) , decoderPayloadType_(0)
, hasDynamicPayloadType_(false) , hasDynamicPayloadType_(false)
, decData_(DEC_BUFFER_SIZE) // std::tr1::arrays will be 0-initialized , decData_(DEC_BUFFER_SIZE) // std::tr1::arrays will be 0-initialized
, resampledData_() , resampledData_(0)
, encodedData_() , encodedData_()
, converterEncode_(0) , converterEncode_(0)
, converterDecode_(0) , converterDecode_(0)
......
...@@ -80,7 +80,7 @@ PulseLayer::PulseLayer(AudioPreference &pref) ...@@ -80,7 +80,7 @@ PulseLayer::PulseLayer(AudioPreference &pref)
, ringtone_(0) , ringtone_(0)
, sinkList_() , sinkList_()
, sourceList_() , sourceList_()
, mic_buffer_() , mic_buffer_(0)
, context_(0) , context_(0)
, mainloop_(pa_threaded_mainloop_new()) , mainloop_(pa_threaded_mainloop_new())
, enumeratingSinks_(false) , enumeratingSinks_(false)
......
...@@ -48,7 +48,7 @@ Tone::Tone(const std::string& definition, unsigned int sampleRate) : ...@@ -48,7 +48,7 @@ Tone::Tone(const std::string& definition, unsigned int sampleRate) :
{ {
fillWavetable(); fillWavetable();
delete buffer_; delete buffer_;
buffer_ = new AudioBuffer(); buffer_ = new AudioBuffer(0);
buffer_->setSampleRate(sampleRate); buffer_->setSampleRate(sampleRate);
genBuffer(definition); // allocate memory with definition parameter genBuffer(definition); // allocate memory with definition parameter
} }
......
...@@ -42,7 +42,7 @@ void AudioBufferTest::testAudioBufferConstructors() ...@@ -42,7 +42,7 @@ void AudioBufferTest::testAudioBufferConstructors()
SFLAudioSample test_samples1[] = {}; SFLAudioSample test_samples1[] = {};
SFLAudioSample test_samples2[] = {10, 11, 12, 13, 14, 15, 16, 17}; SFLAudioSample test_samples2[] = {10, 11, 12, 13, 14, 15, 16, 17};
AudioBuffer empty_buf; AudioBuffer empty_buf(0);
CPPUNIT_ASSERT(empty_buf.samples() == 0); CPPUNIT_ASSERT(empty_buf.samples() == 0);
CPPUNIT_ASSERT(empty_buf.channels() == 1); CPPUNIT_ASSERT(empty_buf.channels() == 1);
CPPUNIT_ASSERT(empty_buf.getChannel(0)->size() == 0); CPPUNIT_ASSERT(empty_buf.getChannel(0)->size() == 0);
...@@ -84,7 +84,7 @@ void AudioBufferTest::testAudioBufferMix() ...@@ -84,7 +84,7 @@ void AudioBufferTest::testAudioBufferMix()
test_buf1.setChannelNum(2, true); test_buf1.setChannelNum(2, true);
CPPUNIT_ASSERT((*test_buf1.getChannel(1))[0] == test_samples1[0]); CPPUNIT_ASSERT((*test_buf1.getChannel(1))[0] == test_samples1[0]);
AudioBuffer test_buf2; AudioBuffer test_buf2(0);
test_buf2.deinterleave(test_samples2, 3, 3); test_buf2.deinterleave(test_samples2, 3, 3);
CPPUNIT_ASSERT((*test_buf2.getChannel(0))[2] == test_samples2[6]); CPPUNIT_ASSERT((*test_buf2.getChannel(0))[2] == test_samples2[6]);
CPPUNIT_ASSERT((*test_buf2.getChannel(1))[1] == test_samples2[4]); CPPUNIT_ASSERT((*test_buf2.getChannel(1))[1] == test_samples2[4]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment