def get_time(self):
        if _debug:
            print 'SilentAudioPlayer.get_time()'
        self._thread.condition.acquire()

        packets = self._packets

        if self._playing:
            # Consume timestamps
            result = None
            offset = time.time() - self._timestamp_time
            while packets:
                packet = packets[0]
                if offset > packet.duration:
                    del packets[0]
                    self._timestamp_time += packet.duration
                    offset -= packet.duration
                    self._packets_duration -= packet.duration
                else:
                    packet.consume(offset)
                    self._packets_duration -= offset
                    self._timestamp_time += offset
                    result = packet.timestamp
                    break
        else:
            # Paused
            if packets:
                result = packets[0].timestamp
            else:
                result = None

        self._thread.condition.release()

        if _debug:
            print 'SilentAudioPlayer.get_time() -> ', result
        return result

    # Worker func that consumes audio data and dispatches events
dataset/ETHPy150Open ardekantur/pyglet/pyglet/media/drivers/silent.py/SilentAudioPlayerPacketConsumer.get_time/original