From 6e9d8cfc02873ec970f6f36be0f5d2705850d021 Mon Sep 17 00:00:00 2001
From: Victor Toso <me@victortoso.com>
Date: Tue, 17 Mar 2020 15:00:17 +0100
Subject: [PATCH] Remove celt support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Follow up of spice-protocol's deprecation of celt mode.
See: https://gitlab.freedesktop.org/spice/spice-protocol/-/merge_requests/15

Signed-off-by: Victor Toso <victortoso@redhat.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 meson.build            | 3 +--
 meson_options.txt      | 4 ----
 src/channel-playback.c | 4 ----
 src/channel-record.c   | 7 -------
 src/spice-session.c    | 2 ++
 5 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/meson.build b/meson.build
index 995268b..d8376e9 100644
--- a/meson.build
+++ b/meson.build
@@ -123,8 +123,7 @@ endforeach
 #
 # Non-mandatory/optional dependencies
 #
-optional_deps = {'celt051' : '>= 0.5.1.1',
-                 'opus'    : '>= 0.9.14'}
+optional_deps = {'opus' : '>= 0.9.14'}
 foreach dep, version : optional_deps
   d = dependency(dep, required : get_option(dep), version : version)
   if d.found()
diff --git a/meson_options.txt b/meson_options.txt
index 9804217..4db3c08 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -65,10 +65,6 @@ option('sasl',
     type : 'feature',
     description : 'Use cyrus SASL authentication')
 
-option('celt051',
-    type : 'feature',
-    description: 'Enable celt051 audio codec')
-
 option('opus',
     type : 'feature',
     description: 'Enable Opus audio codec')
diff --git a/src/channel-playback.c b/src/channel-playback.c
index a00706f..7548044 100644
--- a/src/channel-playback.c
+++ b/src/channel-playback.c
@@ -89,9 +89,6 @@ static void channel_set_handlers(SpiceChannelClass *klass);
 
 static void spice_playback_channel_set_capabilities(SpiceChannel *channel)
 {
-    if (!g_getenv("SPICE_DISABLE_CELT"))
-        if (snd_codec_is_capable(SPICE_AUDIO_DATA_MODE_CELT_0_5_1, SND_CODEC_ANY_FREQUENCY))
-            spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_PLAYBACK_CAP_CELT_0_5_1);
     if (!g_getenv("SPICE_DISABLE_OPUS"))
         if (snd_codec_is_capable(SPICE_AUDIO_DATA_MODE_OPUS, SND_CODEC_ANY_FREQUENCY))
             spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_PLAYBACK_CAP_OPUS);
@@ -347,7 +344,6 @@ static void playback_handle_mode(SpiceChannel *channel, SpiceMsgIn *in)
     c->mode = mode->mode;
     switch (c->mode) {
     case SPICE_AUDIO_DATA_MODE_RAW:
-    case SPICE_AUDIO_DATA_MODE_CELT_0_5_1:
     case SPICE_AUDIO_DATA_MODE_OPUS:
         break;
     default:
diff --git a/src/channel-record.c b/src/channel-record.c
index b46ba45..4d27b74 100644
--- a/src/channel-record.c
+++ b/src/channel-record.c
@@ -85,9 +85,6 @@ static void channel_set_handlers(SpiceChannelClass *klass);
 
 static void spice_record_channel_set_capabilities(SpiceChannel *channel)
 {
-    if (!g_getenv("SPICE_DISABLE_CELT"))
-        if (snd_codec_is_capable(SPICE_AUDIO_DATA_MODE_CELT_0_5_1, SND_CODEC_ANY_FREQUENCY))
-            spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_RECORD_CAP_CELT_0_5_1);
     if (!g_getenv("SPICE_DISABLE_OPUS"))
         if (snd_codec_is_capable(SPICE_AUDIO_DATA_MODE_OPUS, SND_CODEC_ANY_FREQUENCY))
             spice_channel_set_capability(SPICE_CHANNEL(channel), SPICE_RECORD_CAP_OPUS);
@@ -273,10 +270,6 @@ static int spice_record_desired_mode(SpiceChannel *channel, int frequency)
         snd_codec_is_capable(SPICE_AUDIO_DATA_MODE_OPUS, frequency) &&
         spice_channel_test_capability(channel, SPICE_RECORD_CAP_OPUS)) {
         return SPICE_AUDIO_DATA_MODE_OPUS;
-    } else if (!g_getenv("SPICE_DISABLE_CELT") &&
-        snd_codec_is_capable(SPICE_AUDIO_DATA_MODE_CELT_0_5_1, frequency) &&
-        spice_channel_test_capability(channel, SPICE_RECORD_CAP_CELT_0_5_1)) {
-        return SPICE_AUDIO_DATA_MODE_CELT_0_5_1;
     } else {
         return SPICE_AUDIO_DATA_MODE_RAW;
     }
diff --git a/src/spice-session.c b/src/spice-session.c
index 6e533e8..8f790cc 100644
--- a/src/spice-session.c
+++ b/src/spice-session.c
@@ -2672,12 +2672,14 @@ static void spice_session_set_shared_dir(SpiceSession *session, const gchar *dir
 G_GNUC_INTERNAL
 const gchar* spice_audio_data_mode_to_string(gint mode)
 {
+    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
     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",
     };
+    G_GNUC_END_IGNORE_DEPRECATIONS
     return (mode >= 0 && mode < G_N_ELEMENTS(str)) ? str[mode] : "unknown audio codec";
 }
 
-- 
2.25.1

