diff --git a/gst/audioresample/gstaudioresample.c b/gst/audioresample/gstaudioresample.c
index 0cae09e..210c776 100644
--- a/gst/audioresample/gstaudioresample.c
+++ b/gst/audioresample/gstaudioresample.c
@@ -526,6 +526,7 @@ gst_audio_resample_transform_size (GstBaseTransform * base,
   guint32 ratio_den, ratio_num;
   gint inrate, outrate, gcd;
   gint width;
+  gint extra_sample;
 
   GST_LOG_OBJECT (base, "asked to transform size %d in direction %s",
       size, direction == GST_PAD_SINK ? "SINK" : "SRC");
@@ -549,12 +550,19 @@ gst_audio_resample_transform_size (GstBaseTransform * base,
   ratio_num = inrate / gcd;
   ratio_den = outrate / gcd;
 
+  /* If either of ratio_num or ratio_den is 1, we are doing an integral
+   * resample, and won't need to leave an extra sample space in our
+   * output buffers. Otherwise we allocate space for one extra sample,
+   * but then reduce the GST_BUFFER_SIZE for buffers that don't use it. */
+  extra_sample = (ratio_num == 1 || ratio_den == 1) ? 0 : 1;
+
+  g_print ("%d %d %d\n", ratio_num, ratio_den, extra_sample);
   if (direction == GST_PAD_SINK) {
     gint fac = width / 8;
 
     /* asked to convert size of an incoming buffer */
     size /= fac;
-    *othersize = (size * ratio_den + ratio_num - 1) / ratio_num;
+    *othersize = (size * ratio_den + ratio_num - 1) / ratio_num + extra_sample;
     *othersize *= fac;
     size *= fac;
   } else {
@@ -562,7 +570,7 @@ gst_audio_resample_transform_size (GstBaseTransform * base,
 
     /* asked to convert size of an outgoing buffer */
     size /= fac;
-    *othersize = (size * ratio_num + ratio_den - 1) / ratio_den;
+    *othersize = (size * ratio_num + ratio_den - 1) / ratio_den - extra_sample;
     *othersize *= fac;
     size *= fac;
   }
