Stefan Schuermans commited on 2014-03-18 22:40:59
Showing 2 changed files, with 27 additions and 37 deletions.
... | ... |
@@ -39,6 +39,7 @@ Player::Player(const std::string &name, Mgrs &mgrs, |
39 | 39 |
m_fileInSync(dirBase.getFile("insync"), mgrs.m_syncMgr), |
40 | 40 |
m_playlistTracker(*this, dirBase.getSubdir("playlist")), |
41 | 41 |
m_curValid(false), |
42 |
+ m_unknownMovie(false), |
|
42 | 43 |
m_curEntry(m_playlistTracker.m_list.begin()), |
43 | 44 |
m_curFrame(0), |
44 | 45 |
m_curFrameStart(0), |
... | ... |
@@ -117,7 +118,7 @@ void Player::setFrame(const std::string &stream, stBlinkenFrame *pFrame) |
117 | 118 |
*/ |
118 | 119 |
void Player::sendInfo(const std::string &sync, Info &info) |
119 | 120 |
{ |
120 |
- bool change = false, seekPos = true; |
|
121 |
+ bool change = false; |
|
121 | 122 |
|
122 | 123 |
// halt player if pause flag is set |
123 | 124 |
if (info.pause) |
... | ... |
@@ -126,16 +127,13 @@ void Player::sendInfo(const std::string &sync, Info &info) |
126 | 127 |
// seek to other movie if not correct one |
127 | 128 |
if (m_curEntry == m_playlistTracker.m_list.end() || |
128 | 129 |
!checkName(m_curEntry->m_name, info.name)) { |
129 |
- // movie found -> change has been done |
|
130 |
- if (seekToMovie(info.name)) |
|
130 |
+ // movie found -> seek to it |
|
131 |
+ seekToMovie(info.name); |
|
131 | 132 |
change = true; |
132 |
- // movie not found -> do not seek to position (wrong movie anyway) |
|
133 |
- else |
|
134 |
- seekPos = false; |
|
135 | 133 |
} |
136 | 134 |
|
137 | 135 |
// seek to requested position in movie |
138 |
- if (m_curValid && seekPos) { |
|
136 |
+ if (m_curValid) { |
|
139 | 137 |
if (seekToPos(info.pos)) |
140 | 138 |
change = true; |
141 | 139 |
} |
... | ... |
@@ -243,11 +241,13 @@ void Player::procFrame() |
243 | 241 |
while (true) { |
244 | 242 |
// playlist finished -> re-start from beginning |
245 | 243 |
while (m_curEntry == m_playlistTracker.m_list.end()) { |
244 |
+ if (!m_unknownMovie) // do not go to first movie if "playing" unkn. movie |
|
246 | 245 |
m_curEntry = m_playlistTracker.m_list.begin(); |
247 | 246 |
m_curFrame = 0; |
248 | 247 |
m_curFrameStart = 0; |
249 | 248 |
m_curFrameEnd = 0; |
250 | 249 |
// detect empty playlist or playlist with only empty movies |
250 |
+ // also leave here in case of "playing" unknown movie |
|
251 | 251 |
if (wrapped) { |
252 | 252 |
m_curValid = false; |
253 | 253 |
break; |
... | ... |
@@ -301,9 +301,8 @@ void Player::sendFrame() |
301 | 301 |
/** |
302 | 302 |
* @brief seek to movie by name |
303 | 303 |
* @param[in] name name of movie to seek to (name cmp according to SyncRecv) |
304 |
- * @return true if movie was found and seeked to, false otherwise |
|
305 | 304 |
*/ |
306 |
-bool Player::seekToMovie(const std::string &name) |
|
305 |
+void Player::seekToMovie(const std::string &name) |
|
307 | 306 |
{ |
308 | 307 |
// find movie by name |
309 | 308 |
PlaylistIt it = m_playlistTracker.m_list.begin(); |
... | ... |
@@ -313,12 +312,17 @@ bool Player::seekToMovie(const std::string &name) |
313 | 312 |
++it; |
314 | 313 |
} |
315 | 314 |
|
316 |
- // movie not found -> give up, return error |
|
317 |
- if (it == m_playlistTracker.m_list.end()) |
|
318 |
- return false; |
|
315 |
+ // movie not found -> invalidate current movie, "play unkown movie" |
|
316 |
+ if (it == m_playlistTracker.m_list.end()) { |
|
317 |
+ m_curValid = false; |
|
318 |
+ m_unknownMovie = true; |
|
319 |
+ m_curEntry = m_playlistTracker.m_list.end(); |
|
320 |
+ return; |
|
321 |
+ } |
|
319 | 322 |
|
320 | 323 |
// seek to movie |
321 | 324 |
m_curValid = false; |
325 |
+ m_unknownMovie = false; |
|
322 | 326 |
m_curEntry = it; |
323 | 327 |
m_curFrame = 0; |
324 | 328 |
m_remainTime = Time::zero; |
... | ... |
@@ -333,8 +337,6 @@ bool Player::seekToMovie(const std::string &name) |
333 | 337 |
m_curFrameStart = Time::zero; |
334 | 338 |
m_curFrameEnd = m_remainTime; |
335 | 339 |
m_nextTime = Time::now() + m_remainTime; |
336 |
- |
|
337 |
- return true; |
|
338 | 340 |
} |
339 | 341 |
|
340 | 342 |
/** |
... | ... |
@@ -357,14 +359,14 @@ bool Player::seekToPos(const Time &tgtPos) |
357 | 359 |
// seek to earlier position in movie if needed |
358 | 360 |
if (pos > tgtPos + m_maxDeviation) { |
359 | 361 |
Time goback = pos - tgtPos; |
360 |
- if (seekBackwards(goback)) |
|
362 |
+ seekBackwards(goback); |
|
361 | 363 |
change = true; |
362 | 364 |
} // if (pos > tgtPos + m_maxDeviation) |
363 | 365 |
|
364 | 366 |
// seek to later position in movie if needed |
365 | 367 |
if (pos + m_maxDeviation < tgtPos) { |
366 | 368 |
Time go = tgtPos - pos; |
367 |
- if (seekForwards(go)) |
|
369 |
+ seekForwards(go); |
|
368 | 370 |
change = true; |
369 | 371 |
} // if (pos + m_maxDeviation < tgtPos) |
370 | 372 |
|
... | ... |
@@ -374,12 +376,9 @@ bool Player::seekToPos(const Time &tgtPos) |
374 | 376 |
/** |
375 | 377 |
* @brief seek backwards in current movie |
376 | 378 |
* @param[in] goback time to seek backwards in current movie |
377 |
- * @return true if movie position has been changed, false otherwise |
|
378 | 379 |
*/ |
379 |
-bool Player::seekBackwards(Time goback) |
|
380 |
+void Player::seekBackwards(Time goback) |
|
380 | 381 |
{ |
381 |
- bool change = false; |
|
382 |
- |
|
383 | 382 |
// time of current frame |
384 | 383 |
Time frame = m_curFrameEnd - m_curFrameStart; |
385 | 384 |
|
... | ... |
@@ -413,19 +412,14 @@ bool Player::seekBackwards(Time goback) |
413 | 412 |
shown = frame; |
414 | 413 |
|
415 | 414 |
} // while (goback > Time::zero) |
416 |
- |
|
417 |
- return change; |
|
418 | 415 |
} |
419 | 416 |
|
420 | 417 |
/** |
421 | 418 |
* @brief seek forwards in current movie |
422 | 419 |
* @param[in] go time to seek forwards in current movie |
423 |
- * @return true if movie position has been changed, false otherwise |
|
424 | 420 |
*/ |
425 |
-bool Player::seekForwards(Time go) |
|
421 |
+void Player::seekForwards(Time go) |
|
426 | 422 |
{ |
427 |
- bool change = false; |
|
428 |
- |
|
429 | 423 |
// frame count of current movie |
430 | 424 |
int frameCnt = BlinkenMovieGetFrameCnt(m_curEntry->m_pObj->m_pMovie); |
431 | 425 |
|
... | ... |
@@ -433,7 +427,6 @@ bool Player::seekForwards(Time go) |
433 | 427 |
Time frame = m_curFrameEnd - m_curFrameStart; |
434 | 428 |
|
435 | 429 |
while (go > Time::zero) { |
436 |
- change = true; |
|
437 | 430 |
|
438 | 431 |
// correct by just showing current frame some time shorter |
439 | 432 |
if (go <= m_remainTime) { |
... | ... |
@@ -446,10 +439,11 @@ bool Player::seekForwards(Time go) |
446 | 439 |
m_remainTime = Time::zero; |
447 | 440 |
|
448 | 441 |
// go to begin of next frame |
449 |
- if (m_curFrame >= frameCnt) |
|
450 |
- break; |
|
442 |
+ // end of movie -> // stay at last frame (go to begin of last frame) |
|
443 |
+ if (m_curFrame + 1 < frameCnt) { |
|
451 | 444 |
m_curFrame++; |
452 | 445 |
m_curFrameStart = m_curFrameEnd; |
446 |
+ } |
|
453 | 447 |
frame = Time::zero; |
454 | 448 |
stBlinkenFrame *pFrame = |
455 | 449 |
BlinkenMovieGetFrame(m_curEntry->m_pObj->m_pMovie, m_curFrame); |
... | ... |
@@ -459,8 +453,6 @@ bool Player::seekForwards(Time go) |
459 | 453 |
m_remainTime = frame; |
460 | 454 |
|
461 | 455 |
} // while (go > Time::zero) |
462 |
- |
|
463 |
- return change; |
|
464 | 456 |
} |
465 | 457 |
|
466 | 458 |
} // namespace Blinker |
... | ... |
@@ -99,9 +99,8 @@ protected: |
99 | 99 |
/** |
100 | 100 |
* @brief seek to movie by name |
101 | 101 |
* @param[in] name name of movie to seek to (name cmp according to SyncRecv) |
102 |
- * @return true if movie was found and seeked to, false otherwise |
|
103 | 102 |
*/ |
104 |
- bool seekToMovie(const std::string &name); |
|
103 |
+ void seekToMovie(const std::string &name); |
|
105 | 104 |
|
106 | 105 |
/** |
107 | 106 |
* @brief seek to position in current movie |
... | ... |
@@ -113,16 +112,14 @@ protected: |
113 | 112 |
/** |
114 | 113 |
* @brief seek backwards in current movie |
115 | 114 |
* @param[in] goback time to seek backwards in current movie |
116 |
- * @return true if movie position has been changed, false otherwise |
|
117 | 115 |
*/ |
118 |
- bool seekBackwards(Time goback); |
|
116 |
+ void seekBackwards(Time goback); |
|
119 | 117 |
|
120 | 118 |
/** |
121 | 119 |
* @brief seek forwards in current movie |
122 | 120 |
* @param[in] go time to seek forwards in current movie |
123 |
- * @return true if movie position has been changed, false otherwise |
|
124 | 121 |
*/ |
125 |
- bool seekForwards(Time go); |
|
122 |
+ void seekForwards(Time go); |
|
126 | 123 |
|
127 | 124 |
protected: |
128 | 125 |
OutStreamFile m_fileOutStream; ///< output stream name file |
... | ... |
@@ -131,6 +128,7 @@ protected: |
131 | 128 |
InSyncFile m_fileInSync; ///< input sync stream |
132 | 129 |
PlaylistTracker m_playlistTracker; ///< current playlist |
133 | 130 |
bool m_curValid; ///< if there is a current frame |
131 |
+ bool m_unknownMovie; ///< unknown movie is playing (via sync) |
|
134 | 132 |
PlaylistIt m_curEntry; ///< current playlist entry |
135 | 133 |
int m_curFrame; ///< current frame in movie |
136 | 134 |
Time m_curFrameStart; /**< start time of current frame |
137 | 135 |