This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/11295 ) Change subject: codec_pref: cosmetic: seperate half/full rate determination ...................................................................... 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 --- M src/osmo-bsc/codec_pref.c 1 file changed, 36 insertions(+), 21 deletions(-) Approvals: Jenkins Builder: Verified Harald Welte: Looks good to me, approved diff --git a/src/osmo-bsc/codec_pref.c b/src/osmo-bsc/codec_pref.c index 0f0ffa5..a741e11 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 @@ 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 @@ 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); -- To view, visit https://gerrit.osmocom.org/11295 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: Iec1db4621ba5a09bc0e3fc40b66f3a3bc5f54add Gerrit-Change-Number: 11295 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder (1000002) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181010/4e17d3ec/attachment.htm>