def set_sampling_rate(self, rate): if self.unit.get_property('streaming'): raise ValueError('Packet streaming already runs.') if rate not in self.get_sampling_rate_labels(): raise ValueError('Invalid argument for sampling rate') old_timeout = self.unit.fcp.get_property('timeout') # The unit tends to respond with larger interval from these requests. self.unit.fcp.set_property('timeout', 500) AvcConnection.set_plug_signal_format(self.unit.fcp, 'input', 0, rate) AvcConnection.set_plug_signal_format(self.unit.fcp, 'output', 0, rate) self.unit.fcp.set_property('timeout', old_timeout)
def set_sampling_rate(self, rate): if self.get_property('streaming'): raise OSError('Packet streaming starts') curr_rate = AvcConnection.get_plug_signal_format(self.fcp, 'input', 0) for mode, rates in self._RATE_MODES.items(): if curr_rate in rates: break else: raise OSError('Invalid state for sampling rate.') if rate not in rates: raise ValueError('Invalid argument for sampling rate.') AvcConnection.set_plug_signal_format(self.fcp, 'input', 0, rate) AvcConnection.set_plug_signal_format(self.fcp, 'output', 0, rate)
def set_stream_formats(self, playback, capture): if playback not in self.supported_stream_formats['playback']: raise ValueError('Invalid argument for playback stream format') if capture: if self._playback_only: raise ValueError('This unit is playback only') if capture not in self.supported_stream_formats['capture']: raise ValueError('Invalid argument for capture stream format') if playback['sampling-rate'] != capture['sampling-rate']: raise ValueError( 'Sampling rate mis-match between playback and capture') if self._assumed: rate = playback['sampling-rate'] AvcConnection.set_plug_signal_format(self.fcp, 'output', 0, rate) AvcConnection.set_plug_signal_format(self.fcp, 'input', 0, rate) else: AvcStreamFormatInfo.set_format(self.fcp, 'input', 0, playback) if not self._playback_only: AvcStreamFormatInfo.set_format(self.fcp, 'output', 0, capture)
def set_sampling_rate(self, rate): if rate not in self.__SUPPORTED_SAMPLING_RATES: raise ValueError('Invalid argument for sampling rate') AvcConnection.set_plug_signal_format(self.fcp, 'input', 0, rate) AvcConnection.set_plug_signal_format(self.fcp, 'output', 0, rate)