|
a/playlist/playlistohpl.cpp |
|
b/playlist/playlistohpl.cpp |
|
... |
|
... |
16 |
*/
|
16 |
*/
|
17 |
|
17 |
|
18 |
#include <QDebug>
|
18 |
#include <QDebug>
|
19 |
|
19 |
|
20 |
#include "playlistohpl.h"
|
20 |
#include "playlistohpl.h"
|
21 |
|
21 |
#include "upqo/ohtime_qo.h"
|
22 |
#include "libupnpp/log.hxx"
|
22 |
#include "libupnpp/log.hxx"
|
23 |
|
23 |
|
24 |
using namespace UPnPP;
|
24 |
using namespace UPnPP;
|
25 |
|
25 |
|
26 |
// We take ownership of the OHPlayer object
|
26 |
// We take ownership of the OHPlayer object
|
27 |
PlaylistOHPL::PlaylistOHPL(OHPlayer *ohpl, QObject * parent)
|
27 |
PlaylistOHPL::PlaylistOHPL(OHPlayer *ohpl, OHTimeQO *ohtm, QObject * parent)
|
28 |
: Playlist(parent), m_ohplo(ohpl), m_cursongsecs(0), m_lastsong(false),
|
28 |
: Playlist(parent), m_ohplo(ohpl), m_ohtmo(ohtm),
|
29 |
m_closetoend(false)
|
29 |
m_cursongsecs(0), m_lastsong(false), m_closetoend(false)
|
30 |
{
|
30 |
{
|
31 |
// Connections from OpenHome renderer to local playlist
|
31 |
// Connections from OpenHome renderer to local playlist
|
32 |
connect(m_ohplo, SIGNAL(metadataArrayChanged(const MetaDataList&)),
|
32 |
connect(m_ohplo, SIGNAL(metadataArrayChanged(const MetaDataList&)),
|
33 |
this, SLOT(onRemoteMetaArray(const MetaDataList&)));
|
33 |
this, SLOT(onRemoteMetaArray(const MetaDataList&)));
|
34 |
connect(m_ohplo, SIGNAL(currentTrackId(int)),
|
34 |
connect(m_ohplo, SIGNAL(currentTrackId(int)),
|
|
... |
|
... |
78 |
void PlaylistOHPL::psl_seek(int secs)
|
78 |
void PlaylistOHPL::psl_seek(int secs)
|
79 |
{
|
79 |
{
|
80 |
m_ohplo->seek(secs);
|
80 |
m_ohplo->seek(secs);
|
81 |
}
|
81 |
}
|
82 |
|
82 |
|
|
|
83 |
void PlaylistOHPL::maybeSetDuration(bool needsig)
|
|
|
84 |
{
|
|
|
85 |
if (m_play_idx< 0 || m_play_idx >= int(m_meta.size()) || !m_ohtmo) {
|
|
|
86 |
return;
|
|
|
87 |
}
|
|
|
88 |
MetaData& meta(m_meta[m_play_idx]);
|
|
|
89 |
if (meta.length_ms <= 0) {
|
|
|
90 |
UPnPClient::OHTime::Time tm;
|
|
|
91 |
if (m_ohtmo->time(tm)) {
|
|
|
92 |
meta.length_ms = tm.duration * 1000;
|
|
|
93 |
if (needsig) {
|
|
|
94 |
emit sig_track_metadata(meta);
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
}
|
|
|
98 |
// Set the songsec every time, it's cheap and it makes
|
|
|
99 |
// things work when the duration is not in the didl (else
|
|
|
100 |
// there are order of events issues which result in unset
|
|
|
101 |
// songsecs in ohpladapt
|
|
|
102 |
m_ohplo->setSongSecs(meta.length_ms / 1000);
|
|
|
103 |
}
|
|
|
104 |
|
83 |
void PlaylistOHPL::onRemoteCurrentTrackid(int id)
|
105 |
void PlaylistOHPL::onRemoteCurrentTrackid(int id)
|
84 |
{
|
106 |
{
|
85 |
qDebug() << "PlaylistOHPL::onRemoteCurrentTrackid: " << id;
|
107 |
qDebug() << "PlaylistOHPL::onRemoteCurrentTrackid: " << id;
|
86 |
|
108 |
|
87 |
if (id <= 0) {
|
109 |
if (id <= 0) {
|
|
... |
|
... |
96 |
if (m_play_idx == int(m_meta.size()) - 1) {
|
118 |
if (m_play_idx == int(m_meta.size()) - 1) {
|
97 |
m_lastsong = true;
|
119 |
m_lastsong = true;
|
98 |
}
|
120 |
}
|
99 |
//qDebug() << " new track index " << m_play_idx;
|
121 |
//qDebug() << " new track index " << m_play_idx;
|
100 |
}
|
122 |
}
|
|
|
123 |
maybeSetDuration(false);
|
|
|
124 |
|
101 |
// Emit the current index in any case to let the playlist
|
125 |
// Emit the current index in any case to let the playlist
|
102 |
// UI scroll to show the currently playing track (some
|
126 |
// UI scroll to show the currently playing track (some
|
103 |
// time after a user interaction scrolled it off)
|
127 |
// time after a user interaction scrolled it off)
|
104 |
emit sig_playing_track_changed(m_play_idx);
|
128 |
emit sig_playing_track_changed(m_play_idx);
|
105 |
// If the track id change was caused by the currently
|
129 |
// If the track id change was caused by the currently
|
|
... |
|
... |
110 |
m_cursongsecs = it->length_ms / 1000;
|
134 |
m_cursongsecs = it->length_ms / 1000;
|
111 |
return;
|
135 |
return;
|
112 |
}
|
136 |
}
|
113 |
}
|
137 |
}
|
114 |
resetPosState();
|
138 |
resetPosState();
|
115 |
LOGINF("PlaylistOHPL::onRemoteCurrentTrackid: track not found in array" << endl);
|
139 |
LOGINF("PlaylistOHPL::onRemoteCurrentTrackid: track not found in array\n");
|
116 |
}
|
140 |
}
|
117 |
|
141 |
|
118 |
void PlaylistOHPL::onRemoteSecsInSong_impl(quint32 secs)
|
142 |
void PlaylistOHPL::onRemoteSecsInSong_impl(quint32 secs)
|
119 |
{
|
143 |
{
|
120 |
if (m_lastsong && m_cursongsecs > 0 && int(secs) > int(m_cursongsecs) - 3) {
|
144 |
if (m_lastsong && m_cursongsecs > 0 && int(secs) > int(m_cursongsecs) - 3) {
|
121 |
//qDebug() << "PlaylistOHPL::onRemoteSecsInSong_impl: close to end";
|
145 |
//qDebug() << "PlaylistOHPL::onRemoteSecsInSong_impl: close to end";
|
122 |
m_closetoend = true;
|
146 |
m_closetoend = true;
|
123 |
}
|
147 |
}
|
|
|
148 |
maybeSetDuration(true);
|
124 |
}
|
149 |
}
|
125 |
|
150 |
|
126 |
void PlaylistOHPL::onRemoteTpState_impl(int, const char *sst)
|
151 |
void PlaylistOHPL::onRemoteTpState_impl(int, const char *)
|
127 |
{
|
152 |
{
|
128 |
Q_UNUSED(sst);
|
|
|
129 |
//qDebug() << "PlaylistOHPL::onRemoteTpState_impl: " << sst;
|
153 |
//qDebug() << "PlaylistOHPL::onRemoteTpState_impl: " << sst;
|
130 |
if (m_tpstate == AUDIO_STOPPED && m_closetoend == true) {
|
154 |
if (m_tpstate == AUDIO_STOPPED && m_closetoend == true) {
|
131 |
resetPosState();
|
155 |
resetPosState();
|
132 |
emit sig_playlist_done();
|
156 |
emit sig_playlist_done();
|
133 |
}
|
157 |
}
|