diff --git a/main/channel.c b/main/channel.c
index 830775fd87824118589e3aab192b462819bb9380..cece084fbddcd016a011e3190340bfbfed6ea560 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -3095,13 +3095,14 @@ static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *fo
 	int native;
 	int res;
 
+	native = chan->nativeformats;
+
 	if (!fmt || !native)	/* No audio requested */
 		return 0;	/* Let's try a call without any sounds (video, text) */
 	
 	/* Make sure we only consider audio */
 	fmt &= AST_FORMAT_AUDIO_MASK;
 	
-	native = chan->nativeformats;
 	/* Find a translation path from the native format to one of the desired formats */
 	if (!direction)
 		/* reading */