mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-11 10:26:12 +00:00
Provide selected audio device as context
This commit is contained in:
@@ -29,7 +29,7 @@ static snd_pcm_t *handle;
|
||||
static OpusMSDecoder* decoder;
|
||||
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
|
||||
|
||||
static int alsa_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
|
||||
static int alsa_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, void* context, int arFlags) {
|
||||
int rc;
|
||||
unsigned char alsaMapping[MAX_CHANNEL_COUNT];
|
||||
|
||||
@@ -54,6 +54,7 @@ static int alsa_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGUR
|
||||
snd_pcm_uframes_t buffer_size = 2 * period_size;
|
||||
unsigned int sampleRate = opusConfig->sampleRate;
|
||||
|
||||
char* audio_device = (char*) context;
|
||||
if (audio_device == NULL)
|
||||
audio_device = "sysdefault";
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
#define FRAME_SIZE 240
|
||||
#define FRAME_BUFFER 12
|
||||
|
||||
extern const char* audio_device;
|
||||
|
||||
#ifdef HAVE_ALSA
|
||||
extern AUDIO_RENDERER_CALLBACKS audio_callbacks_alsa;
|
||||
#endif
|
||||
@@ -35,5 +33,5 @@ extern AUDIO_RENDERER_CALLBACKS audio_callbacks_sdl;
|
||||
#endif
|
||||
#ifdef HAVE_PULSE
|
||||
extern AUDIO_RENDERER_CALLBACKS audio_callbacks_pulse;
|
||||
bool audio_pulse_init();
|
||||
bool audio_pulse_init(char* audio_device);
|
||||
#endif
|
||||
|
||||
@@ -32,7 +32,7 @@ static OMX_BUFFERHEADERTYPE *buf;
|
||||
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
|
||||
static int channelCount;
|
||||
|
||||
static int omx_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
|
||||
static int omx_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, void* context, int arFlags) {
|
||||
int rc, error;
|
||||
OMX_ERRORTYPE err;
|
||||
unsigned char omxMapping[MAX_CHANNEL_COUNT];
|
||||
|
||||
@@ -31,7 +31,7 @@ static pa_simple *dev = NULL;
|
||||
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
|
||||
static int channelCount;
|
||||
|
||||
bool audio_pulse_init() {
|
||||
bool audio_pulse_init(char* audio_device) {
|
||||
pa_sample_spec spec = {
|
||||
.format = PA_SAMPLE_S16LE,
|
||||
.rate = 44000,
|
||||
@@ -47,7 +47,7 @@ bool audio_pulse_init() {
|
||||
return (bool) dev;
|
||||
}
|
||||
|
||||
static int pulse_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
|
||||
static int pulse_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, void* context, int arFlags) {
|
||||
int rc, error;
|
||||
unsigned char alsaMapping[MAX_CHANNEL_COUNT];
|
||||
|
||||
@@ -74,6 +74,7 @@ static int pulse_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGU
|
||||
.channels = opusConfig->channelCount
|
||||
};
|
||||
|
||||
char* audio_device = (char*) context;
|
||||
dev = pa_simple_new(audio_device, "Moonlight Embedded", PA_STREAM_PLAYBACK, NULL, "Streaming", &spec, NULL, NULL, &error);
|
||||
|
||||
if (!dev) {
|
||||
|
||||
@@ -30,7 +30,7 @@ static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
|
||||
static SDL_AudioDeviceID dev;
|
||||
static int channelCount;
|
||||
|
||||
static int sdl_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
|
||||
static int sdl_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, void* context, int arFlags) {
|
||||
int rc;
|
||||
decoder = opus_multistream_decoder_create(opusConfig->sampleRate, opusConfig->channelCount, opusConfig->streams, opusConfig->coupledStreams, opusConfig->mapping, &rc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user