[Spice-commits] 6 commits - server/sound.c
Jonathon Jongsma
jjongsma at kemper.freedesktop.org
Tue May 2 15:10:48 UTC 2017
server/sound.c | 199 ++++++++++++++++++++++++---------------------------------
1 file changed, 86 insertions(+), 113 deletions(-)
New commits:
commit 3d84e1559f1eea0fbfa133b50cf56b1f25a96623
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date: Thu Apr 20 11:26:37 2017 -0500
sound: don't store client in SndChannel
The base RedChannel already keeps a list of channel clients, so there's
no need for the SndChannel to also keep track of the client itself.
Since the SndChannel only supports a single client (whereas other
channels may have some partial support for multiple clients), I've
provided a convenience function for getting the client and warning if
there is more than one.
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/server/sound.c b/server/sound.c
index eacb7bea..be7e6076 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -166,8 +166,6 @@ GType snd_channel_get_type(void) G_GNUC_CONST;
struct SndChannel {
RedChannel parent;
- SndChannelClient *connection; /* Only one client is supported */
-
bool active;
SpiceVolumeState volume;
uint32_t frequency;
@@ -240,6 +238,17 @@ static GList *snd_channels;
static void snd_send(SndChannelClient * client);
+/* sound channels only support a single client */
+static SndChannelClient *snd_channel_get_client(SndChannel *channel)
+{
+ GList *clients = red_channel_get_clients(RED_CHANNEL(channel));
+ if (clients == NULL) {
+ return NULL;
+ }
+
+ return clients->data;
+}
+
static RedsState* snd_channel_get_server(SndChannelClient *client)
{
g_return_val_if_fail(client != NULL, NULL);
@@ -782,10 +791,6 @@ static bool snd_channel_client_config_socket(RedChannelClient *rcc)
static void snd_channel_on_disconnect(RedChannelClient *rcc)
{
- SndChannel *channel = SND_CHANNEL(red_channel_client_get_channel(rcc));
- if (channel->connection && rcc == RED_CHANNEL_CLIENT(channel->connection)) {
- channel->connection = NULL;
- }
}
static uint8_t*
@@ -821,7 +826,7 @@ static void snd_channel_set_volume(SndChannel *channel,
uint8_t nchannels, uint16_t *volume)
{
SpiceVolumeState *st = &channel->volume;
- SndChannelClient *client = channel->connection;
+ SndChannelClient *client = snd_channel_get_client(channel);
st->volume_nchannels = nchannels;
free(st->volume);
@@ -844,7 +849,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_set_volume(SpicePlaybackInstance *
static void snd_channel_set_mute(SndChannel *channel, uint8_t mute)
{
SpiceVolumeState *st = &channel->volume;
- SndChannelClient *client = channel->connection;
+ SndChannelClient *client = snd_channel_get_client(channel);
st->mute = mute;
@@ -886,12 +891,12 @@ SPICE_GNUC_VISIBLE void spice_server_playback_start(SpicePlaybackInstance *sin)
{
SndChannel *channel = &sin->st->channel;
channel->active = true;
- return playback_channel_client_start(channel->connection);
+ return playback_channel_client_start(snd_channel_get_client(channel));
}
SPICE_GNUC_VISIBLE void spice_server_playback_stop(SpicePlaybackInstance *sin)
{
- SndChannelClient *client = sin->st->channel.connection;
+ SndChannelClient *client = snd_channel_get_client(&sin->st->channel);
sin->st->channel.active = false;
if (!client)
@@ -919,7 +924,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_stop(SpicePlaybackInstance *sin)
SPICE_GNUC_VISIBLE void spice_server_playback_get_buffer(SpicePlaybackInstance *sin,
uint32_t **frame, uint32_t *num_samples)
{
- SndChannelClient *client = sin->st->channel.connection;
+ SndChannelClient *client = snd_channel_get_client(&sin->st->channel);
*frame = NULL;
*num_samples = 0;
@@ -955,7 +960,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_put_samples(SpicePlaybackInstance
}
}
playback_client = frame->client;
- if (!playback_client || sin->st->channel.connection != SND_CHANNEL_CLIENT(playback_client)) {
+ if (!playback_client || snd_channel_get_client(&sin->st->channel) != SND_CHANNEL_CLIENT(playback_client)) {
/* lost last reference, client has been destroyed previously */
spice_debug("audio samples belong to a disconnected client");
return;
@@ -977,18 +982,19 @@ void snd_set_playback_latency(RedClient *client, uint32_t latency)
for (l = snd_channels; l != NULL; l = l->next) {
SndChannel *now = l->data;
+ SndChannelClient *scc = snd_channel_get_client(now);
uint32_t type;
g_object_get(RED_CHANNEL(now), "channel-type", &type, NULL);
- if (type == SPICE_CHANNEL_PLAYBACK && now->connection &&
- red_channel_client_get_client(RED_CHANNEL_CLIENT(now->connection)) == client) {
+ if (type == SPICE_CHANNEL_PLAYBACK && scc &&
+ red_channel_client_get_client(RED_CHANNEL_CLIENT(scc)) == client) {
- if (red_channel_client_test_remote_cap(RED_CHANNEL_CLIENT(now->connection),
+ if (red_channel_client_test_remote_cap(RED_CHANNEL_CLIENT(scc),
SPICE_PLAYBACK_CAP_LATENCY)) {
- PlaybackChannelClient* playback = (PlaybackChannelClient*)now->connection;
+ PlaybackChannelClient* playback = (PlaybackChannelClient*)scc;
playback->latency = latency;
- snd_set_command(now->connection, SND_PLAYBACK_LATENCY_MASK);
- snd_send(now->connection);
+ snd_set_command(scc, SND_PLAYBACK_LATENCY_MASK);
+ snd_send(scc);
} else {
spice_debug("client doesn't not support SPICE_PLAYBACK_CAP_LATENCY");
}
@@ -1069,7 +1075,6 @@ playback_channel_client_constructed(GObject *object)
spice_debug("playback client %p using mode %s", playback_client,
spice_audio_data_mode_to_string(playback_client->mode));
- channel->connection = scc;
if (!red_client_during_migrate_at_target(red_client)) {
snd_set_command(scc, SND_PLAYBACK_MODE_MASK);
if (channel->volume.volume_nchannels) {
@@ -1087,11 +1092,11 @@ static void snd_set_peer(RedChannel *red_channel, RedClient *client, RedsStream
RedChannelCapabilities *caps, GType type)
{
SndChannel *channel = SND_CHANNEL(red_channel);
- SndChannelClient *snd_client;
+ SndChannelClient *snd_client = snd_channel_get_client(channel);
- if (channel->connection) {
- red_channel_client_disconnect(RED_CHANNEL_CLIENT(channel->connection));
- channel->connection = NULL;
+ /* sound channels currently only support a single client */
+ if (snd_client) {
+ red_channel_client_disconnect(RED_CHANNEL_CLIENT(snd_client));
}
snd_client = g_initable_new(type,
@@ -1146,12 +1151,12 @@ SPICE_GNUC_VISIBLE void spice_server_record_start(SpiceRecordInstance *sin)
{
SndChannel *channel = &sin->st->channel;
channel->active = true;
- record_channel_client_start(channel->connection);
+ record_channel_client_start(snd_channel_get_client(channel));
}
SPICE_GNUC_VISIBLE void spice_server_record_stop(SpiceRecordInstance *sin)
{
- SndChannelClient *client = sin->st->channel.connection;
+ SndChannelClient *client = snd_channel_get_client(&sin->st->channel);
sin->st->channel.active = false;
if (!client)
@@ -1169,7 +1174,7 @@ SPICE_GNUC_VISIBLE void spice_server_record_stop(SpiceRecordInstance *sin)
SPICE_GNUC_VISIBLE uint32_t spice_server_record_get_samples(SpiceRecordInstance *sin,
uint32_t *samples, uint32_t bufsize)
{
- SndChannelClient *client = sin->st->channel.connection;
+ SndChannelClient *client = snd_channel_get_client(&sin->st->channel);
uint32_t read_pos;
uint32_t now;
uint32_t len;
@@ -1219,7 +1224,8 @@ static void snd_set_rate(SndChannel *channel, uint32_t frequency, uint32_t cap_o
SPICE_GNUC_VISIBLE uint32_t spice_server_get_best_playback_rate(SpicePlaybackInstance *sin)
{
- return snd_get_best_rate(sin ? sin->st->channel.connection : NULL, SPICE_PLAYBACK_CAP_OPUS);
+ SndChannelClient *client = sin ? snd_channel_get_client(&sin->st->channel) : NULL;
+ return snd_get_best_rate(client, SPICE_PLAYBACK_CAP_OPUS);
}
SPICE_GNUC_VISIBLE void spice_server_set_playback_rate(SpicePlaybackInstance *sin, uint32_t frequency)
@@ -1229,7 +1235,8 @@ SPICE_GNUC_VISIBLE void spice_server_set_playback_rate(SpicePlaybackInstance *si
SPICE_GNUC_VISIBLE uint32_t spice_server_get_best_record_rate(SpiceRecordInstance *sin)
{
- return snd_get_best_rate(sin ? sin->st->channel.connection : NULL, SPICE_RECORD_CAP_OPUS);
+ SndChannelClient *client = sin ? snd_channel_get_client(&sin->st->channel) : NULL;
+ return snd_get_best_rate(client, SPICE_RECORD_CAP_OPUS);
}
SPICE_GNUC_VISIBLE void spice_server_set_record_rate(SpiceRecordInstance *sin, uint32_t frequency)
@@ -1257,7 +1264,6 @@ record_channel_client_constructed(GObject *object)
G_OBJECT_CLASS(record_channel_client_parent_class)->constructed(object);
- channel->connection = scc;
if (channel->volume.volume_nchannels) {
snd_set_command(scc, SND_VOLUME_MUTE_MASK);
}
@@ -1444,10 +1450,11 @@ void snd_set_playback_compression(bool on)
for (l = snd_channels; l != NULL; l = l->next) {
SndChannel *now = l->data;
+ SndChannelClient *client = snd_channel_get_client(now);
uint32_t type;
g_object_get(RED_CHANNEL(now), "channel-type", &type, NULL);
- if (type == SPICE_CHANNEL_PLAYBACK && now->connection) {
- PlaybackChannelClient* playback = (PlaybackChannelClient*)now->connection;
+ if (type == SPICE_CHANNEL_PLAYBACK && client) {
+ PlaybackChannelClient* playback = PLAYBACK_CHANNEL_CLIENT(client);
RedChannelClient *rcc = RED_CHANNEL_CLIENT(playback);
bool client_can_celt = red_channel_client_test_remote_cap(rcc,
SPICE_PLAYBACK_CAP_CELT_0_5_1);
@@ -1457,7 +1464,7 @@ void snd_set_playback_compression(bool on)
client_can_opus, client_can_celt);
if (playback->mode != desired_mode) {
playback->mode = desired_mode;
- snd_set_command(now->connection, SND_PLAYBACK_MODE_MASK);
+ snd_set_command(client, SND_PLAYBACK_MODE_MASK);
spice_debug("playback client %p using mode %s", playback,
spice_audio_data_mode_to_string(playback->mode));
}
commit 74c2137b16f0ae69647b0ef0c3fb69aab47717a2
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date: Thu Apr 20 15:08:49 2017 -0500
sound: Change snd_playback_start/snd_record_start
The content of these functions almost exclusively deals with channel
client functionality except one line where the channel's active state is
set to TRUE.
These functions are called in two different places.
The first place is from the public API spice_server_record_start() and
spice_server_playback_start(). These functions should alter the
channel's active state, and then set the associated channel client to
active.
The second place is when a new channel client is created. In this
case, it is only called if the channel is already active, so it doesn't
make much sense to set the channel's active state inside of the
function.
To simplify things (and enable some future refactoring), this function
now only deals with the SndChannelClient. The functions have also been
renamed to reflect this fact. The SndChannel's active state is now only
modified from the public API functions.
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Acked-by: Pavel Grunt <pgrunt at redhat.com>
diff --git a/server/sound.c b/server/sound.c
index 64072b49..eacb7bea 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -238,8 +238,6 @@ G_DEFINE_TYPE(RecordChannelClient, record_channel_client, TYPE_SND_CHANNEL_CLIEN
/* A list of all Spice{Playback,Record}State objects */
static GList *snd_channels;
-static void snd_playback_start(SndChannel *channel);
-static void snd_record_start(SndChannel *channel);
static void snd_send(SndChannelClient * client);
static RedsState* snd_channel_get_server(SndChannelClient *client)
@@ -862,15 +860,9 @@ SPICE_GNUC_VISIBLE void spice_server_playback_set_mute(SpicePlaybackInstance *si
snd_channel_set_mute(&sin->st->channel, mute);
}
-static void snd_playback_start(SndChannel *channel)
+static void snd_channel_client_start(SndChannelClient *client)
{
- SndChannelClient *client = channel->connection;
-
- channel->active = true;
- if (!client)
- return;
spice_assert(!client->active);
- reds_disable_mm_time(snd_channel_get_server(client));
client->active = true;
if (!client->client_active) {
snd_set_command(client, SND_CTRL_MASK);
@@ -880,9 +872,21 @@ static void snd_playback_start(SndChannel *channel)
}
}
+static void playback_channel_client_start(SndChannelClient *client)
+{
+ if (!client) {
+ return;
+ }
+
+ reds_disable_mm_time(snd_channel_get_server(client));
+ snd_channel_client_start(client);
+}
+
SPICE_GNUC_VISIBLE void spice_server_playback_start(SpicePlaybackInstance *sin)
{
- return snd_playback_start(&sin->st->channel);
+ SndChannel *channel = &sin->st->channel;
+ channel->active = true;
+ return playback_channel_client_start(channel->connection);
}
SPICE_GNUC_VISIBLE void spice_server_playback_stop(SpicePlaybackInstance *sin)
@@ -1074,7 +1078,7 @@ playback_channel_client_constructed(GObject *object)
}
if (channel->active) {
- snd_playback_start(channel);
+ playback_channel_client_start(scc);
}
snd_send(scc);
}
@@ -1126,30 +1130,23 @@ SPICE_GNUC_VISIBLE void spice_server_record_set_mute(SpiceRecordInstance *sin, u
snd_channel_set_mute(&sin->st->channel, mute);
}
-static void snd_record_start(SndChannel *channel)
+static void record_channel_client_start(SndChannelClient *client)
{
- SndChannelClient *client = channel->connection;
-
- channel->active = true;
if (!client) {
return;
}
+
RecordChannelClient *record_client = RECORD_CHANNEL_CLIENT(client);
- spice_assert(!client->active);
record_client->read_pos = record_client->write_pos = 0; //todo: improve by
//stream generation
- client->active = true;
- if (!client->client_active) {
- snd_set_command(client, SND_CTRL_MASK);
- snd_send(client);
- } else {
- client->command &= ~SND_CTRL_MASK;
- }
+ snd_channel_client_start(client);
}
SPICE_GNUC_VISIBLE void spice_server_record_start(SpiceRecordInstance *sin)
{
- snd_record_start(&sin->st->channel);
+ SndChannel *channel = &sin->st->channel;
+ channel->active = true;
+ record_channel_client_start(channel->connection);
}
SPICE_GNUC_VISIBLE void spice_server_record_stop(SpiceRecordInstance *sin)
@@ -1266,7 +1263,7 @@ record_channel_client_constructed(GObject *object)
}
if (channel->active) {
- snd_record_start(channel);
+ record_channel_client_start(scc);
}
snd_send(scc);
}
commit 601a5a27463f875d91a88e33a2372bce90c4ec06
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date: Thu Apr 20 14:29:34 2017 -0500
sound: use GList for global list of sound channels
Instead of putting a 'next' link within the channel structure itself,
just use a generic GList structure to keep a list of active sound
channels.
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Acked-by: Pavel Grunt <pgrunt at redhat.com>
diff --git a/server/sound.c b/server/sound.c
index 980e9687..64072b49 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -167,7 +167,6 @@ struct SndChannel {
RedChannel parent;
SndChannelClient *connection; /* Only one client is supported */
- SndChannel *next; /* For the global SndChannel list */
bool active;
SpiceVolumeState volume;
@@ -237,7 +236,7 @@ G_DEFINE_TYPE(RecordChannelClient, record_channel_client, TYPE_SND_CHANNEL_CLIEN
/* A list of all Spice{Playback,Record}State objects */
-static SndChannel *snd_channels;
+static GList *snd_channels;
static void snd_playback_start(SndChannel *channel);
static void snd_record_start(SndChannel *channel);
@@ -970,9 +969,10 @@ SPICE_GNUC_VISIBLE void spice_server_playback_put_samples(SpicePlaybackInstance
void snd_set_playback_latency(RedClient *client, uint32_t latency)
{
- SndChannel *now = snd_channels;
+ GList *l;
- for (; now; now = now->next) {
+ for (l = snd_channels; l != NULL; l = l->next) {
+ SndChannel *now = l->data;
uint32_t type;
g_object_get(RED_CHANNEL(now), "channel-type", &type, NULL);
if (type == SPICE_CHANNEL_PLAYBACK && now->connection &&
@@ -1282,21 +1282,12 @@ static void snd_set_record_peer(RedChannel *red_channel, RedClient *client, Reds
static void add_channel(SndChannel *channel)
{
- channel->next = snd_channels;
- snd_channels = channel;
+ snd_channels = g_list_prepend(snd_channels, channel);
}
static void remove_channel(SndChannel *channel)
{
- SndChannel **now = &snd_channels;
- while (*now) {
- if (*now == channel) {
- *now = channel->next;
- return;
- }
- now = &(*now)->next;
- }
- spice_printerr("not found");
+ snd_channels = g_list_remove(snd_channels, channel);
}
static void
@@ -1452,9 +1443,10 @@ void snd_detach_record(SpiceRecordInstance *sin)
void snd_set_playback_compression(bool on)
{
- SndChannel *now = snd_channels;
+ GList *l;
- for (; now; now = now->next) {
+ for (l = snd_channels; l != NULL; l = l->next) {
+ SndChannel *now = l->data;
uint32_t type;
g_object_get(RED_CHANNEL(now), "channel-type", &type, NULL);
if (type == SPICE_CHANNEL_PLAYBACK && now->connection) {
commit a2ea1e153624f993828c24d18d5f8d8b9169f93e
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date: Thu Apr 20 11:23:30 2017 -0500
sound: Remove dead code in client constructors
When a new PlaybackChannelClient or RecordChannelClient is created,
there are several places where we make decisions based on whether the
client is active or not. But these checks are done before the 'active'
flag is ever set, so this code is effectively dead. This has been the
case since commit 6fdcb931 and d351bb35, so this code has not been
executed for approximately 7 years now.
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/server/sound.c b/server/sound.c
index c98ddb9e..980e9687 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -1039,7 +1039,6 @@ playback_channel_client_constructed(GObject *object)
RedChannel *red_channel = red_channel_client_get_channel(rcc);
SndChannel *channel = SND_CHANNEL(red_channel);
RedClient *red_client = red_channel_client_get_client(rcc);
- RedsState *reds = red_channel_get_server(red_channel);
SndChannelClient *scc = SND_CHANNEL_CLIENT(playback_client);
G_OBJECT_CLASS(playback_channel_client_parent_class)->constructed(object);
@@ -1069,15 +1068,9 @@ playback_channel_client_constructed(GObject *object)
channel->connection = scc;
if (!red_client_during_migrate_at_target(red_client)) {
snd_set_command(scc, SND_PLAYBACK_MODE_MASK);
- if (scc->active) {
- snd_set_command(scc, SND_CTRL_MASK);
- }
if (channel->volume.volume_nchannels) {
snd_set_command(scc, SND_VOLUME_MUTE_MASK);
}
- if (scc->active) {
- reds_disable_mm_time(reds);
- }
}
if (channel->active) {
@@ -1271,9 +1264,6 @@ record_channel_client_constructed(GObject *object)
if (channel->volume.volume_nchannels) {
snd_set_command(scc, SND_VOLUME_MUTE_MASK);
}
- if (scc->active) {
- snd_set_command(scc, SND_CTRL_MASK);
- }
if (channel->active) {
snd_record_start(channel);
commit 8c88597b48d034798596d0b8b42c376ede9137fe
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date: Wed Apr 19 10:45:56 2017 -0500
sound: Remove on_new_record_channel_client()
It is only called from the constructor, so move all of the code into
that function.
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/sound.c b/server/sound.c
index f20c820f..c98ddb9e 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -1247,19 +1247,6 @@ SPICE_GNUC_VISIBLE void spice_server_set_record_rate(SpiceRecordInstance *sin, u
snd_set_rate(&sin->st->channel, frequency, SPICE_RECORD_CAP_OPUS);
}
-static void on_new_record_channel_client(SndChannel *channel, SndChannelClient *client)
-{
- spice_assert(client);
-
- channel->connection = client;
- if (channel->volume.volume_nchannels) {
- snd_set_command(client, SND_VOLUME_MUTE_MASK);
- }
- if (client->active) {
- snd_set_command(client, SND_CTRL_MASK);
- }
-}
-
static void
record_channel_client_finalize(GObject *object)
{
@@ -1276,14 +1263,22 @@ record_channel_client_constructed(GObject *object)
RecordChannelClient *record_client = RECORD_CHANNEL_CLIENT(object);
RedChannel *red_channel = red_channel_client_get_channel(RED_CHANNEL_CLIENT(record_client));
SndChannel *channel = SND_CHANNEL(red_channel);
+ SndChannelClient *scc = SND_CHANNEL_CLIENT(record_client);
G_OBJECT_CLASS(record_channel_client_parent_class)->constructed(object);
- on_new_record_channel_client(channel, SND_CHANNEL_CLIENT(record_client));
+ channel->connection = scc;
+ if (channel->volume.volume_nchannels) {
+ snd_set_command(scc, SND_VOLUME_MUTE_MASK);
+ }
+ if (scc->active) {
+ snd_set_command(scc, SND_CTRL_MASK);
+ }
+
if (channel->active) {
snd_record_start(channel);
}
- snd_send(SND_CHANNEL_CLIENT(record_client));
+ snd_send(scc);
}
commit f37629996c18770ac923d65397d3504a58a6d5d6
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date: Wed Apr 19 10:40:52 2017 -0500
sound: Remove on_new_playback_channel_client()
This function is only called from the constructor, so move all of that
code into the constructor.
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
diff --git a/server/sound.c b/server/sound.c
index 0d8e1543..f20c820f 100644
--- a/server/sound.c
+++ b/server/sound.c
@@ -1007,29 +1007,6 @@ static int snd_desired_audio_mode(bool playback_compression, int frequency,
return SPICE_AUDIO_DATA_MODE_RAW;
}
-static void on_new_playback_channel_client(SndChannel *channel, SndChannelClient *client)
-{
- RedsState *reds = red_channel_get_server(RED_CHANNEL(channel));
- RedClient *red_client = red_channel_client_get_client(RED_CHANNEL_CLIENT(client));
-
- spice_assert(client);
-
- channel->connection = client;
- if (red_client_during_migrate_at_target(red_client)) {
- return;
- }
- snd_set_command(client, SND_PLAYBACK_MODE_MASK);
- if (client->active) {
- snd_set_command(client, SND_CTRL_MASK);
- }
- if (channel->volume.volume_nchannels) {
- snd_set_command(client, SND_VOLUME_MUTE_MASK);
- }
- if (client->active) {
- reds_disable_mm_time(reds);
- }
-}
-
static void
playback_channel_client_finalize(GObject *object)
{
@@ -1058,14 +1035,17 @@ static void
playback_channel_client_constructed(GObject *object)
{
PlaybackChannelClient *playback_client = PLAYBACK_CHANNEL_CLIENT(object);
- RedChannel *red_channel = red_channel_client_get_channel(RED_CHANNEL_CLIENT(playback_client));
+ RedChannelClient *rcc = RED_CHANNEL_CLIENT(playback_client);
+ RedChannel *red_channel = red_channel_client_get_channel(rcc);
SndChannel *channel = SND_CHANNEL(red_channel);
+ RedClient *red_client = red_channel_client_get_client(rcc);
+ RedsState *reds = red_channel_get_server(red_channel);
+ SndChannelClient *scc = SND_CHANNEL_CLIENT(playback_client);
G_OBJECT_CLASS(playback_channel_client_parent_class)->constructed(object);
- SND_CHANNEL_CLIENT(playback_client)->on_message_done = snd_playback_on_message_done;
+ scc->on_message_done = snd_playback_on_message_done;
- RedChannelClient *rcc = RED_CHANNEL_CLIENT(playback_client);
bool client_can_celt = red_channel_client_test_remote_cap(rcc,
SPICE_PLAYBACK_CAP_CELT_0_5_1);
bool client_can_opus = red_channel_client_test_remote_cap(rcc,
@@ -1086,12 +1066,24 @@ playback_channel_client_constructed(GObject *object)
spice_debug("playback client %p using mode %s", playback_client,
spice_audio_data_mode_to_string(playback_client->mode));
- on_new_playback_channel_client(channel, SND_CHANNEL_CLIENT(playback_client));
+ channel->connection = scc;
+ if (!red_client_during_migrate_at_target(red_client)) {
+ snd_set_command(scc, SND_PLAYBACK_MODE_MASK);
+ if (scc->active) {
+ snd_set_command(scc, SND_CTRL_MASK);
+ }
+ if (channel->volume.volume_nchannels) {
+ snd_set_command(scc, SND_VOLUME_MUTE_MASK);
+ }
+ if (scc->active) {
+ reds_disable_mm_time(reds);
+ }
+ }
if (channel->active) {
snd_playback_start(channel);
}
- snd_send(SND_CHANNEL_CLIENT(playback_client));
+ snd_send(scc);
}
static void snd_set_peer(RedChannel *red_channel, RedClient *client, RedsStream *stream,
More information about the Spice-commits
mailing list