Index: timidity/aq.c
===================================================================
--- timidity/aq.c
+++ timidity/aq.c
@@ -80,6 +80,7 @@
 static AudioBucket *tail = NULL;
 
 static void alloc_soft_queue(void);
+static void set_bucket_size(int size);
 static int add_play_bucket(const char *buf, int n);
 static void reuse_audio_bucket(AudioBucket *bucket);
 static AudioBucket *next_allocated_bucket(void);
@@ -125,7 +126,7 @@
 
 void aq_setup(void)
 {
-    int ch;
+    int ch, frag_size;
 
     /* Initialize Bps, bucket_size, device_qsize, and bucket_time */
 
@@ -140,8 +141,9 @@
     else
 	Bps = ch;
 
-    if(play_mode->acntl(PM_REQ_GETFRAGSIZ, &bucket_size) == -1)
-	bucket_size = audio_buffer_size * Bps;
+    if(play_mode->acntl(PM_REQ_GETFRAGSIZ, &frag_size) == -1)
+	frag_size = audio_buffer_size * Bps;
+    set_bucket_size(frag_size);
     bucket_time = (double)bucket_size / Bps / play_mode->rate;
 
     if(IS_STREAM_TRACE)
@@ -256,7 +258,7 @@
 	{
 	    ctl->cmsg(CMSG_ERROR, VERB_NOISY,
 		      "Can't estimate audio queue length");
-	    bucket_size = audio_buffer_size * Bps;
+	    set_bucket_size(audio_buffer_size * Bps);
 	    free(nullsound);
 	    return 2 * audio_buffer_size * Bps;
 	}
@@ -264,7 +266,7 @@
 	ctl->cmsg(CMSG_WARNING, VERB_DEBUG,
 		  "Retry to estimate audio queue length (%d times)",
 		  ntries);
-	bucket_size /= 2;
+	set_bucket_size(bucket_size / 2);
 	ntries++;
 	goto retry;
     }
@@ -357,6 +359,15 @@
     return 0;
 }
 
+static void set_bucket_size(int size)
+{
+    if (size == bucket_size)
+	return;
+    bucket_size = size;
+    if (nbuckets != 0)
+	alloc_soft_queue();
+}
+
 /* alloc_soft_queue() (re-)initializes audio buckets. */
 static void alloc_soft_queue(void)
 {
