summaryrefslogtreecommitdiff
path: root/encoders
diff options
context:
space:
mode:
Diffstat (limited to 'encoders')
-rw-r--r--encoders/lame_encoder.cpp10
-rw-r--r--encoders/lame_encoder.h10
2 files changed, 10 insertions, 10 deletions
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 <stdexcept>
-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 <lame/lame.h>
-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