Sunshine latest
Self-hosted game stream host for Moonlight.
audio.h File Reference

Declarations for audio capture and encoding. More...

#include "platform/common.h"
#include "thread_safe.h"
#include "utility.h"
#include <bitset>
Include dependency graph for audio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  audio::audio_ctx_t
 
struct  audio::config_t
 
struct  audio::opus_stream_config_t
 
struct  audio::stream_params_t
 

Typedefs

using audio::audio_ctx_ref_t = safe::shared_t<audio_ctx_t>::ptr_t
 
using audio::buffer_t = util::buffer_t<std::uint8_t>
 
using audio::packet_t = std::pair<void *, buffer_t>
 

Enumerations

enum  audio::stream_config_e : int {
  audio::STEREO , audio::HIGH_STEREO , audio::SURROUND51 , audio::HIGH_SURROUND51 ,
  audio::SURROUND71 , audio::HIGH_SURROUND71 , audio::MAX_STREAM_CONFIG
}
 

Functions

void audio::capture (safe::mail_t mail, config_t config, void *channel_data)
 
audio_ctx_ref_t audio::get_audio_ctx_ref ()
 Get the reference to the audio context.
 
bool audio::is_audio_ctx_sink_available (const audio_ctx_t &ctx)
 Check if the audio sink held by audio context is available.
 

Detailed Description

Declarations for audio capture and encoding.

Enumeration Type Documentation

◆ stream_config_e

Enumerator
STEREO 

Stereo.

HIGH_STEREO 

High stereo.

SURROUND51 

Surround 5.1.

HIGH_SURROUND51 

High surround 5.1.

SURROUND71 

Surround 7.1.

HIGH_SURROUND71 

High surround 7.1.

MAX_STREAM_CONFIG 

Maximum audio stream configuration.

Function Documentation

◆ get_audio_ctx_ref()

audio_ctx_ref_t audio::get_audio_ctx_ref ( )

Get the reference to the audio context.

Returns
A shared pointer reference to audio context.
Note
Aside from the configuration purposes, it can be used to extend the audio sink lifetime to capture sink earlier and restore it later.

Examples

audio_ctx_ref_t audio = get_audio_ctx_ref()

◆ is_audio_ctx_sink_available()

bool audio::is_audio_ctx_sink_available ( const audio_ctx_t & ctx)

Check if the audio sink held by audio context is available.

Returns
True if available (and can probably be restored), false otherwise.
Note
Useful for delaying the release of audio context shared pointer (which tries to restore original sink).

Examples

audio_ctx_ref_t audio = get_audio_ctx_ref()
if (audio.get()) {
return is_audio_ctx_sink_available(*audio.get());
}
return false;