diff --git a/gst/audioresample/gstaudioresample.c b/gst/audioresample/gstaudioresample.c
index 0cae09e..b6c2ed4 100644
--- a/gst/audioresample/gstaudioresample.c
+++ b/gst/audioresample/gstaudioresample.c
@@ -929,6 +929,10 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
   gint err = RESAMPLER_ERR_SUCCESS;
   guint8 *in_tmp = NULL, *out_tmp = NULL;
   gboolean need_convert = (resample->funcs->width != resample->width);
+  gboolean skip_gap;
+  guint32 in_latency, out_latency;
+
+  in_latency = resample->funcs->get_input_latency (resample->state);
 
   in_len = GST_BUFFER_SIZE (inbuf) / resample->channels;
   out_len = GST_BUFFER_SIZE (outbuf) / resample->channels;
@@ -939,6 +943,18 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
   in_processed = in_len;
   out_processed = out_len;
 
+  out_latency =
+      resample->funcs->get_output_latency (resample->state) +
+      (in_processed % out_processed);
+
+  if (resample->inrate < resample->outrate) {
+    skip_gap = in_len > in_latency
+        && GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP);
+  } else {
+    skip_gap = out_len > out_latency
+        && GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP);
+  }
+
   if (need_convert) {
     guint in_size_tmp =
         in_len * resample->channels * (resample->funcs->width / 8);
@@ -963,13 +979,20 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
     }
   }
 
-  if (need_convert) {
-    err = resample->funcs->process (resample->state,
-        in_tmp, &in_processed, out_tmp, &out_processed);
+  /* don't bother with the resample filter if it is a gap */
+  if (skip_gap) {
+    GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_GAP);
+    memset (GST_BUFFER_DATA (outbuf), 0, GST_BUFFER_SIZE (outbuf));
+    err = 0;
   } else {
-    err = resample->funcs->process (resample->state,
-        (const guint8 *) GST_BUFFER_DATA (inbuf), &in_processed,
-        (guint8 *) GST_BUFFER_DATA (outbuf), &out_processed);
+    if (need_convert) {
+      err = resample->funcs->process (resample->state,
+          in_tmp, &in_processed, out_tmp, &out_processed);
+    } else {
+      err = resample->funcs->process (resample->state,
+          (const guint8 *) GST_BUFFER_DATA (inbuf), &in_processed,
+          (guint8 *) GST_BUFFER_DATA (outbuf), &out_processed);
+    }
   }
 
   if (G_UNLIKELY (in_len != in_processed))
@@ -994,6 +1017,12 @@ gst_audio_resample_process (GstAudioResample * resample, GstBuffer * inbuf,
     return GST_FLOW_ERROR;
   } else {
 
+    if (skip_gap) {
+      out_processed -= out_latency;
+      gst_audio_resample_push_drain (resample);
+      gst_audio_resample_reset_state (resample);
+    }
+
     if (need_convert)
       gst_audio_resample_convert_buffer (resample, out_tmp,
           GST_BUFFER_DATA (outbuf), out_processed, TRUE);
diff --git a/gst/audioresample/speex_resampler_wrapper.h b/gst/audioresample/speex_resampler_wrapper.h
index 36d444f..e15eb2c 100644
--- a/gst/audioresample/speex_resampler_wrapper.h
+++ b/gst/audioresample/speex_resampler_wrapper.h
@@ -52,6 +52,7 @@ typedef struct {
   void (*get_ratio) (SpeexResamplerState * st,
     guint32 * ratio_num, guint32 * ratio_den);
   int (*get_input_latency) (SpeexResamplerState * st);
+  int (*get_output_latency) (SpeexResamplerState * st);
   int (*set_quality) (SpeexResamplerState * st, gint quality);
   int (*reset_mem) (SpeexResamplerState * st);
   int (*skip_zeros) (SpeexResamplerState * st);
@@ -71,6 +72,7 @@ void resample_float_resampler_get_rate (SpeexResamplerState * st,
 void resample_float_resampler_get_ratio (SpeexResamplerState * st,
     guint32 * ratio_num, guint32 * ratio_den);
 int resample_float_resampler_get_input_latency (SpeexResamplerState * st);
+int resample_float_resampler_get_output_latency (SpeexResamplerState *st);
 int resample_float_resampler_set_quality (SpeexResamplerState * st, gint quality);
 int resample_float_resampler_reset_mem (SpeexResamplerState * st);
 int resample_float_resampler_skip_zeros (SpeexResamplerState * st);
@@ -85,6 +87,7 @@ static const SpeexResampleFuncs float_funcs =
   resample_float_resampler_get_rate,
   resample_float_resampler_get_ratio,
   resample_float_resampler_get_input_latency,
+  resample_float_resampler_get_output_latency,
   resample_float_resampler_set_quality,
   resample_float_resampler_reset_mem,
   resample_float_resampler_skip_zeros,
@@ -104,6 +107,7 @@ void resample_double_resampler_get_rate (SpeexResamplerState * st,
 void resample_double_resampler_get_ratio (SpeexResamplerState * st,
     guint32 * ratio_num, guint32 * ratio_den);
 int resample_double_resampler_get_input_latency (SpeexResamplerState * st);
+int resample_double_resampler_get_output_latency (SpeexResamplerState *st);
 int resample_double_resampler_set_quality (SpeexResamplerState * st, gint quality);
 int resample_double_resampler_reset_mem (SpeexResamplerState * st);
 int resample_double_resampler_skip_zeros (SpeexResamplerState * st);
@@ -118,6 +122,7 @@ static const SpeexResampleFuncs double_funcs =
   resample_double_resampler_get_rate,
   resample_double_resampler_get_ratio,
   resample_double_resampler_get_input_latency,
+  resample_double_resampler_get_output_latency,
   resample_double_resampler_set_quality,
   resample_double_resampler_reset_mem,
   resample_double_resampler_skip_zeros,
@@ -137,6 +142,7 @@ void resample_int_resampler_get_rate (SpeexResamplerState * st,
 void resample_int_resampler_get_ratio (SpeexResamplerState * st,
     guint32 * ratio_num, guint32 * ratio_den);
 int resample_int_resampler_get_input_latency (SpeexResamplerState * st);
+int resample_int_resampler_get_output_latency (SpeexResamplerState * st);
 int resample_int_resampler_set_quality (SpeexResamplerState * st, gint quality);
 int resample_int_resampler_reset_mem (SpeexResamplerState * st);
 int resample_int_resampler_skip_zeros (SpeexResamplerState * st);
@@ -151,6 +157,7 @@ static const SpeexResampleFuncs int_funcs =
   resample_int_resampler_get_rate,
   resample_int_resampler_get_ratio,
   resample_int_resampler_get_input_latency,
+  resample_int_resampler_get_output_latency,
   resample_int_resampler_set_quality,
   resample_int_resampler_reset_mem,
   resample_int_resampler_skip_zeros,
