summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2015-03-05 16:19:14 +0100
committerFrediano Ziglio <fziglio@redhat.com>2015-09-24 16:15:33 +0100
commit36a6aa0a12b7994cd78749311d49f63fcc05489f (patch)
tree6ee89a65716a38f9adf249a7ddfb69e8e6e8f1b8 /server
parent8497bbd18b25d91c53e2b2495585c007b98abd30 (diff)
audio: Remove global 'playback_state' variable
This variable belongs to SpiceServerConfig rather than being a static global variable hidden in sound.c
Diffstat (limited to 'server')
-rw-r--r--server/reds.c8
-rw-r--r--server/reds.h2
-rw-r--r--server/sound.c13
3 files changed, 17 insertions, 6 deletions
diff --git a/server/reds.c b/server/reds.c
index b4ccb0c9..69f4c46c 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -123,6 +123,7 @@ struct _SpiceServerConfig {
int 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;
@@ -624,6 +625,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;
@@ -3452,6 +3458,7 @@ SPICE_GNUC_VISIBLE SpiceServer *spice_server_new(void)
reds->config->ticketing_enabled = TRUE; /* ticketing enabled by default */
reds->config->streaming_video = 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;
@@ -3806,6 +3813,7 @@ uint32_t reds_get_streaming_video(RedsState *reds)
SPICE_GNUC_VISIBLE int spice_server_set_playback_compression(SpiceServer *s, int enable)
{
+ s->config->playback_compression = !!enable;
snd_set_playback_compression(enable);
return 0;
}
diff --git a/server/reds.h b/server/reds.h
index 0025bf26..af00ac2f 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -63,6 +63,8 @@ void reds_unregister_channel(RedsState *reds, RedChannel *channel);
int reds_get_mouse_mode(RedsState *reds); // used by inputs_channel
int reds_config_get_agent_mouse(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 34e1fd07..93c75fe1 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -179,7 +179,6 @@ typedef struct RecordChannel {
} RecordChannel;
static SndWorker *workers;
-static uint32_t playback_compression = TRUE;
static void snd_receive(void* data);
@@ -1156,7 +1155,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) {
@@ -1621,8 +1623,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) {
@@ -1632,7 +1632,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);