コード例 #1
0
ファイル: __init__.py プロジェクト: certik/sympy-oldcore
 def _set_start_time(self, source, timestamp):
     delay = asound.snd_pcm_sframes_t()
     check(asound.snd_pcm_delay(self._device.pcm, ctypes.byref(delay)))
     delay = (delay.value / 
              source.audio_format.bytes_per_sample /
              float(source.audio_format.bytes_per_second))
     self._start_time = self._get_asound_time() - timestamp - delay
コード例 #2
0
    def write(self, audio_data):
        samples = audio_data.length // self.audio_format.bytes_per_sample
        samples_out = asound.snd_pcm_writei(self.pcm, audio_data.data, samples)
        if samples_out < 0:
            if samples_out == -11:  # EAGAIN
                return
            elif samples_out == -32:  # EPIPE (xrun)
                check(asound.snd_pcm_prepare(self.pcm))
                return
            else:
                raise ALSAException(asound.snd_strerror(samples_out))

        delay = asound.snd_pcm_sframes_t()
        check(asound.snd_pcm_delay(self.pcm, delay))
        alsatime = self._get_asound_time() + \
            delay.value / float(self.audio_format.sample_rate)

        self._timestamps.append((alsatime, audio_data.timestamp))

        audio_data.consume(samples_out * self.audio_format.bytes_per_sample,
                           self.audio_format)
コード例 #3
0
ファイル: __init__.py プロジェクト: ematvey/NanoEngineer-1
    def write(self, audio_data):
        samples = audio_data.length // self.audio_format.bytes_per_sample
        samples_out = asound.snd_pcm_writei(self.pcm, audio_data.data,
                                            samples)
        if samples_out < 0:
            if samples_out == -11: # EAGAIN
                return
            elif samples_out == -32: # EPIPE (xrun)
                check(asound.snd_pcm_prepare(self.pcm))
                return
            else:
                raise ALSAException(asound.snd_strerror(samples_out))

        delay = asound.snd_pcm_sframes_t()
        check(asound.snd_pcm_delay(self.pcm, delay))
        alsatime = self._get_asound_time() + \
            delay.value / float(self.audio_format.sample_rate)

        self._timestamps.append((alsatime, audio_data.timestamp))

        audio_data.consume(samples_out * self.audio_format.bytes_per_sample,
                           self.audio_format)