/***************************************************************************** * End: terminate logo video thread output method *****************************************************************************/ static void End( vout_thread_t *p_vout ) { vout_sys_t *p_sys = p_vout->p_sys; int i_index; /* Free the fake output buffers we allocated */ for( i_index = I_OUTPUTPICTURES ; i_index ; ) { i_index--; free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig ); } var_DelCallback( p_sys->p_vout, "mouse-x", MouseEvent, p_vout); var_DelCallback( p_sys->p_vout, "mouse-y", MouseEvent, p_vout); if( p_sys->p_vout ) { DEL_CALLBACKS( p_sys->p_vout, SendEvents ); vlc_object_detach( p_sys->p_vout ); vout_Destroy( p_sys->p_vout ); } if( p_sys->p_blend->p_module ) module_Unneed( p_sys->p_blend, p_sys->p_blend->p_module ); vlc_object_detach( p_sys->p_blend ); vlc_object_destroy( p_sys->p_blend ); }
void services_discovery_Stop ( services_discovery_t * p_sd ) { ObjectKillChildrens( VLC_OBJECT(p_sd) ); if( p_sd->pf_run ) vlc_thread_join( p_sd ); module_Unneed( p_sd, p_sd->p_module ); }
static void osd_ParserUnload( osd_menu_t *p_menu ) { if( p_menu->p_image ) image_HandlerDelete( p_menu->p_image ); if( p_menu->p_parser ) module_Unneed( p_menu, p_menu->p_parser ); free( p_menu->psz_file ); }
/***************************************************************************** * Close: frees unused data *****************************************************************************/ static void Close( vlc_object_t * p_this ) { demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys = p_demux->p_sys; module_Unneed( p_sys->p_packetizer, p_sys->p_packetizer->p_module ); vlc_object_destroy( p_sys->p_packetizer ); free( p_sys ); }
/***************************************************************************** * Close: destroy interface window *****************************************************************************/ static void Close( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; #ifdef NEED_GTK2_MAIN module_Unneed( p_intf, p_intf->p_sys->p_gui_helper ); #endif /* Destroy structure */ free( p_intf->p_sys ); }
/** * \brief Destroy the interface after the main loop endeed. * * \param p_intf the interface thread * \return nothing */ static void intf_Destroy( vlc_object_t *obj ) { intf_thread_t *p_intf = (intf_thread_t *)obj; /* Unlock module if present (a switch may have failed) */ if( p_intf->p_module ) module_Unneed( p_intf, p_intf->p_module ); free( p_intf->psz_intf ); vlc_mutex_destroy( &p_intf->change_lock ); }
/***************************************************************************** * aout_FiltersDestroyPipeline: deallocate a filters pipeline *****************************************************************************/ void aout_FiltersDestroyPipeline( aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters ) { int i; for ( i = 0; i < i_nb_filters; i++ ) { module_Unneed( pp_filters[i], pp_filters[i]->p_module ); vlc_object_detach( pp_filters[i] ); vlc_object_destroy( pp_filters[i] ); } }
/***************************************************************************** * Close: frees unused data *****************************************************************************/ static void Close( vlc_object_t * p_this ) { demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys = p_demux->p_sys; /* Unneed module */ module_Unneed( p_sys->p_packetizer, p_sys->p_packetizer->p_module ); /* Delete the decoder */ vlc_object_destroy( p_sys->p_packetizer ); free( p_sys ); }
/** * Export a playlist to a certain type of playlistfile * * \param p_playlist the playlist to export * \param psz_filename the location where the exported file will be saved * \param psz_type the type of playlist file to create. * \return VLC_SUCCESS on success */ int playlist_Export( playlist_t * p_playlist, const char *psz_filename , const char *psz_type) { module_t *p_module; playlist_export_t *p_export; msg_Info( p_playlist, "saving playlist to file %s", psz_filename ); /* Prepare the playlist_export_t structure */ p_export = (playlist_export_t *)malloc( sizeof(playlist_export_t) ); if( !p_export) { msg_Err( p_playlist, "out of memory"); return VLC_ENOMEM; } p_export->psz_filename = NULL; if ( psz_filename ) p_export->psz_filename = strdup( psz_filename ); p_export->p_file = utf8_fopen( psz_filename, "wt" ); if( !p_export->p_file ) { msg_Err( p_playlist , "could not create playlist file %s" " (%s)", psz_filename, strerror(errno) ); return VLC_EGENERIC; } p_playlist->p_private = (void *)p_export; /* Lock the playlist */ vlc_mutex_lock( &p_playlist->object_lock ); /* And call the module ! All work is done now */ p_module = module_Need( p_playlist, "playlist export", psz_type, VLC_TRUE); if( !p_module ) { msg_Warn( p_playlist, "exporting playlist failed" ); vlc_mutex_unlock( &p_playlist->object_lock ); return VLC_ENOOBJ; } module_Unneed( p_playlist , p_module ); /* Clean up */ fclose( p_export->p_file ); if ( p_export->psz_filename ) free( p_export->psz_filename ); free ( p_export ); p_playlist->p_private = NULL; vlc_mutex_unlock( &p_playlist->object_lock ); return VLC_SUCCESS; }
void vout_ReleaseWindow( vout_thread_t *p_vout, void *dummy ) { vout_window_t *wnd = p_vout->p_window; if (wnd == NULL) return; p_vout->p_window = NULL; assert (wnd->module); module_Unneed (wnd, wnd->module); vlc_object_release (wnd); (void)dummy; }
/***************************************************************************** * Close: destroy interface window *****************************************************************************/ static void Close( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; if( p_intf->p_sys->p_input ) { vlc_object_release( p_intf->p_sys->p_input ); } #ifdef NEED_GTK2_MAIN msg_Dbg( p_intf, "Releasing gui-helper" ); module_Unneed( p_intf, p_intf->p_sys->p_gtk_main ); #endif /* Destroy structure */ free( p_intf->p_sys ); }
/***************************************************************************** * aout_OutputDelete : delete the output ***************************************************************************** * This function is entered with the mixer lock. *****************************************************************************/ void aout_OutputDelete( aout_instance_t * p_aout ) { if ( p_aout->output.b_error ) { return; } module_Unneed( p_aout, p_aout->output.p_module ); aout_FiltersDestroyPipeline( p_aout, p_aout->output.pp_filters, p_aout->output.i_nb_filters ); aout_lock_output_fifo( p_aout ); aout_FifoDestroy( p_aout, &p_aout->output.fifo ); aout_unlock_output_fifo( p_aout ); p_aout->output.b_error = true; }
/***************************************************************************** * aout_InputNew : allocate a new input and rework the filter pipeline *****************************************************************************/ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input ) { audio_sample_format_t chain_input_format; audio_sample_format_t chain_output_format; vlc_value_t val, text; char * psz_filters, *psz_visual; int i_visual; aout_FormatPrint( p_aout, "input", &p_input->input ); p_input->i_nb_filters = 0; /* Prepare FIFO. */ aout_FifoInit( p_aout, &p_input->fifo, p_aout->mixer.mixer.i_rate ); p_input->p_first_byte_to_mix = NULL; /* Prepare format structure */ memcpy( &chain_input_format, &p_input->input, sizeof(audio_sample_format_t) ); memcpy( &chain_output_format, &p_aout->mixer.mixer, sizeof(audio_sample_format_t) ); chain_output_format.i_rate = p_input->input.i_rate; aout_FormatPrepare( &chain_output_format ); /* Now add user filters */ if( var_Type( p_aout, "visual" ) == 0 ) { module_t *p_module; var_Create( p_aout, "visual", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); text.psz_string = _("Visualizations"); var_Change( p_aout, "visual", VLC_VAR_SETTEXT, &text, NULL ); val.psz_string = ""; text.psz_string = _("Disable"); var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = "spectrometer"; text.psz_string = _("Spectrometer"); var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = "scope"; text.psz_string = _("Scope"); var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = "spectrum"; text.psz_string = _("Spectrum"); var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text ); /* Look for goom plugin */ p_module = config_FindModule( VLC_OBJECT(p_aout), "goom" ); if( p_module ) { val.psz_string = "goom"; text.psz_string = "Goom"; var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text ); } /* Look for galaktos plugin */ p_module = config_FindModule( VLC_OBJECT(p_aout), "galaktos" ); if( p_module ) { val.psz_string = "galaktos"; text.psz_string = "GaLaktos"; var_Change( p_aout, "visual", VLC_VAR_ADDCHOICE, &val, &text ); } if( var_Get( p_aout, "effect-list", &val ) == VLC_SUCCESS ) { var_Set( p_aout, "visual", val ); if( val.psz_string ) free( val.psz_string ); } var_AddCallback( p_aout, "visual", VisualizationCallback, NULL ); } if( var_Type( p_aout, "equalizer" ) == 0 ) { module_config_t *p_config; int i; p_config = config_FindConfig( VLC_OBJECT(p_aout), "equalizer-preset" ); if( p_config && p_config->i_list ) { var_Create( p_aout, "equalizer", VLC_VAR_STRING | VLC_VAR_HASCHOICE ); text.psz_string = _("Equalizer"); var_Change( p_aout, "equalizer", VLC_VAR_SETTEXT, &text, NULL ); val.psz_string = ""; text.psz_string = _("Disable"); var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text ); for( i = 0; i < p_config->i_list; i++ ) { val.psz_string = p_config->ppsz_list[i]; text.psz_string = p_config->ppsz_list_text[i]; var_Change( p_aout, "equalizer", VLC_VAR_ADDCHOICE, &val, &text ); } var_AddCallback( p_aout, "equalizer", EqualizerCallback, NULL ); } } if( var_Type( p_aout, "audio-filter" ) == 0 ) { var_Create( p_aout, "audio-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); text.psz_string = _("Audio filters"); var_Change( p_aout, "audio-filter", VLC_VAR_SETTEXT, &text, NULL ); } if( var_Type( p_aout, "audio-visual" ) == 0 ) { var_Create( p_aout, "audio-visual", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); text.psz_string = _("Audio visualizations"); var_Change( p_aout, "audio-visual", VLC_VAR_SETTEXT, &text, NULL ); } var_Get( p_aout, "audio-filter", &val ); psz_filters = val.psz_string; var_Get( p_aout, "audio-visual", &val ); psz_visual = val.psz_string; /* parse user filter lists */ for( i_visual = 0; i_visual < 2; i_visual++ ) { char *psz_next = NULL; char *psz_parser = i_visual ? psz_visual : psz_filters; if( psz_parser == NULL || !*psz_parser ) continue; while( psz_parser && *psz_parser ) { aout_filter_t * p_filter = NULL; if( p_input->i_nb_filters >= AOUT_MAX_FILTERS ) { msg_Dbg( p_aout, "max filters reached (%d)", AOUT_MAX_FILTERS ); break; } while( *psz_parser == ' ' && *psz_parser == ':' ) { psz_parser++; } if( ( psz_next = strchr( psz_parser , ':' ) ) ) { *psz_next++ = '\0'; } if( *psz_parser =='\0' ) { break; } /* Create a VLC object */ p_filter = vlc_object_create( p_aout, sizeof(aout_filter_t) ); if( p_filter == NULL ) { msg_Err( p_aout, "cannot add user filter %s (skipped)", psz_parser ); psz_parser = psz_next; continue; } vlc_object_attach( p_filter , p_aout ); /* try to find the requested filter */ if( i_visual == 1 ) /* this can only be a visualization module */ { /* request format */ memcpy( &p_filter->input, &chain_output_format, sizeof(audio_sample_format_t) ); memcpy( &p_filter->output, &chain_output_format, sizeof(audio_sample_format_t) ); p_filter->p_module = module_Need( p_filter, "visualization", psz_parser, VLC_TRUE ); } else /* this can be a audio filter module as well as a visualization module */ { /* request format */ memcpy( &p_filter->input, &chain_input_format, sizeof(audio_sample_format_t) ); memcpy( &p_filter->output, &chain_output_format, sizeof(audio_sample_format_t) ); p_filter->p_module = module_Need( p_filter, "audio filter", psz_parser, VLC_TRUE ); if ( p_filter->p_module == NULL ) { /* if the filter requested a special format, retry */ if ( !( AOUT_FMTS_IDENTICAL( &p_filter->input, &chain_input_format ) && AOUT_FMTS_IDENTICAL( &p_filter->output, &chain_output_format ) ) ) { aout_FormatPrepare( &p_filter->input ); aout_FormatPrepare( &p_filter->output ); p_filter->p_module = module_Need( p_filter, "audio filter", psz_parser, VLC_TRUE ); } /* try visual filters */ else { memcpy( &p_filter->input, &chain_output_format, sizeof(audio_sample_format_t) ); memcpy( &p_filter->output, &chain_output_format, sizeof(audio_sample_format_t) ); p_filter->p_module = module_Need( p_filter, "visualization", psz_parser, VLC_TRUE ); } } } /* failure */ if ( p_filter->p_module == NULL ) { msg_Err( p_aout, "cannot add user filter %s (skipped)", psz_parser ); vlc_object_detach( p_filter ); vlc_object_destroy( p_filter ); psz_parser = psz_next; continue; } /* complete the filter chain if necessary */ if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &p_filter->input ) ) { if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters, &p_input->i_nb_filters, &chain_input_format, &p_filter->input ) < 0 ) { msg_Err( p_aout, "cannot add user filter %s (skipped)", psz_parser ); module_Unneed( p_filter, p_filter->p_module ); vlc_object_detach( p_filter ); vlc_object_destroy( p_filter ); psz_parser = psz_next; continue; } } /* success */ p_filter->b_continuity = VLC_FALSE; p_input->pp_filters[p_input->i_nb_filters++] = p_filter; memcpy( &chain_input_format, &p_filter->output, sizeof( audio_sample_format_t ) ); /* next filter if any */ psz_parser = psz_next; } } if( psz_filters ) free( psz_filters ); if( psz_visual ) free( psz_visual ); /* complete the filter chain if necessary */ if ( !AOUT_FMTS_IDENTICAL( &chain_input_format, &chain_output_format ) ) { if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters, &p_input->i_nb_filters, &chain_input_format, &chain_output_format ) < 0 ) { inputFailure( p_aout, p_input, "couldn't set an input pipeline" ); return -1; } } /* Prepare hints for the buffer allocator. */ p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP; p_input->input_alloc.i_bytes_per_sec = -1; /* Create resamplers. */ if ( AOUT_FMT_NON_LINEAR( &p_aout->mixer.mixer ) ) { p_input->i_nb_resamplers = 0; } else { chain_output_format.i_rate = (__MAX(p_input->input.i_rate, p_aout->mixer.mixer.i_rate) * (100 + AOUT_MAX_RESAMPLING)) / 100; if ( chain_output_format.i_rate == p_aout->mixer.mixer.i_rate ) { /* Just in case... */ chain_output_format.i_rate++; } p_input->i_nb_resamplers = 0; if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_resamplers, &p_input->i_nb_resamplers, &chain_output_format, &p_aout->mixer.mixer ) < 0 ) { inputFailure( p_aout, p_input, "couldn't set a resampler pipeline"); return -1; } aout_FiltersHintBuffers( p_aout, p_input->pp_resamplers, p_input->i_nb_resamplers, &p_input->input_alloc ); p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP; /* Setup the initial rate of the resampler */ p_input->pp_resamplers[0]->input.i_rate = p_input->input.i_rate; } p_input->i_resampling_type = AOUT_RESAMPLING_NONE; aout_FiltersHintBuffers( p_aout, p_input->pp_filters, p_input->i_nb_filters, &p_input->input_alloc ); p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP; /* i_bytes_per_sec is still == -1 if no filters */ p_input->input_alloc.i_bytes_per_sec = __MAX( p_input->input_alloc.i_bytes_per_sec, (int)(p_input->input.i_bytes_per_frame * p_input->input.i_rate / p_input->input.i_frame_length) ); /* Success */ p_input->b_error = VLC_FALSE; p_input->b_restart = VLC_FALSE; return 0; }
/***************************************************************************** * aout_OutputNew : allocate a new output and rework the filter pipeline ***************************************************************************** * This function is entered with the mixer lock. *****************************************************************************/ int aout_OutputNew( aout_instance_t * p_aout, audio_sample_format_t * p_format ) { /* Retrieve user defaults. */ int i_rate = config_GetInt( p_aout, "aout-rate" ); vlc_value_t val, text; /* kludge to avoid a fpu error when rate is 0... */ if( i_rate == 0 ) i_rate = -1; memcpy( &p_aout->output.output, p_format, sizeof(audio_sample_format_t) ); if ( i_rate != -1 ) p_aout->output.output.i_rate = i_rate; aout_FormatPrepare( &p_aout->output.output ); aout_lock_output_fifo( p_aout ); /* Find the best output plug-in. */ p_aout->output.p_module = module_Need( p_aout, "audio output", "$aout", 0); if ( p_aout->output.p_module == NULL ) { msg_Err( p_aout, "no suitable audio output module" ); aout_unlock_output_fifo( p_aout ); return -1; } if ( var_Type( p_aout, "audio-channels" ) == (VLC_VAR_INTEGER | VLC_VAR_HASCHOICE) ) { /* The user may have selected a different channels configuration. */ var_Get( p_aout, "audio-channels", &val ); if ( val.i_int == AOUT_VAR_CHAN_RSTEREO ) { p_aout->output.output.i_original_channels |= AOUT_CHAN_REVERSESTEREO; } else if ( val.i_int == AOUT_VAR_CHAN_STEREO ) { p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; } else if ( val.i_int == AOUT_VAR_CHAN_LEFT ) { p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT; } else if ( val.i_int == AOUT_VAR_CHAN_RIGHT ) { p_aout->output.output.i_original_channels = AOUT_CHAN_RIGHT; } else if ( val.i_int == AOUT_VAR_CHAN_DOLBYS ) { p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_DOLBYSTEREO; } } else if ( p_aout->output.output.i_physical_channels == AOUT_CHAN_CENTER && (p_aout->output.output.i_original_channels & AOUT_CHAN_PHYSMASK) == (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) ) { /* Mono - create the audio-channels variable. */ var_Create( p_aout, "audio-channels", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); text.psz_string = _("Audio Channels"); var_Change( p_aout, "audio-channels", VLC_VAR_SETTEXT, &text, NULL ); val.i_int = AOUT_VAR_CHAN_STEREO; text.psz_string = _("Stereo"); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); val.i_int = AOUT_VAR_CHAN_LEFT; text.psz_string = _("Left"); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); val.i_int = AOUT_VAR_CHAN_RIGHT; text.psz_string = _("Right"); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); if ( p_aout->output.output.i_original_channels & AOUT_CHAN_DUALMONO ) { /* Go directly to the left channel. */ p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT; val.i_int = AOUT_VAR_CHAN_LEFT; var_Set( p_aout, "audio-channels", val ); } var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart, NULL ); } else if ( p_aout->output.output.i_physical_channels == (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) && (p_aout->output.output.i_original_channels & (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)) ) { /* Stereo - create the audio-channels variable. */ var_Create( p_aout, "audio-channels", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); text.psz_string = _("Audio Channels"); var_Change( p_aout, "audio-channels", VLC_VAR_SETTEXT, &text, NULL ); if ( p_aout->output.output.i_original_channels & AOUT_CHAN_DOLBYSTEREO ) { val.i_int = AOUT_VAR_CHAN_DOLBYS; text.psz_string = _("Dolby Surround"); } else { val.i_int = AOUT_VAR_CHAN_STEREO; text.psz_string = _("Stereo"); } var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); val.i_int = AOUT_VAR_CHAN_LEFT; text.psz_string = _("Left"); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); val.i_int = AOUT_VAR_CHAN_RIGHT; text.psz_string = _("Right"); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); val.i_int = AOUT_VAR_CHAN_RSTEREO; text.psz_string=_("Reverse stereo"); var_Change( p_aout, "audio-channels", VLC_VAR_ADDCHOICE, &val, &text ); if ( p_aout->output.output.i_original_channels & AOUT_CHAN_DUALMONO ) { /* Go directly to the left channel. */ p_aout->output.output.i_original_channels = AOUT_CHAN_LEFT; val.i_int = AOUT_VAR_CHAN_LEFT; var_Set( p_aout, "audio-channels", val ); } var_AddCallback( p_aout, "audio-channels", aout_ChannelsRestart, NULL ); } val.b_bool = true; var_Set( p_aout, "intf-change", val ); aout_FormatPrepare( &p_aout->output.output ); /* Prepare FIFO. */ aout_FifoInit( p_aout, &p_aout->output.fifo, p_aout->output.output.i_rate ); aout_unlock_output_fifo( p_aout ); aout_FormatPrint( p_aout, "output", &p_aout->output.output ); /* Calculate the resulting mixer output format. */ memcpy( &p_aout->mixer.mixer, &p_aout->output.output, sizeof(audio_sample_format_t) ); if ( !AOUT_FMT_NON_LINEAR(&p_aout->output.output) ) { /* Non-S/PDIF mixer only deals with float32 or fixed32. */ p_aout->mixer.mixer.i_format = (vlc_CPU() & CPU_CAPABILITY_FPU) ? VLC_FOURCC('f','l','3','2') : VLC_FOURCC('f','i','3','2'); aout_FormatPrepare( &p_aout->mixer.mixer ); } else { p_aout->mixer.mixer.i_format = p_format->i_format; } aout_FormatPrint( p_aout, "mixer", &p_aout->mixer.mixer ); /* Create filters. */ p_aout->output.i_nb_filters = 0; if ( aout_FiltersCreatePipeline( p_aout, p_aout->output.pp_filters, &p_aout->output.i_nb_filters, &p_aout->mixer.mixer, &p_aout->output.output ) < 0 ) { msg_Err( p_aout, "couldn't create audio output pipeline" ); module_Unneed( p_aout, p_aout->output.p_module ); return -1; } /* Prepare hints for the buffer allocator. */ p_aout->mixer.output_alloc.i_alloc_type = AOUT_ALLOC_HEAP; p_aout->mixer.output_alloc.i_bytes_per_sec = p_aout->mixer.mixer.i_bytes_per_frame * p_aout->mixer.mixer.i_rate / p_aout->mixer.mixer.i_frame_length; aout_FiltersHintBuffers( p_aout, p_aout->output.pp_filters, p_aout->output.i_nb_filters, &p_aout->mixer.output_alloc ); p_aout->output.b_error = 0; return 0; }
/***************************************************************************** * Open: initializes demux structures *****************************************************************************/ static int Open( vlc_object_t * p_this ) { demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys; uint8_t *p_peek; module_t *p_id3; int b_forced = VLC_FALSE; if( p_demux->psz_path ) { int i_len = strlen( p_demux->psz_path ); if( i_len > 4 && !strcasecmp( &p_demux->psz_path[i_len - 4], ".aac" ) ) { b_forced = VLC_TRUE; } } if( !p_demux->b_force && !b_forced ) { return VLC_EGENERIC; } /* skip possible id3 header */ if( ( p_id3 = module_Need( p_demux, "id3", NULL, 0 ) ) ) { module_Unneed( p_demux, p_id3 ); } /* peek the begining (10 is for adts header) */ if( stream_Peek( p_demux->s, &p_peek, 10 ) < 10 ) { msg_Err( p_demux, "cannot peek" ); return VLC_EGENERIC; } if( !strncmp( p_peek, "ADIF", 4 ) ) { msg_Err( p_demux, "ADIF file. Not yet supported. (Please report)" ); return VLC_EGENERIC; } p_demux->pf_demux = Demux; p_demux->pf_control= Control; p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); p_sys->p_es = NULL; p_sys->b_start = VLC_TRUE; /* * Load the mpeg 4 audio packetizer */ p_sys->p_packetizer = vlc_object_create( p_demux, VLC_OBJECT_PACKETIZER ); p_sys->p_packetizer->pf_decode_audio = NULL; p_sys->p_packetizer->pf_decode_video = NULL; p_sys->p_packetizer->pf_decode_sub = NULL; p_sys->p_packetizer->pf_packetize = NULL; es_format_Init( &p_sys->p_packetizer->fmt_in, AUDIO_ES, VLC_FOURCC( 'm', 'p', '4', 'a' ) ); es_format_Init( &p_sys->p_packetizer->fmt_out, UNKNOWN_ES, 0 ); p_sys->p_packetizer->p_module = module_Need( p_sys->p_packetizer, "packetizer", NULL, 0 ); if( p_sys->p_packetizer->p_module == NULL) { vlc_object_destroy( p_sys->p_packetizer ); msg_Err( p_demux, "cannot find mp4a packetizer" ); free( p_sys ); return VLC_EGENERIC; } return VLC_SUCCESS; }
/***************************************************************************** * aout_MixerDelete: delete the mixer ***************************************************************************** * Please note that you must hold the mixer lock. *****************************************************************************/ void aout_MixerDelete( aout_instance_t * p_aout ) { if ( p_aout->mixer.b_error ) return; module_Unneed( p_aout, p_aout->mixer.p_module ); p_aout->mixer.b_error = 1; }
static void ReleaseFilter( aout_filter_t * p_filter ) { module_Unneed( p_filter, p_filter->p_module ); vlc_object_detach( p_filter ); vlc_object_destroy( p_filter ); }
/***************************************************************************** * Thread: *****************************************************************************/ static void Thread( vlc_object_t *p_this ) { galaktos_thread_t *p_thread = (galaktos_thread_t*)p_this; int count=0; double realfps=0,fpsstart=0; int timed=0; int timestart=0; int mspf=0; /* Get on OpenGL provider */ p_thread->p_opengl = (vout_thread_t *)vlc_object_create( p_this, VLC_OBJECT_OPENGL ); if( p_thread->p_opengl == NULL ) { msg_Err( p_thread, "out of memory" ); return; } vlc_object_attach( p_thread->p_opengl, p_this ); /* Initialize vout parameters */ vout_InitFormat( &p_thread->p_opengl->fmt_in, VLC_FOURCC('R','V','3','2'), p_thread->i_width, p_thread->i_height, 1 ); p_thread->p_opengl->i_window_width = p_thread->i_width; p_thread->p_opengl->i_window_height = p_thread->i_height; p_thread->p_opengl->render.i_width = p_thread->i_width; p_thread->p_opengl->render.i_height = p_thread->i_width; p_thread->p_opengl->render.i_aspect = VOUT_ASPECT_FACTOR; p_thread->p_opengl->b_scale = VLC_TRUE; p_thread->p_opengl->b_fullscreen = VLC_FALSE; p_thread->p_opengl->i_alignment = 0; p_thread->p_opengl->fmt_in.i_sar_num = 1; p_thread->p_opengl->fmt_in.i_sar_den = 1; p_thread->p_opengl->fmt_render = p_thread->p_opengl->fmt_in; p_thread->p_module = module_Need( p_thread->p_opengl, "opengl provider", NULL, 0 ); if( p_thread->p_module == NULL ) { msg_Err( p_thread, "unable to initialize OpenGL" ); vlc_object_detach( p_thread->p_opengl ); vlc_object_destroy( p_thread->p_opengl ); return; } p_thread->p_opengl->pf_init( p_thread->p_opengl ); setup_opengl( p_thread->i_width, p_thread->i_height ); CreateRenderTarget(512, &RenderTargetTextureID, NULL); timestart=mdate()/1000; while( !p_thread->b_die ) { mspf = 1000 / 60; if( galaktos_update( p_thread ) == 1 ) { p_thread->b_die = 1; } if( p_thread->psz_title ) { free( p_thread->psz_title ); p_thread->psz_title = NULL; } if (++count%100==0) { realfps=100/((mdate()/1000-fpsstart)/1000); // printf("%f\n",realfps); fpsstart=mdate()/1000; } //framerate limiter timed=mspf-(mdate()/1000-timestart); // printf("%d,%d\n",time,mspf); if (timed>0) msleep(1000*timed); // printf("Limiter %d\n",(mdate()/1000-timestart)); timestart=mdate()/1000; } /* Free the openGL provider */ module_Unneed( p_thread->p_opengl, p_thread->p_module ); vlc_object_detach( p_thread->p_opengl ); vlc_object_destroy( p_thread->p_opengl ); }
/***************************************************************************** * RunInterface: setups necessary data and give control to the interface *****************************************************************************/ static void* RunInterface( vlc_object_t *p_this ) { intf_thread_t *p_intf = (intf_thread_t *)p_this; vlc_value_t val, text; char *psz_intf; /* Variable used for interface spawning */ var_Create( p_intf, "intf-add", VLC_VAR_STRING | VLC_VAR_HASCHOICE | VLC_VAR_ISCOMMAND ); text.psz_string = _("Add Interface"); var_Change( p_intf, "intf-add", VLC_VAR_SETTEXT, &text, NULL ); val.psz_string = (char *)"rc"; text.psz_string = (char *)_("Console"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = (char *)"telnet"; text.psz_string = (char *)_("Telnet Interface"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = (char *)"http"; text.psz_string = (char *)_("Web Interface"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = (char *)"logger"; text.psz_string = (char *)_("Debug logging"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); val.psz_string = (char *)"gestures"; text.psz_string = (char *)_("Mouse Gestures"); var_Change( p_intf, "intf-add", VLC_VAR_ADDCHOICE, &val, &text ); var_AddCallback( p_intf, "intf-add", AddIntfCallback, NULL ); do { /* Give control to the interface */ if( p_intf->pf_run ) p_intf->pf_run( p_intf ); else { vlc_object_lock( p_intf ); while( vlc_object_alive( p_intf ) ) vlc_object_wait( p_intf ); vlc_object_unlock( p_intf ); } if( !p_intf->psz_switch_intf ) { break; } /* Make sure the old interface is completely uninitialized */ module_Unneed( p_intf, p_intf->p_module ); /* Provide ability to switch the main interface on the fly */ psz_intf = p_intf->psz_switch_intf; p_intf->psz_switch_intf = NULL; vlc_object_lock( p_intf ); p_intf->b_die = false; /* FIXME */ p_intf->b_dead = false; vlc_object_unlock( p_intf ); p_intf->psz_intf = psz_intf; p_intf->p_module = module_Need( p_intf, "interface", psz_intf, 0 ); } while( p_intf->p_module ); return NULL; }