diff options
author | Lennart Poettering <lennart@poettering.net> | 2006-05-21 14:06:33 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2006-05-21 14:06:33 +0000 |
commit | 651e575575c307be75e050ed9600d35a43b7819c (patch) | |
tree | fafba5d92d99732b335204c42424433f294aede8 | |
parent | bc87137a8f26152a0589e94e0bc8ffc936566ed6 (diff) |
add new function pa_usec_to_bytes() as inverse of pa_bytes_to_usec()
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@942 fefdeb5f-60dc-0310-8127-8f9354f1896f
-rw-r--r-- | src/polyp/sample.c | 6 | ||||
-rw-r--r-- | src/polyp/sample.h | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/polyp/sample.c b/src/polyp/sample.c index 668a485ed..320e31a05 100644 --- a/src/polyp/sample.c +++ b/src/polyp/sample.c @@ -66,6 +66,12 @@ pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec) { return (pa_usec_t) (((double) length/pa_frame_size(spec)*1000000)/spec->rate); } +size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec) { + assert(spec); + + return ((double) t * spec->rate / 1000000)*pa_frame_size(spec); +} + int pa_sample_spec_valid(const pa_sample_spec *spec) { assert(spec); diff --git a/src/polyp/sample.h b/src/polyp/sample.h index 09b12fd79..2a9a72fef 100644 --- a/src/polyp/sample.h +++ b/src/polyp/sample.h @@ -160,6 +160,9 @@ size_t pa_sample_size(const pa_sample_spec *spec); /** Calculate the time the specified bytes take to play with the specified sample type */ pa_usec_t pa_bytes_to_usec(uint64_t length, const pa_sample_spec *spec); +/** Calculates the number of bytes that are required for the specified time. \since 0.9 */ +size_t pa_usec_to_bytes(pa_usec_t t, const pa_sample_spec *spec); + /** Return non-zero when the sample type specification is valid */ int pa_sample_spec_valid(const pa_sample_spec *spec); |