Esempio n. 1
0
    def __init__(self, audio_format):
        super(OpenALAudioPlayer, self).__init__(audio_format)

        try:
            self._al_format = format_map[(audio_format.channels, audio_format.sample_size)]
        except KeyError:
            raise OpenALException("Unsupported audio format.")

        self._al_source = al.ALuint()
        al.alGenSources(1, self._al_source)

        # Seconds of audio currently queued not processed (estimate)
        self._buffered_time = 0.0

        # Seconds of audio into current (head) buffer
        self._current_buffer_time = 0.0

        # List of (timestamp, duration) corresponding to currently queued AL
        # buffers
        self._timestamps = []

        # OpenAL 1.0 timestamp interpolation
        self._timestamp_system_time = 0.0

        # Desired play state (True even if stopped due to underrun)
        self._playing = False

        # Timestamp when paused
        self._pause_timestamp = 0.0

        self._eos_count = 0
Esempio n. 2
0
    def __init__(self, audio_format):
        super(OpenALAudioPlayer, self).__init__(audio_format)

        try:
            self._al_format = format_map[(audio_format.channels,
                                          audio_format.sample_size)]
        except KeyError:
            raise OpenALException('Unsupported audio format.')

        self._al_source = al.ALuint()
        al.alGenSources(1, self._al_source)

        # Seconds of audio currently queued not processed (estimate)
        self._buffered_time = 0.0

        # Seconds of audio into current (head) buffer
        self._current_buffer_time = 0.0

        # List of (timestamp, duration) corresponding to currently queued AL
        # buffers
        self._timestamps = []

        # OpenAL 1.0 timestamp interpolation
        self._timestamp_system_time = 0.0

        # Desired play state (True even if stopped due to underrun)
        self._playing = False

        # Timestamp when paused
        self._pause_timestamp = 0.0

        self._eos_count = 0
Esempio n. 3
0
    def __init__(self):
        self.source = al.ALuint(0)
        al.alGenSources(1, self.source)

        al.alSourcef(self.source, al.AL_ROLLOFF_FACTOR, 0)
        al.alSourcei(self.source, al.AL_SOURCE_RELATIVE, 0)

        self.state = al.ALint(0)

        self._volume = 1.0
        self._pitch = 1.0
        self._position = [0, 0, 0]
        self._rolloff = 1.0
        self._loop = False
        self.queue = []
Esempio n. 4
0
    def __init__(self):
        self.source = al.ALuint(0)
        al.alGenSources(1, self.source)

        al.alSourcef(self.source, al.AL_ROLLOFF_FACTOR, 0)
        al.alSourcei(self.source, al.AL_SOURCE_RELATIVE, 0)

        self.state = al.ALint(0)

        self._volume = 1.0
        self._pitch = 1.0
        self._position = [0, 0, 0]
        self._rolloff = 1.0
        self._loop = False
        self.queue = []
Esempio n. 5
0
 def __init__(self):
     #load source player
     self.source = al.ALuint(0)
     al.alGenSources(1, self.source)
     #disable rolloff factor by default
     al.alSourcef(self.source, al.AL_ROLLOFF_FACTOR, 0)
     #disable source relative by default
     al.alSourcei(self.source, al.AL_SOURCE_RELATIVE, 0)
     #capture player state buffer
     self.state = al.ALint(0)
     #set internal variable tracking
     self._volume = 1.0
     self._pitch = 1.0
     self._position = [0, 0, 0]
     self._rolloff = 1.0
     self._loop = False
     self.queue = []
Esempio n. 6
0
 def __init__(self):
     # load source player
     self.source = al.ALuint(0)
     al.alGenSources(1, self.source)
     # disable rolloff factor by default
     al.alSourcef(self.source, al.AL_ROLLOFF_FACTOR, 0)
     # disable source relative by default
     al.alSourcei(self.source, al.AL_SOURCE_RELATIVE, 0)
     # capture player state buffer
     self.state = al.ALint(0)
     # set internal variable tracking
     self._volume = 1.0
     self._pitch = 1.0
     self._position = [0, 0, 0]
     self._rolloff = 1.0
     self._loop = True
     self.queue = []
Esempio n. 7
0
    def __init__(self):
        super(OpenALPlayer, self).__init__()

        self._al_source = al.ALuint()
        al.alGenSources(1, self._al_source)
        # OpenAL on Linux lacks the time functions, so this is a stab at
        # interpolating time between the known buffer timestamps.  When a
        # timestamp is read from the active buffer, the current system time is
        # stored in self._last_buffer_time, and the buffer that was used is
        # stored in self._last_buffer. 
        #
        # If the same buffer is in use the next time the time is requested,
        # the elapsed system time is added to the buffer timestamp.
        #
        # The (completely invalid) assumption is that the buffer is just
        # beginning when _last_buffer_time is stored.  This is more likely
        # than not, at least, if the buffers are long.  If the buffers are
        # short, hopefully not much interpolation will be needed and the
        # difference won't be noticeable.
        #
        # The alternative -- reusing the same timestamp without adding system
        # time -- results in slightly jumpy video due to lost frames.
        #
        # When OpenAL 1.1 is present (i.e., on OS X), we add the buffer's
        # timestamp to the retrieved sample offset within the current buffer.
        self._last_buffer = -1
        self._last_known_timestamp = 0
        self._last_known_system_time = 0

        self._sources = []

        # Index into self._sources that is currently the source of new audio
        # buffers
        self._source_read_index = 0

        # List of BufferInformation
        self._queued_buffers = []

        # If not playing, must be paused (irrespective of whether or not
        # sources are queued).
        self._playing = False

        # self._al_playing = (_al_source.state == AL_PLAYING)
        self._al_playing = False