Blame SOURCES/0012-audio-debug-audio-codec-when-audio-stream-starts.patch

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