mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-02-16 10:30:47 +00:00
Can play audio locally
This commit is contained in:
@@ -317,7 +317,7 @@ int client_get_app_id(const char *address, char *name) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void client_start_app(STREAM_CONFIGURATION *config, const char *address, int appId, bool sops) {
|
||||
void client_start_app(STREAM_CONFIGURATION *config, const char *address, int appId, bool sops, bool localaudio) {
|
||||
RAND_bytes(config->remoteInputAesKey, 16);
|
||||
memset(config->remoteInputAesIv, 0, 16);
|
||||
|
||||
@@ -329,7 +329,7 @@ void client_start_app(STREAM_CONFIGURATION *config, const char *address, int app
|
||||
|
||||
struct http_data *data = http_create_data();
|
||||
if (currentGame == 0)
|
||||
sprintf(url, "https://%s:47984/launch?uniqueid=%s&appid=%d&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%s&rikeyid=%d&localAudioPlayMode=0", address, unique_id, appId, config->width, config->height, config->fps, sops, rikey_hex, rikeyid);
|
||||
sprintf(url, "https://%s:47984/launch?uniqueid=%s&appid=%d&mode=%dx%dx%d&additionalStates=1&sops=%d&rikey=%s&rikeyid=%d&localAudioPlayMode=%d", address, unique_id, appId, config->width, config->height, config->fps, sops, rikey_hex, rikeyid, localaudio);
|
||||
else
|
||||
sprintf(url, "https://%s:47984/resume?uniqueid=%s&rikey=%s&rikeyid=%d", address, unique_id, rikey_hex, rikeyid);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "stdbool.h"
|
||||
|
||||
void client_init(const char* serverAddress);
|
||||
void client_start_app(STREAM_CONFIGURATION *config, const char* serverAddress, int appId, bool sops);
|
||||
void client_start_app(STREAM_CONFIGURATION *config, const char* serverAddress, int appId, bool sops, bool localaudio);
|
||||
struct app_list* client_applist(const char* serverAddress);
|
||||
int client_get_app_id(const char* serverAddress, char* name);
|
||||
void client_pair(const char *address);
|
||||
|
||||
14
src/main.c
14
src/main.c
@@ -47,14 +47,14 @@ static void applist(const char* address) {
|
||||
}
|
||||
}
|
||||
|
||||
static void stream(STREAM_CONFIGURATION* config, const char* address, const char* app, bool sops) {
|
||||
static void stream(STREAM_CONFIGURATION* config, const char* address, const char* app, bool sops, bool localaudio) {
|
||||
int appId = client_get_app_id(address, app);
|
||||
if (appId<0) {
|
||||
printf("Can't find app %s\n", app);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
client_start_app(config, address, appId, sops);
|
||||
client_start_app(config, address, appId, sops, localaudio);
|
||||
|
||||
struct in_addr addr;
|
||||
inet_aton(address, &addr);
|
||||
@@ -86,6 +86,7 @@ static void help() {
|
||||
printf("\t-input <device>\t\tUse <device> as input. Can be used multiple times\n");
|
||||
printf("\t-mapping <file>\t\tUse <file> as gamepad mapping configuration file (use before -input)\n");
|
||||
printf("\t-audio <device>\t\tUse <device> as ALSA audio output device (default sysdefault)\n");
|
||||
printf("\t-localaudio\t\tPlay audio locally\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -111,6 +112,7 @@ int main(int argc, char* argv[]) {
|
||||
{"mapping", required_argument, 0, 'k'},
|
||||
{"nosops", no_argument, 0, 'l'},
|
||||
{"audio", required_argument, 0, 'm'},
|
||||
{"localaudio", no_argument, 0, 'n'},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
@@ -120,8 +122,9 @@ int main(int argc, char* argv[]) {
|
||||
char* mapping = NULL;
|
||||
int option_index = 0;
|
||||
bool sops = true;
|
||||
bool localaudio = false;
|
||||
int c;
|
||||
while ((c = getopt_long_only(argc, argv, "-abc:d:efg:h:i:j:k:lm:", long_options, &option_index)) != -1) {
|
||||
while ((c = getopt_long_only(argc, argv, "-abc:d:efg:h:i:j:k:lm:n", long_options, &option_index)) != -1) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
config.width = 720;
|
||||
@@ -164,6 +167,9 @@ int main(int argc, char* argv[]) {
|
||||
case 'm':
|
||||
audio_device = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
localaudio = true;
|
||||
break;
|
||||
case 1:
|
||||
if (action == NULL)
|
||||
action = optarg;
|
||||
@@ -189,7 +195,7 @@ int main(int argc, char* argv[]) {
|
||||
if (strcmp("applist", action) == 0)
|
||||
applist(address);
|
||||
else if (strcmp("stream", action) == 0)
|
||||
stream(&config, address, app, sops);
|
||||
stream(&config, address, app, sops, localaudio);
|
||||
else if (strcmp("pair", action) == 0)
|
||||
client_pair(address);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user