[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.11-159-gbb8263b
Lennart Poettering
gitmailer-noreply at 0pointer.de
Thu Aug 28 08:53:19 PDT 2008
This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.
The master branch has been updated
from 3d07cc8112d693922b176c9dc6bf0fbc6b58a02c (commit)
- Log -----------------------------------------------------------------
bb8263b... add byte-to-usec and usec-to-byte converters that round up, not down
f79c665... document in which direction we round
-----------------------------------------------------------------------
Summary of changes:
src/pulse/sample.h | 8 ++++++--
src/pulsecore/sample-util.c | 33 +++++++++++++++++++++++++++++++++
src/pulsecore/sample-util.h | 3 +++
3 files changed, 42 insertions(+), 2 deletions(-)
-----------------------------------------------------------------------
commit f79c66581292fc76160e29c7e713354cb8037270
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Aug 28 17:52:08 2008 +0200
document in which direction we round
diff --git a/src/pulse/sample.h b/src/pulse/sample.h
index 2680cf7..7061272 100644
--- a/src/pulse/sample.h
+++ b/src/pulse/sample.h
@@ -183,10 +183,14 @@ size_t pa_frame_size(const pa_sample_spec *spec) PA_GCC_PURE;
/** Return the size of a sample with the specific sample type */
size_t pa_sample_size(const pa_sample_spec *spec) PA_GCC_PURE;
-/** Calculate the time the specified bytes take to play with the specified sample type */
+/** Calculate the time the specified bytes take to play with the
+ * specified sample type. The return value will always be rounded
+ * down for non-integral return values. */
pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) PA_GCC_PURE;
-/** Calculates the number of bytes that are required for the specified time. \since 0.9 */
+/** Calculates the number of bytes that are required for the specified
+ * time. The return value will always be rounded down for non-integral
+ * return values. \since 0.9 */
size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) PA_GCC_PURE;
/** Return non-zero when the sample type specification is valid */
commit bb8263be6fbbb227989e8cb4f5dc7dc67216724d
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Aug 28 17:53:01 2008 +0200
add byte-to-usec and usec-to-byte converters that round up, not down
diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index 4b2efe5..b4234af 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -31,6 +31,8 @@
#include <liboil/liboilfuncs.h>
#include <liboil/liboil.h>
+#include <pulse/timeval.h>
+
#include <pulsecore/log.h>
#include <pulsecore/macro.h>
#include <pulsecore/g711.h>
@@ -981,3 +983,34 @@ void pa_sample_clamp(pa_sample_format_t format, void *dst, size_t dstr, const vo
}
}
}
+
+/* Similar to pa_bytes_to_usec() but rounds up, not down */
+
+pa_usec_t pa_bytes_to_usec_round_up(uint64_t length, const pa_sample_spec *spec) {
+ size_t fs;
+ pa_usec_t usec;
+
+ pa_assert(spec);
+
+ fs = pa_frame_size(spec);
+ length = (length + fs - 1) / fs;
+
+ usec = (pa_usec_t) length * PA_USEC_PER_SEC;
+
+ return (usec + spec->rate - 1) / spec->rate;
+}
+
+/* Similar to pa_usec_to_bytes() but rounds up, not down */
+
+size_t pa_usec_to_bytes_round_up(pa_usec_t t, const pa_sample_spec *spec) {
+ uint64_t u;
+ pa_assert(spec);
+
+ u = (uint64_t) t * (uint64_t) spec->rate;
+
+ u = (u + PA_USEC_PER_SEC - 1) / PA_USEC_PER_SEC;
+
+ u *= pa_frame_size(spec);
+
+ return (size_t) u;
+}
diff --git a/src/pulsecore/sample-util.h b/src/pulsecore/sample-util.h
index cef7075..06ecb72 100644
--- a/src/pulsecore/sample-util.h
+++ b/src/pulsecore/sample-util.h
@@ -78,4 +78,7 @@ void pa_deinterleave(const void *src, void *dst[], unsigned channels, size_t ss,
void pa_sample_clamp(pa_sample_format_t format, void *dst, size_t dstr, const void *src, size_t sstr, unsigned n);
+pa_usec_t pa_bytes_to_usec_round_up(uint64_t length, const pa_sample_spec *spec);
+size_t pa_usec_to_bytes_round_up(pa_usec_t t, const pa_sample_spec *spec);
+
#endif
--
hooks/post-receive
PulseAudio Sound Server
More information about the pulseaudio-commits
mailing list