Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Freezes if left until the red debug LED lights up in the top left #5

Closed
Gadgetoid opened this issue Feb 24, 2023 · 12 comments
Closed

Comments

@Gadgetoid
Copy link
Owner

  1. Connect your phone
  2. Play some music
  3. Pause
  4. Leave it for a moment
  5. When FFT vanishes and the red LED lights in the top left try to play music again
  6. BOOM?
@Gadgetoid
Copy link
Owner Author

This seems to mostly happen with iOS (my iPhone) and looking at serial, it floods the:

Error storing samples in SBC ring buffer!!!

Error.

@Gadgetoid
Copy link
Owner Author

Slightly more detailed log, albeit it's not very useful:

Connecting PIO I2S audio
Copying stereo to stereo at 44100 Hz
AVRCP Controller: Playback status changed PLAYING
AVRCP Controller: Playback status changed PLAYING
AVRCP Controller: Playback status changed PAUSED
AVRCP Controller: Playback status changed PAUSED
A2DP  Sink      : Stream paused
AVRCP Target    : Volume set to 18% (23)
A2DP  Sink      : Stream started
AVRCP Controller: Playback status changed PLAYING
AVRCP Controller: Playback status changed PLAYING
AVRCP Controller: Playback status changed PAUSED
AVRCP Controller: Playback status changed PAUSED
A2DP  Sink      : Stream paused
AVRCP Target    : Volume set to 18% (23)
A2DP  Sink      : Stream started
AVRCP Controller: Playback status changed PLAYING
AVRCP Controller: Playback status changed PLAYING
Error storing samples in SBC ring buffer!!!
Error storing samples in SBC ring buffer!!!
Error storing samples in SBC ring buffer!!!
Error storing samples in SBC ring buffer!!!
Error storing samples in SBC ring buffer!!!
Error storing samples in SBC ring buffer!!!
Error storing samples in SBC ring buffer!!!
Error storing samples in SBC ring buffer!!!

This error should (only?) trigger if the buffer is filling faster than the data can be consumed, so potentially the audio output is failing to init after it has been shut off by "A2DP Sink: Stream paused"

@Gadgetoid
Copy link
Owner Author

Bit more info on what functions are called when:

Connecting PIO I2S audio
Copying stereo to stereo at 44100 Hz
AVRCP Controller: Playback status changed PLAYING
AVRCP Controller: Playback status changed PLAYING
btstack_audio_pico_sink_start_stream
AVRCP Controller: Playback status changed PAUSED
AVRCP Controller: Playback status changed PAUSED
A2DP  Sink      : Stream paused
btstack_audio_pico_sink_stop_stream
AVRCP Target    : Volume set to 18% (23)
A2DP  Sink      : Stream started
AVRCP Controller: Playback status changed PLAYING
AVRCP Controller: Playback status changed PLAYING
btstack_audio_pico_sink_start_stream
AVRCP Controller: Playback status changed PAUSED
AVRCP Controller: Playback status changed PAUSED
A2DP  Sink      : Stream paused
btstack_audio_pico_sink_stop_stream
AVRCP Target    : Volume set to 18% (23)
A2DP  Sink      : Stream started
AVRCP Controller: Playback status changed PLAYING
AVRCP Controller: Playback status changed PLAYING
btstack_audio_pico_sink_start_stream
Error storing samples in SBC ring buffer!!!
Error storing samples in SBC ring buffer!!!
Error storing samples in SBC ring buffer!!!

@Gadgetoid
Copy link
Owner Author

I can remove the FFT and display code altogether and this bug still triggers, I'd bet it does the same on the vanilla example.

@Gadgetoid
Copy link
Owner Author

@kilograham @mringwal I’m a little out of my depth here, but I think this bug is in the regular a2dp sink example on the Pico W, do you have any off the cuff insight? Thanks.

@mringwal
Copy link

Hi. Please try this PR and let me know
raspberrypi/pico-extras#58
(Looks like I never created a PR for this. It lets A2DP Sink Demo work after the first pause).

@Gadgetoid
Copy link
Owner Author

Looks like that's fixed it. Thank you!

Now I just have to bug engineering to make me a better speaker 😆

Shout if you want some hardware (Galactic / Cosmic Unicorn) to play with this on.

@kilograham
Copy link

shout ;-)

@mringwal
Copy link

If @kilograham gets one, I'd also like one:)

Here's a futuristic idea: it looks like both iOS and Android support Cover Art since a bit (they didn't three years) ago, now, you've got a nice RGB display although it's a bit rectangular...

BTstack doesn't support Cover Art yet, but we plan to have it by summer.

@Gadgetoid
Copy link
Owner Author

Bung me an email with your particulars!

@Gadgetoid
Copy link
Owner Author

Here's a futuristic idea: it looks like both iOS and Android support Cover Art since a bit (they didn't three years) ago, now, you've got a nice RGB display although it's a bit rectangular...

Cosmic is 32x32 pixels so album art could work - https://fosstodon.org/@gadgetoid/109933594917821802

Any idea off the top of your head what formats it would be expected in, or if that's controllable? You're right, Lo-Fi album art could be really cool.

@mringwal
Copy link

Not top of my head, but I checked. It's mandatory to provide a 200x200 pixel thumbnail as JPEG. Other than that, the client can ask for a format/size/... and the server may or may not provide it. I'd assume that iOS/Android probably can scale the image and provide it as JPEG and PNG as a minimum. For your project, the 200x200 JPEG Thumbnail looks like the obvious choice.

Btw. audio over a2dp is encoded as SBC, which dynamically distributes the available bits on a number of subbands - it's documented in Appendix B of the A2DP Specification. I guess, if you really really want to reduce computation, you could try to access these / the spectrum before it is even converted back to PCM... (just if you're really really bored or interested in maths).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants