Beispiel #1
0
 def _parse_supported_sampling_rates(self):
     sampling_rates = {}
     playback = []
     capture  = []
     # Assume that PCM playback is available for all of models.
     for rate in AvcConnection.sampling_rates:
         if AvcConnection.ask_plug_signal_format(self.fcp, 'input', 0, rate):
             playback.append(rate)
     # PCM capture is not always available depending on models.
     for rate in AvcConnection.sampling_rates:
         if AvcConnection.ask_plug_signal_format(self.fcp, 'output', 0,rate):
             capture.append(rate)
     self._playback_only = (len(capture) == 0)
     for rate in AvcConnection.sampling_rates:
         if rate in playback or rate in capture:
             sampling_rates[rate] = True
     return sampling_rates
Beispiel #2
0
 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)
Beispiel #3
0
 def _parse_unit_plugs(self, fcp):
     unit_plugs = {}
     info = AvcConnection.get_unit_plug_info(fcp)
     for type, params in info.items():
         if type not in unit_plugs:
             unit_plugs[type] = {}
         for dir, num in params.items():
             if dir not in unit_plugs[type]:
                 unit_plugs[type][dir] = []
             for i in range(num):
                 plug = self._parse_unit_plug(fcp, dir, type, i)
                 unit_plugs[type][dir].append(plug)
     return unit_plugs
Beispiel #4
0
 def _parse_unit_plugs(self, fcp):
     unit_plugs = {}
     info = AvcConnection.get_unit_plug_info(fcp)
     for type, params in info.items():
         if type not in unit_plugs:
             unit_plugs[type] = {}
         for dir, num in params.items():
             if dir not in unit_plugs[type]:
                 unit_plugs[type][dir] = []
             for i in range(num):
                 plug = self._parse_unit_plug(fcp, dir, type, i)
                 unit_plugs[type][dir].append(plug)
     return unit_plugs
Beispiel #5
0
 def _parse_unit_plugs(self):
     unit_plugs = {}
     info = AvcConnection.get_unit_plug_info(self.fcp)
     for type, params in info.items():
         if type not in unit_plugs:
             unit_plugs[type] = {}
             unit_plugs[type]['output'] = {}
             unit_plugs[type]['input'] = {}
         for dir, num in params.items():
             for i in range(num + 1):
                 try:
                     plug = self._parse_unit_plug(dir, type, i)
                     unit_plugs[type][dir][i] = plug
                 except:
                     continue
     return unit_plugs
Beispiel #6
0
 def _parse_subunit_plugs(self):
     subunit_plugs = {}
     subunits = BcoSubunitInfo.get_subunits(self.fcp)
     for subunit in subunits:
         type = subunit['type']
         id = subunit['id']
         if subunit['id'] != 0:
             raise RuntimeError('Unsupported number for subunit id')
         if type not in subunit_plugs:
             subunit_plugs[type] = {}
             subunit_plugs[type]['output'] = {}
             subunit_plugs[type]['input'] = {}
         info = AvcConnection.get_subunit_plug_info(self.fcp, type, 0)
         for dir, num in info.items():
             for i in range(num):
                 plug = self._parse_subunit_plug(dir, type, 0, i)
                 subunit_plugs[type][dir][i] = plug
     return subunit_plugs
Beispiel #7
0
 def _parse_subunit_plugs(self, fcp):
     subunit_plugs = {}
     subunits = BcoSubunitInfo.get_subunits(fcp)
     for subunit in subunits:
         type = subunit['type']
         id = subunit['id']
         if subunit['id'] != 0:
             raise RuntimeError('Unsupported number for subunit id')
         if type not in subunit_plugs:
             subunit_plugs[type] = {}
             subunit_plugs[type]['input'] = []
             subunit_plugs[type]['output'] = []
         info = AvcConnection.get_subunit_plug_info(fcp, type, 0)
         for dir, num in info.items():
             for i in range(num):
                 plug = self._parse_subunit_plug(fcp, dir, type, 0, i)
                 subunit_plugs[type][dir].append(plug)
     return subunit_plugs
 def get_sampling_rate(self):
     return AvcConnection.get_plug_signal_format(self.fcp, "output", 0)
 def set_sampling_rate(self, rate):
     AvcConnection.set_plug_signal_format(self.fcp, "input", 0, rate)
     AvcConnection.set_plug_signal_format(self.fcp, "output", 0, rate)