Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
platf::pa::server_t Class Reference
Inheritance diagram for platf::pa::server_t:
[legend]
Collaboration diagram for platf::pa::server_t:
[legend]

Classes

class  lock_t
struct  [struct].index

Public Member Functions

template<class Make>
bool issue (Make make)
int context_errno ()
int init ()
int load_null (const char *name, const std::uint8_t *channel_mapping, int channels)
int unload_null (std::uint32_t i)
std::uint32_t find_sink_module (const std::string &name)
 The module index behind a sink, or PA_INVALID_INDEX for none.
bool sink_exists (const std::string &name)
 Whether a sink of this name is present right now.
bool create_session_sink (const std::string &name, const std::uint8_t *mapping, int channels) override
 Create a sink that belongs to one isolated session alone.
void remove_session_sink (const std::string &name) override
 Remove a sink created by create_session_sink(). Removing one that is already gone is not an error.
std::optional< sink_t > sink_info () override
std::string get_default_sink_name ()
std::string get_monitor_name (const std::string &sink_name)
std::unique_ptr< mic_t > microphone (const std::uint8_t *mapping, int channels, std::uint32_t sample_rate, std::uint32_t frame_size) override
std::unique_ptr< mic_t > microphone_from (const std::string &sink, const std::uint8_t *mapping, int channels, std::uint32_t sample_rate, std::uint32_t frame_size) override
 Record a named sink's monitor, whatever the current sink is.
bool is_sink_available (const std::string &sink) override
 Check if the audio sink is available in the system.
std::vector< std::string > streams_playing_elsewhere (const std::string &sink) override
 Applications playing to a sink other than sink.
int set_sink (const std::string &sink) override

Public Attributes

loop_t loop
ctx_t ctx
std::string requested_sink
struct  index
std::unique_ptr< safe::event_t< ctx_event_e > > events
std::unique_ptr< std::function< void(ctx_t::pointer)> > events_cb
bool running = false

Detailed Description

Definition at line 193 of file audio.cpp.

Constructor & Destructor Documentation

◆ ~server_t()

platf::pa::server_t::~server_t ( )
inlineoverride

Definition at line 729 of file audio.cpp.

Member Function Documentation

◆ context_errno()

int platf::pa::server_t::context_errno ( )
inline

Definition at line 256 of file audio.cpp.

◆ create_session_sink()

bool platf::pa::server_t::create_session_sink ( const std::string & name,
const std::uint8_t * mapping,
int channels )
inlineoverridevirtual

Create a sink that belongs to one isolated session alone.

The sinks behind sink_info() are the server's: there is one set of them, and capture reaches them by making one of them the host's default, which is what puts everything the host plays into the stream. That is right for a session that is the host's desktop and wrong for a session that is somebody else's - it hands one client the host's audio and every other client's along with it.

A session sink is named for the session, is never made anyone's default, and is captured by name. Nothing is asked to move: the session's own applications are pointed at it when they start.

Returns
false where the platform has no virtual sinks to create, which leaves the caller with the shared behaviour it had before.

Reimplemented from platf::audio_control_t.

Definition at line 431 of file audio.cpp.

◆ find_sink_module()

std::uint32_t platf::pa::server_t::find_sink_module ( const std::string & name)
inline

The module index behind a sink, or PA_INVALID_INDEX for none.

Sinks are removed by module, not by name, and a session sink's module index is not known here - it may have been loaded by an earlier run of Hermes that a client is now reconnecting to. Looking it up keeps removal honest across a restart.

Definition at line 358 of file audio.cpp.

◆ get_default_sink_name()

std::string platf::pa::server_t::get_default_sink_name ( )
inline

Definition at line 558 of file audio.cpp.

◆ get_monitor_name()

std::string platf::pa::server_t::get_monitor_name ( const std::string & sink_name)
inline

Definition at line 585 of file audio.cpp.

◆ init()

int platf::pa::server_t::init ( )
inline

Definition at line 261 of file audio.cpp.

◆ is_sink_available()

bool platf::pa::server_t::is_sink_available ( const std::string & sink)
inlineoverridevirtual

Check if the audio sink is available in the system.

Parameters
sinkSink to be checked.
Returns
True if available, false otherwise.

Implements platf::audio_control_t.

Definition at line 647 of file audio.cpp.

◆ issue()

template<class Make>
bool platf::pa::server_t::issue ( Make make)
inline

Start an operation under the lock and let go of it there. The operation still completes, and its callback rings the caller's alarm, which the caller waits on without the lock.

Returns
Whether the operation started.

Definition at line 246 of file audio.cpp.

◆ load_null()

int platf::pa::server_t::load_null ( const char * name,
const std::uint8_t * channel_mapping,
int channels )
inline

Definition at line 310 of file audio.cpp.

◆ microphone()

std::unique_ptr< mic_t > platf::pa::server_t::microphone ( const std::uint8_t * mapping,
int channels,
std::uint32_t sample_rate,
std::uint32_t frame_size )
inlineoverridevirtual

Implements platf::audio_control_t.

Definition at line 621 of file audio.cpp.

◆ microphone_from()

std::unique_ptr< mic_t > platf::pa::server_t::microphone_from ( const std::string & sink,
const std::uint8_t * mapping,
int channels,
std::uint32_t sample_rate,
std::uint32_t frame_size )
inlineoverridevirtual

Record a named sink's monitor, whatever the current sink is.

microphone() picks its source from state the whole process shares - the configured sink, the last one swapped to, the default - which is right while there is one session and wrong once there are several. A session sink is not negotiable: the session it belongs to must be recorded from it and from nothing else.

The default below is never reached in practice, because a session sink is only ever named after create_session_sink() agreed to make one, and a platform without virtual sinks refuses that.

Reimplemented from platf::audio_control_t.

Definition at line 640 of file audio.cpp.

◆ remove_session_sink()

void platf::pa::server_t::remove_session_sink ( const std::string & name)
inlineoverridevirtual

Remove a sink created by create_session_sink(). Removing one that is already gone is not an error.

Reimplemented from platf::audio_control_t.

Definition at line 451 of file audio.cpp.

◆ set_sink()

int platf::pa::server_t::set_sink ( const std::string & sink)
inlineoverridevirtual

Implements platf::audio_control_t.

Definition at line 704 of file audio.cpp.

◆ sink_exists()

bool platf::pa::server_t::sink_exists ( const std::string & name)
inline

Whether a sink of this name is present right now.

Asked separately from find_sink_module() because presence and ownership are not the same question: a sink that is there can still report no owner module - PipeWire's PulseAudio server does that for the devices it did not load itself - so a module index is the wrong thing to read an answer out of.

Definition at line 399 of file audio.cpp.

◆ sink_info()

std::optional< sink_t > platf::pa::server_t::sink_info ( )
inlineoverridevirtual

Implements platf::audio_control_t.

Definition at line 461 of file audio.cpp.

◆ streams_playing_elsewhere()

std::vector< std::string > platf::pa::server_t::streams_playing_elsewhere ( const std::string & sink)
inlineoverridevirtual

Applications playing to a sink other than sink.

A stream follows the default sink unless something chose an output for it: the user in the desktop's sound settings, or the sound server restoring that choice the next time the application plays. Such a stream does not move when Hermes makes its sink the default, so the client never hears it.

Returns
One "application -> sink" entry per stream that is playing.

Reimplemented from platf::audio_control_t.

Definition at line 656 of file audio.cpp.

◆ unload_null()

int platf::pa::server_t::unload_null ( std::uint32_t i)
inline

Definition at line 325 of file audio.cpp.

Member Data Documentation

◆ ctx

ctx_t platf::pa::server_t::ctx

Definition at line 202 of file audio.cpp.

◆ events

std::unique_ptr<safe::event_t<ctx_event_e> > platf::pa::server_t::events

Definition at line 211 of file audio.cpp.

◆ events_cb

std::unique_ptr<std::function<void(ctx_t::pointer)> > platf::pa::server_t::events_cb

Definition at line 212 of file audio.cpp.

◆ loop

loop_t platf::pa::server_t::loop

Definition at line 201 of file audio.cpp.

◆ requested_sink

std::string platf::pa::server_t::requested_sink

Definition at line 203 of file audio.cpp.

◆ running

bool platf::pa::server_t::running = false

Definition at line 214 of file audio.cpp.


The documentation for this class was generated from the following file: