Big round of fixes in the aout3.
[vlc.git] / modules / audio_output / esd.c
index 99a7e27..cbf8130 100644 (file)
@@ -2,7 +2,7 @@
  * esd.c : EsounD module
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: esd.c,v 1.3 2002/08/13 14:53:46 sam Exp $
+ * $Id: esd.c,v 1.8 2002/08/19 23:07:30 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -58,7 +58,7 @@ static int  Open         ( vlc_object_t * );
 static void Close        ( vlc_object_t * );
 
 static int  SetFormat    ( aout_instance_t * );
-static void Play         ( aout_instance_t *, aout_buffer_t * );
+static void Play         ( aout_instance_t * );
 static int  ESDThread    ( aout_instance_t * );
 
 /*****************************************************************************
@@ -146,12 +146,15 @@ static int SetFormat( aout_instance_t *p_aout )
     /* ESD latency is calculated for 44100 Hz. We don't have any way to get the
      * number of buffered samples, so I assume ESD_BUF_SIZE/2 */
     p_sys->latency =
-        (mtime_t)( esd_get_latency( esd_open_sound(NULL) ) + ESD_BUF_SIZE / 2
-                    * p_aout->output.output.i_rate / ESD_DEFAULT_RATE
-                    * aout_FormatTo( &p_aout->output.output, 1 ) )
+        (mtime_t)( esd_get_latency( esd_open_sound(NULL) ) + ESD_BUF_SIZE/2
+                    * p_aout->output.output.i_bytes_per_frame
+                    * p_aout->output.output.i_rate
+                    / p_aout->output.output.i_frame_length
+                    / ESD_DEFAULT_RATE )
       * (mtime_t)1000000
-      / (mtime_t)aout_FormatToByterate( &p_aout->output.output,
-                                        p_aout->output.output.i_rate );
+      / p_aout->output.output.i_bytes_per_frame
+      / p_aout->output.output.i_rate
+      * p_aout->output.output.i_frame_length;
 
     p_sys->b_initialized = VLC_TRUE;
 
@@ -161,9 +164,8 @@ static int SetFormat( aout_instance_t *p_aout )
 /*****************************************************************************
  * Play: queue a buffer for playing by ESDThread
  *****************************************************************************/
-static void Play( aout_instance_t *p_aout, aout_buffer_t * p_buffer )
+static void Play( aout_instance_t *p_aout )
 {
-    aout_FifoPush( p_aout, &p_aout->output.fifo, p_buffer );
 }
 
 /*****************************************************************************
@@ -202,18 +204,18 @@ static int ESDThread( aout_instance_t * p_aout )
 
         /* Get the presentation date of the next write() operation. It
          * is equal to the current date + buffered samples + esd latency */
-        p_buffer = aout_OutputNextBuffer( p_aout, mdate() + p_sys->latency );
+        p_buffer = aout_OutputNextBuffer( p_aout, mdate() + p_sys->latency, 0 );
 
         if ( p_buffer != NULL )
         {
             p_bytes = p_buffer->p_buffer;
-            i_size = aout_FormatToSize( &p_aout->output.output,
-                                        p_buffer->i_nb_samples );
+            i_size = p_buffer->i_nb_bytes;
         }
         else
         {
-            i_size = aout_FormatToSize( &p_aout->output.output,
-                                        ESD_BUF_SIZE * 2 );
+            i_size = ESD_BUF_SIZE * 2
+                      / p_aout->output.output.i_frame_length
+                      * p_aout->output.output.i_bytes_per_frame;
             p_bytes = alloca( i_size );
             memset( p_bytes, 0, i_size );
         }