mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-07-04 00:36:01 +00:00
Provide selected audio device as context
This commit is contained in:
parent
c2036acca1
commit
f5cb2d1880
@ -29,7 +29,7 @@ static snd_pcm_t *handle;
|
|||||||
static OpusMSDecoder* decoder;
|
static OpusMSDecoder* decoder;
|
||||||
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
|
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;
|
int rc;
|
||||||
unsigned char alsaMapping[MAX_CHANNEL_COUNT];
|
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;
|
snd_pcm_uframes_t buffer_size = 2 * period_size;
|
||||||
unsigned int sampleRate = opusConfig->sampleRate;
|
unsigned int sampleRate = opusConfig->sampleRate;
|
||||||
|
|
||||||
|
char* audio_device = (char*) context;
|
||||||
if (audio_device == NULL)
|
if (audio_device == NULL)
|
||||||
audio_device = "sysdefault";
|
audio_device = "sysdefault";
|
||||||
|
|
||||||
|
@ -25,8 +25,6 @@
|
|||||||
#define FRAME_SIZE 240
|
#define FRAME_SIZE 240
|
||||||
#define FRAME_BUFFER 12
|
#define FRAME_BUFFER 12
|
||||||
|
|
||||||
extern const char* audio_device;
|
|
||||||
|
|
||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
extern AUDIO_RENDERER_CALLBACKS audio_callbacks_alsa;
|
extern AUDIO_RENDERER_CALLBACKS audio_callbacks_alsa;
|
||||||
#endif
|
#endif
|
||||||
@ -35,5 +33,5 @@ extern AUDIO_RENDERER_CALLBACKS audio_callbacks_sdl;
|
|||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_PULSE
|
#ifdef HAVE_PULSE
|
||||||
extern AUDIO_RENDERER_CALLBACKS audio_callbacks_pulse;
|
extern AUDIO_RENDERER_CALLBACKS audio_callbacks_pulse;
|
||||||
bool audio_pulse_init();
|
bool audio_pulse_init(char* audio_device);
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,7 +32,7 @@ static OMX_BUFFERHEADERTYPE *buf;
|
|||||||
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
|
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
|
||||||
static int channelCount;
|
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;
|
int rc, error;
|
||||||
OMX_ERRORTYPE err;
|
OMX_ERRORTYPE err;
|
||||||
unsigned char omxMapping[MAX_CHANNEL_COUNT];
|
unsigned char omxMapping[MAX_CHANNEL_COUNT];
|
||||||
|
@ -31,7 +31,7 @@ static pa_simple *dev = NULL;
|
|||||||
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
|
static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
|
||||||
static int channelCount;
|
static int channelCount;
|
||||||
|
|
||||||
bool audio_pulse_init() {
|
bool audio_pulse_init(char* audio_device) {
|
||||||
pa_sample_spec spec = {
|
pa_sample_spec spec = {
|
||||||
.format = PA_SAMPLE_S16LE,
|
.format = PA_SAMPLE_S16LE,
|
||||||
.rate = 44000,
|
.rate = 44000,
|
||||||
@ -47,7 +47,7 @@ bool audio_pulse_init() {
|
|||||||
return (bool) dev;
|
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;
|
int rc, error;
|
||||||
unsigned char alsaMapping[MAX_CHANNEL_COUNT];
|
unsigned char alsaMapping[MAX_CHANNEL_COUNT];
|
||||||
|
|
||||||
@ -74,6 +74,7 @@ static int pulse_renderer_init(int audioConfiguration, POPUS_MULTISTREAM_CONFIGU
|
|||||||
.channels = opusConfig->channelCount
|
.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);
|
dev = pa_simple_new(audio_device, "Moonlight Embedded", PA_STREAM_PLAYBACK, NULL, "Streaming", &spec, NULL, NULL, &error);
|
||||||
|
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
|
@ -30,7 +30,7 @@ static short pcmBuffer[FRAME_SIZE * MAX_CHANNEL_COUNT];
|
|||||||
static SDL_AudioDeviceID dev;
|
static SDL_AudioDeviceID dev;
|
||||||
static int channelCount;
|
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;
|
int rc;
|
||||||
decoder = opus_multistream_decoder_create(opusConfig->sampleRate, opusConfig->channelCount, opusConfig->streams, opusConfig->coupledStreams, opusConfig->mapping, &rc);
|
decoder = opus_multistream_decoder_create(opusConfig->sampleRate, opusConfig->channelCount, opusConfig->streams, opusConfig->coupledStreams, opusConfig->mapping, &rc);
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
#define write_config_bool(fd, key, value) fprintf(fd, "%s = %s\n", key, value?"true":"false");
|
#define write_config_bool(fd, key, value) fprintf(fd, "%s = %s\n", key, value?"true":"false");
|
||||||
|
|
||||||
bool inputAdded = false;
|
bool inputAdded = false;
|
||||||
const char* audio_device = NULL;
|
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"720", no_argument, NULL, 'a'},
|
{"720", no_argument, NULL, 'a'},
|
||||||
@ -172,7 +171,7 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) {
|
|||||||
config->sops = false;
|
config->sops = false;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
audio_device = value;
|
config->audio_device = value;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
config->localaudio = true;
|
config->localaudio = true;
|
||||||
@ -303,6 +302,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
|
|||||||
config->action = NULL;
|
config->action = NULL;
|
||||||
config->address = NULL;
|
config->address = NULL;
|
||||||
config->config_file = NULL;
|
config->config_file = NULL;
|
||||||
|
config->audio_device = NULL;
|
||||||
config->sops = true;
|
config->sops = true;
|
||||||
config->localaudio = false;
|
config->localaudio = false;
|
||||||
config->fullscreen = true;
|
config->fullscreen = true;
|
||||||
|
@ -32,6 +32,7 @@ typedef struct _CONFIGURATION {
|
|||||||
char* address;
|
char* address;
|
||||||
char* mapping;
|
char* mapping;
|
||||||
char* platform;
|
char* platform;
|
||||||
|
char* audio_device;
|
||||||
char* config_file;
|
char* config_file;
|
||||||
char key_dir[4096];
|
char key_dir[4096];
|
||||||
bool sops;
|
bool sops;
|
||||||
|
@ -111,7 +111,7 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys
|
|||||||
printf("Stream %d x %d, %d fps, %d kbps\n", config->stream.width, config->stream.height, config->stream.fps, config->stream.bitrate);
|
printf("Stream %d x %d, %d fps, %d kbps\n", config->stream.width, config->stream.height, config->stream.fps, config->stream.bitrate);
|
||||||
|
|
||||||
platform_start(system);
|
platform_start(system);
|
||||||
LiStartConnection(&server->serverInfo, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system), NULL, drFlags);
|
LiStartConnection(&server->serverInfo, &config->stream, &connection_callbacks, platform_get_video(system), platform_get_audio(system, config->audio_device), NULL, drFlags, config->audio_device, 0);
|
||||||
|
|
||||||
if (IS_EMBEDDED(system)) {
|
if (IS_EMBEDDED(system)) {
|
||||||
evdev_start();
|
evdev_start();
|
||||||
@ -193,7 +193,7 @@ int main(int argc, char* argv[]) {
|
|||||||
if (system == 0) {
|
if (system == 0) {
|
||||||
fprintf(stderr, "Platform '%s' not found\n", config.platform);
|
fprintf(stderr, "Platform '%s' not found\n", config.platform);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
} else if (system == SDL && audio_device != NULL) {
|
} else if (system == SDL && config.audio_device != NULL) {
|
||||||
fprintf(stderr, "You can't select a audio device for SDL\n");
|
fprintf(stderr, "You can't select a audio device for SDL\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ DECODER_RENDERER_CALLBACKS* platform_get_video(enum platform system) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum platform system) {
|
AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum platform system, char* audio_device) {
|
||||||
switch (system) {
|
switch (system) {
|
||||||
#ifdef HAVE_SDL
|
#ifdef HAVE_SDL
|
||||||
case SDL:
|
case SDL:
|
||||||
@ -144,7 +144,7 @@ AUDIO_RENDERER_CALLBACKS* platform_get_audio(enum platform system) {
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
#ifdef HAVE_PULSE
|
#ifdef HAVE_PULSE
|
||||||
if (audio_pulse_init())
|
if (audio_pulse_init(audio_device))
|
||||||
return &audio_callbacks_pulse;
|
return &audio_callbacks_pulse;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
|
@ -30,7 +30,7 @@ enum platform { NONE, SDL, X11, PI, IMX, AML, FAKE };
|
|||||||
|
|
||||||
enum platform platform_check(char*);
|
enum platform platform_check(char*);
|
||||||
PDECODER_RENDERER_CALLBACKS platform_get_video(enum platform system);
|
PDECODER_RENDERER_CALLBACKS platform_get_video(enum platform system);
|
||||||
PAUDIO_RENDERER_CALLBACKS platform_get_audio(enum platform system);
|
PAUDIO_RENDERER_CALLBACKS platform_get_audio(enum platform system, char* audio_device);
|
||||||
bool platform_supports_hevc(enum platform system);
|
bool platform_supports_hevc(enum platform system);
|
||||||
|
|
||||||
void platform_start(enum platform system);
|
void platform_start(enum platform system);
|
||||||
|
2
third_party/moonlight-common-c
vendored
2
third_party/moonlight-common-c
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 560cd3241fb0273b040e28a269a83d4483a0454b
|
Subproject commit 66ce27ab19213f8e4b36dcaf33c5b3e909912b9c
|
Loading…
x
Reference in New Issue
Block a user