Commit Diff


commit - aecca17ce0a487ea94b7e3f0c8e5387c1fce31e7
commit + 4d8a06d41dc96cb9b17dcbf3a20477dfb5566b82
blob - 186f54ae4a4834635ab06530b67e187941817d95
blob + 3b31d13e0fa20c8e21c70786a3f98c6a1895672b
--- player.c
+++ player.c
@@ -56,11 +56,18 @@ player_signal_handler(int signo)
 int
 player_setup(int bits, int rate, int channels)
 {
-	struct sio_par par;
-	int nfds;
+	static struct sio_par par;
+	int nfds, fpct;
 
 	log_debug("%s: bits=%d, rate=%d, channels=%d", __func__,
 	    bits, rate, channels);
+
+	fpct = (rate*5)/100;
+
+	/* don't stop if the parameters are the same */
+	if (bits == par.bits && channels == par.pchan &&
+	    par.rate - fpct <= rate && rate <= par.rate + fpct)
+		goto end;
 
 again:
 	if (!stopped) {
@@ -95,6 +102,7 @@ again:
 
 	/* TODO: check the sample rate? */
 
+end:
 	if (!sio_start(hdl)) {
 		log_warn("sio_start");
 		return -1;