diff --git a/livesupport/modules/core/src/Playlist.cxx b/livesupport/modules/core/src/Playlist.cxx index 9fc0bbed1..f94b97c7d 100644 --- a/livesupport/modules/core/src/Playlist.cxx +++ b/livesupport/modules/core/src/Playlist.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.30 $ + Version : $Revision: 1.31 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $ ------------------------------------------------------------------------------*/ @@ -497,33 +497,35 @@ Playlist::removePlaylistElement(Ptr::Ref playlistElementId) bool Playlist::valid(void) throw () { - Ptr::Ref runningTime(new time_duration(0,0,0,0)); - Ptr::Ref playlistElement; - Ptr::Ref audioClip; - Ptr::Ref playlist; + time_duration runningTime(0,0,0,0); PlaylistElementListType::const_iterator it = elementList->begin(); while (it != elementList->end()) { - playlistElement = it->second; - if (*runningTime != *(playlistElement->getRelativeOffset())) { + Ptr::Ref playlistElement = it->second; + + if (playlistElement->getType() == PlaylistElement::PlaylistType + && !playlistElement->getPlaylist()->valid()) { return false; } - if (playlistElement->getType() == PlaylistElement::AudioClipType) { - audioClip = playlistElement->getAudioClip(); - *runningTime += *(audioClip->getPlaylength()); - } else if (playlistElement->getType() - == PlaylistElement::PlaylistType) { - playlist = playlistElement->getPlaylist(); - if (!playlist->valid()) { - return false; - } - *runningTime += *(playlist->getPlaylength()); - } else { // this should never happen - return false; + + time_duration relativeOffset = *playlistElement->getRelativeOffset(); + if (runningTime < relativeOffset) { + return false; // found a gap in the playlist } + + time_duration endTime = + relativeOffset + + *playlistElement->getPlayable()->getPlaylength(); + if (endTime > runningTime) { + runningTime = endTime; + } + ++it; } - setPlaylength(runningTime); // fix playlength, if everything else is OK + + Ptr::Ref playlength(new time_duration()); + *playlength = runningTime; + setPlaylength(playlength); // fix playlength, if everything else is OK return true; }