[Spice-devel] [PATCH 16/16] audio: Remove global 'playback_state' variable
Jonathon Jongsma
jjongsma at redhat.com
Tue Apr 19 16:00:10 UTC 2016
From: Christophe Fergeau <cfergeau at redhat.com>
This variable belongs to SpiceServerConfig rather than being a static
global variable hidden in sound.c
---
server/reds.c | 8 ++++++++
server/reds.h | 2 ++
server/sound.c | 13 +++++++------
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/server/reds.c b/server/reds.c
index 337d90b..60d8903 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -177,6 +177,7 @@ struct SpiceServerConfig {
gboolean ticketing_enabled;
uint32_t streaming_video;
SpiceImageCompression image_compression;
+ uint32_t playback_compression;
spice_wan_compression_t jpeg_state;
spice_wan_compression_t zlib_glz_state;
@@ -677,6 +678,11 @@ static void reds_mig_disconnect(RedsState *reds)
}
}
+int reds_config_get_playback_compression(RedsState *reds)
+{
+ return reds->config->playback_compression;
+}
+
int reds_get_mouse_mode(RedsState *reds)
{
return reds->mouse_mode;
@@ -3534,6 +3540,7 @@ SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
reds->config->ticketing_enabled = TRUE; /* ticketing enabled by default */
reds->config->streaming_video = SPICE_STREAM_VIDEO_FILTER;
reds->config->image_compression = SPICE_IMAGE_COMPRESSION_AUTO_GLZ;
+ reds->config->playback_compression = TRUE;
reds->config->jpeg_state = SPICE_WAN_COMPRESSION_AUTO;
reds->config->zlib_glz_state = SPICE_WAN_COMPRESSION_AUTO;
reds->config->agent_mouse = TRUE;
@@ -3892,6 +3899,7 @@ uint32_t reds_get_streaming_video(const RedsState *reds)
SPICE_GNUC_VISIBLE int spice_server_set_playback_compression(SpiceServer *reds, int enable)
{
+ reds->config->playback_compression = !!enable;
snd_set_playback_compression(enable);
return 0;
}
diff --git a/server/reds.h b/server/reds.h
index 9de506f..fbf7372 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -60,6 +60,8 @@ void reds_unregister_channel(RedsState *reds, RedChannel *channel);
int reds_get_mouse_mode(RedsState *reds); // used by inputs_channel
gboolean reds_config_get_agent_mouse(const RedsState *reds); // used by inputs_channel
int reds_has_vdagent(RedsState *reds); // used by inputs channel
+int reds_config_get_playback_compression(RedsState *reds); // used by playback channel
+
void reds_handle_agent_mouse_event(RedsState *reds, const VDAgentMouseState *mouse_state); // used by inputs_channel
GArray* reds_get_renderers(RedsState *reds);
diff --git a/server/sound.c b/server/sound.c
index 453e42a..b95e7e7 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -183,7 +183,6 @@ typedef struct RecordChannel {
/* A list of all Spice{Playback,Record}State objects */
static SndWorker *workers;
-static uint32_t playback_compression = TRUE;
static void snd_receive(SndChannel *channel);
@@ -1157,7 +1156,8 @@ void snd_set_playback_latency(RedClient *client, uint32_t latency)
}
}
-static int snd_desired_audio_mode(int frequency, int client_can_celt, int client_can_opus)
+static int snd_desired_audio_mode(int playback_compression, int frequency,
+ int client_can_celt, int client_can_opus)
{
if (! playback_compression)
return SPICE_AUDIO_DATA_MODE_RAW;
@@ -1236,7 +1236,9 @@ static void snd_set_playback_peer(RedChannel *channel, RedClient *client, RedsSt
SPICE_PLAYBACK_CAP_CELT_0_5_1);
int client_can_opus = red_channel_client_test_remote_cap(playback_channel->base.channel_client,
SPICE_PLAYBACK_CAP_OPUS);
- int desired_mode = snd_desired_audio_mode(st->frequency, client_can_celt, client_can_opus);
+ int playback_compression = reds_config_get_playback_compression(channel->reds);
+ int desired_mode = snd_desired_audio_mode(playback_compression, st->frequency,
+ client_can_celt, client_can_opus);
playback_channel->mode = SPICE_AUDIO_DATA_MODE_RAW;
if (desired_mode != SPICE_AUDIO_DATA_MODE_RAW) {
if (snd_codec_create(&playback_channel->codec, desired_mode, st->frequency, SND_CODEC_ENCODE) == SND_CODEC_OK) {
@@ -1617,8 +1619,6 @@ void snd_set_playback_compression(int on)
{
SndWorker *now = workers;
- playback_compression = !!on;
-
for (; now; now = now->next) {
g_critical("untested code path");
if (now->base_channel->type == SPICE_CHANNEL_PLAYBACK && now->connection) {
@@ -1628,7 +1628,8 @@ void snd_set_playback_compression(int on)
SPICE_PLAYBACK_CAP_CELT_0_5_1);
int client_can_opus = red_channel_client_test_remote_cap(playback->base.channel_client,
SPICE_PLAYBACK_CAP_OPUS);
- int desired_mode = snd_desired_audio_mode(st->frequency, client_can_opus, client_can_celt);
+ int desired_mode = snd_desired_audio_mode(on, st->frequency,
+ client_can_opus, client_can_celt);
if (playback->mode != desired_mode) {
playback->mode = desired_mode;
snd_set_command(now->connection, SND_PLAYBACK_MODE_MASK);
--
2.4.11
More information about the Spice-devel
mailing list