Browse files

Revert "spotify: Remove gst import from spotify.playback module"

This reverts commit b4028e9.
  • Loading branch information...
1 parent b4028e9 commit ea431c2f184fa432ff03b1d77778eb3a21690df0 @jodal jodal committed Dec 27, 2012
Showing with 10 additions and 6 deletions.
  1. +6 −2 mopidy/backends/spotify/playback.py
  2. +4 −4 mopidy/backends/spotify/session_manager.py
View
8 mopidy/backends/spotify/playback.py
@@ -1,5 +1,9 @@
from __future__ import unicode_literals
+import pygst
+pygst.require('0.10')
+import gst
+
import logging
import functools
@@ -35,7 +39,7 @@ def play(self, track):
self.backend.spotify.session.load(
Link.from_string(track.uri).as_track())
self.backend.spotify.session.play(1)
- self.backend.spotify.buffer_timestamp_in_ms = 0
+ self.backend.spotify.buffer_timestamp = 0
self.audio.prepare_change()
self.audio.set_appsrc(
@@ -55,5 +59,5 @@ def stop(self):
def on_seek_data(self, time_position):
logger.debug('playback.on_seek_data(%d) called', time_position)
- self.backend.spotify.buffer_timestamp_in_ms = time_position
+ self.backend.spotify.buffer_timestamp = time_position * gst.MSECOND
self.backend.spotify.session.seek(time_position)
View
8 mopidy/backends/spotify/session_manager.py
@@ -46,7 +46,7 @@ def __init__(self, username, password, audio, backend_ref, proxy=None,
self.backend_ref = backend_ref
self.connected = threading.Event()
- self.buffer_timestamp_in_ms = 0
+ self.buffer_timestamp = 0
self.container_manager = None
self.playlist_manager = None
@@ -124,10 +124,10 @@ def music_delivery(self, session, frames, frame_size, num_frames,
buffer_ = gst.Buffer(bytes(frames))
buffer_.set_caps(gst.caps_from_string(capabilites))
- buffer_.timestamp = self.buffer_timestamp_in_ms * gst.MSECOND
- buffer_.duration = num_frames * gst.SECOND // sample_rate
+ buffer_.timestamp = self.buffer_timestamp
+ buffer_.duration = num_frames * gst.SECOND / sample_rate
- self.buffer_timestamp_in_ms += buffer_.duration // gst.MSECOND
+ self.buffer_timestamp += buffer_.duration
if self.audio.emit_data(buffer_).get():
return num_frames

0 comments on commit ea431c2

Please sign in to comment.