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

Playlists and error handling #8

Merged
merged 2 commits into from
Nov 20, 2022

Conversation

kmod-midori
Copy link

What have I done:

  • Move event sinks to a separate class, similar to the Android code. This was done because sometimes we try to send out events before the sinks are ready, causing segfaults.
  • Added support for playlists, except moving (I could not wrap my head around how that is done).
  • Some try-catching, since Windows API sometimes throws in unexpected places, such as getters (mediaPlayer.PlaybackSession() can fail in event handlers).
  • Updated some of the std::get_if calls, since according to docs, numbers are encoded as int32_t when they are small enough, and trying to do std::get_if<int64_t> on small values does not work (they are distinct types).
  • Formatting, which was done by Visual Studio before I realized that it was too late.

I don't write a lot of C++ (mostly Rust), but this code works in my product (which relies heavliy on playlists) without crashing, so please review carefully before merging.

Copy link
Owner

@bdlukaa bdlukaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! I just tested it and it works in the example/example_playlist.dart app!

Tho, it sometimes crashes, so there must be a memory leak somewhere! I've experienced crashes before, mostly related to int-32 and int-64 casts.

Also, when the app doesn't crash, it prints this to the console
[just_audio_windows] Broadcast event error: Não há suporte para esta interface (there isn't support for this interface)

just_audio_windows/windows/player.hpp Outdated Show resolved Hide resolved
just_audio_windows/windows/player.hpp Show resolved Hide resolved
just_audio_windows/windows/player.hpp Outdated Show resolved Hide resolved
just_audio_windows/windows/player.hpp Outdated Show resolved Hide resolved
@kmod-midori
Copy link
Author

Other WinRT APIs experience similar problems that if you try to obtain information in event handlers, they sometimes fail with strange exceptions (sometimes even fail with OK). The only way to handle this is to catch and ignore them, since not catching may crash the process.

We need to use Visual Studio to launch the project, which attaches Windows' native debugger. I think we are still having some issues related to memory and/or exceptions, but only the debugger will tell us.

@bdlukaa bdlukaa merged commit d5b2c3d into bdlukaa:master Nov 20, 2022
@bdlukaa bdlukaa mentioned this pull request Nov 20, 2022
3 tasks
@bdlukaa bdlukaa linked an issue Nov 20, 2022 that may be closed by this pull request
3 tasks
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

Successfully merging this pull request may close these issues.

Support playlists
2 participants