[polypaudio-commits] r942 - in /trunk/src/polyp: sample.c sample.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sun May 21 07:06:34 PDT 2006


Author: lennart
Date: Sun May 21 16:06:33 2006
New Revision: 942

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=942&root=polypaudio&view=rev
Log:
add new function pa_usec_to_bytes() as inverse of pa_bytes_to_usec()

Modified:
    trunk/src/polyp/sample.c
    trunk/src/polyp/sample.h

Modified: trunk/src/polyp/sample.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/sample.c?rev=942&root=polypaudio&r1=941&r2=942&view=diff
==============================================================================
--- trunk/src/polyp/sample.c (original)
+++ trunk/src/polyp/sample.c Sun May 21 16:06:33 2006
@@ -64,6 +64,12 @@
     assert(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) {

Modified: trunk/src/polyp/sample.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/polyp/sample.h?rev=942&root=polypaudio&r1=941&r2=942&view=diff
==============================================================================
--- trunk/src/polyp/sample.h (original)
+++ trunk/src/polyp/sample.h Sun May 21 16:06:33 2006
@@ -160,6 +160,9 @@
 /** 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);
 




More information about the pulseaudio-commits mailing list