>From d30ed3997bd1bcb732c0b3afba17153fe6af4d8c Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Sun, 3 Mar 2013 02:09:35 +0900
Subject: [PATCH] kai: enlarge an audio buffer size to AOUT_MAX_ADVANCE_TIME

And add a comment for a condition falling into a indefinite lock.
---
 modules/audio_output/kai.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/audio_output/kai.c b/modules/audio_output/kai.c
index 20b995b..18985dc 100644
--- a/modules/audio_output/kai.c
+++ b/modules/audio_output/kai.c
@@ -37,7 +37,7 @@
 
 #define FRAME_SIZE 2048
 
-#define AUDIO_BUFFER_SIZE ( 64 * 1024 )
+#define AUDIO_BUFFER_SIZE_IN_SECONDS ( AOUT_MAX_ADVANCE_TIME / CLOCK_FREQ )
 
 struct audio_buffer_t
 {
@@ -225,7 +225,8 @@ static int Start ( audio_output_t *p_aout, audio_sample_format_t *fmt )
 
     aout_SoftVolumeStart( p_aout );
 
-    CreateBuffer( p_aout, AUDIO_BUFFER_SIZE );
+    CreateBuffer( p_aout, AUDIO_BUFFER_SIZE_IN_SECONDS *
+                          format.i_rate * format.i_bytes_per_frame );
 
     if ( var_Type( p_aout, "audio-device" ) == 0 )
     {
@@ -458,6 +459,9 @@ static int WriteBuffer( audio_output_t *aout, uint8_t *data, int size )
 
     vlc_mutex_lock( &buffer->mutex );
 
+    /* FIXME :
+     * If size is larger than buffer->size, this is locked indefinitely.
+     */
     while( buffer->length + size > buffer->size )
         vlc_cond_wait( &buffer->cond, &buffer->mutex );
 
-- 
1.7.3.2

