예제 #1
0
void SxPlaylist::reLoad() {
    Logger::printOut("reload play");
    if (m_isValid && !isFolder()) {
        m_thumb = NULL;
        //TODO fix a thumb, why is it never returning any images?
        byte image[20];
        if (sp_playlist_get_image(m_spPlaylist, image)) {
            m_thumb = ThumbStore::getInstance()->getThumb(image);
        }
        Logger::printOut("reload play 3");

        vector<SxTrack*> newTracks;
        for (int index = 0; index < sp_playlist_num_tracks(m_spPlaylist); index++) {
            sp_track* spTrack = sp_playlist_track(m_spPlaylist, index);
            if (!sp_track_get_availability(Session::getInstance()->getSpSession(), spTrack)) continue;
            SxTrack* track = TrackStore::getInstance()->getTrack(spTrack);
            if (track) {
                newTracks.push_back(track);
                //no thumb, lets pick one from the track list
                if (m_thumb == NULL)
                    if (track->getThumb() != NULL)
                        //no need to add ref to the thumb, when the track disappears the playlist will switch thumb
                        m_thumb = track->getThumb();
            }
        }

        removeAllTracks();

        Logger::printOut("reload play done");
        m_tracks = newTracks;
    }
    Utils::updatePlaylist(m_index);
}
예제 #2
0
/* This function configure the initial state of the player
 * MPD keep its own internal state, so we have to reset it
 */
void Player::configureInitial()
{
    stop();
    setRepeat(false);
    setRandom(false);
    removeAllTracks();
}
예제 #3
0
void TopLists::unloadLists() {
	m_albumsLoaded = false;
	m_artistsLoaded = false;
	m_tracksLoaded = false;

	removeAllTracks();
	removeAllAlbums();
	removeAllArtists();
}
예제 #4
0
SxPlaylist::~SxPlaylist() {
    sp_playlist_remove_callbacks(m_spPlaylist, &m_plCallbacks, this);
    if (!isFolder()) {
        removeAllTracks();
    }
    //let it bleed a little, not sure if the reference actualy goes up or if it is linked to the container
    // if (m_isValid)
    //   sp_playlist_release(m_spPlaylist);
}
예제 #5
0
  Search::~Search() {
    //we need to wait for the results
    //m_cancelSearch = true;
    //while (m_currentSearch != NULL)
    //  ;
    Logger::printOut("cleaning after search");
    removeAllTracks();
    removeAllAlbums();
    removeAllArtists();
    Logger::printOut("cleaning after search done");

  }
예제 #6
0
	SxArtist::~SxArtist() {
		while (m_isLoadingDetails) {
			//Session::getInstance()->processEvents();
			Logger::printOut("waiting for artist to die");
		}

		removeAllTracks();
		removeAllAlbums();
		removeAllArtists();

		if (m_thumb)
			ThumbStore::getInstance()->removeThumb(m_thumb);
		delete m_uri;
		if (hasDetails() && m_browse != NULL)
            m_dll->sp_artistbrowse_release(m_browse);
        m_dll->sp_artist_release(m_spArtist);
        delete m_dll;
	}
예제 #7
0
/* This function update the internal status tracking
 * the MPD status. At then end, if the status has changed, a signal is emmited.
 */
void Player::updateStatus()
{
    struct mpd_status *statusMpd;
    EMSPlayerStatus statusEMS;

    /* Get the status structure from MPD */
    mpd_send_status(conn);
    statusMpd = mpd_recv_status(conn);
    if (statusMpd == NULL)
    {
        qCritical() << "Error while trying to get MPD status";
        qCritical() << "Reconnecting...";
        connectToMpd(); /* Reconnect */
        return;
    }

    if (mpd_status_get_error(statusMpd) != NULL)
    {
        qCritical() << "MPD error: " << QString::fromUtf8(mpd_status_get_error(statusMpd));
    }

    if (!mpd_response_finish(conn))
    {
        qCritical() << "Error while trying to get MPD status" ;
        qCritical() << "Reconnecting...";
        connectToMpd();
        return;
    }

    /* Fill the internal state from the answer */
    switch (mpd_status_get_state(statusMpd))
    {
        case MPD_STATE_PAUSE:
            statusEMS.state = STATUS_PAUSE;
            break;
        case MPD_STATE_PLAY:
            statusEMS.state = STATUS_PLAY;
            break;
        case MPD_STATE_STOP:
            statusEMS.state = STATUS_STOP;
            break;
        default:
            statusEMS.state = STATUS_UNKNOWN;
            break;
    }

    statusEMS.repeat = mpd_status_get_repeat(statusMpd);
    statusEMS.random = mpd_status_get_random(statusMpd);

    if (statusEMS.state == STATUS_PLAY || statusEMS.state == STATUS_PAUSE)
    {
        if (mpd_status_get_queue_length(statusMpd) != (unsigned int)playlist.tracks.size())
        {
            qCritical() << "Error: the playlist does not have the same size as the one used by MPD!";
            /* We should not do this... */
            removeAllTracks();
        }

        statusEMS.posInPlaylist = mpd_status_get_song_pos(statusMpd);
        statusEMS.progress = mpd_status_get_elapsed_time(statusMpd);
    }

    mpd_status_free(statusMpd);

    if (statusEMS.posInPlaylist != status.posInPlaylist ||
        statusEMS.progress != status.progress ||
        statusEMS.random != status.random ||
        statusEMS.repeat != status.repeat ||
        statusEMS.state != status.state )
    {
        mutex.lock();
        status = statusEMS;
        mutex.unlock();
        emit statusChanged(statusEMS);
    }
}
예제 #8
0
 SxRadio::~SxRadio() {
   removeAllTracks();
 }