[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdemultimedia/kscd
From: Shaheed Haque <srhaque () iee ! org>
Date: 2005-03-23 4:30:18
Message-ID: 20050323043018.04C073CC () office ! kde ! org
[Download RAW message or body]
CVS commit by shaheed:
1. Clear all state correctly on ejected disc. Allows clients to clear their
state as required.
2. Guard against some invalid array accesses on ejected discs.
M +22 -3 kcompactdisc.cpp 1.3
M +6 -1 kcompactdisc.h 1.2
--- kdemultimedia/kscd/kcompactdisc.cpp #1.2:1.3
@@ -84,8 +84,13 @@ extern "C"
#include <fixx11h.h>
+// Our internal definition of when we have no disc. Used to guard some
+// internal arrays.
+#define NO_DISC ((m_discId == missingDisc) && (m_previousDiscId == 0))
+
#define FRAMES_TO_MS(frames) \
((frames) * 1000 / 75)
const QString KCompactDisc::defaultDevice = DEFAULT_CD_DEVICE;
+const unsigned KCompactDisc::missingDisc = (unsigned)-1;
KCompactDisc::KCompactDisc() :
@@ -93,5 +98,5 @@ KCompactDisc::KCompactDisc() :
m_status(0),
m_previousStatus(123456),
- m_discId((unsigned)-1),
+ m_discId(missingDisc),
m_previousDiscId(0),
m_artist(""),
@@ -124,4 +129,6 @@ const QString &KCompactDisc::device() co
unsigned KCompactDisc::discLength() const
{
+ if (NO_DISC)
+ return 0;
return FRAMES_TO_MS(m_trackStartFrames[m_tracks - 1] - m_trackStartFrames[0]);
}
@@ -289,4 +296,6 @@ unsigned KCompactDisc::trackLength() con
unsigned KCompactDisc::trackLength(unsigned track) const
{
+ if (NO_DISC)
+ return 0;
return cd->trk[track - 1].length * 1000;
}
@@ -317,6 +326,16 @@ void KCompactDisc::timerExpired()
if (WM_CDS_NO_DISC(m_status))
{
- m_discId = (unsigned)-1;
+ if (m_previousStatus != m_status)
+ {
+ m_previousStatus = m_status;
+ m_discId = missingDisc;
m_previousDiscId = 0;
+ m_trackArtists.clear();
+ m_trackTitles.clear();
+ m_trackStartFrames.clear();
+ m_tracks = 0;
+ m_track = 0;
+ emit discChanged(m_discId);
+ }
}
else
--- kdemultimedia/kscd/kcompactdisc.h #1.1:1.2
@@ -97,5 +97,10 @@ public:
/**
- * Current disc, zero if no disc.
+ * The discId for a missing disc.
+ */
+ static const unsigned missingDisc;
+
+ /**
+ * Current disc, missingDisc if no disc.
*/
unsigned discId() const { return m_discId; }
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic