]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/esd.c
* include/input_ext-intf.h, include/vlc_es.h: moved ES categories into vlc_es.h
[vlc] / modules / audio_output / esd.c
index 272cd558d87a2d02ecdf4d5b60f70992baf8a335..68dcb9e6381af030f392d7c2c17e3e0a6d30ff8c 100644 (file)
@@ -2,7 +2,7 @@
  * esd.c : EsounD module
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: esd.c,v 1.17 2003/01/28 22:52:30 sam Exp $
+ * $Id: esd.c,v 1.19 2003/06/25 21:17:21 asmax Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -34,6 +34,8 @@
 #include <vlc/aout.h>
 #include "aout_internal.h"
 
+#include <sys/socket.h>
+
 #include <esd.h>
 
 /*****************************************************************************
@@ -61,7 +63,7 @@ static void Play         ( aout_instance_t * );
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
-    set_description( _("EsounD audio module") );
+    set_description( _("EsounD audio output") );
     set_capability( "audio output", 50 );
     set_callbacks( Open, Close );
     add_shortcut( "esound" );
@@ -75,6 +77,7 @@ static int Open( vlc_object_t *p_this )
     aout_instance_t *p_aout = (aout_instance_t *)p_this;
     struct aout_sys_t * p_sys;
     int i_nb_channels;
+    int fl;
 
     /* Allocate structure */
     p_sys = malloc( sizeof( aout_sys_t ) );
@@ -113,6 +116,9 @@ static int Open( vlc_object_t *p_this )
         break;
     }
 
+    /* Force the rate, otherwise the sound is very noisy */
+    p_aout->output.output.i_rate = ESD_DEFAULT_RATE;
+    
     /* open a socket for playing a stream
      * and try to open /dev/dsp if there's no EsounD */
     p_sys->i_fd = esd_play_stream_fallback( p_sys->esd_format,
@@ -154,13 +160,18 @@ static void Play( aout_instance_t *p_aout )
 
     if ( p_buffer != NULL )
     {
-        i_tmp = write( p_sys->i_fd, p_buffer->p_buffer, p_buffer->i_nb_bytes );
+        int pos;
+        char *data = p_buffer->p_buffer;
 
-        if( i_tmp < 0 )
+        for( pos = 0; pos + ESD_BUF_SIZE <= p_buffer->i_nb_bytes; 
+             pos += ESD_BUF_SIZE )
         {
-            msg_Err( p_aout, "write failed (%s)", strerror(errno) );
+            i_tmp = write( p_sys->i_fd, data + pos, ESD_BUF_SIZE );
+            if( i_tmp < 0 )
+            {
+                msg_Err( p_aout, "write failed (%s)", strerror(errno) );
+            }
         }
-
         aout_BufferFree( p_buffer );
     }
 }