diff --git a/inc/streams/DataStream.h b/inc/streams/DataStream.h index 35b15481..ad4866f8 100644 --- a/inc/streams/DataStream.h +++ b/inc/streams/DataStream.h @@ -65,8 +65,9 @@ namespace codal virtual ManagedBuffer pull(); virtual void connect(DataSink &sink); - virtual int getFormat(); - virtual int setFormat(int format); + virtual void disconnect(); + virtual int getFormat(); + virtual int setFormat(int format); }; /** @@ -138,19 +139,19 @@ namespace codal * * @sink The component that data will be delivered to, when it is availiable */ - virtual void connect(DataSink &sink); + virtual void connect(DataSink &sink) override; /** * Define a downstream component for data stream. * * @sink The component that data will be delivered to, when it is availiable */ - void disconnect(); + virtual void disconnect() override; /** * Determine the data format of the buffers streamed out of this component. */ - int getFormat(); + virtual int getFormat() override; /** * Determine the number of bytes that are currnetly buffered before blocking subsequent push() operations. diff --git a/inc/streams/StreamNormalizer.h b/inc/streams/StreamNormalizer.h index 79b4c010..6ce01a03 100644 --- a/inc/streams/StreamNormalizer.h +++ b/inc/streams/StreamNormalizer.h @@ -28,6 +28,13 @@ DEALINGS IN THE SOFTWARE. #ifndef STREAM_NORMALIZER_H #define STREAM_NORMALIZER_H +/** + * Sample read/write functions for 8, 16, 24, 32 bit signed/unsigned data. + */ +typedef int (*SampleReadFn)(uint8_t *); +typedef void (*SampleWriteFn)(uint8_t *, int); + + /** * Default configuration values */ @@ -49,6 +56,8 @@ namespace codal{ DataStream output; // The downstream output stream of this StreamNormalizer. ManagedBuffer buffer; // The buffer being processed. + static SampleReadFn readSample[9]; + static SampleWriteFn writeSample[9]; /** * Creates a component capable of translating one data representation format into another diff --git a/source/streams/DataStream.cpp b/source/streams/DataStream.cpp index f5fd035d..42604079 100644 --- a/source/streams/DataStream.cpp +++ b/source/streams/DataStream.cpp @@ -41,6 +41,10 @@ void DataSource::connect(DataSink& ) { } +void DataSource::disconnect() +{ +} + int DataSource::getFormat() { return DATASTREAM_FORMAT_UNKNOWN; diff --git a/source/streams/StreamNormalizer.cpp b/source/streams/StreamNormalizer.cpp index 1771df86..eb9eda66 100644 --- a/source/streams/StreamNormalizer.cpp +++ b/source/streams/StreamNormalizer.cpp @@ -112,11 +112,9 @@ static void write_sample_8(uint8_t *ptr, int value) *(int32_t *)ptr = (int32_t) value; } -// Lookup table to optimse parsin gof input stream. -typedef int (*SampleReadFn)(uint8_t *); -typedef void (*SampleWriteFn)(uint8_t *, int); -SampleReadFn readSample[] = {read_sample_1, read_sample_1, read_sample_2, read_sample_3, read_sample_4, read_sample_5, read_sample_6, read_sample_7, read_sample_8}; -SampleWriteFn writeSample[] = {write_sample_1, write_sample_1, write_sample_2, write_sample_3, write_sample_4, write_sample_5_6, write_sample_5_6, write_sample_7, write_sample_8}; +// Lookup table to optimse parsing of input stream. +SampleReadFn StreamNormalizer::readSample[] = {read_sample_1, read_sample_1, read_sample_2, read_sample_3, read_sample_4, read_sample_5, read_sample_6, read_sample_7, read_sample_8}; +SampleWriteFn StreamNormalizer::writeSample[] = {write_sample_1, write_sample_1, write_sample_2, write_sample_3, write_sample_4, write_sample_5_6, write_sample_5_6, write_sample_7, write_sample_8}; /** * Creates a component capable of translating one data representation format into another