pcm: Pull pcm_is_ready back out of the sink structure

It is referenced by multiple threads, and as such needs to be both
volatile and SHAREDBSS to keep everyone happy.

...should address hangs on startup observed on nano2g and mini2g when
voiced menus are enabled

Regression introduced in dfa33c2 and made far worse by 759ef27

Change-Id: I202ec6c0d5825ff3a319b7d95d600b4ce06dd685
This commit is contained in:
Solomon Peachy 2026-06-10 08:50:46 -04:00
parent 0a1858b9d1
commit 59a42fbf61
2 changed files with 8 additions and 6 deletions

View file

@ -49,7 +49,6 @@ struct pcm_sink {
/* runtime states */
unsigned long pending_freq;
unsigned long configured_freq;
unsigned long pcm_is_ready;
};
enum pcm_sink_ids {

View file

@ -76,6 +76,9 @@
*
*/
/* 'true' when all stages of pcm initialization have completed */
volatile static bool pcm_is_ready[PCM_SINK_NUM] SHAREDBSS_ATTR = { false };
#ifdef USB_ENABLE_IAP
extern struct pcm_sink iap_pcm_sink;
#endif
@ -86,7 +89,7 @@ static struct pcm_sink* sinks[PCM_SINK_NUM] = {
[PCM_SINK_IAP] = &iap_pcm_sink,
#endif
};
static enum pcm_sink_ids cur_sink = PCM_SINK_BUILTIN;
static enum pcm_sink_ids cur_sink SHAREDBSS_ATTR = PCM_SINK_BUILTIN;
/* The registered callback function to ask for more mp3 data */
volatile pcm_play_callback_type
@ -146,7 +149,7 @@ void pcm_play_stop_int(void)
static void pcm_wait_for_init(void)
{
while (!sinks[cur_sink]->pcm_is_ready)
while (!pcm_is_ready[cur_sink])
sleep(0);
}
@ -256,9 +259,9 @@ void pcm_init(void)
for(size_t i = 0; i < PCM_SINK_NUM; i += 1) {
struct pcm_sink* sink = sinks[i];
pcm_is_ready[i] = false;
sink->pending_freq = sink->caps.default_freq;
sink->configured_freq = -1U;
sink->pcm_is_ready = false;
sink->ops.init();
}
}
@ -271,7 +274,7 @@ void pcm_postinit(void)
for(size_t i = 0; i < PCM_SINK_NUM; i += 1) {
struct pcm_sink* sink = sinks[i];
sink->ops.postinit();
sink->pcm_is_ready = true;
pcm_is_ready[i] = true;
}
/* Ensure mixer is in a sane state */
@ -280,7 +283,7 @@ void pcm_postinit(void)
bool pcm_is_initialized(void)
{
return sinks[cur_sink]->pcm_is_ready;
return pcm_is_ready[cur_sink];
}
enum pcm_sink_ids pcm_current_sink(void)