From 6f2fefdd9ff5f8561b3538efb5eb0765a9b4a141 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Thu, 6 Jan 2011 05:29:39 +0100 Subject: Replaced iostream-based decoder-encoder chain with direct chain. --- encoders/lame_encoder.cpp | 10 +++++----- encoders/lame_encoder.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'encoders') diff --git a/encoders/lame_encoder.cpp b/encoders/lame_encoder.cpp index 7bf2ebc..be6f684 100644 --- a/encoders/lame_encoder.cpp +++ b/encoders/lame_encoder.cpp @@ -2,7 +2,7 @@ #include -EncoderLame::EncoderLame() { +EncoderLame::EncoderLame(RawAudioSource::p source_) : source(source_) { gfp = lame_init(); int error = lame_init_params(gfp); @@ -23,15 +23,15 @@ size_t EncoderLame::flush(uint8_t *output, size_t output_size) { return lame_encode_flush(gfp, output, output_size); } -size_t EncoderLame::encode(ReadFunc read, uint8_t *output, size_t output_size) { +std::size_t EncoderLame::read(char* buf, std::size_t buf_size) { char src_data[0x2000]; - std::streamsize src_read = read(src_data, 0x2000); + std::streamsize src_read = source->read(src_data, 0x2000); if(src_read < 0) src_read = 0; - std::streamsize size = encode((const uint8_t*)src_data, src_read, (uint8_t*)output, output_size); + std::streamsize size = encode((const uint8_t*)src_data, src_read, (uint8_t*)buf, buf_size); // no more data, flush encoder if(src_read == 0 && size == 0) { - size = flush((uint8_t*)output, output_size); + size = flush((uint8_t*)buf, buf_size); } return size; diff --git a/encoders/lame_encoder.h b/encoders/lame_encoder.h index 98ebc9f..3d1137d 100644 --- a/encoders/lame_encoder.h +++ b/encoders/lame_encoder.h @@ -5,19 +5,19 @@ #include -class EncoderLame : public EncoderBase { +class EncoderLame : public Encoder { private: lame_global_flags *gfp; + RawAudioSource::p source; size_t encode(const uint8_t *input, size_t input_size, uint8_t *output, size_t output_size); size_t flush(uint8_t *output, size_t output_size); - protected: - virtual size_t encode(ReadFunc read, uint8_t *output, size_t output_size); - public: - EncoderLame(); + EncoderLame(RawAudioSource::p source_); ~EncoderLame(); + + virtual std::size_t read(char* buf, std::size_t buf_size); }; #endif -- cgit v1.2.3