From 2a18630718e4e82cd50e092d90e82cf4d4e2ce1b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 8 Aug 2013 18:43:03 -0700 Subject: [PATCH] Move files to proper location. Get rid of unnecessary lock. Remove wrongly-committed file. --- protocols/vnc/.travis.yml | 54 -------------- src/protocols/vnc/Makefile.am | 23 +++--- .../vnc/src => src/protocols/vnc}/buffer.c | 0 .../include => src/protocols/vnc}/buffer.h | 0 src/protocols/vnc/client.c | 73 ++++++++----------- src/protocols/vnc/client.h | 2 +- .../src => src/protocols/vnc}/pa_handlers.c | 0 .../protocols/vnc}/pa_handlers.h | 0 .../vnc/src => src/protocols/vnc}/queue.c | 0 .../vnc/include => src/protocols/vnc}/queue.h | 0 src/protocols/vnc/vnc_handlers.c | 25 ------- 11 files changed, 41 insertions(+), 136 deletions(-) delete mode 100644 protocols/vnc/.travis.yml rename {protocols/vnc/src => src/protocols/vnc}/buffer.c (100%) rename {protocols/vnc/include => src/protocols/vnc}/buffer.h (100%) rename {protocols/vnc/src => src/protocols/vnc}/pa_handlers.c (100%) rename {protocols/vnc/include => src/protocols/vnc}/pa_handlers.h (100%) rename {protocols/vnc/src => src/protocols/vnc}/queue.c (100%) rename {protocols/vnc/include => src/protocols/vnc}/queue.h (100%) diff --git a/protocols/vnc/.travis.yml b/protocols/vnc/.travis.yml deleted file mode 100644 index 834ad91d..00000000 --- a/protocols/vnc/.travis.yml +++ /dev/null @@ -1,54 +0,0 @@ -# Set environment variables -env: - global: - - secure: "eNufz0915oMHd4cNbvo+YysNgJSP3IFrsWPFkVtg2S/L3hCv9+sTto/yuX00\nHvaJ1lcvak2DkiQmslJubcjpGNOysjp6rjhY92YodZs+wZwsrevjoanj9qWH\nwHz2eM1N6fvebMmzNS9fwwFmY3DiCDwBoTssz8aLs0etg+2xVBw=" - - matrix: - - secure: "eNufz0915oMHd4cNbvo+YysNgJSP3IFrsWPFkVtg2S/L3hCv9+sTto/yuX00\nHvaJ1lcvak2DkiQmslJubcjpGNOysjp6rjhY92YodZs+wZwsrevjoanj9qWH\nwHz2eM1N6fvebMmzNS9fwwFmY3DiCDwBoTssz8aLs0etg+2xVBw=" - -# use c and gcc -language: c -compiler: gcc - -# install all vnc-related dependencies -before_install: - - sudo apt-get install tomcat6 - - sudo apt-get install libvncserver0 - - sudo apt-get install libvncserver-dev - - sudo apt-get install libfreerdp1 - - sudo apt-get install libvorbis-dev - - sudo apt-get install libvorbisenc2 - - sudo apt-get install libpulse-dev - - sudo apt-get install libcairo2-dev - - git clone git://github.com/cmujedi/libguac.git - - cd libguac - - autoreconf -i - - ./configure - - make - - sudo make install - - sudo ldconfig - - cd .. - -# before build script, run autoreconf -before_script: autoreconf -i - -# Default is "./configure && make && make test", but no tests yet -script: "./configure && make" - -# after build script, run make install -after_success: - - sudo make install - - curl -s -o output.txt $IRC_TREELOGIC_CHANNEL_TOKEN -d "service=TravisCI" -d "message=$TRAVIS_REPO_SLUG $TRAVIS_BUILD_NUMBER ( $TRAVIS_BRANCH - $TRAVIS_COMMIT ) - Passed" -d "url=https://grove.io/app" -d "icon_url=https://secure.travis-ci.org/$TRAVIS_REPO_SLUG.png" - - -# after build script, run make install -after_failure: - - curl -s -o output.txt $IRC_TREELOGIC_CHANNEL_TOKEN -d "service=TravisCI" -d "message=$TRAVIS_REPO_SLUG $TRAVIS_BUILD_NUMBER ( $TRAVIS_BRANCH - $TRAVIS_COMMIT ) - Failed" -d "url=https://grove.io/app" -d "icon_url=https://secure.travis-ci.org/$TRAVIS_REPO_SLUG.png" - -# add notification email addresses -notifications: - email: - recipients: - - cmujedi@west.cmu.edu - webhooks: - - secure: "eNufz0915oMHd4cNbvo+YysNgJSP3IFrsWPFkVtg2S/L3hCv9+sTto/yuX00\nHvaJ1lcvak2DkiQmslJubcjpGNOysjp6rjhY92YodZs+wZwsrevjoanj9qWH\nwHz2eM1N6fvebMmzNS9fwwFmY3DiCDwBoTssz8aLs0etg+2xVBw=" \ No newline at end of file diff --git a/src/protocols/vnc/Makefile.am b/src/protocols/vnc/Makefile.am index f1f68301..9b7fa9d1 100644 --- a/src/protocols/vnc/Makefile.am +++ b/src/protocols/vnc/Makefile.am @@ -42,28 +42,25 @@ AM_CFLAGS = -Werror -Wall -pedantic -Iinclude @LIBGUAC_INCLUDE@ lib_LTLIBRARIES = libguac-client-vnc.la libguac_client_vnc_la_SOURCES = \ + buffer.c \ client.c \ - vnc_handlers.c \ + convert.c \ guac_handlers.c \ - convert.c + queue.c \ + vnc_handlers.c noinst_HEADERS = \ + buffer.h \ client.h \ - vnc_handlers.h \ + convert.h \ guac_handlers.h \ - convert.h + queue.h \ + vnc_handlers.h # Optional PulseAudio support if ENABLE_PULSE -libguac_client_vnc_la_SOURCES += \ - pa_handlers.c \ - queue.c \ - buffer.c - -noinst_HEADERS += \ - pa_handlers.h \ - queue.h \ - buffer.h +libguac_client_vnc_la_SOURCES += pa_handlers.c +noinst_HEADERS += pa_handlers.h endif libguac_client_vnc_la_LDFLAGS = -version-info 0:0:0 @VNC_LIBS@ @CAIRO_LIBS@ @PULSE_LIBS@ diff --git a/protocols/vnc/src/buffer.c b/src/protocols/vnc/buffer.c similarity index 100% rename from protocols/vnc/src/buffer.c rename to src/protocols/vnc/buffer.c diff --git a/protocols/vnc/include/buffer.h b/src/protocols/vnc/buffer.h similarity index 100% rename from protocols/vnc/include/buffer.h rename to src/protocols/vnc/buffer.h diff --git a/src/protocols/vnc/client.c b/src/protocols/vnc/client.c index a0404ac0..3d8a31a2 100644 --- a/src/protocols/vnc/client.c +++ b/src/protocols/vnc/client.c @@ -44,12 +44,7 @@ #include #include #include - #include -#include -#ifdef ENABLE_OGG -#include -#endif #include "client.h" #include "vnc_handlers.h" @@ -111,13 +106,13 @@ int guac_client_init(guac_client* client, int argc, char** argv) { rfbClient* rfb_client; vnc_guac_client_data* guac_client_data; - + +#ifdef ENABLE_PULSE audio_args* args; - pthread_t pa_read_thread, pa_send_thread; +#endif int read_only; - int i; /* Set up libvncclient logging */ rfbClientLog = guac_vnc_client_log_info; @@ -173,37 +168,19 @@ int guac_client_init(guac_client* client, int argc, char** argv) { #ifdef ENABLE_PULSE guac_client_data->audio_enabled = (strcmp(argv[IDX_DISABLE_AUDIO], "true") != 0); - - /* If audio enabled, choose an encoder */ - if (guac_client_data->audio_enabled) { - - /* Choose an encoding */ - for (i=0; client->info.audio_mimetypes[i] != NULL; i++) { - - const char* mimetype = client->info.audio_mimetypes[i]; - -#ifdef ENABLE_OGG - /* If Ogg is supported, done. */ - if (strcmp(mimetype, ogg_encoder->mimetype) == 0) { - guac_client_log_info(client, "Loading Ogg Vorbis encoder."); - guac_client_data->audio = audio_stream_alloc(client, - ogg_encoder); - break; - } -#endif - - /* If wav is supported, done. */ - if (strcmp(mimetype, wav_encoder->mimetype) == 0) { - guac_client_log_info(client, "Loading wav encoder."); - guac_client_data->audio = audio_stream_alloc(client, - wav_encoder); - break; - } - } - - /* If an encoding is available, load the sound plugin */ + + /* If an encoding is available, load an audio stream */ + if (guac_client_data->audio_enabled) { + + guac_client_data->audio = guac_audio_stream_alloc(client, NULL); + + /* If successful, init audio system */ if (guac_client_data->audio != NULL) { + guac_client_log_info(client, + "Audio will be encoded as %s", + guac_client_data->audio->encoder->mimetype); + guac_client_data->audio_buffer = guac_pa_buffer_alloc(); args = malloc(sizeof(audio_args)); @@ -211,8 +188,10 @@ int guac_client_init(guac_client* client, int argc, char** argv) { args->audio_buffer = guac_client_data->audio_buffer; /* Create a thread to read audio data */ - if (pthread_create(&pa_read_thread, NULL, guac_pa_read_audio, (void*) args)) { - guac_protocol_send_error(client->socket, "Error initializing PulseAudio thread"); + if (pthread_create(&pa_read_thread, NULL, guac_pa_read_audio, + (void*) args)) { + guac_protocol_send_error(client->socket, + "Error initializing PulseAudio thread"); guac_socket_flush(client->socket); return 1; } @@ -220,17 +199,25 @@ int guac_client_init(guac_client* client, int argc, char** argv) { guac_client_data->audio_read_thread = &pa_read_thread; /* Create a thread to send audio data */ - if (pthread_create(&pa_send_thread, NULL, guac_pa_send_audio, (void*) args)) { - guac_protocol_send_error(client->socket, "Error initializing PulseAudio thread"); + if (pthread_create(&pa_send_thread, NULL, guac_pa_send_audio, + (void*) args)) { + guac_protocol_send_error(client->socket, + "Error initializing PulseAudio thread"); guac_socket_flush(client->socket); return 1; } guac_client_data->audio_send_thread = &pa_send_thread; } + + /* Otherwise, audio loading failed */ else - guac_client_log_info(client, "No available audio encoding. Sound disabled."); - + guac_client_log_info(client, + "No available audio encoding. Sound disabled."); + + /* Require threadsafe sockets if audio enabled */ + guac_socket_require_threadsafe(client->socket); + } /* end if audio enabled */ #endif diff --git a/src/protocols/vnc/client.h b/src/protocols/vnc/client.h index 1cdb0dbe..74bdcb4d 100644 --- a/src/protocols/vnc/client.h +++ b/src/protocols/vnc/client.h @@ -66,7 +66,7 @@ typedef struct vnc_guac_client_data { /** * Audio output, if any. */ - audio_stream* audio; + guac_audio_stream* audio; /** * Audio buffer, if any. diff --git a/protocols/vnc/src/pa_handlers.c b/src/protocols/vnc/pa_handlers.c similarity index 100% rename from protocols/vnc/src/pa_handlers.c rename to src/protocols/vnc/pa_handlers.c diff --git a/protocols/vnc/include/pa_handlers.h b/src/protocols/vnc/pa_handlers.h similarity index 100% rename from protocols/vnc/include/pa_handlers.h rename to src/protocols/vnc/pa_handlers.h diff --git a/protocols/vnc/src/queue.c b/src/protocols/vnc/queue.c similarity index 100% rename from protocols/vnc/src/queue.c rename to src/protocols/vnc/queue.c diff --git a/protocols/vnc/include/queue.h b/src/protocols/vnc/queue.h similarity index 100% rename from protocols/vnc/include/queue.h rename to src/protocols/vnc/queue.h diff --git a/src/protocols/vnc/vnc_handlers.c b/src/protocols/vnc/vnc_handlers.c index cbf0681b..d4e217e8 100644 --- a/src/protocols/vnc/vnc_handlers.c +++ b/src/protocols/vnc/vnc_handlers.c @@ -39,7 +39,6 @@ #include #include #include -#include #include @@ -134,20 +133,12 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { /* Send cursor data*/ surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, w, h, stride); - pthread_mutex_lock(&(gc->send_lock)); - guac_protocol_send_png(socket, GUAC_COMP_SRC, cursor_layer, 0, 0, surface); - pthread_mutex_unlock(&(gc->send_lock)); - - pthread_mutex_lock(&(gc->send_lock)); - /* Update cursor */ guac_protocol_send_cursor(socket, x, y, cursor_layer, 0, 0, w, h); - pthread_mutex_unlock(&(gc->send_lock)); - /* Free surface */ cairo_surface_destroy(surface); free(buffer); @@ -242,12 +233,8 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { /* For now, only use default layer */ surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride); - pthread_mutex_lock(&(gc->send_lock)); - guac_protocol_send_png(socket, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, x, y, surface); - pthread_mutex_unlock(&(gc->send_lock)); - /* Free surface */ cairo_surface_destroy(surface); free(buffer); @@ -259,15 +246,11 @@ void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, in guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); guac_socket* socket = gc->socket; - pthread_mutex_lock(&(gc->send_lock)); - /* For now, only use default layer */ guac_protocol_send_copy(socket, GUAC_DEFAULT_LAYER, src_x, src_y, w, h, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, dest_x, dest_y); - pthread_mutex_unlock(&(gc->send_lock)); - ((vnc_guac_client_data*) gc->data)->copy_rect_used = 1; } @@ -320,14 +303,10 @@ rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { guac_client* gc = rfbClientGetClientData(rfb_client, __GUAC_CLIENT); vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data; - pthread_mutex_lock(&(gc->send_lock)); - /* Send new size */ guac_protocol_send_size(gc->socket, GUAC_DEFAULT_LAYER, rfb_client->width, rfb_client->height); - pthread_mutex_unlock(&(gc->send_lock)); - /* Use original, wrapped proc */ return guac_client_data->rfb_MallocFrameBuffer(rfb_client); } @@ -340,12 +319,8 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { /* Convert ASCII character data to UTF-8 */ char* utf8_text = convert("ISO_8859-1", "UTF-8", text); - pthread_mutex_lock(&(gc->send_lock)); - guac_protocol_send_clipboard(socket, utf8_text); - pthread_mutex_unlock(&(gc->send_lock)); - free(utf8_text); }