How to use the pulsectl.pulsectl.PulsePortInfo function in pulsectl

To help you get started, we’ve selected a few pulsectl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mk-fg / python-pulse-control / pulsectl / pulsectl.py View on Github external
if struct:
			if hasattr(struct, 'proplist'):
				self.proplist, state = dict(), c.c_void_p()
				while True:
					k = c.pa.proplist_iterate(struct.proplist, c.byref(state))
					if not k: break
					self.proplist[c.force_str(k)] = c.force_str(c.pa.proplist_gets(struct.proplist, k))
			if hasattr(struct, 'volume'):
				self.volume = self._get_wrapper(PulseVolumeInfo)(struct.volume)
			if hasattr(struct, 'n_ports'):
				cls_port = self._get_wrapper(PulsePortInfo)
				self.port_list = list(
					cls_port(struct.ports[n].contents) for n in range(struct.n_ports) )
			if hasattr(struct, 'active_port'):
				cls_port = self._get_wrapper(PulsePortInfo)
				self.port_active = (
					None if not struct.active_port else cls_port(struct.active_port.contents) )
			if hasattr(struct, 'channel_map'):
				self.channel_count, self.channel_list = struct.channel_map.channels, list()
				if self.channel_count > 0:
					s = c.create_string_buffer(b'\0' * 512)
					c.pa.channel_map_snprint(s, len(s), struct.channel_map)
					self.channel_list.extend(map(c.force_str, s.value.strip().split(b',')))
			if hasattr(struct, 'state'):
				self.state = PulseStateEnum._c_val(
					struct.state, u'state.{}'.format(struct.state) )
				self.state_values = sorted(PulseStateEnum._values.values())
			if hasattr(struct, 'corked'): self.corked = bool(struct.corked)
			self._init_from_struct(struct)
github mk-fg / python-pulse-control / pulsectl / pulsectl.py View on Github external
if struct is None: field_data, struct = dict(), field_data
		assert not set(field_data.keys()).difference(fields)
		if field_data: self._copy_struct_fields(field_data, fields=field_data.keys())
		self._copy_struct_fields(struct, fields=set(fields).difference(field_data.keys()))

		if struct:
			if hasattr(struct, 'proplist'):
				self.proplist, state = dict(), c.c_void_p()
				while True:
					k = c.pa.proplist_iterate(struct.proplist, c.byref(state))
					if not k: break
					self.proplist[c.force_str(k)] = c.force_str(c.pa.proplist_gets(struct.proplist, k))
			if hasattr(struct, 'volume'):
				self.volume = self._get_wrapper(PulseVolumeInfo)(struct.volume)
			if hasattr(struct, 'n_ports'):
				cls_port = self._get_wrapper(PulsePortInfo)
				self.port_list = list(
					cls_port(struct.ports[n].contents) for n in range(struct.n_ports) )
			if hasattr(struct, 'active_port'):
				cls_port = self._get_wrapper(PulsePortInfo)
				self.port_active = (
					None if not struct.active_port else cls_port(struct.active_port.contents) )
			if hasattr(struct, 'channel_map'):
				self.channel_count, self.channel_list = struct.channel_map.channels, list()
				if self.channel_count > 0:
					s = c.create_string_buffer(b'\0' * 512)
					c.pa.channel_map_snprint(s, len(s), struct.channel_map)
					self.channel_list.extend(map(c.force_str, s.value.strip().split(b',')))
			if hasattr(struct, 'state'):
				self.state = PulseStateEnum._c_val(
					struct.state, u'state.{}'.format(struct.state) )
				self.state_values = sorted(PulseStateEnum._values.values())
github mk-fg / python-pulse-control / pulsectl / pulsectl.py View on Github external
def __str__(self):
		return self._as_str(self.volume, fields='index name description mute')

class PulseSourceOutputInfo(PulseObject):
	c_struct_fields = ( 'index name mute corked client'
		' owner_module source sample_spec'
		' buffer_usec source_usec resample_method driver' )

	def __str__(self):
		return self._as_str(fields='index name mute')

class PulseCardProfileInfo(PulseObject):
	c_struct_fields = 'name description n_sinks n_sources priority available'

class PulseCardPortInfo(PulsePortInfo):
	c_struct_fields = 'name description available priority direction latency_offset'

	def _init_from_struct(self, struct):
		super(PulseCardPortInfo, self)._init_from_struct(struct)
		self.direction = PulseDirectionEnum._c_val(struct.direction)

class PulseCardInfo(PulseObject):
	c_struct_fields = 'name index driver owner_module n_profiles'
	c_struct_wrappers = {PulsePortInfo: PulseCardPortInfo}

	def __init__(self, struct):
		super(PulseCardInfo, self).__init__(struct)
		self.profile_list = list(
			PulseCardProfileInfo(struct.profiles2[n][0]) for n in range(self.n_profiles) )
		self.profile_active = PulseCardProfileInfo(struct.active_profile2.contents)
github mk-fg / python-pulse-control / pulsectl / pulsectl.py View on Github external
		lambda port: port.name if isinstance(port, PulsePortInfo) else port )
github mk-fg / python-pulse-control / pulsectl / pulsectl.py View on Github external
def __str__(self):
		return self._as_str(fields='index name mute')

class PulseCardProfileInfo(PulseObject):
	c_struct_fields = 'name description n_sinks n_sources priority available'

class PulseCardPortInfo(PulsePortInfo):
	c_struct_fields = 'name description available priority direction latency_offset'

	def _init_from_struct(self, struct):
		super(PulseCardPortInfo, self)._init_from_struct(struct)
		self.direction = PulseDirectionEnum._c_val(struct.direction)

class PulseCardInfo(PulseObject):
	c_struct_fields = 'name index driver owner_module n_profiles'
	c_struct_wrappers = {PulsePortInfo: PulseCardPortInfo}

	def __init__(self, struct):
		super(PulseCardInfo, self).__init__(struct)
		self.profile_list = list(
			PulseCardProfileInfo(struct.profiles2[n][0]) for n in range(self.n_profiles) )
		self.profile_active = PulseCardProfileInfo(struct.active_profile2.contents)

	def __str__(self):
		return self._as_str(
			fields='name index driver n_profiles',
			profile_active='[{}]'.format(self.profile_active.name) )

class PulseVolumeInfo(PulseObject):

	def __init__(self, struct_or_values=None, channels=None):
		if is_num(struct_or_values):