aboutsummaryrefslogtreecommitdiffstats
path: root/android/hw-pipe-net.c
diff options
context:
space:
mode:
Diffstat (limited to 'android/hw-pipe-net.c')
-rw-r--r--android/hw-pipe-net.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/android/hw-pipe-net.c b/android/hw-pipe-net.c
index 2a09718..8b8017d 100644
--- a/android/hw-pipe-net.c
+++ b/android/hw-pipe-net.c
@@ -23,6 +23,7 @@
#include "android/utils/panic.h"
#include "android/utils/system.h"
#include "android/async-utils.h"
+#include "android/opengles.h"
#include "android/looper.h"
#include "hw/goldfish_pipe.h"
@@ -454,7 +455,11 @@ static const GoldfishPipeFuncs netPipeUnix_funcs = {
};
#endif
-#define DEFAULT_OPENGLES_PORT 22468
+/* This is set to 1 in android_init_opengles() below, and tested
+ * by openglesPipe_init() to refuse a pipe connection if the function
+ * was never called.
+ */
+static int _opengles_init;
static void*
openglesPipe_init( void* hwpipe, void* _looper, const char* args )
@@ -462,25 +467,34 @@ openglesPipe_init( void* hwpipe, void* _looper, const char* args )
char temp[32];
NetPipe *pipe;
+ if (!_opengles_init) {
+ /* This should never happen, unless there is a bug in the
+ * emulator's initialization, or the system image. */
+ D("Trying to open the OpenGLES pipe without GPU emulation!");
+ return NULL;
+ }
+
/* For now, simply connect through tcp */
- snprintf(temp, sizeof temp, "%d", DEFAULT_OPENGLES_PORT);
+ snprintf(temp, sizeof temp, "%d", ANDROID_OPENGLES_BASE_PORT);
pipe = (NetPipe *)netPipe_initTcp(hwpipe, _looper, temp);
- // Disable TCP nagle algorithm to improve throughput of small packets
- socket_set_nodelay(pipe->io->fd);
+ if (pipe != NULL) {
+ // Disable TCP nagle algorithm to improve throughput of small packets
+ socket_set_nodelay(pipe->io->fd);
// On Win32, adjust buffer sizes
#ifdef _WIN32
- {
- int sndbuf = 128 * 1024;
- int len = sizeof(sndbuf);
- if (setsockopt(pipe->io->fd, SOL_SOCKET, SO_SNDBUF,
- (char*)&sndbuf, len) == SOCKET_ERROR) {
- D("Failed to set SO_SNDBUF to %d error=0x%x\n",
- sndbuf, WSAGetLastError());
+ {
+ int sndbuf = 128 * 1024;
+ int len = sizeof(sndbuf);
+ if (setsockopt(pipe->io->fd, SOL_SOCKET, SO_SNDBUF,
+ (char*)&sndbuf, len) == SOCKET_ERROR) {
+ D("Failed to set SO_SNDBUF to %d error=0x%x\n",
+ sndbuf, WSAGetLastError());
+ }
}
- }
#endif /* _WIN32 */
+ }
return pipe;
}
@@ -494,7 +508,6 @@ static const GoldfishPipeFuncs openglesPipe_funcs = {
netPipe_wakeOn,
};
-
void
android_net_pipes_init(void)
{
@@ -506,3 +519,13 @@ android_net_pipes_init(void)
#endif
goldfish_pipe_add_type( "opengles", looper, &openglesPipe_funcs );
}
+
+int
+android_init_opengles_pipes(void)
+{
+ /* TODO: Check that we can load and initialize the host emulation
+ * libraries, and return -1 in case of error.
+ */
+ _opengles_init = 1;
+ return 0;
+}