示例#1
0
/*
 * The purpose of this function is to let the user to select 
 *   the input where he plugged his signals.
 * Now if user select "default", as device, we have to select the input
 *   on the mixer of the card used by  "default".
 * What is the card used by device  "default" ?
 */ 
static void
as_setup_input_combo (GtkWidget *combo, SoundParams *sparams)
{
   snd_mixer_t *handle;
   int i ;
   snd_mixer_selem_id_t *sid;
   snd_mixer_elem_t *elem;
   snd_mixer_selem_id_alloca(&sid);
   char *devname;
   char name[32];

   devname = sparams->device_name;
   if ( *sparams->indexstr == '-' ) {
      sprintf(name, "hw:%d", sparams->firstcard);
      devname = name;
   }
   handle = sound_open_mixer(devname);
   if ( handle == NULL ){
      return ;
   }   

   for (elem = snd_mixer_first_elem(handle); elem; elem = snd_mixer_elem_next(elem)) {
      snd_mixer_selem_get_id(elem, sid);
      if (! snd_mixer_selem_is_active(elem)) {
	 continue;
      }
      const char *control_name = snd_mixer_selem_id_get_name(sid);
//      printf("Simple mixer control '%s',%i\n", control_name,  snd_mixer_selem_id_get_index(sid));
      if (snd_mixer_selem_is_enum_capture(elem)) {
	 int items;
	 char itemname[40];
	 app_free(sparams->control_name);
	 sparams->control_name = app_strdup(control_name);
	 items = snd_mixer_selem_get_enum_items(elem);
//	 printf("  Items:");
	 for (i = 0; i < items; i++) {
	    snd_mixer_selem_get_enum_item_name(elem, i, sizeof(itemname) - 1, itemname);
//	    printf(" '%s'", itemname);
            gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), itemname );
	    if ( i == sparams->input ) {
	       gtk_combo_box_set_active (GTK_COMBO_BOX (combo), i);
	    }
	 }
//	 printf("\n");
      }
   }
   snd_mixer_close(handle);
   return ;
}
示例#2
0
int sound_init( void ) {
	int i;
	
	for( i = 0 ; i < NUM_SOUNDS ; i++ )
		sounds[i] = NULL;
	
	if( sound_open_mixer() != 0 )
		return -1;

	for( i = 0 ; i < NUM_SOUNDS ; i++ ) {
		sounds[i] = Mix_LoadWAV( config_get()->iface.theme.sounds[i] );
		if( sounds[i] == NULL ) {
			fprintf( stderr, "Warning: Unable to open sound: %s\n", config_get()->iface.theme.sounds[i] );
		}
	}

	return 0;
}
示例#3
0
void video_close( void ) {
    int timeout = 10;
    stop = 1;

    packet_queue_flush( &audio_queue );
    frame_queue_flush( &video_queue );

    while( (reader_running || audio_running) && timeout-- )
        SDL_Delay( 10 );

    if( audio_open )
        SDL_CloseAudio();
    audio_open = 0;

    if( video_codec_context )
        avcodec_close( video_codec_context );
    video_codec_context = NULL;

    if( audio_codec_context )
        avcodec_close( audio_codec_context );
    audio_codec_context = NULL;

    if( format_context )
        av_close_input_file( format_context );
    format_context = NULL;

    if( video_buffer )
        av_free( video_buffer );
    video_buffer = NULL;

    video_stream = -1;
    audio_stream = -1;

    if( texture )
        ogl_free_texture( texture );
    texture = NULL;
    got_texture = 0;

    sound_open_mixer();
}