Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

FS#13836 - Remove the pcm sink_mutex to unbreak usb_dac mode

The purpose of the mutex is to make it possible to switch pcm sinks
safely, but pcm_play_lock/unlock and pcm_set_frequency need to be
called from IRQ context which is fundamentally incompatible with
our mutex implementation.

The proper path forward will be to promote the counter-based per-sink
lock/unlock implementation to the pcm core, and only allowing sink
switching when the counter is 0.

In the mean time, just remove sink_mutex entirely as the sink switching
code has yet to be committed.

Change-Id: I029459d7ec6ea47c6e2b8fce52d203129a282832

-9
-9
firmware/pcm.c
··· 83 83 [PCM_SINK_BUILTIN] = &builtin_pcm_sink, 84 84 }; 85 85 static enum pcm_sink_ids cur_sink = PCM_SINK_BUILTIN; 86 - static struct mutex sink_mutex; /* protects sinks and cur_sink */ 87 86 88 87 /* The registered callback function to ask for more mp3 data */ 89 88 volatile pcm_play_callback_type ··· 238 237 */ 239 238 240 239 void pcm_play_lock(void) { 241 - mutex_lock(&sink_mutex); 242 240 sinks[cur_sink]->ops.lock(); 243 - /* hold sink_mutex until pcm_play_unlock() */ 244 241 } 245 242 246 243 void pcm_play_unlock(void) { 247 244 sinks[cur_sink]->ops.unlock(); 248 - mutex_unlock(&sink_mutex); 249 245 } 250 246 251 247 /* This should only be called at startup before any audio playback or ··· 254 250 { 255 251 logf("pcm_init"); 256 252 257 - mutex_init(&sink_mutex); 258 253 for(size_t i = 0; i < ARRAYLEN(sinks); i += 1) { 259 254 sinks[i]->pending_freq = sinks[i]->caps.default_freq; 260 255 sinks[i]->configured_freq = -1UL; ··· 359 354 samplerate = pcm_sampr_to_hw_sampr(samplerate, type); 360 355 #endif /* CONFIG_SAMPR_TYPES */ 361 356 362 - mutex_lock(&sink_mutex); 363 357 struct pcm_sink* sink = sinks[cur_sink]; 364 358 index = round_value_to_list32(samplerate, sink->caps.samprs, sink->caps.num_samprs, false); 365 359 ··· 367 361 index = sink->caps.default_freq; /* Invalid = default */ 368 362 369 363 sink->pending_freq = index; 370 - mutex_unlock(&sink_mutex); 371 364 } 372 365 373 366 /* return last-set frequency */ ··· 384 377 385 378 pcm_wait_for_init(); 386 379 387 - mutex_lock(&sink_mutex); 388 380 struct pcm_sink* sink = sinks[cur_sink]; 389 381 if(sink->pending_freq != sink->configured_freq) { 390 382 logf(" sink->set_freq"); 391 383 sink->ops.set_freq(sink->pending_freq); 392 384 sink->configured_freq = sink->pending_freq; 393 385 } 394 - mutex_unlock(&sink_mutex); 395 386 } 396 387 397 388 #ifdef HAVE_RECORDING