예제 #1
0
    def pump(self):
        # Release spent buffers
        processed = al.ALint()
        al.alGetSourcei(self._al_source, al.AL_BUFFERS_PROCESSED, processed)
        processed = processed.value
        if processed:
            buffers = (al.ALuint * processed)()
            al.alSourceUnqueueBuffers(self._al_source, len(buffers), buffers)
            al.alDeleteBuffers(len(buffers), buffers)

        # Pop timestamps and check for eos markers
        try:
            while processed:
                if not _have_1_1:
                    self._timestamp_system_time = time.time()
                _, duration = self._timestamps.pop(0)
                self._buffered_time -= duration
                while self._timestamps[0][0] is None:
                    self._eos_count += 1
                    self._timestamps.pop(0)
                processed -= 1
        except IndexError:
            pass

        if _have_1_1:
            samples = al.ALint()
            al.alGetSourcei(self._al_source, al.AL_SAMPLE_OFFSET, samples)
            self._current_buffer_time = samples.value / float(self.audio_format.sample_rate)
        else:
            # Interpolate system time past buffer timestamp
            self._current_buffer_time = time.time() - self._timestamp_system_time

        # Begin playing if underrun previously
        if self._playing:
            self._al_play()
예제 #2
0
    def clear(self):
        al.alSourceStop(self._al_source)
        self._playing = False

        processed = al.ALint()
        al.alGetSourcei(self._al_source, al.AL_BUFFERS_PROCESSED, processed)
        if processed.value:
            buffers = (al.ALuint * processed.value)()
            al.alSourceUnqueueBuffers(self._al_source, len(buffers), buffers)
            al.alDeleteBuffers(len(buffers), buffers)

        self._pause_timestamp = 0.0
        self._buffered_time = 0.0
        self._timestamps = []
예제 #3
0
    def clear(self):
        al.alSourceStop(self._al_source)
        self._playing = False

        processed = al.ALint()
        al.alGetSourcei(self._al_source, al.AL_BUFFERS_PROCESSED, processed)
        if processed.value:
            buffers = (al.ALuint * processed.value)()
            al.alSourceUnqueueBuffers(self._al_source, len(buffers), buffers)
            al.alDeleteBuffers(len(buffers), buffers)

        self._pause_timestamp = 0.0
        self._buffered_time = 0.0
        self._timestamps = []
예제 #4
0
    def pump(self):

        # Release spent buffers
        processed = al.ALint()
        al.alGetSourcei(self._al_source, al.AL_BUFFERS_PROCESSED, processed)
        processed = processed.value
        if processed:
            buffers = (al.ALuint * processed)()
            al.alSourceUnqueueBuffers(self._al_source, len(buffers), buffers)
            al.alDeleteBuffers(len(buffers), buffers)

        # Pop timestamps and check for eos markers
        try:
            while processed:
                if not _have_1_1:
                    self._timestamp_system_time = time.time()
                _, duration = self._timestamps.pop(0)
                self._buffered_time -= duration
                while self._timestamps[0][0] is None:
                    self._eos_count += 1
                    self._timestamps.pop(0)
                processed -= 1
        except IndexError:
            pass

        if _have_1_1:
            samples = al.ALint()
            al.alGetSourcei(self._al_source, al.AL_SAMPLE_OFFSET, samples)
            self._current_buffer_time = samples.value / \
                float(self.audio_format.sample_rate)
        else:
            # Interpolate system time past buffer timestamp
            self._current_buffer_time = time.time() - \
                self._timestamp_system_time

        # Check for underrun
        if self._playing:
            state = al.ALint()
            al.alGetSourcei(self._al_source, al.AL_SOURCE_STATE, state)
            if state.value != al.AL_PLAYING:
                al.alSourcePlay(self._al_source)
                return True  # underrun notification
예제 #5
0
파일: OpenAL_HRTF.py 프로젝트: shaix/PyAL
 def delete(self):
     al.alDeleteBuffers(1, self.buf)
예제 #6
0
파일: OpenAL.py 프로젝트: anden3/Python
 def delete(self):
     al.alDeleteBuffers(1, self.buffer)
예제 #7
0
 def __del__(self, al=al):
     if al and al.ALuint and al.alDeleteBuffers:
         buffers = (al.ALuint * len(self))(*self)
         al.alDeleteBuffers(len(self), buffers)