]> git.sesse.net Git - vlc/commitdiff
* Fixed AOUT_CHAN_CHANNEL2 trivial mixer,
authorChristophe Massiot <massiot@videolan.org>
Wed, 16 Oct 2002 23:12:46 +0000 (23:12 +0000)
committerChristophe Massiot <massiot@videolan.org>
Wed, 16 Oct 2002 23:12:46 +0000 (23:12 +0000)
* Fixed a compile issue in the vcd plug-in,
* Fixed SDL behavior with > 2 channels.

modules/access/vcd/cdrom.c
modules/access/vcd/cdrom.h
modules/audio_filter/channel_mixer/trivial.c
modules/audio_output/sdl.c

index b6cf06a37a40a5b5150ea53860794c4bbe21e9ca..d17c8a80eb334caf04504061558b3a252730173f 100644 (file)
@@ -2,7 +2,7 @@
  * cdrom.c: cdrom tools
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: cdrom.c,v 1.4 2002/10/15 19:56:59 gbazin Exp $
+ * $Id: cdrom.c,v 1.5 2002/10/16 23:12:46 massiot Exp $
  *
  * Authors: Johan Bilien <jobi@via.ecp.fr>
  *          Gildas Bazin <gbazin@netcourrier.com>
@@ -37,6 +37,7 @@
 
 #include <fcntl.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <string.h>
 #include <errno.h>
 
@@ -222,7 +223,7 @@ int ioctl_GetTracksMap( vlc_object_t *p_this, const vcddev_t *p_vcddev,
         CDTOC *pTOC;
         int i_descriptors;
 
-        if( ( pTOC = darwin_getTOC( p_this, p_vcddev->psz_dev ) ) == NULL )
+        if( ( pTOC = darwin_getTOC( p_this, p_vcddev ) ) == NULL )
         {
             msg_Err( p_this, "failed to get the TOC" );
             return 0;
@@ -868,7 +869,7 @@ static void CloseVCDImage( vlc_object_t * p_this, vcddev_t *p_vcddev )
 /****************************************************************************
  * darwin_getTOC: get the TOC
  ****************************************************************************/
-static CDTOC *darwin_getTOC( vlc_object_t * p_this, vcddev_t *p_vcddev )
+static CDTOC *darwin_getTOC( vlc_object_t * p_this, const vcddev_t *p_vcddev )
 {
     mach_port_t port;
     char *psz_devname;
@@ -876,7 +877,7 @@ static CDTOC *darwin_getTOC( vlc_object_t * p_this, vcddev_t *p_vcddev )
     CDTOC *pTOC = NULL;
     io_iterator_t iterator;
     io_registry_entry_t service;
-    CFDictionaryRef properties;
+    CFMutableDictionaryRef properties;
     CFDataRef data;
 
     /* get the device name */
index cd40b26ea3cae2755a85b6246078419cd219ccc1..afee0177e705da92db84e1d637de282ea2474898 100644 (file)
@@ -2,7 +2,7 @@
  * cdrom.h: cdrom tools header
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: cdrom.h,v 1.3 2002/10/15 19:56:59 gbazin Exp $
+ * $Id: cdrom.h,v 1.4 2002/10/16 23:12:46 massiot Exp $
  *
  * Authors: Johan Bilien <jobi@via.ecp.fr>
  *          Gildas Bazin <gbazin@netcourrier.com>
@@ -203,7 +203,7 @@ static int    OpenVCDImage( vlc_object_t *, const char *, vcddev_t * );
 static void   CloseVCDImage( vlc_object_t *, vcddev_t * );
 
 #if defined( SYS_DARWIN )
-static CDTOC *darwin_getTOC( vlc_object_t *, const char * );
+static CDTOC *darwin_getTOC( vlc_object_t *, const vcddev_t * );
 static int    darwin_getNumberOfDescriptors( CDTOC * );
 static int    darwin_getNumberOfTracks( CDTOC *, int );
 
index 4a023c4b33843977e965e3aeae1b802ee7703311..7f7748edbee788c0e72e36c7964b0ee890ca8710 100644 (file)
@@ -2,7 +2,7 @@
  * trivial.c : trivial channel mixer plug-in (drops unwanted channels)
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: trivial.c,v 1.4 2002/09/30 21:32:31 massiot Exp $
+ * $Id: trivial.c,v 1.5 2002/10/16 23:12:46 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -107,9 +107,13 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
 {
     int i_input_nb = aout_FormatNbChannels( &p_filter->input );
     int i_output_nb = aout_FormatNbChannels( &p_filter->output );
+    s32 * p_dest = (s32 *)p_out_buf->p_buffer;
+    s32 * p_src = (s32 *)p_in_buf->p_buffer;
+    if ( p_filter->output.i_channels == AOUT_CHAN_CHANNEL2 )
+        p_src++;
 
-    SparseCopy( (s32 *)p_out_buf->p_buffer, (s32 *)p_in_buf->p_buffer,
-                p_in_buf->i_nb_samples, i_output_nb, i_input_nb );
+    SparseCopy( p_dest, p_src, p_in_buf->i_nb_samples, i_output_nb,
+                i_input_nb );
 
     p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
     p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * i_output_nb / i_input_nb;
index bc388c3952a151b91c1b2a6d3c877ec61fe218d8..8620022659ad22b4ff9ae08467b0519c4b8dce86 100644 (file)
@@ -2,11 +2,12 @@
  * sdl.c : SDL audio output plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2002 VideoLAN
- * $Id: sdl.c,v 1.13 2002/09/30 11:05:35 sam Exp $
+ * $Id: sdl.c,v 1.14 2002/10/16 23:12:45 massiot Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
  *          Pierre Baillet <oct@zoy.org>
+ *          Christophe Massiot <massiot@via.ecp.fr>
  *      
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -76,20 +77,18 @@ vlc_module_end();
 static int Open ( vlc_object_t *p_this )
 {
     aout_instance_t *p_aout = (aout_instance_t *)p_this;
-    SDL_AudioSpec desired;
+    SDL_AudioSpec desired, obtained;
+    int i_nb_channels;
 
+    /* Check that no one uses the DSP. */
     Uint32 i_flags = SDL_INIT_AUDIO;
-
     if( SDL_WasInit( i_flags ) )
     {
         return VLC_EGENERIC;
     }
 
-    p_aout->output.pf_play = Play;
-
-    aout_VolumeSoftInit( p_aout );
 #ifndef WIN32
-    /* Win32 SDL implementation doesn't support SDL_INIT_EVENTTHREAD yet*/
+    /* Win32 SDL implementation doesn't support SDL_INIT_EVENTTHREAD yet */
     i_flags |= SDL_INIT_EVENTTHREAD;
 #endif
 #ifdef DEBUG
@@ -105,28 +104,57 @@ static int Open ( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    if ( p_aout->output.output.i_channels > 2 )
-        p_aout->output.output.i_channels = 2;
-    p_aout->output.output.i_format = AOUT_FMT_S16_NE;
-    p_aout->output.i_nb_samples = FRAME_SIZE;
-
-    /* TODO: finish and clean this */
-
+    i_nb_channels = aout_FormatNbChannels( &p_aout->output.output );
+    if ( i_nb_channels > 2 )
+    {
+        /* SDL doesn't support more than two channels. */
+        i_nb_channels = 2;
+        p_aout->output.output.i_channels = AOUT_CHAN_STEREO;
+    }
     desired.freq       = p_aout->output.output.i_rate;
     desired.format     = AUDIO_S16SYS;
-    desired.channels   = p_aout->output.output.i_channels;
+    desired.channels   = i_nb_channels;
     desired.callback   = SDLCallback;
     desired.userdata   = p_aout;
     desired.samples    = FRAME_SIZE;
 
-    /* Open the sound device - FIXME : get the "natural" parameters */
-    if( SDL_OpenAudio( &desired, NULL ) < 0 )
+    /* Open the sound device. */
+    if( SDL_OpenAudio( &desired, &obtained ) < 0 )
     {
         return VLC_EGENERIC;
     }
 
     SDL_PauseAudio( 0 );
 
+    /* Now have a look at what we got. */
+    switch ( obtained.format )
+    {
+    case AUDIO_S16LSB:
+        p_aout->output.output.i_format = VLC_FOURCC('s','1','6','l'); break;
+    case AUDIO_S16MSB:
+        p_aout->output.output.i_format = VLC_FOURCC('s','1','6','b'); break;
+    case AUDIO_U16LSB:
+        p_aout->output.output.i_format = VLC_FOURCC('u','1','6','l'); break;
+    case AUDIO_U16MSB:
+        p_aout->output.output.i_format = VLC_FOURCC('u','1','6','b'); break;
+    case AUDIO_S8:
+        p_aout->output.output.i_format = VLC_FOURCC('s','8',' ',' '); break;
+    case AUDIO_U8:
+        p_aout->output.output.i_format = VLC_FOURCC('u','8',' ',' '); break;
+    }
+    /* Volume is entirely done in software. */
+    aout_VolumeSoftInit( p_aout );
+
+    if ( obtained.channels != i_nb_channels )
+    {
+        p_aout->output.output.i_channels = (obtained.channels == 2 ?
+                                            AOUT_CHAN_STEREO :
+                                            AOUT_CHAN_MONO);
+    }
+    p_aout->output.output.i_rate = obtained.freq;
+    p_aout->output.i_nb_samples = obtained.samples;
+    p_aout->output.pf_play = Play;
+
     return VLC_SUCCESS;
 }