diff options
author | phintuka <phintuka> | 2008-02-19 04:24:34 +0000 |
---|---|---|
committer | phintuka <phintuka> | 2008-02-19 04:24:34 +0000 |
commit | 3f055412f82e92e650f7a5f507f6f931a7c18476 (patch) | |
tree | 206a46c10390592137d29d646aa6f092df8c05c4 | |
parent | 08200321121b7aa1ba4cd832517da23d7db12099 (diff) | |
download | xineliboutput-3f055412f82e92e650f7a5f507f6f931a7c18476.tar.gz xineliboutput-3f055412f82e92e650f7a5f507f6f931a7c18476.tar.bz2 |
Fix cID3Scanner <-> cPlaylist synchronication:
- playlist iterator is invalid after playlist modification
- scanner might skip files that are added during scan
-rw-r--r-- | tools/playlist.c | 19 | ||||
-rw-r--r-- | tools/playlist.h | 3 |
2 files changed, 18 insertions, 4 deletions
diff --git a/tools/playlist.c b/tools/playlist.c index 05e80fcb..9500b286 100644 --- a/tools/playlist.c +++ b/tools/playlist.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: playlist.c,v 1.14 2008-02-19 04:15:37 phintuka Exp $ + * $Id: playlist.c,v 1.15 2008-02-19 04:24:34 phintuka Exp $ * */ @@ -130,11 +130,21 @@ class cID3Scanner : public cThread virtual void Action(void) { cPlaylistItem *Item = NULL; + unsigned int Version = 0; (void)nice(10); LOGDBG("ID3Scanner Started"); while(Running()) { + + cMutexLock ml(&m_List.m_Lock); + + if(Version < m_List.m_Version) { + // restart after sort, add, del + Item = NULL; + Version = m_List.m_Version; + } + if(!(Item = m_List.Next(Item))) break; @@ -161,7 +171,6 @@ class cID3Scanner : public cThread cPipe p; if(p.Open(*Cmd, "r")) { - cMutexLock ml(&m_List.m_Lock); cReadLine r; char *pt; while(NULL != (pt = r.Read(p))) { @@ -333,6 +342,7 @@ cPlaylist::cPlaylist() m_Menu = NULL; m_Scanner = NULL; m_Current = NULL; + m_Version = 1; } cPlaylist::~cPlaylist() @@ -365,6 +375,7 @@ void cPlaylist::Sort(void) { cMutexLock ml(&m_Lock); cListBase::Sort(); + m_Version++; } int cPlaylist::Count(void) const @@ -396,6 +407,7 @@ void cPlaylist::Del(cPlaylistItem *it) cList<cPlaylistItem>::Prev(Current()); cListBase::Del(it); + m_Version++; } void cPlaylist::SetCurrent(cPlaylistItem *current) @@ -861,7 +873,8 @@ bool cPlaylist::Read(const char *PlaylistFile, bool Recursive) LOGMSG("Empty playlist %s !", PlaylistFile); Add(new cPlaylistItem(PlaylistFile)); } - + + m_Version++; return Result; } diff --git a/tools/playlist.h b/tools/playlist.h index 4f36b415..50c3d97a 100644 --- a/tools/playlist.h +++ b/tools/playlist.h @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: playlist.h,v 1.7 2008-01-10 23:37:36 phelin Exp $ + * $Id: playlist.h,v 1.8 2008-02-19 04:24:34 phintuka Exp $ * */ @@ -74,6 +74,7 @@ class cPlaylist : protected cList<cPlaylistItem> cString m_Name; // playlist (or folder) name cString m_Folder; // path to "root" of playlist cPlaylistItem *m_Current; // now playing + unsigned int m_Version; enum { ePlaylist, eImplicit } m_Origin; |