[retro-gtk] retro-gobject: Add Core.frames_per_second
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk] retro-gobject: Add Core.frames_per_second
- Date: Tue, 24 Jan 2017 16:20:38 +0000 (UTC)
commit e00ca136e94f06971f8550ee3ac093b26bba53df
Author: Adrien Plazas <kekun plazas laposte net>
Date: Mon Jan 23 15:58:18 2017 +0100
retro-gobject: Add Core.frames_per_second
Add the Core.frames_per_second property and make MainLoop use it instead
of Core.av_info.fps.
https://bugzilla.gnome.org/show_bug.cgi?id=777489
retro-gobject/core.vala | 5 +++++
retro-gobject/loop/main-loop.vala | 16 +++++++++++++---
retro-gobject/retro-environment.c | 1 +
3 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/retro-gobject/core.vala b/retro-gobject/core.vala
index 1b8964d..c9c3b21 100644
--- a/retro-gobject/core.vala
+++ b/retro-gobject/core.vala
@@ -151,6 +151,10 @@ public class Core : Object {
*/
public AvInfo av_info { internal set; get; }
+ public double frames_per_second {
+ get { return av_info.fps; }
+ }
+
/**
* The disk controlling interface.
*
@@ -318,6 +322,7 @@ public class Core : Object {
SystemAvInfo info;
module.get_system_av_info (out info);
av_info = new AvInfo (info);
+ notify_property ("frames-per-second");
}
else {
av_info = null;
diff --git a/retro-gobject/loop/main-loop.vala b/retro-gobject/loop/main-loop.vala
index fd95bfa..6d8cccd 100644
--- a/retro-gobject/loop/main-loop.vala
+++ b/retro-gobject/loop/main-loop.vala
@@ -43,6 +43,8 @@ public class MainLoop : Object {
break;
}
});
+
+ core.notify["frames-per-second"].connect (on_frames_per_second_changed);
}
~MainLoop () {
@@ -53,10 +55,10 @@ public class MainLoop : Object {
* Starts running the {@link core}.
*/
public void start () {
- var info = core.av_info;
- var fps = info != null ? info.fps : 60.0;
+ // TODO What if FPSs <= 0?
+
if (loop == null && speed_rate > 0) {
- loop = Timeout.add ((uint) (1000 / (fps * speed_rate)), run);
+ loop = Timeout.add ((uint) (1000 / (core.frames_per_second * speed_rate)), run);
}
}
@@ -88,6 +90,14 @@ public class MainLoop : Object {
return false;
}
+
+ private void on_frames_per_second_changed () {
+ if (loop == null)
+ return;
+
+ stop ();
+ start ();
+ }
}
}
diff --git a/retro-gobject/retro-environment.c b/retro-gobject/retro-environment.c
index 279883b..0d739c9 100644
--- a/retro-gobject/retro-environment.c
+++ b/retro-gobject/retro-environment.c
@@ -187,6 +187,7 @@ static gboolean set_support_no_game (RetroCore *self, gboolean *support_no_game)
static gboolean set_system_av_info (RetroCore *self, RetroSystemAvInfo *system_av_info) {
retro_core_set_av_info (self, retro_av_info_new (system_av_info));
+ g_object_notify (G_OBJECT (self), "frames-per-second");
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]