]> git.sesse.net Git - vlc/blobdiff - plugins/sdl/aout_sdl.c
* ALL: the first libvlc commit.
[vlc] / plugins / sdl / aout_sdl.c
index 2150b7e3afbb5c0f41b4f2088a10a7619f08d79b..4db795f30388be9a6e3470e3eab53fb6335e7889 100644 (file)
@@ -2,7 +2,7 @@
  * aout_sdl.c : audio sdl functions library
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: aout_sdl.c,v 1.27 2002/02/24 22:06:50 sam Exp $
+ * $Id: aout_sdl.c,v 1.29 2002/06/01 12:32:00 sam Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
 #include <fcntl.h>                                       /* open(), O_WRONLY */
 #include <string.h>                                            /* strerror() */
 #include <unistd.h>                                      /* write(), close() */
-#include <stdio.h>                                           /* "intf_msg.h" */
 #include <stdlib.h>                            /* calloc(), malloc(), free() */
 
-#include <videolan/vlc.h>
+#include <vlc/vlc.h>
+#include <vlc/aout.h>
 
 #include SDL_INCLUDE_FILE
 
-#include "audio_output.h"                                   /* aout_thread_t */
-
 /*****************************************************************************
  * aout_sys_t: dsp audio output method descriptor
  *****************************************************************************
 /* the overflow limit is used to prevent the fifo from growing too big */
 #define OVERFLOWLIMIT 100000
 
-typedef struct aout_sys_s
+struct aout_sys_s
 {
     byte_t  * audio_buf;
     int i_audio_end;
 
-    boolean_t b_active;
-
-} aout_sys_t;
+    vlc_bool_t b_active;
+};
 
 /*****************************************************************************
  * Local prototypes.
@@ -103,7 +100,7 @@ static int aout_Open( aout_thread_t *p_aout )
 
     if( p_aout->p_sys == NULL )
     {
-        intf_ErrMsg( "aout error: %s", strerror(ENOMEM) );
+        msg_Err( p_aout, "out of memory" );
         return( 1 );
     }
 
@@ -120,7 +117,7 @@ static int aout_Open( aout_thread_t *p_aout )
 #endif
                 ) < 0 )
     {
-        intf_ErrMsg( "aout error: can't initialize SDL (%s)", SDL_GetError() );
+        msg_Err( p_aout, "cannot initialize SDL (%s)", SDL_GetError() );
         free( p_aout->p_sys );
         return( 1 );
     }
@@ -133,7 +130,11 @@ static int aout_Open( aout_thread_t *p_aout )
     /* TODO: write conversion beetween AOUT_FORMAT_DEFAULT
      * AND AUDIO* from SDL. */
     desired.freq       = p_aout->i_rate;
+#ifdef WORDS_BIGENDIAN
+    desired.format     = AUDIO_S16MSB;                     /* stereo 16 bits */
+#else
     desired.format     = AUDIO_S16LSB;                     /* stereo 16 bits */
+#endif
     desired.channels   = p_aout->i_channels;
     desired.callback   = aout_SDLCallback;
     desired.userdata   = p_aout->p_sys;
@@ -146,7 +147,7 @@ static int aout_Open( aout_thread_t *p_aout )
      */
     if( SDL_OpenAudio( &desired, NULL ) < 0 )
     {
-        intf_ErrMsg( "aout error: SDL_OpenAudio failed (%s)", SDL_GetError() );
+        msg_Err( p_aout, "SDL_OpenAudio failed (%s)", SDL_GetError() );
         SDL_QuitSubSystem( SDL_INIT_AUDIO );
         free( p_aout->p_sys );
         return( -1 );
@@ -173,7 +174,11 @@ static int aout_SetFormat( aout_thread_t *p_aout )
 
     /*i_format = p_aout->i_format;*/
     desired.freq       = p_aout->i_rate;             /* Set the output rate */
+#ifdef WORDS_BIGENDIAN
+    desired.format     = AUDIO_S16MSB;                    /* stereo 16 bits */
+#else
     desired.format     = AUDIO_S16LSB;                    /* stereo 16 bits */
+#endif
     desired.channels   = p_aout->i_channels;
     desired.callback   = aout_SDLCallback;
     desired.userdata   = p_aout->p_sys;
@@ -259,11 +264,11 @@ static void aout_Close( aout_thread_t *p_aout )
  *****************************************************************************/
 static void aout_SDLCallback( void *userdata, byte_t *stream, int len )
 {
-    struct aout_sys_s * p_sys = userdata;
+    aout_sys_t * p_sys = userdata;
 
     if( p_sys->i_audio_end > OVERFLOWLIMIT )
     {
-        intf_ErrMsg( "aout error: aout_SDLCallback overflowed" );
+//X        msg_Err( p_aout, "aout_SDLCallback overflowed" );
 
         free( p_sys->audio_buf );
         p_sys->audio_buf = NULL;