mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-13 00:09:43 -05:00
Extract processor factory function.
A small code size reduction. I tried using std::unique_ptr, but code bloated between 150 and 400 bytes!
This commit is contained in:
parent
ef315f0d92
commit
f369885062
@ -321,6 +321,19 @@ private:
|
|||||||
|
|
||||||
static constexpr auto direction = baseband::Direction::Receive;
|
static constexpr auto direction = baseband::Direction::Receive;
|
||||||
|
|
||||||
|
static BasebandProcessor* create_processor(const int32_t mode) {
|
||||||
|
switch(mode) {
|
||||||
|
case 0: return new NarrowbandAMAudio();
|
||||||
|
case 1: return new NarrowbandFMAudio();
|
||||||
|
case 2: return new WidebandFMAudio();
|
||||||
|
case 3: return new AISProcessor();
|
||||||
|
case 4: return new WidebandSpectrum();
|
||||||
|
case 5: return new TPMSProcessor();
|
||||||
|
case 6: return new ERTProcessor();
|
||||||
|
default: return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@ -346,38 +359,7 @@ int main(void) {
|
|||||||
baseband_thread.baseband_processor = nullptr;
|
baseband_thread.baseband_processor = nullptr;
|
||||||
delete old_p;
|
delete old_p;
|
||||||
|
|
||||||
switch(message->configuration.mode) {
|
baseband_thread.baseband_processor = create_processor(message->configuration.mode);
|
||||||
case 0:
|
|
||||||
baseband_thread.baseband_processor = new NarrowbandAMAudio();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
baseband_thread.baseband_processor = new NarrowbandFMAudio();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
baseband_thread.baseband_processor = new WidebandFMAudio();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
baseband_thread.baseband_processor = new AISProcessor();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
baseband_thread.baseband_processor = new WidebandSpectrum();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
baseband_thread.baseband_processor = new TPMSProcessor();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 6:
|
|
||||||
baseband_thread.baseband_processor = new ERTProcessor();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( baseband_thread.baseband_processor ) {
|
if( baseband_thread.baseband_processor ) {
|
||||||
if( direction == baseband::Direction::Receive ) {
|
if( direction == baseband::Direction::Receive ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user