diff --git a/src/protocols/spice/channels/audio.c b/src/protocols/spice/channels/audio.c index 425275f2..ecabac10 100644 --- a/src/protocols/spice/channels/audio.c +++ b/src/protocols/spice/channels/audio.c @@ -20,7 +20,9 @@ #include "config.h" #include "audio.h" +#include "spice.h" +#include #include void guac_spice_client_audio_playback_data_handler( @@ -28,6 +30,9 @@ void guac_spice_client_audio_playback_data_handler( guac_client* client) { guac_client_log(client, GUAC_LOG_DEBUG, "Calling audio playback data handler."); + guac_spice_client* spice_client = (guac_spice_client*) client->data; + + guac_audio_stream_write_pcm(spice_client->audio_playback, data, size); } @@ -43,6 +48,20 @@ void guac_spice_client_audio_playback_start_handler( guac_client* client) { guac_client_log(client, GUAC_LOG_DEBUG, "Calling audio playback start handler."); + guac_client_log(client, GUAC_LOG_DEBUG, "Format: %d", format); + guac_client_log(client, GUAC_LOG_DEBUG, "Channels: %d", channels); + guac_client_log(client, GUAC_LOG_DEBUG, "Rate: %d", rate); + + guac_spice_client* spice_client = (guac_spice_client*) client->data; + + int bps = 16; + + if (format != SPICE_AUDIO_FMT_S16) { + guac_client_log(client, GUAC_LOG_WARNING, "Unknown Spice audio format: %d", format); + return; + } + + spice_client->audio_playback = guac_audio_stream_alloc(client, NULL, rate, channels, bps); } @@ -50,6 +69,10 @@ void guac_spice_client_audio_playback_stop_handler( SpicePlaybackChannel* channel, guac_client* client) { guac_client_log(client, GUAC_LOG_DEBUG, "Calling audio playback stop handler."); + + guac_spice_client* spice_client = (guac_spice_client*) client->data; + + guac_audio_stream_free(spice_client->audio_playback); } diff --git a/src/protocols/spice/spice-constants.h b/src/protocols/spice/spice-constants.h index 92d02839..88c7780c 100644 --- a/src/protocols/spice/spice-constants.h +++ b/src/protocols/spice/spice-constants.h @@ -333,7 +333,7 @@ * A signal sent when the server is notifying the client that audio playback * should begin, which also contains characteristics of that audio data. */ -#define SPICE_SIGNAL_PLAYBACK_START "plaback-start" +#define SPICE_SIGNAL_PLAYBACK_START "playback-start" /** * A signal sent when audio playback should cease. diff --git a/src/protocols/spice/spice.h b/src/protocols/spice/spice.h index 25e3e333..0d920f2f 100644 --- a/src/protocols/spice/spice.h +++ b/src/protocols/spice/spice.h @@ -29,6 +29,7 @@ #include "keyboard.h" #include "settings.h" +#include #include #include #include @@ -155,6 +156,11 @@ typedef struct guac_spice_client { */ pthread_mutex_t message_lock; + /** + * Audio output, if any. + */ + guac_audio_stream* audio_playback; + } guac_spice_client; /**