summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-12-03 15:24:41 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-12-22 18:00:37 -0500
commit34a092a99729dd4de014aa1f76c48660f28a9c97 (patch)
tree40bd89c62bb6b1b7da10ede5a744b83c9c29bee5
parentb96b7640de381757c5ceac182e01bc84f668e64a (diff)
downloadrockbox-34a092a99729dd4de014aa1f76c48660f28a9c97.tar.gz
rockbox-34a092a99729dd4de014aa1f76c48660f28a9c97.zip
rbcodec dsp: Replace enum dsp_ids arguments with unsigned int
Because casting to and from "enum dsp_id" just adds noise, change everything to unsigned int. Change-Id: I52a7ae55f406e673d5b811b29657fcdc4b62ab10
-rw-r--r--apps/plugin.h2
-rw-r--r--lib/rbcodec/dsp/dsp_core.c15
-rw-r--r--lib/rbcodec/dsp/dsp_core.h4
-rw-r--r--lib/rbcodec/dsp/dsp_misc.c4
-rw-r--r--lib/rbcodec/dsp/dsp_sample_input.c5
-rw-r--r--lib/rbcodec/dsp/dsp_sample_io.c2
-rw-r--r--lib/rbcodec/dsp/dsp_sample_io.h2
-rw-r--r--lib/rbcodec/dsp/resample.c7
-rw-r--r--lib/rbcodec/dsp/tdspeed.c5
9 files changed, 19 insertions, 27 deletions
diff --git a/apps/plugin.h b/apps/plugin.h
index 377b18773f..e44511a6f5 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -714,7 +714,7 @@ struct plugin_api {
714#endif 714#endif
715 intptr_t (*dsp_configure)(struct dsp_config *dsp, 715 intptr_t (*dsp_configure)(struct dsp_config *dsp,
716 unsigned int setting, intptr_t value); 716 unsigned int setting, intptr_t value);
717 struct dsp_config * (*dsp_get_config)(enum dsp_ids id); 717 struct dsp_config * (*dsp_get_config)(unsigned int dsp_id);
718 void (*dsp_process)(struct dsp_config *dsp, struct dsp_buffer *src, 718 void (*dsp_process)(struct dsp_config *dsp, struct dsp_buffer *src,
719 struct dsp_buffer *dst); 719 struct dsp_buffer *dst);
720 720
diff --git a/lib/rbcodec/dsp/dsp_core.c b/lib/rbcodec/dsp/dsp_core.c
index 3e72322ea6..14bf228bd6 100644
--- a/lib/rbcodec/dsp/dsp_core.c
+++ b/lib/rbcodec/dsp/dsp_core.c
@@ -483,24 +483,19 @@ intptr_t dsp_configure(struct dsp_config *dsp, unsigned int setting,
483 return proc_broadcast(dsp, setting, value); 483 return proc_broadcast(dsp, setting, value);
484} 484}
485 485
486struct dsp_config * dsp_get_config(enum dsp_ids id) 486struct dsp_config *dsp_get_config(unsigned int dsp_id)
487{ 487{
488 if (id >= DSP_COUNT) 488 if (dsp_id >= DSP_COUNT)
489 return NULL; 489 return NULL;
490 490
491 return &dsp_conf[id]; 491 return &dsp_conf[dsp_id];
492} 492}
493 493
494/* Return the id given a dsp pointer (or even via something within 494/* Return the id given a dsp pointer (or even via something within
495 the struct itself) */ 495 the struct itself) */
496enum dsp_ids dsp_get_id(const struct dsp_config *dsp) 496unsigned int dsp_get_id(const struct dsp_config *dsp)
497{ 497{
498 ptrdiff_t id = dsp - dsp_conf; 498 return dsp - dsp_conf;
499
500 if (id < 0 || id >= DSP_COUNT)
501 return DSP_COUNT; /* obviously invalid */
502
503 return (enum dsp_ids)id;
504} 499}
505 500
506/* Do what needs initializing before enable/disable calls can be made. 501/* Do what needs initializing before enable/disable calls can be made.
diff --git a/lib/rbcodec/dsp/dsp_core.h b/lib/rbcodec/dsp/dsp_core.h
index e18d045056..3544084056 100644
--- a/lib/rbcodec/dsp/dsp_core.h
+++ b/lib/rbcodec/dsp/dsp_core.h
@@ -128,10 +128,10 @@ static inline void dsp_advance_buffer32(struct dsp_buffer *buf,
128} 128}
129 129
130/* Get DSP pointer */ 130/* Get DSP pointer */
131struct dsp_config * dsp_get_config(enum dsp_ids id); 131struct dsp_config *dsp_get_config(unsigned int dsp_id);
132 132
133/* Get DSP id */ 133/* Get DSP id */
134enum dsp_ids dsp_get_id(const struct dsp_config *dsp); 134unsigned int dsp_get_id(const struct dsp_config *dsp);
135 135
136/** General DSP processing **/ 136/** General DSP processing **/
137 137
diff --git a/lib/rbcodec/dsp/dsp_misc.c b/lib/rbcodec/dsp/dsp_misc.c
index 83e577935b..8687abc06a 100644
--- a/lib/rbcodec/dsp/dsp_misc.c
+++ b/lib/rbcodec/dsp/dsp_misc.c
@@ -149,7 +149,7 @@ unsigned int dsp_get_output_frequency(struct dsp_config *dsp)
149 return dsp_configure(dsp, DSP_GET_OUT_FREQUENCY, 0); 149 return dsp_configure(dsp, DSP_GET_OUT_FREQUENCY, 0);
150} 150}
151 151
152static void misc_dsp_init(struct dsp_config *dsp, enum dsp_ids dsp_id) 152static void misc_dsp_init(struct dsp_config *dsp, unsigned int dsp_id)
153{ 153{
154 /* Enable us for the audio DSP at startup */ 154 /* Enable us for the audio DSP at startup */
155 if (dsp_id == CODEC_IDX_AUDIO) 155 if (dsp_id == CODEC_IDX_AUDIO)
@@ -168,7 +168,7 @@ static intptr_t misc_handler_configure(struct dsp_proc_entry *this,
168 switch (setting) 168 switch (setting)
169 { 169 {
170 case DSP_INIT: 170 case DSP_INIT:
171 misc_dsp_init(dsp, (enum dsp_ids)value); 171 misc_dsp_init(dsp, value);
172 break; 172 break;
173 173
174 case DSP_PROC_CLOSE: 174 case DSP_PROC_CLOSE:
diff --git a/lib/rbcodec/dsp/dsp_sample_input.c b/lib/rbcodec/dsp/dsp_sample_input.c
index 8068ce5097..06ce11fab7 100644
--- a/lib/rbcodec/dsp/dsp_sample_input.c
+++ b/lib/rbcodec/dsp/dsp_sample_input.c
@@ -242,8 +242,7 @@ void dsp_sample_input_flush(struct sample_io_data *this)
242 this->sample_buf.remcount = 0; 242 this->sample_buf.remcount = 0;
243} 243}
244 244
245void dsp_sample_input_init(struct sample_io_data *this, 245void dsp_sample_input_init(struct sample_io_data *this, unsigned int dsp_id)
246 enum dsp_ids dsp_id)
247{ 246{
248 int32_t *lbuf, *rbuf; 247 int32_t *lbuf, *rbuf;
249 248
@@ -260,7 +259,7 @@ void dsp_sample_input_init(struct sample_io_data *this,
260 259
261 default: 260 default:
262 /* orly */ 261 /* orly */
263 DEBUGF("DSP Input- unknown dsp %d\n", (int)dsp_id); 262 DEBUGF("DSP Input- unknown dsp %u\n", dsp_id);
264 return; 263 return;
265 } 264 }
266 265
diff --git a/lib/rbcodec/dsp/dsp_sample_io.c b/lib/rbcodec/dsp/dsp_sample_io.c
index 637d41a918..af3a424aa0 100644
--- a/lib/rbcodec/dsp/dsp_sample_io.c
+++ b/lib/rbcodec/dsp/dsp_sample_io.c
@@ -46,7 +46,7 @@ bool dsp_sample_io_configure(struct sample_io_data *this,
46 { 46 {
47 case DSP_INIT: 47 case DSP_INIT:
48 this->output_sampr = DSP_OUT_DEFAULT_HZ; 48 this->output_sampr = DSP_OUT_DEFAULT_HZ;
49 dsp_sample_input_init(this, (enum dsp_ids)value); 49 dsp_sample_input_init(this, value);
50 dsp_sample_output_init(this); 50 dsp_sample_output_init(this);
51 break; 51 break;
52 52
diff --git a/lib/rbcodec/dsp/dsp_sample_io.h b/lib/rbcodec/dsp/dsp_sample_io.h
index 483f24112c..7e41337a5b 100644
--- a/lib/rbcodec/dsp/dsp_sample_io.h
+++ b/lib/rbcodec/dsp/dsp_sample_io.h
@@ -56,7 +56,7 @@ struct sample_io_data
56 uint8_t output_version; /* Format version of src buffer at output */ 56 uint8_t output_version; /* Format version of src buffer at output */
57}; 57};
58 58
59void dsp_sample_input_init(struct sample_io_data *this, enum dsp_ids dsp_id); 59void dsp_sample_input_init(struct sample_io_data *this, unsigned int dsp_id);
60void dsp_sample_input_flush(struct sample_io_data *this); 60void dsp_sample_input_flush(struct sample_io_data *this);
61void dsp_sample_input_format_change(struct sample_io_data *this, 61void dsp_sample_input_format_change(struct sample_io_data *this,
62 struct sample_format *format); 62 struct sample_format *format);
diff --git a/lib/rbcodec/dsp/resample.c b/lib/rbcodec/dsp/resample.c
index a583f60a55..77e1c5e0e5 100644
--- a/lib/rbcodec/dsp/resample.c
+++ b/lib/rbcodec/dsp/resample.c
@@ -262,8 +262,7 @@ static intptr_t resample_new_format(struct dsp_proc_entry *this,
262 return PROC_NEW_FORMAT_DEACTIVATED; 262 return PROC_NEW_FORMAT_DEACTIVATED;
263} 263}
264 264
265static void resample_dsp_init(struct dsp_config *dsp, 265static void resample_dsp_init(struct dsp_config *dsp, unsigned int dsp_id)
266 enum dsp_ids dsp_id)
267{ 266{
268 int32_t *lbuf, *rbuf; 267 int32_t *lbuf, *rbuf;
269 268
@@ -280,7 +279,7 @@ static void resample_dsp_init(struct dsp_config *dsp,
280 279
281 default: 280 default:
282 /* huh? */ 281 /* huh? */
283 DEBUGF("DSP_PROC_RESAMPLE- unknown DSP %d\n", (int)dsp_id); 282 DEBUGF("DSP_PROC_RESAMPLE- unknown DSP %u\n", dsp_id);
284 return; 283 return;
285 } 284 }
286 285
@@ -312,7 +311,7 @@ static intptr_t resample_configure(struct dsp_proc_entry *this,
312 switch (setting) 311 switch (setting)
313 { 312 {
314 case DSP_INIT: 313 case DSP_INIT:
315 resample_dsp_init(dsp, (enum dsp_ids)value); 314 resample_dsp_init(dsp, value);
316 break; 315 break;
317 316
318 case DSP_FLUSH: 317 case DSP_FLUSH:
diff --git a/lib/rbcodec/dsp/tdspeed.c b/lib/rbcodec/dsp/tdspeed.c
index 7a9d818f19..88d057560c 100644
--- a/lib/rbcodec/dsp/tdspeed.c
+++ b/lib/rbcodec/dsp/tdspeed.c
@@ -521,8 +521,7 @@ static intptr_t tdspeed_new_format(struct dsp_proc_entry *this,
521 (void)this; 521 (void)this;
522} 522}
523 523
524static void tdspeed_dsp_init(struct tdspeed_state_s *st, 524static void tdspeed_dsp_init(struct tdspeed_state_s *st, unsigned int dsp_id)
525 enum dsp_ids dsp_id)
526{ 525{
527 /* everything is at 100% until dsp_set_timestretch is called with 526 /* everything is at 100% until dsp_set_timestretch is called with
528 some other value and timestretch is enabled at the time */ 527 some other value and timestretch is enabled at the time */
@@ -543,7 +542,7 @@ static intptr_t tdspeed_configure(struct dsp_proc_entry *this,
543 switch (setting) 542 switch (setting)
544 { 543 {
545 case DSP_INIT: 544 case DSP_INIT:
546 tdspeed_dsp_init(st, (enum dsp_ids)value); 545 tdspeed_dsp_init(st, value);
547 break; 546 break;
548 547
549 case DSP_FLUSH: 548 case DSP_FLUSH: