[Spice-devel] [spice-gtk v1] audio: debug audio codec when audio stream starts

Marc-André Lureau marcandre.lureau at redhat.com
Tue Mar 28 12:04:32 UTC 2017



----- Original Message -----
> From: Victor Toso <me at victortoso.com>
> 
> 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 at redhat.com>
> ---
>  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 66376ff..3a7a905 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 < SPICE_AUDIO_DATA_MODE_ENUM_END) ? str[mode]
> : "error";

You better use the size of the array rather than a value that may change.

Rather than "error" I would return "unknown audio codec" or "unknown audio mode".

> +}
> +
> +
>  /**
>   * spice_session_get_proxy_uri:
>   * @session: a #SpiceSession
> --
> 2.9.3
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
> 


More information about the Spice-devel mailing list