From a279657cabec5af3a0d58cb63dbd039b13fe563f Mon Sep 17 00:00:00 2001
From: Victor Toso <me@victortoso.com>
Date: Tue, 28 Mar 2017 13:45:16 +0200
Subject: [PATCH 12/13] audio: debug audio codec when audio stream starts
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We already debug a few parameters but the audio codec is missing.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1436249
Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
(cherry picked from commit 7721d0906d55cfaa6ce8f5786829c5c738adf74c)
---
src/channel-playback.c | 5 +++--
src/channel-record.c | 5 +++--
src/spice-session-priv.h | 1 +
src/spice-session.c | 13 +++++++++++++
4 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/channel-playback.c b/src/channel-playback.c
index 39c2178..ca14b96 100644
--- a/src/channel-playback.c
+++ b/src/channel-playback.c
@@ -367,8 +367,9 @@ static void playback_handle_start(SpiceChannel *channel, SpiceMsgIn *in)
SpicePlaybackChannelPrivate *c = SPICE_PLAYBACK_CHANNEL(channel)->priv;
SpiceMsgPlaybackStart *start = spice_msg_in_parsed(in);
- CHANNEL_DEBUG(channel, "%s: fmt %u channels %u freq %u time %u", __FUNCTION__,
- start->format, start->channels, start->frequency, start->time);
+ CHANNEL_DEBUG(channel, "%s: fmt %u channels %u freq %u time %u mode %s", __FUNCTION__,
+ start->format, start->channels, start->frequency, start->time,
+ spice_audio_data_mode_to_string(c->mode));
c->frame_count = 0;
c->last_time = start->time;
diff --git a/src/channel-record.c b/src/channel-record.c
index c1d9afa..9834e85 100644
--- a/src/channel-record.c
+++ b/src/channel-record.c
@@ -405,8 +405,9 @@ static void record_handle_start(SpiceChannel *channel, SpiceMsgIn *in)
c->mode = spice_record_desired_mode(channel, start->frequency);
- CHANNEL_DEBUG(channel, "%s: fmt %u channels %u freq %u", __FUNCTION__,
- start->format, start->channels, start->frequency);
+ CHANNEL_DEBUG(channel, "%s: fmt %u channels %u freq %u mode %s", __FUNCTION__,
+ start->format, start->channels, start->frequency,
+ spice_audio_data_mode_to_string(c->mode));
g_return_if_fail(start->format == SPICE_AUDIO_FMT_S16);
diff --git a/src/spice-session-priv.h b/src/spice-session-priv.h
index 049973a..03005aa 100644
--- a/src/spice-session-priv.h
+++ b/src/spice-session-priv.h
@@ -99,6 +99,7 @@ guint spice_session_get_n_display_channels(SpiceSession *session);
void spice_session_set_main_channel(SpiceSession *session, SpiceChannel *channel);
gboolean spice_session_set_migration_session(SpiceSession *session, SpiceSession *mig_session);
SpiceAudio *spice_audio_get(SpiceSession *session, GMainContext *context);
+const gchar* spice_audio_data_mode_to_string(gint mode);
G_END_DECLS
#endif /* __SPICE_CLIENT_SESSION_PRIV_H__ */
diff --git a/src/spice-session.c b/src/spice-session.c
index 3f450d9..a972002 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -2602,6 +2602,19 @@ void spice_session_set_shared_dir(SpiceSession *session, const gchar *dir)
s->shared_dir = g_strdup(dir);
}
+G_GNUC_INTERNAL
+const gchar* spice_audio_data_mode_to_string(gint mode)
+{
+ static const char *str[] = {
+ [ SPICE_AUDIO_DATA_MODE_INVALID ] = "invalid",
+ [ SPICE_AUDIO_DATA_MODE_RAW ] = "raw",
+ [ SPICE_AUDIO_DATA_MODE_CELT_0_5_1 ] = "celt",
+ [ SPICE_AUDIO_DATA_MODE_OPUS ] = "opus",
+ };
+ return (mode >= 0 && mode < G_N_ELEMENTS(str)) ? str[mode] : "unknown audio codec";
+}
+
+
/**
* spice_session_get_proxy_uri:
* @session: a #SpiceSession
--
2.12.2