[vlma-devel] commit: Correct isTimeToPlay in order to take the repetitions parameter into account . (Adrien Grand )
git version control
git at videolan.org
Tue Mar 3 04:45:27 CET 2009
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Tue Mar 3 04:42:12 2009 +0100| [b69eaccfa33bfc73734b1122f28d6ed3c3501556] | committer: Adrien Grand
Correct isTimeToPlay in order to take the repetitions parameter into account.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=b69eaccfa33bfc73734b1122f28d6ed3c3501556
---
.../main/java/org/videolan/vlma/model/Program.java | 41 ++++++++++---------
1 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/vlma-api/src/main/java/org/videolan/vlma/model/Program.java b/vlma-api/src/main/java/org/videolan/vlma/model/Program.java
index 0c09000..50cdbb2 100644
--- a/vlma-api/src/main/java/org/videolan/vlma/model/Program.java
+++ b/vlma-api/src/main/java/org/videolan/vlma/model/Program.java
@@ -65,17 +65,19 @@ public final class Program implements Serializable {
private InetAddress ip;
/**
- * Time interval in seconds between two executions of this program. A
- * number inferior or equals to 0 means not to wait between two executions
- * of the program.
+ * Time interval in milliseconds between two executions of this program.
+ * This number will be taken into account to know wether the program should
+ * be played only if <code>liveLength</code> is positive.
+ * This number should be positive.
*/
- private int liveInterval;
+ private long liveInterval;
/**
- * Length of the execution in seconds. A number inferior to 0 means
- * infinity.
+ * Length of the execution in milliseconds. A number inferior to 0 means
+ * infinity. 0 means that nothing will be broadcasted, whatever the other
+ * parameters are.
*/
- private int liveLength;
+ private long liveLength;
/**
* Number of repetitions of the program. A numer inferior to 0 means
@@ -121,7 +123,7 @@ public final class Program implements Serializable {
public Program() {
group = null;
name = "";
- setLiveInterval(-1);
+ setLiveInterval(0);
setLiveRepetitions(1);
setLiveLength(-1);
liveStart = new Date();
@@ -184,7 +186,7 @@ public final class Program implements Serializable {
*
* @return the repetition interval
*/
- public int getLiveInterval() {
+ public long getLiveInterval() {
return liveInterval;
}
@@ -193,7 +195,7 @@ public final class Program implements Serializable {
*
* @return the programmation length
*/
- public int getLiveLength() {
+ public long getLiveLength() {
return liveLength;
}
@@ -312,13 +314,14 @@ public final class Program implements Serializable {
*/
public boolean isTimeToPlay() {
long now = System.currentTimeMillis();
- long when = getLiveStart().getTime();
- if (getLiveInterval() > 0) {
- return (now >= when)
- && ((now - when) % getLiveInterval() < getLiveLength());
- } else {
- return (now >= when);
- }
+ long startTime = getLiveStart().getTime();
+
+ return (startTime - now >= 0) &&
+ (liveLength < 0 || now - startTime <= liveLength ||
+ (liveLength > 0 && liveInterval > 0 &&
+ (now - startTime) % liveInterval <= liveLength &&
+ (liveRepetitions < 0 || (liveRepetitions > 0 &&
+ (now - startTime) / liveInterval <= liveRepetitions))));
}
/**
@@ -355,7 +358,7 @@ public final class Program implements Serializable {
* @param liveInterval
* the repetition interval
*/
- public void setLiveInterval(int liveInterval) {
+ public void setLiveInterval(long liveInterval) {
this.liveInterval = liveInterval;
}
@@ -365,7 +368,7 @@ public final class Program implements Serializable {
* @param liveLength
* the programmation length
*/
- public void setLiveLength(int liveLength) {
+ public void setLiveLength(long liveLength) {
this.liveLength = liveLength;
}
More information about the vlma-devel
mailing list