changeset 27435:f3cd247a4aa3

Work correctly with very small files where less than outburst is to be played. patch by Tobias Diedrich, ranma tdiedrich de
author diego
date Fri, 15 Aug 2008 17:14:53 +0000
parents 8f9c58ac2af2
children ad011045b17f
files libao2/ao_nas.c
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_nas.c	Fri Aug 15 11:40:01 2008 +0000
+++ b/libao2/ao_nas.c	Fri Aug 15 17:14:53 2008 +0000
@@ -574,6 +574,29 @@
 	if (len == 0)
 		return 0;
 
+	if (len < ao_data.outburst) {
+		unsigned tempbufsz = ao_data.outburst;
+		void *tempbuf = malloc(tempbufsz);
+
+		memset(tempbuf, 0, tempbufsz);
+		memcpy(tempbuf, data, len);
+
+		play(tempbuf, ao_data.outburst, flags);
+
+		if (nas_data->state != AuStateStart) {
+			mp_msg(MSGT_AO, MSGL_DBG2, "ao_nas: play(): Starting flow.\n");
+			nas_data->expect_underrun = 1;
+			nas_data->state = AuStateStart;
+			AuStartFlow(nas_data->aud, nas_data->flow, &as);
+			if (as != AuSuccess)
+				nas_print_error(nas_data->aud, "play(): AuStartFlow", as);
+		}
+
+		free(tempbuf);
+
+		return len;
+	}
+
 	pthread_mutex_lock(&nas_data->buffer_mutex);
 	maxbursts = (nas_data->client_buffer_size -
 		     nas_data->client_buffer_used) / ao_data.outburst;