plugins: pdbox: remove HW_SAMPR_CAPS usage
rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
| Newsgroups | gmane.comp.systems.archos.rockbox.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 6be230275e1868f7c1e4ab53b69a4b6d16e64e7c Author: mojyack <[email protected]> Date: Fri Feb 13 22:37:47 2026 +0900 plugins: pdbox: remove HW_SAMPR_CAPS usage Change-Id: I4e37213a38ac5d1260bc2fa208828abd55fc2647 diff --git a/apps/plugins/pdbox/pdbox.c b/apps/plugins/pdbox/pdbox.c index 08236bfeba..78d6037fa6 100644 --- a/apps/plugins/pdbox/pdbox.c +++ b/apps/plugins/pdbox/pdbox.c @@ -188,6 +188,26 @@ enum plugin_status plugin_start(const void* parameter) /* Set audio API. */ sys_set_audio_api(API_ROCKBOX); + /* Determine sample rate. */ +#if defined(SIMULATOR) +#define PREFERRED_SAMPR SAMPR_44 +#else +#define PREFERRED_SAMPR SAMPR_22 +#endif + int samplerate; + { + int i; + const struct pcm_sink_caps* caps = rb->pcm_current_sink_caps(); + for (i = 0; i < caps->num_samprs; i++) { + if (caps->samprs[i] == PREFERRED_SAMPR) + break; + } + if (i == caps->num_samprs) + samplerate = SAMPR_44; + else + samplerate = caps->samprs[i]; + } + /* Initialize audio subsystem. */ sys_open_audio(0, /* No sound input yet */ sys_soundindevlist, @@ -197,7 +217,7 @@ enum plugin_status plugin_start(const void* parameter) sys_soundoutdevlist, -1, /* Use the default amount (2) of channels */ sys_choutlist, - PD_SAMPLERATE, /* Sample rate */ + samplerate, /* Sample rate */ DEFAULTADVANCE, /* Scheduler advance */ 1 /* Enable */); diff --git a/apps/plugins/pdbox/pdbox.h b/apps/plugins/pdbox/pdbox.h index 8dcb152479..36fb6c4fa8 100644 --- a/apps/plugins/pdbox/pdbox.h +++ b/apps/plugins/pdbox/pdbox.h @@ -40,17 +40,9 @@ #define calloc(elements, elem_size) tlsf_calloc(elements, elem_size) /* Audio declarations. */ -#ifdef SIMULATOR - #define PD_SAMPLERATE 44100 -#elif (HW_SAMPR_CAPS & SAMPR_CAP_22) - #define PD_SAMPLERATE 22050 -#elif (HW_SAMPR_CAPS & SAMPR_CAP_32) - #define PD_SAMPLERATE 32000 -#elif (HW_SAMPR_CAPS & SAMPR_CAP_44) - #define PD_SAMPLERATE 44100 -#else - #error No sufficient sample rate available! -#endif +/* Maximum sample rate; used for buffer sizing. + * Actual rate is determined at runtime from pcm sink capabilities. */ +#define PD_SAMPLERATE 44100 #define PD_SAMPLES_PER_HZ ((PD_SAMPLERATE / HZ) + \ (PD_SAMPLERATE % HZ > 0 ? 1 : 0)) #define PD_OUT_CHANNELS 2 -- rockbox-cvs mailing list [email protected] https://lists.haxx.se/mailman/listinfo/rockbox-cvs