Module lua_libpulse_glib.context

Bindings for libpulse’s connection context.

The connection Context provides introspection calls to query state from the server and various commands to change this state.

In many cases, sinks and sources may be addressed by either their name or their numeric index. Both can be queried using the get_(sink|source)_info or get_(sink|source)s calls.

Table of contents

Class Context

Context:connect([server_address=nil], cb) Connects the context to the given server address.
Context:disconnect() Disconnects from the server.
Context:get_server_info(cb) Gets information about the server the context is connected to.
Context:get_sink_info(sink, cb) Gets information about the given sink.
Context:get_sinks(cb) Gets information about all sinks.
Context:set_sink_volume(sink, volume, cb) Sets the sink’s volume to the given value.
Context:set_sink_mute(sink, mute, cb) Sets the sink’s mute state.
Context:set_sink_suspended(sink, suspended, cb) Sets the sink’s suspended state.
Context:get_sink_input_info(sink, cb) Gets information about the given sink input.
Context:get_sink_inputs(cb) Gets information about all sink inputs.
Context:set_sink_suspended(The, sink, cb) Moves the sink input to a different name.
Context:set_sink_input_volume(sink_input, volume, cb) Sets the sink input’s volume to the given value.
Context:set_sink_input_mute(sink_input, mute, cb) Sets the sink input’s mute state.
Context:kill_sink_input(sink_input, cb) Kills the sink input.
Context:get_source_info(source, cb) Gets information about the given source.
Context:get_sources(cb) Gets information about all sources.
Context:set_source_volume(source, volume, cb) Sets the source’s volume to the given value.
Context:set_source_mute(source, mute, cb) Sets the source’s mute state.
Context:set_source_suspended(source, suspended, cb) Sets the source’s suspended state.
Context:get_source_output_info(source_output, cb) Gets information about the given source output.
Context:get_source_outputs(cb) Gets information about all source outputs.
Context:set_source_suspended(The, source, cb) Moves the source output to a different name.
Context:set_source_output_volume(source_output, volume, cb) Sets the source output’s volume to the given value.
Context:set_source_output_mute(source_output, mute, cb) Sets the source output’s mute state.
Context:kill_source_output(source_output, cb) Kills the source output.

Class Context

Context
Context:connect([server_address=nil], cb) async
Connects the context to the given server address.

If the server address is nil, libpulse will attempt to connect to what it considers the default server. In most cases, this is the local machine.

The provided callback function will be registered as state callback function, and will be called whenever the context’s connection state changes.

Parameters:

  • server_address :  The server address.
    type string
    default nil
  • cb :  The connection state callback.
    type function

Callback parameters:

Context:disconnect()
Disconnects from the server.
Context:get_server_info(cb) async
Gets information about the server the context is connected to.

See pa_server_info for documentation on the return type.

This will fail when the connection state is anything other than READY.

Parameters:

  • cb
    type function

Callback parameters:

  • string The error
    type
  • table The server info.
    type
Context:get_sink_info(sink, cb) async
Gets information about the given sink.

The sink may be indicated by either its name or its index.

See pa_sink_info for documentation on the return type.

Parameters:

  • sink :  The index or name of the sink to query.
    type number or string
  • cb
    type function

Callback parameters:

Context:get_sinks(cb) async
Gets information about all sinks.

This returns the same information as Context:get_sink_info would have returned for every sink that’s currently registered at the server.

See pa_sink_info for documentation on the return type.

Parameters:

  • cb
    type function

Callback parameters:

Context:set_sink_volume(sink, volume, cb) async
Sets the sink’s volume to the given value.

The sink may be indicated by either its name or its index.

Parameters:

  • sink :  The sink to update.
    type number or string
  • volume
    type Volume
  • cb
    type function

Callback parameters:

Context:set_sink_mute(sink, mute, cb) async
Sets the sink’s mute state.

The sink may be indicated by either its name or its index.

Parameters:

  • sink :  The sink to update.
    type number or string
  • mute
    type boolean
  • cb
    type function

Callback parameters:

Context:set_sink_suspended(sink, suspended, cb) async
Sets the sink’s suspended state.

The sink may be indicated by either its name or its index.

Parameters:

  • sink :  The sink to update.
    type number or string
  • suspended
    type boolean
  • cb
    type function

Callback parameters:

Context:get_sink_input_info(sink, cb) async
Gets information about the given sink input.

The sink input may be indicated by either its name or its index.

See pa_sink_input_info for documentation on the return type.

Parameters:

  • sink :  input The index or name of the sink input to query.
    type number or string
  • cb
    type function

Callback parameters:

Context:get_sink_inputs(cb) async
Gets information about all sink inputs.

This returns the same information as Context:get_sink_input_info would have returned for every sink input that’s currently registered at the server.

See pa_sink_input_info for documentation on the return type.

Parameters:

  • cb
    type function

Callback parameters:

Context:set_sink_suspended(The, sink, cb) async
Moves the sink input to a different name.

The target sink may be indicated by either its name or its index.

Parameters:

  • The :  sink input to move.
    type number
  • sink :  The sink to update.
    type number or string
  • cb
    type function

Callback parameters:

Context:set_sink_input_volume(sink_input, volume, cb) async
Sets the sink input’s volume to the given value.

Parameters:

  • sink_input :  The sink input to update.
    type number
  • volume
    type Volume
  • cb
    type function

Callback parameters:

Context:set_sink_input_mute(sink_input, mute, cb) async
Sets the sink input’s mute state.

Parameters:

  • sink_input :  The sink input to update.
    type number
  • mute
    type boolean
  • cb
    type function

Callback parameters:

Context:kill_sink_input(sink_input, cb) async
Kills the sink input.

Parameters:

  • sink_input :  The sink input to kill.
    type number
  • cb
    type function

Callback parameters:

Context:get_source_info(source, cb) async
Gets information about the given source.

The source may be indicated by either its name or its index.

See pa_source_info for documentation on the return type.

Parameters:

  • source :  The index or name of the source to query.
    type number or string
  • cb
    type function

Callback parameters:

Context:get_sources(cb) async
Gets information about all sources.

This returns the same information as Context:get_source_info would have returned for every source that’s currently registered at the server.

See pa_source_info for documentation on the return type.

Parameters:

  • cb
    type function

Callback parameters:

Context:set_source_volume(source, volume, cb) async
Sets the source’s volume to the given value.

The source may be indicated by either its name or its index.

Parameters:

  • source :  The source to update.
    type number or string
  • volume
    type Volume
  • cb
    type function

Callback parameters:

Context:set_source_mute(source, mute, cb) async
Sets the source’s mute state.

The source may be indicated by either its name or its index.

Parameters:

  • source :  The source to update.
    type number or string
  • mute
    type boolean
  • cb
    type function

Callback parameters:

Context:set_source_suspended(source, suspended, cb) async
Sets the source’s suspended state.

The source may be indicated by either its name or its index.

Parameters:

  • source :  The source to update.
    type number or string
  • suspended
    type boolean
  • cb
    type function

Callback parameters:

Context:get_source_output_info(source_output, cb) async
Gets information about the given source output.

See pa_source_output_info for documentation on the return type.

Parameters:

  • source_output :  The index of the source output to query.
    type number
  • cb
    type function

Callback parameters:

Context:get_source_outputs(cb) async
Gets information about all source outputs.

This returns the same information as Context:get_source_output_info would have returned for every source output that’s currently registered at the server.

See pa_source_output_info for documentation on the return type.

Parameters:

  • cb
    type function

Callback parameters:

Context:set_source_suspended(The, source, cb) async
Moves the source output to a different name.

The target source may be indicated by either its name or its index.

Parameters:

  • The :  source output to move.
    type number
  • source :  The source to update.
    type number or string
  • cb
    type function

Callback parameters:

Context:set_source_output_volume(source_output, volume, cb) async
Sets the source output’s volume to the given value.

Parameters:

  • source_output :  The source output to update.
    type number
  • volume
    type Volume
  • cb
    type function

Callback parameters:

Context:set_source_output_mute(source_output, mute, cb) async
Sets the source output’s mute state.

Parameters:

  • source_output :  The source output to update.
    type number
  • mute
    type boolean
  • cb
    type function

Callback parameters:

Context:kill_source_output(source_output, cb) async
Kills the source output.

Parameters:

  • source_output :  The source output to kill.
    type number
  • cb
    type function

Callback parameters: