Fixed max FPS calculation
This commit is contained in:
parent
8d8d9f3ff1
commit
3033e05467
|
@ -3,8 +3,8 @@ Infinity
|
||||||
|
|
||||||
Visualization plugin for [Audacious](http://audacious-media-player.org/) music player.
|
Visualization plugin for [Audacious](http://audacious-media-player.org/) music player.
|
||||||
|
|
||||||
It generates beautiful light effects. Supports full-screen mode, mouse resizing and preferences
|
It generates beautiful light effects. Supports full-screen mode, mouse resizing, preferences
|
||||||
saving.
|
saving and player control through keyboard.
|
||||||
|
|
||||||
**[Go to Downloads](https://github.com/dprotti/infinity-plugin/releases/latest/)**
|
**[Go to Downloads](https://github.com/dprotti/infinity-plugin/releases/latest/)**
|
||||||
|
|
||||||
|
@ -13,11 +13,11 @@ saving.
|
||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Audacious >= 3.5, 1.0.6 <= SDL < 2, Glib >= 2.8, Gtk+ >= 2.8
|
Audacious >= 3.5, 1.0.6 <= SDL < 2, Glib >= 2.28, Gtk+ >= 2.8
|
||||||
|
|
||||||
**Install deps in Ubuntu**
|
**Install deps in Ubuntu**
|
||||||
|
|
||||||
`sudo apt -y install audacious-dev libaudclient-dev libsdl1.2-dev libglib2.0-dev libgtk2.0-dev`
|
`sudo apt -y install audacious-dev libsdl1.2-dev libglib2.0-dev libgtk2.0-dev`
|
||||||
|
|
||||||
Install from tarball
|
Install from tarball
|
||||||
-------
|
-------
|
||||||
|
|
|
@ -34,7 +34,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check some dependencies
|
# Check some dependencies
|
||||||
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.8,,)
|
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28,,)
|
||||||
AC_SUBST(GLIB_LIBS)
|
AC_SUBST(GLIB_LIBS)
|
||||||
AC_SUBST(GLIB_CFLAGS)
|
AC_SUBST(GLIB_CFLAGS)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ static const char about_text[] =
|
||||||
|
|
||||||
static const PreferencesWidget prefs_fps[] = {
|
static const PreferencesWidget prefs_fps[] = {
|
||||||
WidgetLabel ("<b>Frames per second</b>"),
|
WidgetLabel ("<b>Frames per second</b>"),
|
||||||
WidgetSpin ("Max. :", WidgetInt (CFGID, "max_fps"), {10, 120, 1, "fps"}),
|
WidgetSpin ("Max. :", WidgetInt (CFGID, "max_fps"), {15, 60, 1, "fps"}),
|
||||||
WidgetLabel ("<b>How often change effect</b>"),
|
WidgetLabel ("<b>How often change effect</b>"),
|
||||||
WidgetSpin ("Every", WidgetInt (CFGID, "effect_time"), {50, 500, 5, "frames "}),
|
WidgetSpin ("Every", WidgetInt (CFGID, "effect_time"), {50, 500, 5, "frames "}),
|
||||||
WidgetLabel ("<b>How often change colors</b>"),
|
WidgetLabel ("<b>How often change colors</b>"),
|
||||||
|
@ -116,7 +116,7 @@ static const char * const defaults[] = {
|
||||||
"effect_time", "100",
|
"effect_time", "100",
|
||||||
"palette_time", "100",
|
"palette_time", "100",
|
||||||
"scale_factor", "1",
|
"scale_factor", "1",
|
||||||
"max_fps", "15",
|
"max_fps", "30",
|
||||||
"show_title", "true"
|
"show_title", "true"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -399,22 +399,20 @@ static void check_events()
|
||||||
}
|
}
|
||||||
|
|
||||||
// log calling line to improve bug reports
|
// log calling line to improve bug reports
|
||||||
static gint32 calculate_frame_length(gint32 fps, int line) {
|
static gint64 calculate_frame_length_usecs(gint32 fps, int line) {
|
||||||
gint32 frame_length = (gint32)(((1.0 / fps) * 1000));
|
gint64 frame_length = (gint64)(((1.0 / fps) * 1000000));
|
||||||
g_message("Infinity[%d]: setting maximum rate at ~%d frames/second", line, fps);
|
g_message("Infinity[%d]: setting maximum rate at ~%d frames/second", line, fps);
|
||||||
return frame_length;
|
return frame_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int renderer(void *arg)
|
static int renderer(void *arg)
|
||||||
{
|
{
|
||||||
gint32 render_time, now;
|
|
||||||
gint32 frame_length;
|
gint32 frame_length;
|
||||||
gint32 idle_time;
|
|
||||||
gint32 fps, new_fps;
|
gint32 fps, new_fps;
|
||||||
gint32 t_between_effects, t_between_colors;
|
gint32 t_between_effects, t_between_colors;
|
||||||
|
|
||||||
fps = aud_get_int(CFGID, "max_fps");
|
fps = aud_get_int(CFGID, "max_fps");
|
||||||
frame_length = calculate_frame_length(fps, __LINE__);
|
frame_length = calculate_frame_length_usecs(fps, __LINE__);
|
||||||
t_between_effects = aud_get_int(CFGID, "effect_time");
|
t_between_effects = aud_get_int(CFGID, "effect_time");
|
||||||
t_between_colors = aud_get_int(CFGID, "palette_time");
|
t_between_colors = aud_get_int(CFGID, "palette_time");
|
||||||
initializing = FALSE;
|
initializing = FALSE;
|
||||||
|
@ -438,7 +436,7 @@ static int renderer(void *arg)
|
||||||
resizing = FALSE;
|
resizing = FALSE;
|
||||||
g_return_val_if_fail(SDL_UnlockMutex(resizing_mutex) >= 0, -1);
|
g_return_val_if_fail(SDL_UnlockMutex(resizing_mutex) >= 0, -1);
|
||||||
}
|
}
|
||||||
render_time = (gint32)SDL_GetTicks();
|
auto t_begin = g_get_monotonic_time();
|
||||||
display_blur(scr_par.width * scr_par.height * current_effect.num_effect);
|
display_blur(scr_par.width * scr_par.height * current_effect.num_effect);
|
||||||
spectral(¤t_effect);
|
spectral(¤t_effect);
|
||||||
curve(¤t_effect);
|
curve(¤t_effect);
|
||||||
|
@ -478,12 +476,14 @@ static int renderer(void *arg)
|
||||||
new_fps = aud_get_int(CFGID, "max_fps");
|
new_fps = aud_get_int(CFGID, "max_fps");
|
||||||
if (new_fps != fps) {
|
if (new_fps != fps) {
|
||||||
fps = new_fps;
|
fps = new_fps;
|
||||||
frame_length = calculate_frame_length(fps, __LINE__);
|
frame_length = calculate_frame_length_usecs(fps, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
now = (gint32)SDL_GetTicks();
|
auto now = g_get_monotonic_time();
|
||||||
if ((idle_time = (now - render_time)) < frame_length)
|
auto render_time = now - t_begin;
|
||||||
g_usleep(idle_time * 900);
|
if (render_time < frame_length) {
|
||||||
|
g_usleep(frame_length - render_time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -523,7 +523,7 @@ static int renderer_mmx(void *arg)
|
||||||
resizing = FALSE;
|
resizing = FALSE;
|
||||||
g_return_val_if_fail(SDL_UnlockMutex(resizing_mutex) >= 0, -1);
|
g_return_val_if_fail(SDL_UnlockMutex(resizing_mutex) >= 0, -1);
|
||||||
}
|
}
|
||||||
render_time = SDL_GetTicks();
|
auto t_begin = g_get_monotonic_time();
|
||||||
display_blur_mmx(scr_par.width * scr_par.height * current_effect.num_effect);
|
display_blur_mmx(scr_par.width * scr_par.height * current_effect.num_effect);
|
||||||
spectral(¤t_effect);
|
spectral(¤t_effect);
|
||||||
curve(¤t_effect);
|
curve(¤t_effect);
|
||||||
|
@ -566,9 +566,11 @@ static int renderer_mmx(void *arg)
|
||||||
frame_length = calculate_frame_length(fps, __LINE__);
|
frame_length = calculate_frame_length(fps, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
now = SDL_GetTicks();
|
auto now = g_get_monotonic_time();
|
||||||
if ((idle_time = (now - render_time)) < frame_length)
|
auto render_time = now - t_begin;
|
||||||
g_usleep(idle_time * 900);
|
if (render_time < frame_length) {
|
||||||
|
g_usleep(frame_length - render_time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue