GNOME Bugzilla – Bug 777489
Refactor the whole API
Last modified: 2018-06-01 10:51:47 UTC
retro-gtk's goal is to offer a simple way to use Libretro cores in a GTK+ environment. It doesn't really achieve that as it exposes a lot of the behavior of Libretro without making it that much simpler to use. It requires more work from the frontend than it should and the complex design of Libretro isn't abstracted enough, and the design of the various interfaces (Video, Audio, Input…) ended up being not as convenient as expected and often requires two way bonds between the interface and the core which is a sign of poor design. Also, the separation between retro-gobject and retro-gtk is somewhat artificial: retro-gtk has the bits depending on GDK, GTK+, PulseAudio, etc. which doesn't make much sense. To sum things up: - the API should be simplified and untangled, - Libretro should be abstracted more, - retro-gobject should be merged into retro-gtk.
Created attachment 344135 [details] [review] retro-gobject: Merge video commands into core commands This will help giving the core more power over how these commands are handled.
Created attachment 344136 [details] [review] retro-gobject: Merge input commands into core commands This will help giving the core more power over how these commands are handled.
Created attachment 344137 [details] [review] retro-gobject: Merge variables commands into core commands This will help giving the core more power over how these commands are handled.
Created attachment 344138 [details] [review] retro-gobject: Merge interface commands into core commands This will help giving the core more power over how these commands are handled.
Attachment 344135 [details] pushed as 5bfad6e - retro-gobject: Merge video commands into core commands Attachment 344136 [details] pushed as a067061 - retro-gobject: Merge input commands into core commands Attachment 344137 [details] pushed as 1b266d4 - retro-gobject: Merge variables commands into core commands Attachment 344138 [details] pushed as d12a981 - retro-gobject: Merge interface commands into core commands
Created attachment 344164 [details] [review] retro-gobject: Unnest nested functions Unnest several real_cb() nested function to: - on_environment_interface() - on_video_refresh() - on_audio_sample() - on_audio_sample_batch() - on_input_poll() - on_input_state() This makes the code cleaner and helps to support compilers not supporting nested functions.
Created attachment 344165 [details] [review] retro-gobject: Set Core callbacks in C This makes the code simpler.
Created attachment 344166 [details] [review] Replace Video interface by Core.video_output() Remove the Video interface, add the Core.video_output() signal and adapt CairoDisplay accordingly.
Created attachment 344167 [details] [review] Replace Audio interface by Core.audio_output() Remove the Audio interface, add the Core.audio_output() signal and adapt PaPlayer accordingly.
Created attachment 344168 [details] [review] 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.
Created attachment 344169 [details] [review] retro-gobject: Add AV infos to Core Add aspect_ratio, _frames_per_second and sample_rate to Core and use these instead of the ones from Core.av_info. This is needed to remove AvInfo in the next commits.
Created attachment 344170 [details] [review] retro-gobject: Remove AvInfo This helps making the public API simpler.
Created attachment 344215 [details] [review] retro-gobject: Make Core.variables_interface private Make the variables interface internal. This simplifies the public API.
Created attachment 344216 [details] [review] retro-gobject: Remove the logging interface Directly handles the logs sent by the Libretro core. This simplifies the public API.
Attachment 344215 [details] pushed as f731804 - retro-gobject: Make Core.variables_interface private Attachment 344216 [details] pushed as 8449612 - retro-gobject: Remove the logging interface
Created attachment 344249 [details] [review] retro-gobject: Fix style of core memory functions Fix the style of retro_core_get_memory() and retro_core_set_memory() to make it closer to the GLib C style.
Created attachment 344250 [details] [review] retro-gobject: Refactor serialization functions
Attachment 344249 [details] pushed as 4bb861e - retro-gobject: Fix style of core memory functions Attachment 344250 [details] pushed as 7705f99 - retro-gobject: Refactor serialization functions
Created attachment 344299 [details] [review] retro-gobject: Remove rarely used Core.unload_game() Replaces the two private calls to Core.unload_game() by its small content.
Created attachment 344300 [details] [review] retro-gobject: Remove rarely used Core.deinit() Replaces the only private call to Core.deinit() by its small content.
Created attachment 344301 [details] [review] retro-gobject: Default aspect ratio to width/height Follow the Libretro specification and default the aspect ration to width/height. This avoids having an invalid aspect ratio as long as the width and height are valid.
Attachment 344299 [details] pushed as 0ee99a6 - retro-gobject: Remove rarely used Core.unload_game() Attachment 344300 [details] pushed as 3121bf3 - retro-gobject: Remove rarely used Core.deinit() Attachment 344301 [details] pushed as 2ecf599 - retro-gobject: Default aspect ratio to width/height
Created attachment 345174 [details] [review] retro-gtk: Refactor video format conversion Completely refactor video-converter.c to make it more readable, maintainable and hopefully slightly faster.
Comment on attachment 345174 [details] [review] retro-gtk: Refactor video format conversion Attachment 345174 [details] pushed as 00e8d56 - retro-gtk: Refactor video format conversion
Created attachment 345616 [details] [review] retro-gtk: Remove unused gamepad.vala file
Created attachment 345617 [details] [review] retro-gtk: Remove useless gamepad code
Created attachment 345618 [details] [review] retro-gtk: Drop usage of 'using' keyword Drop the usage of the 'using' keyword in favor of explicit namespaces.
Created attachment 345619 [details] [review] Move retro-gtk/video to retro-gobject/video
Created attachment 345620 [details] [review] Move retro-gtk/audio to retro-gobject/audio
Created attachment 345621 [details] [review] Move retro-gtk/input to retro-gobject/input
Created attachment 345622 [details] [review] Rename retro-gobject as retro-gtk
Created attachment 345623 [details] [review] Unify the library as retro-gtk in the Retro namespace
Attachment 345616 [details] pushed as 119a45d - retro-gtk: Remove unused gamepad.vala file Attachment 345617 [details] pushed as 05438d0 - retro-gtk: Remove useless gamepad code Attachment 345618 [details] pushed as 933a6d6 - retro-gtk: Drop usage of 'using' keyword Attachment 345619 [details] pushed as a16d2a8 - Move retro-gtk/video to retro-gobject/video Attachment 345620 [details] pushed as 0a74391 - Move retro-gtk/audio to retro-gobject/audio Attachment 345621 [details] pushed as dc492f4 - Move retro-gtk/input to retro-gobject/input Attachment 345622 [details] pushed as 80681d9 - Rename retro-gobject as retro-gtk Attachment 345623 [details] pushed as 00abc57 - Unify the library as retro-gtk in the Retro namespace
Created attachment 355063 [details] [review] core: Move some internal fields to C Move aspect ratio, overscan, pixel format, rotation and sample rate Core fields from Vala to C. This will help porting the library to C.
Created attachment 355064 [details] [review] core: Move Core.on_input_key_event() to C This help porting the library to C.
Created attachment 355065 [details] [review] core: Move Core.set_controller_port_device() to C This help porting the library to C.
Created attachment 355066 [details] [review] core: Move Core.on_input_controller_disconnected() to C This help porting the library to C.
Created attachment 355067 [details] [review] core: Move Core.on_input_controller_connected() to C This help porting the library to C.
Created attachment 355068 [details] [review] core: Move Core.init_input() to C Also move Core.Core.init_controller_device() to C. This help porting the library to C.
Created attachment 355069 [details] [review] core: Move Core.get_memory_size() to C This help porting the library to C.
Created attachment 355070 [details] [review] core: Move Core.prepare() to C This help porting the library to C.
Created attachment 355071 [details] [review] core: Move Core.load_game() to C This help porting the library to C.
Created attachment 355072 [details] [review] core: Move Core.run() to C This help porting the library to C.
Created attachment 355073 [details] [review] core: Move Core.reset() to C This help porting the library to C.
Created attachment 355074 [details] [review] rotation: Port Rotation to C This help porting the library to C.
Created attachment 355075 [details] [review] core: Add Core.set_medias() This will be used to simplify loading the games and by extension to simplify preparing the cores, exposing less of the internal working. By extension, simplifying the public API will help porting the library to C.
Created attachment 355076 [details] [review] core: Add Core.load_medias() and Core.set_current_media() These will be used to simplify game loading by the users of the library. By extension, simplifying the public API will help porting the library to C.
Created attachment 355077 [details] [review] core: Load medias in Core.init() Also make the ancient loading mechanisms private to avoid any conflict.
Attachment 355063 [details] pushed as 17457c3 - core: Move some internal fields to C Attachment 355064 [details] pushed as ffa1e14 - core: Move Core.on_input_key_event() to C Attachment 355065 [details] pushed as 9296306 - core: Move Core.set_controller_port_device() to C Attachment 355066 [details] pushed as 5051c3a - core: Move Core.on_input_controller_disconnected() to C Attachment 355067 [details] pushed as 8b8eb04 - core: Move Core.on_input_controller_connected() to C Attachment 355068 [details] pushed as 5541e58 - core: Move Core.init_input() to C Attachment 355069 [details] pushed as 1b7f57d - core: Move Core.get_memory_size() to C Attachment 355070 [details] pushed as 81abe41 - core: Move Core.prepare() to C Attachment 355071 [details] pushed as 94ce22d - core: Move Core.load_game() to C Attachment 355072 [details] pushed as 59bc4fd - core: Move Core.run() to C Attachment 355073 [details] pushed as 16ea652 - core: Move Core.reset() to C Attachment 355074 [details] pushed as 204980e - rotation: Port Rotation to C Attachment 355075 [details] pushed as 6b653a3 - core: Add Core.set_medias() Attachment 355076 [details] pushed as 3107f06 - core: Add Core.load_medias() and Core.set_current_media() Attachment 355077 [details] pushed as fde726b - core: Load medias in Core.init()
Created attachment 356029 [details] [review] memory: Remove unused types Remove the currently unused MemDesc, MemoryDescriptor and MemoryMap types. This will help porting the library to C.
Comment on attachment 356029 [details] [review] memory: Remove unused types Attachment 356029 [details] pushed as 47589d6 - memory: Remove unused types
Created attachment 356030 [details] [review] core: Remove unused extern functions Remove the extern prepare() and load_game() from the Vala code, also move the C implementations in the C code to avoid compilation warnings by using the functions before their declaration.
Created attachment 356031 [details] [review] core: Make the init() signal into a method It is never used as a signal and will probably never be, so this helps to make the code simpler.
Created attachment 356032 [details] [review] core: Let init() throw errors This will help to convey a failure when loading the games to the user of the library.
Created attachment 356033 [details] [review] core: Port init() to C
Created attachment 356034 [details] [review] core: Port the content of the destructor to C
Created attachment 356035 [details] [review] core: Port the content of the constructor to C
Created attachment 356036 [details] [review] core: Port api_version to C
Created attachment 356037 [details] [review] core: Port system_info to C
Created attachment 356038 [details] [review] core: Port callback data handling to C
Attachment 356030 [details] pushed as 0c43e51 - core: Remove unused extern functions Attachment 356031 [details] pushed as 99e3a3c - core: Make the init() signal into a method Attachment 356032 [details] pushed as d7d3f64 - core: Let init() throw errors Attachment 356033 [details] pushed as 6a59ef5 - core: Port init() to C Attachment 356034 [details] pushed as 3f2ea86 - core: Port the content of the destructor to C Attachment 356035 [details] pushed as ed43854 - core: Port the content of the constructor to C Attachment 356036 [details] pushed as 1f9d570 - core: Port api_version to C Attachment 356037 [details] pushed as a0f00e2 - core: Port system_info to C Attachment 356038 [details] pushed as fe1cde9 - core: Port callback data handling to C
Created attachment 356092 [details] [review] Make error domains private This will help reduce the public API and port the code to C.
Created attachment 356093 [details] [review] core: Use Gdk.EventKey instead of Libretro equivalent This helps to make the conversion from the GDK keyboard events to the Libretro equivalent hidden inside the library without the need to expose the Libretro symbols on the public API.
Created attachment 356094 [details] [review] input: Port keyboard keys to C
Attachment 356092 [details] pushed as 1158ff4 - Make error domains private Attachment 356093 [details] pushed as 1479f19 - core: Use Gdk.EventKey instead of Libretro equivalent Attachment 356094 [details] pushed as 27bf426 - input: Port keyboard keys to C
Created attachment 356104 [details] [review] input: Make some device IDs public This helps reducing the public API
Created attachment 356105 [details] [review] input: Remove useless Keyboard type
Attachment 356104 [details] pushed as 75c6d4f - input: Make some device IDs public Attachment 356105 [details] pushed as e60214e - input: Remove useless Keyboard type
Created attachment 356592 [details] [review] memory: Remove SNES memory types It has even been removed by upstream. Also remove the type mask and the base type getter as they are useless without the SNES specific types.
Created attachment 356593 [details] [review] input: Remove GamepadButtonType This type is useless as it is a copy of JoypadId with an extra useless value.
Created attachment 356594 [details] [review] Make DiskControl private This helps reducing the public API as it is now only used internally.
Attachment 356592 [details] pushed as 452afeb - memory: Remove SNES memory types Attachment 356593 [details] pushed as 6d075a4 - input: Remove GamepadButtonType Attachment 356594 [details] pushed as ff90fce - Make DiskControl private