[Spice-devel] [PATCH v2 5/6] sound: Change snd_playback_start/snd_record_start
Pavel Grunt
pgrunt at redhat.com
Tue Apr 25 08:14:52 UTC 2017
On Mon, 2017-04-24 at 12:09 -0500, Jonathon Jongsma wrote:
> The content of these functions alsmost exclusively deals with
> channel client functionality except one line where the channel's
> active
> state is set to TRUE.
>
s/alsmost/almost/
> 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 SndChannel's active
> state
> is now only modified from the public API functions.
>
> Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
> ---
> server/sound.c | 24 ++++++++++--------------
> 1 file changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/server/sound.c b/server/sound.c
> index 44b7582..543449a 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,11 +860,8 @@ 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_playback_start(SndChannelClient *client)
> {
> - SndChannelClient *client = channel->connection;
> -
> - channel->active = TRUE;
> if (!client)
> return;
> spice_assert(!client->active);
> @@ -882,7 +877,9 @@ static void snd_playback_start(SndChannel
> *channel)
>
> 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 snd_playback_start(channel->connection);
> }
>
> SPICE_GNUC_VISIBLE void
> spice_server_playback_stop(SpicePlaybackInstance *sin)
> @@ -1074,7 +1071,7 @@ playback_channel_client_constructed(GObject
> *object)
> }
>
> if (channel->active) {
> - snd_playback_start(channel);
> + snd_playback_start(scc);
> }
> snd_send(scc);
> }
> @@ -1126,11 +1123,8 @@ 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 snd_record_start(SndChannelClient *client)
> {
> - SndChannelClient *client = channel->connection;
> -
> - channel->active = TRUE;
> if (!client) {
> return;
> }
> @@ -1149,7 +1143,9 @@ static void snd_record_start(SndChannel
> *channel)
>
> SPICE_GNUC_VISIBLE void
> spice_server_record_start(SpiceRecordInstance *sin)
> {
> - snd_record_start(&sin->st->channel);
> + SndChannel *channel = &sin->st->channel;
> + channel->active = TRUE;
> + snd_record_start(channel->connection);
> }
>
> SPICE_GNUC_VISIBLE void
> spice_server_record_stop(SpiceRecordInstance *sin)
> @@ -1266,7 +1262,7 @@ record_channel_client_constructed(GObject
> *object)
> }
>
> if (channel->active) {
> - snd_record_start(channel);
> + snd_record_start(scc);
> }
> snd_send(scc);
> }
Ack,
Pavel
More information about the Spice-devel
mailing list