Skip to content
This repository was archived by the owner on Jan 10, 2021. It is now read-only.
This repository was archived by the owner on Jan 10, 2021. It is now read-only.

Improve management of PlaylistContainer #53

@ChrisBrandhorst

Description

@ChrisBrandhorst

At the moment, a couple of things go wrong concerning the PlaylistContainer:

  • If PlaylistContainer ^Session::PlaylistContainer::get() is called when the Session has not logged in yet, an AccesViolationException occurs in the constructor of PlaylistContainer, since the supplied pointer (gotten through sp_session_playlistcontainer) is not valid;
  • If the Session is logged out, and then back in, the PlaylistContainer remains empty, and the count always gives -1. This is because the PlaylistContainer apparently is scoped within a Session login timespan (see https://developer.spotify.com/docs/libspotify/12.1.51/group__session.html#ga319767f0b795f1c46a08390b587c5671)

All in all, we need to relate the creation of the PlaylistContainer to the login/logout process of the Session.

A quick fix is nulling the _pc pointer in Session on logout, but this has two disadvantages:

  • The PlaylistContainers that were instantiated earlier on are still references somewhere and not GC-ed: they still receive some events from libspotify;
  • The client may have references to the 'first' PlaylistContainer. With this fix, this reference silently becomes useless (since it then points to a PlaylistContainer with count -1).

I think the best option is creating the PlaylistContainer just once, but re-linking it to libspotify on Session login/logout, using the appropriate libspotify methods (sp_session_playlistcontainer, sp_playlistcontainer_add_ref, sp_playlistcontainer_add_callbacks, sp_playlistcontainer_remove_callbacks, sp_playlistcontainer_release).

Also, we need to manage the PlaylistContainer when not logged in. I think, with the approach described above, the best option is to be able to retrieve it and throw an Exception if something is done which requires the Session to be logged in.

Your ideas?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions