aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2012-07-12 15:55:22 -0700
committerandroid code review <noreply-gerritcodereview@google.com>2012-07-12 15:55:23 -0700
commit3dcbebfd43e409c3bbff7fc79288e40666a947fd (patch)
tree4338811f487cd81e377017016e3a1779bcd3a7e6
parenta593847491224cfab9eb94b1e36c85333dc081da (diff)
parent055adab0b70c70890634649a27c12b2c25afcaca (diff)
downloadexternal_qemu-3dcbebfd43e409c3bbff7fc79288e40666a947fd.zip
external_qemu-3dcbebfd43e409c3bbff7fc79288e40666a947fd.tar.gz
external_qemu-3dcbebfd43e409c3bbff7fc79288e40666a947fd.tar.bz2
Merge "Use a per-process server address for the GLES server"
-rw-r--r--android/hw-pipe-net.c11
-rw-r--r--android/opengles.c21
-rw-r--r--android/opengles.h10
3 files changed, 16 insertions, 26 deletions
diff --git a/android/hw-pipe-net.c b/android/hw-pipe-net.c
index 3e8dc70..1c71f18 100644
--- a/android/hw-pipe-net.c
+++ b/android/hw-pipe-net.c
@@ -492,19 +492,18 @@ openglesPipe_init( void* hwpipe, void* _looper, const char* args )
return NULL;
}
+ char server_addr[PATH_MAX];
+ android_gles_server_path(server_addr, sizeof(server_addr));
#ifndef _WIN32
if (android_gles_fast_pipes) {
- char unix_path[PATH_MAX];
- android_gles_unix_path(unix_path, sizeof(unix_path), ANDROID_OPENGLES_BASE_PORT);
- pipe = (NetPipe *)netPipe_initUnix(hwpipe, _looper, unix_path);
- D("Creating Unix OpenGLES pipe for GPU emulation: %s", unix_path);
+ pipe = (NetPipe *)netPipe_initUnix(hwpipe, _looper, server_addr);
+ D("Creating Unix OpenGLES pipe for GPU emulation: %s", server_addr);
} else {
#else /* _WIN32 */
{
#endif
/* Connect through TCP as a fallback */
- snprintf(temp, sizeof temp, "%d", ANDROID_OPENGLES_BASE_PORT);
- pipe = (NetPipe *)netPipe_initTcp(hwpipe, _looper, temp);
+ pipe = (NetPipe *)netPipe_initTcp(hwpipe, _looper, server_addr);
D("Creating TCP OpenGLES pipe for GPU emulation!");
}
if (pipe != NULL) {
diff --git a/android/opengles.c b/android/opengles.c
index 7405750..1fa6421 100644
--- a/android/opengles.c
+++ b/android/opengles.c
@@ -61,6 +61,7 @@ extern int android_init_opengles_pipes(void);
static ADynamicLibrary* rendererLib;
static int rendererStarted;
+static char rendererAddress[256];
/* Define the function pointers */
#define DYNLINK_FUNC(name) \
@@ -152,7 +153,7 @@ android_startOpenglesRenderer(int width, int height)
return 0;
}
- if (!initOpenGLRenderer(width, height, ANDROID_OPENGLES_BASE_PORT)) {
+ if (!initOpenGLRenderer(width, height, rendererAddress, sizeof(rendererAddress))) {
D("Can't start OpenGLES renderer?");
return -1;
}
@@ -177,7 +178,6 @@ static void strncpy_safe(char* dst, const char* src, size_t n)
static void extractBaseString(char* dst, const char* src, size_t dstSize)
{
- size_t len = strlen(src);
const char* begin = strchr(src, '(');
const char* end = strrchr(src, ')');
@@ -211,7 +211,7 @@ android_getOpenglesHardwareStrings(char* vendor, size_t vendorBufSize,
if (!rendererStarted) {
D("Can't get OpenGL ES hardware strings when renderer not started");
- vendor[0] = renderer[0] = version = '\0';
+ vendor[0] = renderer[0] = version[0] = '\0';
return;
}
@@ -274,18 +274,9 @@ android_redrawOpenglesWindow(void)
}
void
-android_gles_unix_path(char* buff, size_t buffsize, int port)
+android_gles_server_path(char* buff, size_t buffsize)
{
- const char* user = getenv("USER");
- char *p = buff, *end = buff + buffsize;
-
- /* The logic here must correspond to the one inside
- * development/tools/emulator/opengl/shared/libOpenglCodecCommon/UnixStream.cpp */
- p = bufprint(p, end, "/tmp/");
- if (user && user[0]) {
- p = bufprint(p, end, "android-%s/", user);
- }
- p = bufprint(p, end, "qemu-gles-%d", port);
+ strncpy_safe(buff, rendererAddress, buffsize);
}
#else // CONFIG_ANDROID_OPENGLES
@@ -330,7 +321,7 @@ int android_hideOpenglesWindow(void)
void android_redrawOpenglesWindow(void)
{}
-void android_gles_unix_path(char* buff, size_t buffsize, int port)
+void android_gles_server_path(char* buff, size_t buffsize)
{
buff[0] = '\0';
}
diff --git a/android/opengles.h b/android/opengles.h
index aac6249..6330287 100644
--- a/android/opengles.h
+++ b/android/opengles.h
@@ -14,8 +14,6 @@
#include <stddef.h>
-#define ANDROID_OPENGLES_BASE_PORT 22468
-
/* Call this function to initialize the hardware opengles emulation.
* This function will abort if we can't find the corresponding host
* libraries through dlopen() or equivalent.
@@ -59,8 +57,10 @@ void android_stopOpenglesRenderer(void);
*/
extern int android_gles_fast_pipes;
-/* Write the path of the Unix socket we're going to use to access GLES on a given <port> */
-/* The result is only valid on Unix systems */
-void android_gles_unix_path(char* buff, size_t buffsize, int port);
+/* Get the address of the socket that clients should connect to to access GLES.
+ * For TCP this is just the port number (as a string) on the loopback address.
+ * For UNIX and Win32 pipes it is the full pathname of the pipe.
+ */
+void android_gles_server_path(char* buff, size_t buffsize);
#endif /* ANDROID_OPENGLES_H */