<p>dexter has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/11295">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">codec_pref: cosmetic: seperate half/full rate determination<br><br>The function match_codec_pref determines whether a permitted speech<br>value belongs to a half-rate or full-rate codec. Lets seperate this into<br>a separate function.<br><br>Change-Id: Iec1db4621ba5a09bc0e3fc40b66f3a3bc5f54add<br>Related: OS#3503<br>---<br>M src/osmo-bsc/codec_pref.c<br>1 file changed, 36 insertions(+), 21 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/95/11295/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bsc/codec_pref.c b/src/osmo-bsc/codec_pref.c</span><br><span>index 0f0ffa5..a741e11 100644</span><br><span>--- a/src/osmo-bsc/codec_pref.c</span><br><span>+++ b/src/osmo-bsc/codec_pref.c</span><br><span>@@ -26,6 +26,38 @@</span><br><span> #include <osmocom/bsc/codec_pref.h></span><br><span> #include <osmocom/bsc/gsm_data.h></span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+/* Determine whether a permitted speech value is specifies a half rate or full</span><br><span style="color: hsl(120, 100%, 40%);">+ * rate codec */</span><br><span style="color: hsl(120, 100%, 40%);">+static int full_rate_from_perm_spch(bool * full_rate,</span><br><span style="color: hsl(120, 100%, 40%);">+ enum gsm0808_permitted_speech perm_spch)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Check if the result is a half or full rate codec */</span><br><span style="color: hsl(120, 100%, 40%);">+ switch (perm_spch) {</span><br><span style="color: hsl(120, 100%, 40%);">+ case GSM0808_PERM_HR1:</span><br><span style="color: hsl(120, 100%, 40%);">+ case GSM0808_PERM_HR2:</span><br><span style="color: hsl(120, 100%, 40%);">+ case GSM0808_PERM_HR3:</span><br><span style="color: hsl(120, 100%, 40%);">+ case GSM0808_PERM_HR4:</span><br><span style="color: hsl(120, 100%, 40%);">+ case GSM0808_PERM_HR6:</span><br><span style="color: hsl(120, 100%, 40%);">+ *full_rate = false;</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ case GSM0808_PERM_FR1:</span><br><span style="color: hsl(120, 100%, 40%);">+ case GSM0808_PERM_FR2:</span><br><span style="color: hsl(120, 100%, 40%);">+ case GSM0808_PERM_FR3:</span><br><span style="color: hsl(120, 100%, 40%);">+ case GSM0808_PERM_FR4:</span><br><span style="color: hsl(120, 100%, 40%);">+ case GSM0808_PERM_FR5:</span><br><span style="color: hsl(120, 100%, 40%);">+ *full_rate = true;</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ default:</span><br><span style="color: hsl(120, 100%, 40%);">+ LOGP(DMSC, LOGL_ERROR, "Invalid permitted-speech value: %u\n",</span><br><span style="color: hsl(120, 100%, 40%);">+ perm_spch);</span><br><span style="color: hsl(120, 100%, 40%);">+ return -EINVAL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* Helper function for match_codec_pref(), looks up a matching chan mode for</span><br><span> * a given permitted speech value */</span><br><span> static enum gsm48_chan_mode gsm88_to_chan_mode(enum gsm0808_permitted_speech speech)</span><br><span>@@ -225,6 +257,7 @@</span><br><span> bool match = false;</span><br><span> const struct gsm0808_speech_codec *sc_match = NULL;</span><br><span> uint16_t amr_s15_s0_supported;</span><br><span style="color: hsl(120, 100%, 40%);">+ int rc;</span><br><span> </span><br><span> /* Note: Normally the MSC should never try to advertise a codec that</span><br><span> * we did not advertise as supported before. In order to ensure that</span><br><span>@@ -255,28 +288,10 @@</span><br><span> return -1;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* Check if the result is a half or full rate codec */</span><br><span style="color: hsl(0, 100%, 40%);">- switch (perm_spch) {</span><br><span style="color: hsl(0, 100%, 40%);">- case GSM0808_PERM_HR1:</span><br><span style="color: hsl(0, 100%, 40%);">- case GSM0808_PERM_HR2:</span><br><span style="color: hsl(0, 100%, 40%);">- case GSM0808_PERM_HR3:</span><br><span style="color: hsl(0, 100%, 40%);">- case GSM0808_PERM_HR4:</span><br><span style="color: hsl(0, 100%, 40%);">- case GSM0808_PERM_HR6:</span><br><span style="color: hsl(0, 100%, 40%);">- *full_rate = false;</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- case GSM0808_PERM_FR1:</span><br><span style="color: hsl(0, 100%, 40%);">- case GSM0808_PERM_FR2:</span><br><span style="color: hsl(0, 100%, 40%);">- case GSM0808_PERM_FR3:</span><br><span style="color: hsl(0, 100%, 40%);">- case GSM0808_PERM_FR4:</span><br><span style="color: hsl(0, 100%, 40%);">- case GSM0808_PERM_FR5:</span><br><span style="color: hsl(0, 100%, 40%);">- *full_rate = true;</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- default:</span><br><span style="color: hsl(0, 100%, 40%);">- LOGP(DMSC, LOGL_ERROR, "Invalid permitted-speech value: %u\n", perm_spch);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Determine if the result is a half or full rate codec */</span><br><span style="color: hsl(120, 100%, 40%);">+ rc = full_rate_from_perm_spch(full_rate, perm_spch);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (rc < 0)</span><br><span> return -EINVAL;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span> </span><br><span> /* Lookup a channel mode for the selected codec */</span><br><span> *chan_mode = gsm88_to_chan_mode(perm_spch);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/11295">change 11295</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/11295"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: osmo-bsc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Iec1db4621ba5a09bc0e3fc40b66f3a3bc5f54add </div>
<div style="display:none"> Gerrit-Change-Number: 11295 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: dexter <pmaier@sysmocom.de> </div>