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

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