cosmetic: move check for CSD further above

Currently the CSD check is in the middle of figuring out the voice codec
for normal voice calls. Rather do the CSD check first, and then do voice
in one coherent section.

(prep for upcoming change in this code, to support AMR rate selection.)

Change-Id: Ibd21f0bb46c66a406904105564ce961a8760cbe7
diff --git a/src/libmsc/msc_a.c b/src/libmsc/msc_a.c
index 4fa9676..38f05a6 100644
--- a/src/libmsc/msc_a.c
+++ b/src/libmsc/msc_a.c
@@ -1464,6 +1464,15 @@
 	if (codec_if_known) {
 		const struct codec_mapping *codec_assigned;
 
+		/* Check for unexpected codec with CSD */
+		if (cc_trans->bearer_cap.transfer == GSM48_BCAP_ITCAP_UNR_DIG_INF &&
+		    codec_if_known->type != GSM0808_SCT_CSD) {
+			LOG_TRANS(cc_trans, LOGL_ERROR, "Unexpected codec in Assignment Complete for CSD: %s\n",
+				  gsm0808_speech_codec_type_name(codec_if_known->type));
+			call_leg_release(msc_a->cc.call_leg);
+			return;
+		}
+
 		/* For 2G:
 		 * - The Assignment Complete has returned a specific codec (e.g. FR3 for AMR FR).
 		 * - Set this codec at the MGW endpoint facing the RAN.
@@ -1486,15 +1495,6 @@
 			return;
 		}
 
-		/* Check for unexpected codec with CSD */
-		if (cc_trans->bearer_cap.transfer == GSM48_BCAP_ITCAP_UNR_DIG_INF &&
-		    codec_if_known->type != GSM0808_SCT_CSD) {
-			LOG_TRANS(cc_trans, LOGL_ERROR, "Unexpected codec in Assignment Complete for CSD: %s\n",
-				  gsm0808_speech_codec_type_name(codec_if_known->type));
-			call_leg_release(msc_a->cc.call_leg);
-			return;
-		}
-
 		/* Update RAN-side endpoint CI from Assignment result -- unless it is forced by the ran_infra, in which
 		 * case it remains unchanged as passed to the earlier call of call_leg_ensure_ci(). */
 		if (msc_a->c.ran->force_mgw_codecs_to_ran.count == 0)