Conditionally compile audio support.

This commit is contained in:
Michael Jumper 2013-08-08 17:25:08 -07:00
parent 8c0e0e019b
commit 8e732ed2ab
3 changed files with 48 additions and 20 deletions

View File

@ -42,23 +42,30 @@ AM_CFLAGS = -Werror -Wall -pedantic -Iinclude @LIBGUAC_INCLUDE@
lib_LTLIBRARIES = libguac-client-vnc.la lib_LTLIBRARIES = libguac-client-vnc.la
libguac_client_vnc_la_SOURCES = \ libguac_client_vnc_la_SOURCES = \
src/client.c \ client.c \
src/vnc_handlers.c \ vnc_handlers.c \
src/guac_handlers.c \ guac_handlers.c \
src/pa_handlers.c \ convert.c
src/queue.c \
src/buffer.c \
src/convert.c
noinst_HEADERS = \ noinst_HEADERS = \
include/client.h \ client.h \
include/vnc_handlers.h \ vnc_handlers.h \
include/guac_handlers.h \ guac_handlers.h \
include/pa_handlers.h \ convert.h
include/queue.h \
include/buffer.h \
include/convert.h
libguac_client_vnc_la_LDFLAGS = -version-info 0:0:0 @VNC_LIBS@ @CAIRO_LIBS@ # 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
endif
libguac_client_vnc_la_LDFLAGS = -version-info 0:0:0 @VNC_LIBS@ @CAIRO_LIBS@ @PULSE_LIBS@
libguac_client_vnc_la_LIBADD = @LIBGUAC_LTLIB@ libguac_client_vnc_la_LIBADD = @LIBGUAC_LTLIB@

View File

@ -54,7 +54,10 @@
#include "client.h" #include "client.h"
#include "vnc_handlers.h" #include "vnc_handlers.h"
#include "guac_handlers.h" #include "guac_handlers.h"
#ifdef ENABLE_PULSE
#include "pa_handlers.h" #include "pa_handlers.h"
#endif
/* Client plugin arguments */ /* Client plugin arguments */
const char* GUAC_CLIENT_ARGS[] = { const char* GUAC_CLIENT_ARGS[] = {
@ -65,11 +68,16 @@ const char* GUAC_CLIENT_ARGS[] = {
"password", "password",
"swap-red-blue", "swap-red-blue",
"color-depth", "color-depth",
#ifdef ENABLE_VNC_REPEATER #ifdef ENABLE_VNC_REPEATER
"dest-host", "dest-host",
"dest-port", "dest-port",
#endif #endif
#ifdef ENABLE_PULSE
"disable-audio", "disable-audio",
#endif
NULL NULL
}; };
@ -82,10 +90,16 @@ enum VNC_ARGS_IDX {
IDX_PASSWORD, IDX_PASSWORD,
IDX_SWAP_RED_BLUE, IDX_SWAP_RED_BLUE,
IDX_COLOR_DEPTH, IDX_COLOR_DEPTH,
#ifdef ENABLE_VNC_REPEATER #ifdef ENABLE_VNC_REPEATER
IDX_DEST_HOST, IDX_DEST_HOST,
IDX_DEST_PORT, IDX_DEST_PORT,
#endif #endif
#ifdef ENABLE_PULSE
IDX_DISABLE_AUDIO,
#endif
VNC_ARGS_COUNT VNC_ARGS_COUNT
}; };
@ -155,11 +169,12 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
rfb_client->GetPassword = guac_vnc_get_password; rfb_client->GetPassword = guac_vnc_get_password;
/* Depth */ /* Depth */
guac_vnc_set_pixel_format(rfb_client, atoi(argv[6])); guac_vnc_set_pixel_format(rfb_client, atoi(argv[IDX_COLOR_DEPTH]));
guac_client_data->audio_enabled = (strcmp(argv[7], "true") != 0); #ifdef ENABLE_PULSE
guac_client_data->audio_enabled = (strcmp(argv[IDX_DISABLE_AUDIO], "true") != 0);
/* If audio enabled, choose an encoder */ /* If audio enabled, choose an encoder */
if (guac_client_data->audio_enabled) { if (guac_client_data->audio_enabled) {
/* Choose an encoding */ /* Choose an encoding */
@ -217,6 +232,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
guac_client_log_info(client, "No available audio encoding. Sound disabled."); guac_client_log_info(client, "No available audio encoding. Sound disabled.");
} /* end if audio enabled */ } /* end if audio enabled */
#endif
/* Hook into allocation so we can handle resize. */ /* Hook into allocation so we can handle resize. */
guac_client_data->rfb_MallocFrameBuffer = rfb_client->MallocFrameBuffer; guac_client_data->rfb_MallocFrameBuffer = rfb_client->MallocFrameBuffer;

View File

@ -47,7 +47,10 @@
#include "client.h" #include "client.h"
#include "convert.h" #include "convert.h"
#ifdef ENABLE_PULSE
#include "pa_handlers.h" #include "pa_handlers.h"
#endif
int vnc_guac_client_handle_messages(guac_client* client) { int vnc_guac_client_handle_messages(guac_client* client) {
@ -126,6 +129,7 @@ int vnc_guac_client_free_handler(guac_client* client) {
vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) client->data; vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) client->data;
rfbClient* rfb_client = guac_client_data->rfb_client; rfbClient* rfb_client = guac_client_data->rfb_client;
#ifdef ENABLE_PULSE
if (guac_client_data->audio_enabled) { if (guac_client_data->audio_enabled) {
/* Wait for audio read and send threads to join */ /* Wait for audio read and send threads to join */
@ -139,6 +143,7 @@ int vnc_guac_client_free_handler(guac_client* client) {
if(guac_client_data->audio_buffer) if(guac_client_data->audio_buffer)
guac_pa_buffer_free(guac_client_data->audio_buffer); guac_pa_buffer_free(guac_client_data->audio_buffer);
} }
#endif
/* Free encodings string, if used */ /* Free encodings string, if used */
if (guac_client_data->encodings != NULL) if (guac_client_data->encodings != NULL)