From a3d5595519b457ddfbf94ddea08b6cdb85886657 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Sat, 13 Mar 2021 01:24:39 +0200 Subject: [PATCH] XSDL: option to disable PulseAudio --- .../application/xserver/AndroidAppSettings.cfg | 4 ++-- project/jni/application/xserver/gfx.c | 15 +++++++++++---- project/jni/application/xserver/gfx.h | 2 +- project/jni/application/xserver/main.c | 7 +++++-- project/jni/application/xserver/xserver | 2 +- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/project/jni/application/xserver/AndroidAppSettings.cfg b/project/jni/application/xserver/AndroidAppSettings.cfg index 7d7014c51..ef3c816eb 100644 --- a/project/jni/application/xserver/AndroidAppSettings.cfg +++ b/project/jni/application/xserver/AndroidAppSettings.cfg @@ -7,10 +7,10 @@ AppName="XServer XSDL" AppFullName=x.org.server # Application version code (integer) -AppVersionCode=12050 +AppVersionCode=12051 # Application user-visible version name (string) -AppVersionName="1.20.50" +AppVersionName="1.20.51" # Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...' # If you'll start Description with '!' symbol it will be enabled by default, '!!' will also hide the entry from the menu, so it cannot be disabled diff --git a/project/jni/application/xserver/gfx.c b/project/jni/application/xserver/gfx.c index 8bb3b68cb..d84c433d0 100644 --- a/project/jni/application/xserver/gfx.c +++ b/project/jni/application/xserver/gfx.c @@ -426,7 +426,7 @@ void XSDL_unpackFiles(int _freeSpaceRequiredMb) SDL_JoystickClose(j0); } -void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, int * displayH, int * builtinKeyboard, int * ctrlAltShiftKeys, char * portStr) +void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, int * displayH, int * builtinKeyboard, int * ctrlAltShiftKeys, char * portStr, int * pulseAudio) { int x = 0, y = 0, i, ii; SDL_Event event; @@ -493,7 +493,7 @@ void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, i cfgfile = fopen(cfgpath, "r"); if( cfgfile ) { - fscanf(cfgfile, "%d %d %d %d %d %d %d", &savedRes, &savedDpi, &customX, &customY, builtinKeyboard, ctrlAltShiftKeys, &port); + fscanf(cfgfile, "%d %d %d %d %d %d %d %d", &savedRes, &savedDpi, &customX, &customY, builtinKeyboard, ctrlAltShiftKeys, &port, pulseAudio); fclose(cfgfile); if (strcmp(portStr, ":0") != 0) { @@ -782,7 +782,11 @@ void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, i port ++; port %= 4; } - if( y > VID_Y * 4 / 6 && y < VID_Y * 6 / 6 ) + if( y > VID_Y * 3.5f / 6 && y < VID_Y * 4.5f / 6 ) + { + *pulseAudio = !(*pulseAudio); + } + if( y > VID_Y * 4.5 / 6 && y < VID_Y * 6 / 6 ) { okay = 1; } @@ -822,6 +826,9 @@ void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, i sprintf(buf, "Display number: %d", port); renderString(buf, VID_X/2, VID_Y * 3 / 6); + sprintf(buf, "PulseAudio: %s", *pulseAudio ? "Yes" : "No"); + renderString(buf, VID_X/2, VID_Y * 4 / 6); + sprintf(buf, "Okay"); renderString(buf, VID_X/2, VID_Y * 5 / 6); @@ -837,7 +844,7 @@ void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, i cfgfile = fopen(cfgpath, "w"); if( cfgfile ) { - fprintf(cfgfile, "%d %d %d %d %d %d %d\n", res, dpi, customX, customY, *builtinKeyboard, *ctrlAltShiftKeys, port); + fprintf(cfgfile, "%d %d %d %d %d %d %d %d\n", res, dpi, customX, customY, *builtinKeyboard, *ctrlAltShiftKeys, port, *pulseAudio); fclose(cfgfile); } } diff --git a/project/jni/application/xserver/gfx.h b/project/jni/application/xserver/gfx.h index 41e46e882..f2ecb7eae 100644 --- a/project/jni/application/xserver/gfx.h +++ b/project/jni/application/xserver/gfx.h @@ -6,7 +6,7 @@ enum { VID_X = 480, VID_Y = 320 }; void XSDL_initSDL(); void XSDL_deinitSDL(); void XSDL_unpackFiles(int freeSpaceRequiredMb); -void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, int * displayH, int * builtinKeyboard, int * ctrlAltShiftKeys, char * port); +void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, int * displayH, int * builtinKeyboard, int * ctrlAltShiftKeys, char * port, int * pulseAudio); void XSDL_generateBackground(const char * port, int showHelp, int resolutionW, int resolutionH); void XSDL_showServerLaunchErrorMessage(); diff --git a/project/jni/application/xserver/main.c b/project/jni/application/xserver/main.c index e639761a5..3bb117c92 100644 --- a/project/jni/application/xserver/main.c +++ b/project/jni/application/xserver/main.c @@ -61,6 +61,8 @@ int main( int argc, char* argv[] ) int displayW = atoi(getenv("DISPLAY_WIDTH_MM")); int displayH = atoi(getenv("DISPLAY_HEIGHT_MM")); + int pulseAudio = 1; + __android_log_print(ANDROID_LOG_INFO, "XSDL", "Actual video resolution %d/%dx%d/%d", resolutionW, displayW, resolutionH, displayH); setupEnv(); @@ -125,7 +127,7 @@ int main( int argc, char* argv[] ) if( !screenResOverride ) { - XSDL_showConfigMenu(&resolutionW, &displayW, &resolutionH, &displayH, &builtinKeyboard, &screenButtons, port); + XSDL_showConfigMenu(&resolutionW, &displayW, &resolutionH, &displayH, &builtinKeyboard, &screenButtons, port, &pulseAudio); sprintf( screenres, "%d/%dx%d/%dx%d", resolutionW, displayW, resolutionH, displayH, SDL_GetVideoInfo()->vfmt->BitsPerPixel == 24 ? 32 : SDL_GetVideoInfo()->vfmt->BitsPerPixel ); } @@ -177,7 +179,8 @@ int main( int argc, char* argv[] ) __android_log_print(ANDROID_LOG_INFO, "XSDL", "XSDL chdir to: %s", getenv("SECURE_STORAGE_DIR")); chdir( getenv("SECURE_STORAGE_DIR") ); // Megahack: change /proc/self/cwd to the X.org data dir, and use /proc/self/cwd path in libX11 - startPulseAudio(); + if( pulseAudio ) + startPulseAudio(); android_main( argnum, args, envp ); // Should never exit on success, if we want to terminate we kill ourselves diff --git a/project/jni/application/xserver/xserver b/project/jni/application/xserver/xserver index 56bee4b9c..eb7bca21a 160000 --- a/project/jni/application/xserver/xserver +++ b/project/jni/application/xserver/xserver @@ -1 +1 @@ -Subproject commit 56bee4b9c78a21359fb56d31a98fbf3f5f77c57d +Subproject commit eb7bca21ac02f81483e421d4908acac3d74db420