summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2015-02-11 11:38:57 -0600
committerFabiano FidĂȘncio <fidencio@redhat.com>2015-02-23 23:00:46 +0100
commit23d60783ddb060a5a452ff2fd45e2f5601a06ded (patch)
tree9b82a88d74477e47d717e1920066a8821d34d085
parentc359443e0ca23a5d3f36a0b9d0ebe451938e2e2b (diff)
downloadspice-23d60783ddb060a5a452ff2fd45e2f5601a06ded.tar.gz
spice-23d60783ddb060a5a452ff2fd45e2f5601a06ded.tar.xz
spice-23d60783ddb060a5a452ff2fd45e2f5601a06ded.zip
Remove use of global 'reds' from sound.c
Pass RedsState variable to snd_attach_(playback|record) and get a reference to this variable when needed by various functions.
-rw-r--r--server/reds.c4
-rw-r--r--server/sound.c20
-rw-r--r--server/sound.h4
3 files changed, 22 insertions, 6 deletions
diff --git a/server/reds.c b/server/reds.c
index bd8e6c2c..6c97a55b 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3120,7 +3120,7 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
spice_warning("unsupported playback interface");
return -1;
}
- snd_attach_playback(SPICE_CONTAINEROF(sin, SpicePlaybackInstance, base));
+ snd_attach_playback(s, SPICE_CONTAINEROF(sin, SpicePlaybackInstance, base));
} else if (strcmp(interface->type, SPICE_INTERFACE_RECORD) == 0) {
spice_info("SPICE_INTERFACE_RECORD");
@@ -3129,7 +3129,7 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
spice_warning("unsupported record interface");
return -1;
}
- snd_attach_record(SPICE_CONTAINEROF(sin, SpiceRecordInstance, base));
+ snd_attach_record(s, SPICE_CONTAINEROF(sin, SpiceRecordInstance, base));
} else if (strcmp(interface->type, SPICE_INTERFACE_CHAR_DEVICE) == 0) {
if (interface->major_version != SPICE_INTERFACE_CHAR_DEVICE_MAJOR ||
diff --git a/server/sound.c b/server/sound.c
index f44eb479..8622ab42 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -199,14 +199,22 @@ static SndChannel *snd_channel_put(SndChannel *channel)
return channel;
}
+static RedsState* snd_channel_get_server(SndChannel *channel)
+{
+ g_return_val_if_fail(channel != NULL, NULL);
+ return red_channel_get_server(channel->worker->base_channel);
+}
+
static void snd_disconnect_channel(SndChannel *channel)
{
SndWorker *worker;
+ RedsState *reds;
if (!channel || !channel->stream) {
spice_debug("not connected");
return;
}
+ reds = snd_channel_get_server(channel);
spice_debug("SndChannel=%p rcc=%p type=%d",
channel, channel->channel_client, channel->channel_client->channel->type);
worker = channel->worker;
@@ -247,6 +255,7 @@ static void snd_record_on_message_done(SndChannel *channel)
static int snd_send_data(SndChannel *channel)
{
+ RedsState *reds = snd_channel_get_server(channel);
uint32_t n;
if (!channel) {
@@ -900,6 +909,7 @@ static SndChannel *__new_channel(SndWorker *worker, int size, uint32_t channel_i
#endif
int tos;
MainChannelClient *mcc = red_client_get_main(client);
+ RedsState *reds = red_channel_get_server(worker->base_channel);
spice_assert(stream);
if ((flags = fcntl(stream->socket, F_GETFL)) == -1) {
@@ -1036,6 +1046,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_start(SpicePlaybackInstance *sin)
{
SndChannel *channel = sin->st->worker.connection;
PlaybackChannel *playback_channel = SPICE_CONTAINEROF(channel, PlaybackChannel, base);
+ RedsState *reds = snd_channel_get_server(channel);
sin->st->worker.active = 1;
if (!channel)
@@ -1055,6 +1066,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_stop(SpicePlaybackInstance *sin)
{
SndChannel *channel = sin->st->worker.connection;
PlaybackChannel *playback_channel = SPICE_CONTAINEROF(channel, PlaybackChannel, base);
+ RedsState *reds = snd_channel_get_server(channel);
sin->st->worker.active = 0;
if (!channel)
@@ -1160,6 +1172,7 @@ static int snd_desired_audio_mode(int frequency, int client_can_celt, int client
static void on_new_playback_channel(SndWorker *worker)
{
+ RedsState *reds = red_channel_get_server(worker->base_channel);
PlaybackChannel *playback_channel =
SPICE_CONTAINEROF(worker->connection, PlaybackChannel, base);
SpicePlaybackState *st = SPICE_CONTAINEROF(worker, SpicePlaybackState, worker);
@@ -1180,6 +1193,7 @@ static void on_new_playback_channel(SndWorker *worker)
static void snd_playback_cleanup(SndChannel *channel)
{
+ RedsState *reds = snd_channel_get_server(channel);
PlaybackChannel *playback_channel = SPICE_CONTAINEROF(channel, PlaybackChannel, base);
if (playback_channel->base.active) {
@@ -1503,7 +1517,7 @@ static void remove_worker(SndWorker *worker)
spice_printerr("not found");
}
-void snd_attach_playback(SpicePlaybackInstance *sin)
+void snd_attach_playback(RedsState *reds, SpicePlaybackInstance *sin)
{
SndWorker *playback_worker;
RedChannel *channel;
@@ -1534,7 +1548,7 @@ void snd_attach_playback(SpicePlaybackInstance *sin)
reds_register_channel(reds, playback_worker->base_channel);
}
-void snd_attach_record(SpiceRecordInstance *sin)
+void snd_attach_record(RedsState *reds, SpiceRecordInstance *sin)
{
SndWorker *record_worker;
RedChannel *channel;
@@ -1568,6 +1582,8 @@ static void snd_detach_common(SndWorker *worker)
if (!worker) {
return;
}
+ RedsState *reds = red_channel_get_server(worker->base_channel);
+
remove_worker(worker);
snd_disconnect_channel(worker->connection);
reds_unregister_channel(reds, worker->base_channel);
diff --git a/server/sound.h b/server/sound.h
index 8de746de..80bee558 100644
--- a/server/sound.h
+++ b/server/sound.h
@@ -20,10 +20,10 @@
#include "spice.h"
-void snd_attach_playback(SpicePlaybackInstance *sin);
+void snd_attach_playback(RedsState *reds, SpicePlaybackInstance *sin);
void snd_detach_playback(SpicePlaybackInstance *sin);
-void snd_attach_record(SpiceRecordInstance *sin);
+void snd_attach_record(RedsState *reds, SpiceRecordInstance *sin);
void snd_detach_record(SpiceRecordInstance *sin);
void snd_set_playback_compression(int on);