Make rc4 encryption/decryption more explicit.
[paraslash.git] / time.c
diff --git a/time.c b/time.c
index b7155cb0566dc9f04de83d4056338c199135da06..6e1d603d2751566f3afa55d518367e162ae1b06b 100644 (file)
--- a/time.c
+++ b/time.c
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2005-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2009 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -169,3 +169,23 @@ int tv_convex_combination(const long a, const struct timeval *tv1,
                        ret = -ret;
        return ret;
 }
                        ret = -ret;
        return ret;
 }
+
+/**
+ * Compute when to send a chunk of an audio file.
+ *
+ * \param chunk_num The number of the chunk.
+ * \param chunk_tv The duration of one chunk.
+ * \param stream_start When the first chunk was sent.
+ * \param result The time when to send chunk number \a chunk_num.
+ *
+ * This function computes stream_start + chunk_num * chunk_time.
+ */
+void compute_chunk_time(long unsigned chunk_num,
+               struct timeval *chunk_tv, struct timeval *stream_start,
+               struct timeval *result)
+{
+       struct timeval tmp;
+
+       tv_scale(chunk_num, chunk_tv, &tmp);
+       tv_add(&tmp, stream_start, result);
+}