[WIP]: [SOUND] Implement sound playback.

This commit is contained in:
Virtually Nick 2022-07-04 11:54:46 -04:00
parent 36bb5a0dba
commit 6fbc713358
3 changed files with 30 additions and 1 deletions

View File

@ -20,7 +20,9 @@
#include "config.h"
#include "audio.h"
#include "spice.h"
#include <guacamole/audio.h>
#include <guacamole/client.h>
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);
}
@ -51,6 +70,10 @@ void guac_spice_client_audio_playback_stop_handler(
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);
}
void guac_spice_client_audio_record_start_handler(SpiceRecordChannel* channel,

View File

@ -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.

View File

@ -29,6 +29,7 @@
#include "keyboard.h"
#include "settings.h"
#include <guacamole/audio.h>
#include <guacamole/client.h>
#include <guacamole/layer.h>
#include <guacamole/recording.h>
@ -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;
/**