]> git.sesse.net Git - vlc/blobdiff - src/interface/intf_ctrl.c
Encore un commit venu tout droit des abysses de l'enfer, d�sol� pour
[vlc] / src / interface / intf_ctrl.c
index d46ea45b12ab3592b6a354420bbc7723d2f27c63..5ccff0acbe43ce3892f056ad6f48e368c6ae98cf 100644 (file)
@@ -1,7 +1,5 @@
 /*****************************************************************************
  * intf_ctrl.c: interface commands access to control functions
- * (c)1999 VideoLAN
- *****************************************************************************
  * Library of functions common to all interfaces, allowing access to various
  * structures and settings. Interfaces should only use those functions
  * to read or write informations from other threads.
  * error codes defined in command.h. Custom error codes are allowed, but should
  * be positive.
  * More informations about parameters stand in `list of commands' section.
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ *
+ * Authors:
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "vlc.h"
-#include <sys/stat.h>
+#include <sys/types.h>                        /* on BSD, uio.h needs types.h */
+#include <sys/stat.h>                        /* on BSD, fstat() needs stat.h */
+#include <sys/uio.h>                                            /* "input.h" */
+#include <stdio.h>                                              /* fprintf() */
+#include <stdlib.h>                                      /* malloc(), free() */
+#include <unistd.h>                                       /* close(), read() */
+#include <fcntl.h>                                                 /* open() */
+
+/* Common headers */
+#include "config.h"
+#include "common.h"
+#include "mtime.h"
+#include "threads.h"
+#include "debug.h"
+#include "intf_msg.h"
+
+#include "input.h"
+#include "audio_output.h"
+#include "intf_cmd.h"
+#include "interface.h"
+#include "main.h"
 
 /*
  * Local prototypes
@@ -202,7 +238,7 @@ static int Exec( int i_argc, intf_arg_t *p_argv )
  *****************************************************************************/
 static int DisplayImage( int i_argc, intf_arg_t *p_argv )
 {
-    /* ?? */
+    /* XXX?? */
     return( INTF_NO_ERROR );
 }
 
@@ -275,7 +311,7 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv )
     }
 
     /* Set default configuration */
-    fifo.i_channels = 1 + AOUT_DEFAULT_STEREO;
+    fifo.i_channels = 1 + ( fifo.b_stereo = AOUT_DEFAULT_STEREO );
     fifo.l_rate = AOUT_DEFAULT_RATE;
 
     /* The channels and rate parameters are essential ! */
@@ -322,17 +358,17 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv )
 
     /* Get file size to calculate number of audio units */
     fstat( i_fd, &stat_buffer );
-    fifo.l_units = ( long )( stat_buffer.st_size / (sizeof(s16) << (fifo.i_channels - 1)) );
+    fifo.l_units = ( long )( stat_buffer.st_size / (sizeof(s16) << fifo.b_stereo) );
 
     /* Allocate memory, read file and close it */
-    if ( (fifo.buffer = malloc(sizeof(s16)*(fifo.l_units << (fifo.i_channels - 1)))) == NULL ) /* !! */
+    if ( (fifo.buffer = malloc(sizeof(s16)*(fifo.l_units << fifo.b_stereo))) == NULL ) /* !! */
     {
         intf_IntfMsg("play-audio error: not enough memory to read `%s'", psz_file );
         close( i_fd );                                         /* close file */
         return( INTF_OTHER_ERROR );
     }
-    if ( read(i_fd, fifo.buffer, sizeof(s16)*(fifo.l_units << (fifo.i_channels - 1)))
-        != sizeof(s16)*(fifo.l_units << (fifo.i_channels - 1)) )
+    if ( read(i_fd, fifo.buffer, sizeof(s16)*(fifo.l_units << fifo.b_stereo))
+        != sizeof(s16)*(fifo.l_units << fifo.b_stereo) )
     {
         intf_IntfMsg("play-audio error: can't read %s", psz_file);
         free( fifo.buffer );
@@ -341,7 +377,7 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv )
     }
     close( i_fd );
 
-    /* Now we can work out how many output units we can compute with the fifo */
+   /* Now we can work out how many output units we can compute with the fifo */
     fifo.l_units = (long)(((s64)fifo.l_units*(s64)p_main->p_aout->l_rate)/(s64)fifo.l_rate);
 
     /* Create the fifo */
@@ -358,11 +394,11 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv )
 /*****************************************************************************
  * PlayVideo: play a video sequence from a file
  *****************************************************************************
- * ??
+ * XXX??
  *****************************************************************************/
 static int PlayVideo( int i_argc, intf_arg_t *p_argv )
 {
-    /* ?? */
+    /* XXX?? */
     return( INTF_NO_ERROR );
 }
 
@@ -394,7 +430,7 @@ static int SelectPID( int i_argc, intf_arg_t *p_argv )
       switch( p_argv[i_arg].i_index )
       {
       case 0:
-          // ?? useless
+          /* FIXME: useless ?? */
           i_input = p_argv[i_arg].i_num;
           break;
       case 1:
@@ -406,8 +442,8 @@ static int SelectPID( int i_argc, intf_arg_t *p_argv )
 
     /* Find to which input this command is destinated */
     intf_IntfMsg( "Adding PID %d to input %d\n", i_pid, i_input );
-//????    input_AddPgrmElem( p_main->p_intf->p_x11->p_input,
-//????                       i_pid );
+    //XXX?? input_AddPgrmElem( p_main->p_intf->p_x11->p_input,
+    //XXX??                    i_pid );
     return( INTF_NO_ERROR );
 }
 
@@ -471,7 +507,7 @@ static int Test( int i_argc, intf_arg_t *p_argv )
 {
     int i_thread;
 
-/*??    if( i_argc == 1 )
+/*XXX??    if( i_argc == 1 )
     {
         i_thread = intf_CreateVoutThread( &p_main->intf_thread, NULL, -1, -1);
         intf_IntfMsg("return value: %d", i_thread );
@@ -479,7 +515,7 @@ static int Test( int i_argc, intf_arg_t *p_argv )
     else*/
     {
         i_thread = p_argv[1].i_num;
-    //??    intf_DestroyVoutThread( &p_main->intf_thread, i_thread );
+    //XXX??    intf_DestroyVoutThread( &p_main->intf_thread, i_thread );
     }
 
     return( INTF_NO_ERROR );
@@ -512,12 +548,12 @@ static int Vlan( int i_argc, intf_arg_t *p_argv  )
     /* Command is 'join' */
     if( !strcmp(p_argv[i_command].psz_str, "join") )
     {
-        /* ?? */
+        /* XXX?? */
     }
     /* Command is 'leave' */
     else if( !strcmp(p_argv[i_command].psz_str, "leave") )
     {
-        /* ?? */
+        /* XXX?? */
     }
     /* Command is unknown */
     else
@@ -540,6 +576,6 @@ static int Psi( int i_argc, intf_arg_t *p_argv )
     int i_index = p_argv[1].i_num;
 
     intf_IntfMsg("Reading PSI table for input %d\n", i_index);
-//????    input_PsiRead(p_main->p_intf->p_x11->p_input );
+    //XXX?? input_PsiRead(p_main->p_intf->p_x11->p_input );
     return( INTF_NO_ERROR );
 }