def get_stream_formats(self): fmts = {} addr = BcoPlugInfo.get_unit_addr('output', 'isoc', 0) fmts['capture'] = BcoStreamFormatInfo.get_entry_list(self.fcp, addr) addr = BcoPlugInfo.get_unit_addr('input', 'isoc', 0) fmts['playback'] = BcoStreamFormatInfo.get_entry_list(self.fcp, addr) return fmts
def _parse_subunit_plug(self, dir, type, id, num): plug = {} addr = BcoPlugInfo.get_subunit_addr(dir, type, id, num) plug['type'] = BcoPlugInfo.get_plug_type(self.fcp, addr) plug['name'] = BcoPlugInfo.get_plug_name(self.fcp, addr) plug['channels'] = [] channels = BcoPlugInfo.get_plug_channels(self.fcp, addr) for channel in range(channels): ch = BcoPlugInfo.get_plug_ch_name(self.fcp, addr, channel + 1) plug['channels'].append(ch) plug['clusters'] = [] if plug['type'] == 'IsoStream': clusters = BcoPlugInfo.get_plug_clusters(self.fcp, addr) for cluster in range(len(clusters)): clst = BcoPlugInfo.get_plug_cluster_info( self.fcp, addr, cluster + 1) plug['clusters'].append(clst) plug['input'] = {} plug['outputs'] = [] # Music subunits have counter direction. try: plug['input'] = BcoPlugInfo.get_plug_input(self.fcp, addr) except: pass try: plug['outputs'] = BcoPlugInfo.get_plug_outputs(self.fcp, addr) except: pass return plug
def parse_fb_plug(cls, fcp, dir, subunit_type, subunit_id, fb_type, fb_id, num): plug = {} addr = BcoPlugInfo.get_function_block_addr(dir, subunit_type, subunit_id, fb_type, fb_id, num) plug['type'] = BcoPlugInfo.get_plug_type(fcp, addr) plug['name'] = BcoPlugInfo.get_plug_name(fcp, addr) plug['channels'] = [] channels = BcoPlugInfo.get_plug_channels(fcp, addr) for channel in range(channels): ch = BcoPlugInfo.get_plug_ch_name(fcp, addr, channel + 1) plug['channels'].append(ch) plug['clusters'] = [] if plug['type'] == 'IsoStream': clusters = BcoPlugInfo.get_plug_clusters(fcp, addr) for cluster in range(len(clusters)): clst = BcoPlugInfo.get_plug_cluster_info( fcp, addr, cluster + 1) plug['clusters'].append(clst) plug['input'] = {} plug['outputs'] = [] # Music subunits have counter direction. try: plug['input'] = BcoPlugInfo.get_plug_input(fcp, addr) except Exception: pass try: plug['outputs'] = BcoPlugInfo.get_plug_outputs(fcp, addr) except Exception: pass return plug
def __get_clock_plugs(self): plugs = {} info = AvcConnection.get_subunit_plug_info(self.fcp, 'music', 0) for direction in ('input', 'output'): for i in range(info[direction]): addr = BcoPlugInfo.get_subunit_addr(direction, 'music', 0, i) plug_type = BcoPlugInfo.get_plug_type(self.fcp, addr) if plug_type == 'Sync': plugs[direction] = \ AvcCcm.get_subunit_signal_addr('music', 0, i) break else: raise OSError('Unexpected state of device for clock source.') return plugs
def get_plug_spec(cls, fcp, info): data = info['data'] if info['mode'] == 'unit': addr = BcoPlugInfo.get_unit_addr(info['dir'], data['unit-type'], data['plug']) elif info['mode'] == 'subunit': addr = BcoPlugInfo.get_subunit_addr(info['dir'], data['subunit-type'], data['subunit-id'], data['plug']) else: raise ValueError('Invalid mode of plug info.') spec = { 'name': BcoPlugInfo.get_plug_name(fcp, addr), 'type': BcoPlugInfo.get_plug_type(fcp, addr), } if info['dir'] == 'input': spec['input'] = BcoPlugInfo.get_plug_input(fcp, addr), else: spec['outputs'] = BcoPlugInfo.get_plug_outputs(fcp, addr), return spec if info['mode'] == 'unit': spec['clusters'] = [] clusters = BcoPlugInfo.get_plug_clusters(fcp, addr) for i, cluster in enumerate(clusters): mapping = [] name = BcoPlugInfo.get_plug_cluster_info(fcp, addr, i + 1) for info in cluster: idx, pos = info ch_name = BcoPlugInfo.get_plug_ch_name(fcp, addr, idx) mapping.append(ch_name) entry = { 'name': name, 'channels': mapping, } spec['clusters'].append(entry) return spec
def parse_stream_formats(cls, fcp, unit_plugs): formats = {} for type, dir_plugs in unit_plugs.items(): if type == 'async': continue formats[type] = {} for dir, plugs in dir_plugs.items(): formats[type][dir] = {} for i, plug in plugs.items(): addr = BcoPlugInfo.get_unit_addr(dir, type, i) try: fmts = BcoStreamFormatInfo.get_entry_list(fcp, addr) formats[type][dir][i] = fmts except Exception: continue return formats
def _parse_stream_formats(self): hoge = {} for type, dir_plugs in self.unit_plugs.items(): if type == 'async': continue hoge[type] = {} for dir, plugs in dir_plugs.items(): hoge[type][dir] = {} for i, plug in plugs.items(): addr = BcoPlugInfo.get_unit_addr(dir, type, i) try: fmts = BcoStreamFormatInfo.get_entry_list( self.fcp, addr) hoge[type][dir][i] = fmts except: continue return hoge
def _parse_unit_plug(self, dir, type, num): plug = {} addr = BcoPlugInfo.get_unit_addr(dir, type, num) plug['type'] = BcoPlugInfo.get_plug_type(self.fcp, addr) plug['name'] = BcoPlugInfo.get_plug_name(self.fcp, addr) plug['channels'] = [] channels = BcoPlugInfo.get_plug_channels(self.fcp, addr) for channel in range(channels): ch = BcoPlugInfo.get_plug_ch_name(self.fcp, addr, channel + 1) plug['channels'].append(ch) plug['clusters'] = [] if plug['type'] is 'IsoStream': clusters = BcoPlugInfo.get_plug_clusters(self.fcp, addr) for cluster in range(len(clusters)): clst = BcoPlugInfo.get_plug_cluster_info( self.fcp, addr, cluster + 1) plug['clusters'].append(clst) plug['input'] = [] plug['outputs'] = [] if dir == 'output': plug['input'] = BcoPlugInfo.get_plug_input(self.fcp, addr) else: plug['outputs'] = BcoPlugInfo.get_plug_outputs(self.fcp, addr) return plug