Lines Matching refs:node

147     """Set the volume of the given output node.
149 @param node_id: the id of the output node to be set the volume.
191 @returns: A dict containing information of each node.
201 field is a list of selected node IDs returned from Cras DBus API.
209 for node in nodes:
210 if node['Active']:
211 if node['IsInput']:
212 input_nodes.append(node['Id'])
214 output_nodes.append(node['Id'])
219 """Sets the selected output node volume.
257 """Determine if there is any node of node_type plugged.
263 Since Cras only reports the plugged node in GetNodes, we can
264 parse the return value to see if there is any node with the given type.
273 @param node_type: A str representing node type defined in CRAS_NODE_TYPES.
276 @returns: True if there is any node of node_type plugged. False otherwise.
284 # Cras node types reported from Cras DBus control API.
294 """Returns the pair of filtered output node types and input node types.
296 @param callback: A callback function which takes a node as input parameter
297 and filter the node based on its return value.
300 field is a list of node types defined in CRAS_NODE_TYPES,
307 for node in nodes:
308 if callback(node):
309 node_type = str(node['Type'])
312 'node type %s is not valid' % node_type)
313 if node['IsInput']:
321 """Returns the pair of active output node types and input node types.
324 field is a list of selected node types defined in CRAS_NODE_TYPES.
327 def is_selected(node):
328 """Checks if a node is selected.
330 A node is selected if its Active attribute is True.
332 @returns: True is a node is selected, False otherwise.
335 return node['Active']
341 """Returns the pair of plugged output node types and input node types.
344 field is a list of plugged node types defined in CRAS_NODE_TYPES.
347 def is_plugged(node):
348 """Checks if a node is plugged and is not unknown node.
350 Cras DBus API only reports plugged node, so every node reported by Cras
351 DBus API is plugged. However, we filter out UNKNOWN node here because
352 the existence of unknown node depends on the number of redundant
356 @returns: True if a node is plugged and is not an UNKNOWN node.
359 return node['Type'] != 'UNKNOWN'
365 """Sets selected node types.
367 @param output_node_types: A list of output node types. None to skip setting.
368 @param input_node_types: A list of input node types. None to skip setting.
382 """Sets one selected output node.
385 to select one output node.
387 @param node_type: A node type.
391 for node in nodes:
392 if node['IsInput']:
394 if node['Type'] == node_type:
395 set_active_output_node(node['Id'])
399 """Sets one selected input node.
402 to select one input node.
404 @param node_type: A node type.
408 for node in nodes:
409 if not node['IsInput']:
411 if node['Type'] == node_type:
412 set_active_input_node(node['Id'])
416 """Sets selected output node types.
419 to select one output node. Here we use add/remove active output node
422 @param types: A list of output node types.
426 for node in nodes:
427 if node['IsInput']:
429 if node['Type'] in types:
430 add_active_output_node(node['Id'])
431 elif node['Active']:
432 remove_active_output_node(node['Id'])
436 """Sets selected input node types.
439 to select one input node. Here we use add/remove active input node
442 @param types: A list of input node types.
446 for node in nodes:
447 if not node['IsInput']:
449 if node['Type'] in types:
450 add_active_input_node(node['Id'])
451 elif node['Active']:
452 remove_active_input_node(node['Id'])
456 """Sets one active input node.
458 @param node_id: node id.
465 """Sets one active output node.
467 @param node_id: node id.
474 """Adds an active output node.
476 @param node_id: node id.
483 """Adds an active input node.
485 @param node_id: node id.
492 """Removes an active output node.
494 @param node_id: node id.
501 """Removes an active input node.
503 @param node_id: node id.
510 """Gets node id from node type.
512 @param types: A node type defined in CRAS_NODE_TYPES.
513 @param is_input: True if the node is input. False otherwise.
515 @returns: A string for node id.
517 @raises: CrasUtilsError: if unique node id can not be found.
522 for node in nodes:
523 if node['Type'] == node_type and node['IsInput'] == is_input:
524 find_ids.append(node['Id'])
527 'Can not find unique node id from node type %s' % node_type)
531 """Returns volume from active node.
535 @raises: CrasUtilsError: if node volume cannot be found.
538 for node in nodes:
539 if node['Active'] == 1 and node['IsInput'] == 0:
540 return int(node['NodeVolume'])
541 raise CrasUtilsError('Cannot find active node volume from nodes.')