diff options
author | Philipp Maier <pmaier@sysmocom.de> | 2018-10-10 10:42:43 +0200 |
---|---|---|
committer | Philipp Maier <pmaier@sysmocom.de> | 2018-10-10 10:42:43 +0200 |
commit | bf3eb8f6eb8410b643bde366f9a5e6fcc0556d14 (patch) | |
tree | 4e222ab5f60c074b810befb36be97d46f70ea0ef /src/osmo-bsc/codec_pref.c | |
parent | b5208d45b1d3a5138635bd173e26833fe332e76e (diff) |
codec_pref: cosmetic: seperate half/full rate determination
The function match_codec_pref determines whether a permitted speech
value belongs to a half-rate or full-rate codec. Lets seperate this into
a separate function.
Change-Id: Iec1db4621ba5a09bc0e3fc40b66f3a3bc5f54add
Related: OS#3503
Diffstat (limited to 'src/osmo-bsc/codec_pref.c')
-rw-r--r-- | src/osmo-bsc/codec_pref.c | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/src/osmo-bsc/codec_pref.c b/src/osmo-bsc/codec_pref.c index 0f0ffa546..a741e1115 100644 --- a/src/osmo-bsc/codec_pref.c +++ b/src/osmo-bsc/codec_pref.c @@ -26,6 +26,38 @@ #include <osmocom/bsc/codec_pref.h> #include <osmocom/bsc/gsm_data.h> +/* Determine whether a permitted speech value is specifies a half rate or full + * rate codec */ +static int full_rate_from_perm_spch(bool * full_rate, + enum gsm0808_permitted_speech perm_spch) +{ + /* Check if the result is a half or full rate codec */ + switch (perm_spch) { + case GSM0808_PERM_HR1: + case GSM0808_PERM_HR2: + case GSM0808_PERM_HR3: + case GSM0808_PERM_HR4: + case GSM0808_PERM_HR6: + *full_rate = false; + break; + + case GSM0808_PERM_FR1: + case GSM0808_PERM_FR2: + case GSM0808_PERM_FR3: + case GSM0808_PERM_FR4: + case GSM0808_PERM_FR5: + *full_rate = true; + break; + + default: + LOGP(DMSC, LOGL_ERROR, "Invalid permitted-speech value: %u\n", + perm_spch); + return -EINVAL; + } + + return 0; +} + /* Helper function for match_codec_pref(), looks up a matching chan mode for * a given permitted speech value */ static enum gsm48_chan_mode gsm88_to_chan_mode(enum gsm0808_permitted_speech speech) @@ -225,6 +257,7 @@ int match_codec_pref(enum gsm48_chan_mode *chan_mode, bool match = false; const struct gsm0808_speech_codec *sc_match = NULL; uint16_t amr_s15_s0_supported; + int rc; /* Note: Normally the MSC should never try to advertise a codec that * we did not advertise as supported before. In order to ensure that @@ -255,28 +288,10 @@ int match_codec_pref(enum gsm48_chan_mode *chan_mode, return -1; } - /* Check if the result is a half or full rate codec */ - switch (perm_spch) { - case GSM0808_PERM_HR1: - case GSM0808_PERM_HR2: - case GSM0808_PERM_HR3: - case GSM0808_PERM_HR4: - case GSM0808_PERM_HR6: - *full_rate = false; - break; - - case GSM0808_PERM_FR1: - case GSM0808_PERM_FR2: - case GSM0808_PERM_FR3: - case GSM0808_PERM_FR4: - case GSM0808_PERM_FR5: - *full_rate = true; - break; - - default: - LOGP(DMSC, LOGL_ERROR, "Invalid permitted-speech value: %u\n", perm_spch); + /* Determine if the result is a half or full rate codec */ + rc = full_rate_from_perm_spch(full_rate, perm_spch); + if (rc < 0) return -EINVAL; - } /* Lookup a channel mode for the selected codec */ *chan_mode = gsm88_to_chan_mode(perm_spch); |