1. Michael Ziegler
  2. failplay

Commits

Michael Ziegler  committed 96349c5

heh, looks like we can replace the err variable with some good old flow control there

  • Participants
  • Parent commits 0247d3d
  • Branches default

Comments (0)

Files changed (1)

File myffmpeg/ffmpegmodule.c

View file
 
 static PyObject* ffmpeg_resampler_resample( ffmpegResamplerObject* self, PyObject* args ){
 	const char** indata = NULL;
-	int err = 0;
 	int i;
 	int innb;
 	int inlen;
 			av_get_channel_layout_nb_channels(self->output_channel_layout),
 			outnb, self->output_sample_format, 0) < 0 ){
 		PyErr_SetString(FfmpegResampleError, "out of memory");
-		err = 1;
 	}
-	
-	if( !err ){
-		if( avresample_convert(self->pResampleCtx, outbuf, 0, outnb, (uint8_t **)indata, 0, innb) < 0 ){
-			PyErr_SetString(FfmpegResampleError, "resampling failed");
-			err = 2;
-		}
-		else{
-			outplanes = 1;
-			if(av_sample_fmt_is_planar(self->output_sample_format))
-				outplanes = av_get_channel_layout_nb_channels(self->output_channel_layout);
-			ret = PyTuple_New(outplanes);
-			for( i = 0; i < outplanes; i++ )
-				PyTuple_SetItem(ret, i, PyString_FromStringAndSize( (const char*)outbuf[i], outlen ));
-		}
+	else if( avresample_convert(self->pResampleCtx, outbuf, 0, outnb, (uint8_t **)indata, 0, innb) < 0 ){
+		PyErr_SetString(FfmpegResampleError, "resampling failed");
+	}
+	else{
+		outplanes = 1;
+		if(av_sample_fmt_is_planar(self->output_sample_format))
+			outplanes = av_get_channel_layout_nb_channels(self->output_channel_layout);
+		ret = PyTuple_New(outplanes);
+		for( i = 0; i < outplanes; i++ )
+			PyTuple_SetItem(ret, i, PyString_FromStringAndSize( (const char*)outbuf[i], outlen ));
 	}
 	
 	free(indata);