From 64ae7865bb52cf5737595652fd8bf2a7629cc8d8 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Thu, 3 Jan 2013 19:38:31 +0100 Subject: [PATCH] audio: Add clocktime_to_millisecond util function --- mopidy/audio/utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mopidy/audio/utils.py b/mopidy/audio/utils.py index 9d0f46dd..5bb3c4ca 100644 --- a/mopidy/audio/utils.py +++ b/mopidy/audio/utils.py @@ -6,7 +6,8 @@ import gst def calculate_duration(num_samples, sample_rate): - """Determine duration of samples using GStreamer helper for precise math.""" + """Determine duration of samples using GStreamer helper for precise + math.""" return gst.util_uint64_scale(num_samples, gst.SECOND, sample_rate) @@ -28,10 +29,15 @@ def create_buffer(data, capabilites=None, timestamp=None, duration=None): def millisecond_to_clocktime(value): - """Convert a millisecond time to internal gstreamer time.""" + """Convert a millisecond time to internal GStreamer time.""" return value * gst.MSECOND +def clocktime_to_millisecond(value): + """Convert a millisecond time to internal GStreamer time.""" + return value // gst.MSECOND + + def supported_uri_schemes(uri_schemes): """Determine which URIs we can actually support from provided whitelist.