⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intf_ctrl.c

📁 vlc stand 0.1.99 ist sehr einfach
💻 C
📖 第 1 页 / 共 2 页
字号:
}/***************************************************************************** * PlayAudio: play an audio file                                         (ok ?) ***************************************************************************** * Play a raw audio file from a file, at a given rate. *****************************************************************************/static int PlayAudio( int i_argc, intf_arg_t *p_argv ){    char * psz_file = NULL;              /* name of the audio raw file (s16) */    int i_fd;      /* file descriptor of the audio file that is to be loaded */    aout_fifo_t fifo;         /* fifo stores the informations about the file */    struct stat stat_buffer;      /* needed to find out the size of psz_file */    int i_arg;                                             /* argument index */    if ( !p_main->b_audio )                  /* audio is disabled */    {        intf_IntfMsg("play-audio error: audio is disabled");        return( INTF_NO_ERROR );    }    /* Set default configuration */    fifo.i_channels = 1 + ( fifo.b_stereo = AOUT_DEFAULT_STEREO );    fifo.l_rate = AOUT_DEFAULT_RATE;    /* The channels and rate parameters are essential ! */    /* Parse parameters - see command list above */    for ( i_arg = 1; i_arg < i_argc; i_arg++ )    {        switch( p_argv[i_arg].i_index )        {        case 0:                                                  /* channels */            fifo.i_channels = p_argv[i_arg].i_num;            break;        case 1:                                                      /* rate */            fifo.l_rate = p_argv[i_arg].i_num;            break;        case 2:                                                  /* filename */            psz_file = p_argv[i_arg].psz_str;            break;        }    }    /* Setting up the type of the fifo */    switch ( fifo.i_channels )    {        case 1:            fifo.i_type = AOUT_INTF_MONO_FIFO;            break;        case 2:            fifo.i_type = AOUT_INTF_STEREO_FIFO;            break;        default:            intf_IntfMsg("play-audio error: channels must be 1 or 2");            return( INTF_OTHER_ERROR );    }    /* Open file */    i_fd =  open( psz_file, O_RDONLY );    if ( i_fd < 0 )                                                 /* error */    {        intf_IntfMsg("play-audio error: can't open `%s'", psz_file);        return( INTF_OTHER_ERROR );    }    /* 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.b_stereo) );    /* Allocate memory, read file and close it */    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.b_stereo))        != sizeof(s16)*(fifo.l_units << fifo.b_stereo) )    {        intf_IntfMsg("play-audio error: can't read %s", psz_file);        free( fifo.buffer );        close( i_fd );        return( INTF_OTHER_ERROR );    }    close( i_fd );   /* 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 */    if ( aout_CreateFifo(p_main->p_aout, &fifo) == NULL )    {        intf_IntfMsg("play-audio error: can't create audio fifo");        free( fifo.buffer );        return( INTF_OTHER_ERROR );    }    return( INTF_NO_ERROR );}/***************************************************************************** * 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 );}/***************************************************************************** * Quit: quit program                                                    (ok ?) ***************************************************************************** * This function set `die' flag of interface, asking the program to terminate. *****************************************************************************/static int Quit( int i_argc, intf_arg_t *p_argv ){    p_main->p_intf->b_die = 1;    return( INTF_NO_ERROR );}/***************************************************************************** * ***************************************************************************** * *****************************************************************************/static int SelectPID( int i_argc, intf_arg_t *p_argv ){    int i_input = -1, i_pid = -1;    int i_arg;    /* Parse parameters - see command list above */    for ( i_arg = 1; i_arg < i_argc; i_arg++ )    {      switch( p_argv[i_arg].i_index )      {      case 0:          /* FIXME: useless ?? */          i_input = p_argv[i_arg].i_num;          break;      case 1:         i_pid = p_argv[i_arg].i_num;        break;      }    }    /* Find to which input this command is destinated */    intf_IntfMsg( "Adding PID %d to input %d\n", i_pid, i_input );    //XXX?? input_AddPgrmElem( p_main->p_intf->p_x11->p_input,    //XXX??                    i_pid );    return( INTF_NO_ERROR );}/***************************************************************************** * SpawnInput: spawn an input thread                                     (ok ?) ***************************************************************************** * Spawn an input thread *****************************************************************************/static int SpawnInput( int i_argc, intf_arg_t *p_argv ){    int                 i_arg;    int                 i_method = 0;                    /* method parameter */    char *              p_source = NULL;                 /* source parameter */    int                 i_port = 0;                        /* port parameter */    int                 i_vlan = 0;                        /* vlan parameter */    fprintf( stderr, "spawn input\n" );    /* Parse parameters - see command list above */    for ( i_arg = 1; i_arg < i_argc; i_arg++ )    {        switch( p_argv[i_arg].i_index )        {        case 0:                                                    /* method */            i_method = p_argv[i_arg].i_num;            break;        case 1:                                    /* filename, hostname, ip */        case 2:        case 3:            p_source = p_argv[i_arg].psz_str;            break;        case 4:                                                      /* port */            i_port = p_argv[i_arg].i_num;            break;        case 5:                                                      /* VLAN */            i_vlan = p_argv[i_arg].i_num;            break;        }    }    /* Destroy current input, if any */    if( p_main->p_intf->p_input != NULL )    {        input_DestroyThread( p_main->p_intf->p_input, NULL );    }    p_main->p_intf->p_input = input_CreateThread( i_method, p_source, i_port, i_vlan,                                                  p_main->p_intf->p_vout, p_main->p_aout,                                                  NULL );    return( INTF_NO_ERROR );}/***************************************************************************** * Test: test function ***************************************************************************** * This function is provided to test new functions in the program. Fell free * to modify ! * This function is only defined in DEBUG mode. *****************************************************************************/#ifdef DEBUGstatic int Test( int i_argc, intf_arg_t *p_argv ){    int i_thread;/*XXX??    if( i_argc == 1 )    {        i_thread = intf_CreateVoutThread( &p_main->intf_thread, NULL, -1, -1);        intf_IntfMsg("return value: %d", i_thread );    }    else*/    {        i_thread = p_argv[1].i_num;    //XXX??    intf_DestroyVoutThread( &p_main->intf_thread, i_thread );    }    return( INTF_NO_ERROR );}#endif/***************************************************************************** * Vlan: vlan operations ***************************************************************************** * This function performs various vlan operations. *****************************************************************************/static int Vlan( int i_argc, intf_arg_t *p_argv  ){    int i_command;                                /* command argument number */    /* Do not try anything if vlans are desactivated */    if( !p_main->b_vlans )    {        intf_IntfMsg("vlans are desactivated");        return( INTF_OTHER_ERROR );    }    /* Look for command in list of arguments - this argument is mandatory and     * imposed by the calling function */    for( i_command = 1; p_argv[i_command].i_index == 1; i_command++ )    {        ;    }    /* 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    {        intf_IntfMsg("vlan error: unknown command %s", p_argv[i_command].psz_str );        return( INTF_USAGE_ERROR );    }    return( INTF_NO_ERROR );}/***************************************************************************** * Psi ***************************************************************************** * This function is provided to display PSI tables. *****************************************************************************/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);    //XXX?? input_PsiRead(p_main->p_intf->p_x11->p_input );    return( INTF_NO_ERROR );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -