Commit 5f151d51 authored by Gildas Bazin's avatar Gildas Bazin

* src/audio_output/input.c: on-the-fly visualization changes.
* modules/gui/wxwindows/menus.cpp: added a visualization entry.
parent faf9b659
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* menus.cpp : wxWindows plugin for vlc * menus.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: menus.cpp,v 1.23 2003/10/19 23:38:09 gbazin Exp $ * $Id: menus.cpp,v 1.24 2003/11/02 12:22:45 gbazin Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -122,6 +122,8 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent, ...@@ -122,6 +122,8 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent,
pi_objects[i++] = p_object->i_object_id; pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "audio-channels"; ppsz_varnames[i] = "audio-channels";
pi_objects[i++] = p_object->i_object_id; pi_objects[i++] = p_object->i_object_id;
ppsz_varnames[i] = "visual";
pi_objects[i++] = p_object->i_object_id;
vlc_object_release( p_object ); vlc_object_release( p_object );
} }
...@@ -219,7 +221,7 @@ wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent ) ...@@ -219,7 +221,7 @@ wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent )
{ {
#define MAX_AUDIO_ITEMS 10 #define MAX_AUDIO_ITEMS 10
vlc_object_t *p_object; vlc_object_t *p_object1, *p_object2;
char *ppsz_varnames[MAX_AUDIO_ITEMS]; char *ppsz_varnames[MAX_AUDIO_ITEMS];
int pi_objects[MAX_AUDIO_ITEMS]; int pi_objects[MAX_AUDIO_ITEMS];
int i = 0; int i = 0;
...@@ -227,24 +229,30 @@ wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent ) ...@@ -227,24 +229,30 @@ wxMenu *AudioMenu( intf_thread_t *_p_intf, wxWindow *p_parent )
/* Initializations */ /* Initializations */
memset( pi_objects, 0, MAX_AUDIO_ITEMS * sizeof(int) ); memset( pi_objects, 0, MAX_AUDIO_ITEMS * sizeof(int) );
p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_AOUT, p_object1 = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE ); FIND_ANYWHERE );
if( p_object != NULL ) if( p_object1 != NULL )
{ {
ppsz_varnames[i] = "audio-device"; ppsz_varnames[i] = "audio-device";
pi_objects[i++] = p_object->i_object_id; pi_objects[i++] = p_object1->i_object_id;
ppsz_varnames[i] = "audio-channels"; ppsz_varnames[i] = "audio-channels";
pi_objects[i++] = p_object->i_object_id; pi_objects[i++] = p_object1->i_object_id;
vlc_object_release( p_object );
} }
p_object = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT, p_object2 = (vlc_object_t *)vlc_object_find( _p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE ); FIND_ANYWHERE );
if( p_object != NULL ) if( p_object2 != NULL )
{ {
ppsz_varnames[i] = "audio-es"; ppsz_varnames[i] = "audio-es";
pi_objects[i++] = p_object->i_object_id; pi_objects[i++] = p_object2->i_object_id;
vlc_object_release( p_object ); vlc_object_release( p_object2 );
}
if( p_object1 != NULL )
{
ppsz_varnames[i] = "visual";
pi_objects[i++] = p_object1->i_object_id;
vlc_object_release( p_object1 );
} }
/* Build menu */ /* Build menu */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input.c : internal management of input streams for the audio output * input.c : internal management of input streams for the audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: input.c,v 1.39 2003/11/02 06:33:49 hartman Exp $ * $Id: input.c,v 1.40 2003/11/02 12:22:45 gbazin Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -75,7 +75,40 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input ) ...@@ -75,7 +75,40 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
} }
/* Now add user filters */ /* Now add user filters */
if( ( psz_filters = config_GetPsz( p_aout , "audio-filter" ) ) ) if( var_Type( p_aout, "visual" ) == 0 )
{
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 = "random"; text.psz_string = _("Random");
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 );
val.psz_string = "goom"; text.psz_string = _("Goom");
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, "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 );
}
var_Get( p_aout, "audio-filter", &val );
psz_filters = val.psz_string;
if( psz_filters && *psz_filters )
{ {
char *psz_parser = psz_filters; char *psz_parser = psz_filters;
char *psz_next; char *psz_next;
...@@ -151,38 +184,8 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input ) ...@@ -151,38 +184,8 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
/* next filter if any */ /* next filter if any */
psz_parser = psz_next; psz_parser = psz_next;
} }
free( psz_filters );
}
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 = "random"; text.psz_string = _("Random");
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 );
val.psz_string = "goom"; text.psz_string = _("Goom");
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 );
} }
var_AddCallback( p_aout, "visual", VisualizationCallback, NULL ); if( psz_filters ) free( psz_filters );
var_Create( p_aout, "audio-filter", VLC_VAR_STRING );
text.psz_string = _("Audio filters");
var_Change( p_aout, "audio-filter", VLC_VAR_SETTEXT, &text, NULL );
var_Change( p_aout, "audio-filter", VLC_VAR_INHERITVALUE, &val, NULL );
if( var_Get( p_aout, "audio-filter", &val ) == VLC_SUCCESS )
{
var_Set( p_aout, "audio-filter", val );
}
//var_AddCallback( p_aout, "audio-filter", AudioFilterCallback, NULL );
/* Prepare hints for the buffer allocator. */ /* Prepare hints for the buffer allocator. */
p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP; p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
...@@ -213,6 +216,7 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input ) ...@@ -213,6 +216,7 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters, aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters,
p_input->i_nb_filters ); p_input->i_nb_filters );
aout_FifoDestroy( p_aout, &p_input->fifo ); aout_FifoDestroy( p_aout, &p_input->fifo );
var_Destroy( p_aout, "visual" );
p_input->b_error = 1; p_input->b_error = 1;
return -1; return -1;
...@@ -423,29 +427,28 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -423,29 +427,28 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
return 0; return 0;
} }
static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd, static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
aout_instance_t *p_aout = (aout_instance_t *)p_this; aout_instance_t *p_aout = (aout_instance_t *)p_this;
input_thread_t *p_input;
vlc_value_t val; vlc_value_t val;
char *psz_mode = newval.psz_string; char *psz_mode = newval.psz_string;
char *psz_filter; char *psz_filter;
unsigned int i;
psz_filter = config_GetPsz( p_aout, "audio-filter" ); var_Get( p_aout, "audio-filter", &val );
psz_filter = val.psz_string;
if( !psz_mode || !*psz_mode ) if( !psz_mode || !*psz_mode )
{ {
config_PutPsz( p_aout, "audio-filter", "" ); val.psz_string = "";
var_Set( p_aout, "audio-filter", val );
} }
else else
{ {
if( !psz_filter || !*psz_filter ) if( !psz_filter || !*psz_filter )
{ {
config_PutPsz( p_aout, "audio-filter", "visual" ); val.psz_string = "visual";
var_Set( p_aout, "audio-filter", val );
} }
else else
{ {
...@@ -454,16 +457,22 @@ static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -454,16 +457,22 @@ static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd,
psz_filter = realloc( psz_filter, strlen( psz_filter ) + 20 ); psz_filter = realloc( psz_filter, strlen( psz_filter ) + 20 );
strcat( psz_filter, ",visual" ); strcat( psz_filter, ",visual" );
} }
config_PutPsz( p_aout, "audio-filter", psz_filter ); val.psz_string = psz_filter;
var_Set( p_aout, "audio-filter", val );
} }
} }
if( psz_mode && *psz_mode ) if( psz_mode && *psz_mode )
{ {
config_PutPsz( p_aout, "effect-list", psz_mode ); vlc_value_t val;
val.psz_string = psz_mode;
var_Create( p_aout, "effect-list", VLC_VAR_STRING );
var_Set( p_aout, "effect-list", val);
} }
if( psz_filter ) free( psz_filter ); if( psz_filter ) free( psz_filter );
aout_Restart( p_aout );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment