diff --git a/README.md b/README.md index 647291b..4e60464 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ playing sound. Requirements ------------ -- Audacious >= 3.2 (http://audacious-media-player.org/) +- Audacious >= 3.1 (http://audacious-media-player.org/) - SDL >= 1.0.6 - Glib >= 2.8 - Gtk+ >= 2.8 diff --git a/configure.ac b/configure.ac index 770fa3d..7d3770e 100644 --- a/configure.ac +++ b/configure.ac @@ -81,7 +81,7 @@ PKG_CHECK_MODULES(DBUSGLIB1, dbus-glib-1 >= 0.92,,) AC_SUBST(DBUSGLIB1) AC_SUBST(DBUSGLIB1) -PKG_CHECK_MODULES(AUDACIOUS, audacious,,) +PKG_CHECK_MODULES(AUDACIOUS, audacious >= 3.1,,) AC_SUBST(AUDACIOUS_LIBS) AC_SUBST(AUDACIOUS_CFLAGS) diff --git a/src/compute.c b/src/compute.c index 9ed3f23..5005644 100644 --- a/src/compute.c +++ b/src/compute.c @@ -23,7 +23,6 @@ #include "mmx.h" #endif - typedef struct t_coord { gint32 x,y; } t_coord; @@ -32,14 +31,11 @@ typedef struct t_complex { gfloat x,y; } t_complex; - static t_screen_parameters scr_par; static byte* surface1; static byte* surface2; - - static inline t_complex fct (t_complex a,guint32 n,gint32 p1,gint32 p2) /* p1 et p2:0-4 */ { t_complex b; @@ -145,7 +141,6 @@ static inline t_complex fct (t_complex a,guint32 n,gint32 p1,gint32 p2) /* p1 return b; } - /* We are trusting here on vector_field != NULL !!! */ static inline void compute_generate_sector (guint32 g, guint32 f, guint32 p1, guint32 p2, guint32 debut, guint32 step, vector_field_t *vector_field) @@ -189,12 +184,9 @@ static inline void compute_generate_sector (guint32 g, guint32 f, guint32 p1, gu } } - - -/*--------------------------------*/ -/* Public functions */ -/*--------------------------------*/ - +/* + * Public functions + */ void compute_init (void) { @@ -216,7 +208,6 @@ void compute_resize (gint32 width, gint32 height) surface2 = (byte*) g_malloc ((gulong)(scr_par.width+1) * (scr_par.height+1)); } - vector_field_t *compute_vector_field_new (gint32 width, gint32 height) { vector_field_t *field; @@ -228,7 +219,6 @@ vector_field_t *compute_vector_field_new (gint32 width, gint32 height) return field; } - void compute_vector_field_destroy (vector_field_t *vector_field) { g_return_if_fail (vector_field != NULL); @@ -259,7 +249,6 @@ void compute_generate_vector_field (vector_field_t *vector_field) } } - inline byte *compute_surface (t_interpol* vector, gint32 width, gint32 height) { gint32 i,j; @@ -292,7 +281,6 @@ inline byte *compute_surface (t_interpol* vector, gint32 width, gint32 height) return surface1; } - #if MMX_DETECTION inline byte *compute_surface_mmx (t_interpol* vector, gint32 width, gint32 height) { diff --git a/src/display.c b/src/display.c index 5b40446..5d71ad9 100644 --- a/src/display.c +++ b/src/display.c @@ -23,8 +23,6 @@ #include "infconfig.h" #include "gettext.h" - - #define wrap(a) ( a < 0 ? 0 : ( a > 255 ? 255 : a )) #define assign_max(p,a) ( *p <= a ? *p = a : 0 ) @@ -36,14 +34,11 @@ */ #define VIDEO_FLAGS ((Uint32)(SDL_HWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF | SDL_RESIZABLE)) - typedef struct sincos { gint32 i; gfloat *f; } sincos_t; - - static gint16 pcm_data[2][512]; static SDL_mutex *pcm_data_mutex; @@ -62,8 +57,6 @@ static gint16 current_colors[256]; static byte* surface1; - - static void init_sdl (gint32 width, gint32 height, gint32 scale) { if (SDL_Init((Uint32)(SDL_INIT_VIDEO | SDL_INIT_TIMER)) < 0) @@ -76,7 +69,6 @@ static void init_sdl (gint32 width, gint32 height, gint32 scale) (void)SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); } - static void generate_colors() { gint32 i, k; @@ -102,8 +94,6 @@ static void generate_colors() } } - - static void display_surface () { @@ -158,14 +148,12 @@ static void display_surface () (void)SDL_Flip (screen); } - #define plot1(x,y,c)\ \ if ((x)>0 && (x)0 && (y)= 0); + // TODO check this out, different types here... memcpy (pcm_data, data, 2*512*sizeof(gint16)); g_return_if_fail (SDL_mutexV (pcm_data_mutex) >= 0); /* end CS */ } - void change_color (gint32 t2, gint32 t1, gint32 w) { gint32 i; @@ -308,7 +293,6 @@ void change_color (gint32 t2, gint32 t1, gint32 w) } } - inline void display_blur (guint32 vector_index) { surface1 = compute_surface (&(vector_field->vector[vector_index]), @@ -316,7 +300,6 @@ inline void display_blur (guint32 vector_index) display_surface(); } - #if MMX_DETECTION inline void display_blur_mmx (guint32 vector_index) { @@ -326,7 +309,6 @@ inline void display_blur_mmx (guint32 vector_index) } #endif - void spectral (t_effect* current_effect) { gint32 i, halfheight, halfwidth; @@ -436,7 +418,6 @@ void spectral (t_effect* current_effect) current_effect->spectral_color); } - /** * \todo current_effect->curve_color must be a byte. This is related to * t_effect typo. @@ -464,14 +445,12 @@ void curve (t_effect* current_effect) current_effect->x_curve = k; } - void display_toggle_fullscreen (void) { if (SDL_WM_ToggleFullScreen (screen) < 0) g_warning (_("Cannot toggle to fullscreen mode: %s"), SDL_GetError()); } - void display_save_screen (void) { gchar name[256]; @@ -484,7 +463,6 @@ void display_save_screen (void) g_message (_("saved")); } - inline void display_save_effect (t_effect *effect) { effects_save_effect (effect); diff --git a/src/display.h b/src/display.h index 98e5d96..58ea19b 100644 --- a/src/display.h +++ b/src/display.h @@ -29,11 +29,8 @@ #include "compute.h" #include "effects.h" - #define NB_PALETTES 5 - - /** * Initializes the display related structures. * @@ -42,9 +39,8 @@ * It also initializes the SDL library. * * \warning Because this function initializes the SDL - * library, must be called before to perform any SDL - * operation and must not be called when SDL was already - * started. + * library, must be called before any SDL operation and + * must not be called when SDL was already started. */ void display_init (void); @@ -78,12 +74,11 @@ void display_resize (gint32 width, gint32 height); * * This function makes a copy of \a data. * - * \warning This function locks a mutex, take that - * into account. + * \warning Be aware that this function locks a mutex. * * \see display_quit(). */ -void display_set_pcm_data (gint16 data[2][512]); +void display_set_pcm_data (const float * data, int channels); void display_show (void); @@ -104,5 +99,4 @@ void display_save_screen (void); void display_save_effect (t_effect *effect); void display_load_random_effect (t_effect *effect); - #endif /* __INFINITY_DISPLAY__ */ diff --git a/src/effects.c b/src/effects.c index da44aed..bd4e926 100644 --- a/src/effects.c +++ b/src/effects.c @@ -10,7 +10,6 @@ static t_effect effects[100]; static gint32 nb_effects = 0; static gboolean initialized = FALSE; - void effects_save_effect (t_effect *effect) { gchar datafile[256], path[256]; @@ -30,7 +29,6 @@ void effects_save_effect (t_effect *effect) fclose (f); } - void effects_load_effects (void) { gchar path[255]; diff --git a/src/main.c b/src/main.c index 4ca25f0..d9bc7c2 100644 --- a/src/main.c +++ b/src/main.c @@ -29,25 +29,44 @@ #include "renderer.h" #include "gettext.h" -static void plugin_init (void); -static void plugin_close (void); +static bool_t plugin_init (void); +static void plugin_close (void); +static void clear (void); -/** - * Structure shared with Audacious in order to register and get information - * about the plugin. +/* + * Registers plugin with Audacious. */ -static VisPlugin infinity_vp = { - .description = "Infinity", - .num_pcm_chs_wanted = 2, - .num_freq_chs_wanted = 0, +AUD_VIS_PLUGIN ( + .name = "Infinity", .init = plugin_init, .cleanup = plugin_close, + .take_message = NULL, + .about = NULL, // TODO .configure = config_plugin_config_window, - .playback_stop = NULL, - .render_pcm = renderer_set_pcm_data, -}; + .settings = NULL, // TODO + //.playback_stop = NULL, -static void plugin_init(void) + /* reset internal state and clear display */ + .clear = clear, + + /* 512 frames of a single-channel PCM signal */ + .render_mono_pcm = NULL, + + /* 512 frames of an interleaved multi-channel PCM signal */ + .render_multi_pcm = renderer_render_multi_pcm, + + /* intensity of frequencies 1/512, 2/512, ..., 256/512 of sample rate */ + .render_freq = NULL, + + /* GtkWidget * (* get_widget) (void); */ + .get_widget = NULL +); + +static void clear (void) { + g_message ("TODO implement clear()"); +} + +static bool_t plugin_init (void) { #if ENABLE_NLS (void) setlocale (LC_MESSAGES, ""); @@ -69,8 +88,8 @@ static void plugin_init(void) "- F11:\t\tscreenshot.\n" "- F12:\t\tchange palette.")); config_plugin_load_prefs (); - renderer_set_plugin_info (&infinity_vp); renderer_init (); + return TRUE; } static void plugin_close (void) @@ -79,17 +98,3 @@ static void plugin_close (void) renderer_finish (); } -static void dummy (void) -{ -} - -/* - * - * Public functions - * - */ - -VisPlugin *infinity_vplist[] = { &infinity_vp, NULL }; - -DECLARE_PLUGIN (infinity, NULL, NULL, NULL, NULL, NULL, NULL, infinity_vplist, NULL); - diff --git a/src/maintest.c b/src/maintest.c index ea8419e..7951b4b 100644 --- a/src/maintest.c +++ b/src/maintest.c @@ -3,7 +3,6 @@ #include #include - #include "main.h" #include "renderer.h" diff --git a/src/renderer.c b/src/renderer.c index 5b90e44..eb6dea5 100644 --- a/src/renderer.c +++ b/src/renderer.c @@ -38,12 +38,10 @@ #include "cputest.h" #endif - #define wrap(a) ( a < 0 ? 0 : ( a > 255 ? 255 : a )) #define next_effect() (t_last_effect += 1) #define next_color() (t_last_color += 1) - typedef struct t_general_parameters { gint32 t_between_effects; gint32 t_between_colors; @@ -52,7 +50,6 @@ typedef struct t_general_parameters { typedef gint32 t_color; typedef gint32 t_num_effect; - static t_screen_parameters scr_par; static t_effect current_effect; @@ -72,8 +69,6 @@ static gboolean first_xevent; static gchar *current_title; static GTimer *title_timer; -/* VisPlugin structure that holds info shared with Audacious */ -static VisPlugin *plugin; static SDL_Thread *thread; static DBusGConnection * connection = NULL; @@ -87,11 +82,8 @@ static int renderer_mmx (void *); #endif static void set_title (void); - /* - * * Public functions - * */ void renderer_init (void) @@ -157,13 +149,12 @@ void renderer_init (void) thread = SDL_CreateThread (renderer,NULL); } - void renderer_finish (void) { gint32 try; if (initializing) { - g_warning (_("The plugin have not yet initialize")); + g_warning (_("The plugin have not yet initialized")); try = 0; while (initializing) { g_usleep (1000000); @@ -176,7 +167,7 @@ void renderer_finish (void) SDL_WaitThread (thread, NULL); SDL_DestroyMutex (resizing_mutex); /* - * Take some time to let it know renderer_set_pcm_data() + * Take some time to let it know renderer_render_multi_pcm() * that must not call display_set_pcm_data(). * If it do that while calling display_quit(), * we could make Audacious crash, because display_quit @@ -192,31 +183,16 @@ void renderer_finish (void) g_message ("Infinity: Closing..."); } - -void renderer_set_plugin_info (VisPlugin *vplugin) -{ - g_return_if_fail (vplugin != NULL); - - if (initializing) - return; - plugin = vplugin; -} - - -void renderer_set_pcm_data (gint16 data[2][512]) +void renderer_render_multi_pcm (const float * data, int channels) { if (!initializing && !quiting) - display_set_pcm_data (data); + display_set_pcm_data (data, channels); } - /* - * * Private functions - * */ - static gint32 event_filter (const SDL_Event *event) { if (!event) { @@ -230,8 +206,7 @@ static gint32 event_filter (const SDL_Event *event) if (resizing) { g_return_val_if_fail (SDL_UnlockMutex (resizing_mutex) >= 0, 0); /* - * VIDEORESIZE event is dropped - * from the event queue + * VIDEORESIZE event dropped from event queue */ return 0; } else { @@ -261,17 +236,12 @@ static gint32 event_filter (const SDL_Event *event) return 1; } - static gint disable_func (gpointer data) { - g_return_val_if_fail (plugin != NULL, FALSE); - - plugin->disable_plugin (plugin); - + renderer_finish(); return FALSE; } - static void check_events () { SDL_Event event; @@ -284,7 +254,6 @@ static void check_events () if (config_get_show_title()) { if (g_timer_elapsed (title_timer, NULL) > 1.0) { - g_return_if_fail (plugin != NULL); if (audacious_remote_is_playing (dbus_proxy)) { if (current_title) g_free (current_title); @@ -448,7 +417,6 @@ static void check_events () #endif /* INFINITY_DEBUG */ } - static int renderer (void *arg) { gint32 render_time, now; @@ -530,7 +498,6 @@ static int renderer (void *arg) return 0; } - #if MMX_DETECTION static int renderer_mmx (void *arg) { @@ -618,3 +585,4 @@ static void set_title (void) { SDL_WM_SetCaption (current_title, "Infinity"); } + diff --git a/src/renderer.h b/src/renderer.h index 4974cea..a37d4dd 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -1,8 +1,8 @@ /** * \file renderer.h * - * \brief This module control the rendering process and his interaction - * with the events that affects the application. + * \brief Controls the rendering process and its interaction with application + * events. */ /* @@ -23,43 +23,26 @@ #ifndef __INFINITY_RENDERER__ #define __INFINITY_RENDERER__ -#include #include - /** - * Initializes the rendering process. + * Initializes rendering process. * - * It reads the plugin's configuration parameters and launchs - * a thread on which almost all the job of the plugin will be - * done. + * Reads configuration parameters and launchs a thread where most of the + * plugin job gets done. */ void renderer_init (void); /** - * Closes the rendering process. + * Closes rendering process. */ void renderer_finish (void); -/* - * Set a reference to a structure where there is the - * information about the plugin. - * - * @param vplugin Must be a non NULL reference to an - * Audacity VisPlugin structure properly initialized. - * - * \see - */ -void renderer_set_plugin_info (VisPlugin *vplugin); - /** - * Copy the actual PCM data from Audacity. + * Copies PCM data from Audacity. * - * It is supposed that this function is called periodically - * by Audacity copying the PCM data which corresponds to the - * current sound played. + * Called periodically by Audacity with actual PCM data. */ -void renderer_set_pcm_data (gint16 data[2][512]); - +void renderer_render_multi_pcm (const float * data, int channels); #endif /* __INFINITY_RENDERER__ */