[retro-gtk] core: Move some internal fields to C
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk] core: Move some internal fields to C
- Date: Fri, 7 Jul 2017 09:05:57 +0000 (UTC)
commit 17457c32417facd741c824f8e877322ce9c6a4d8
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu Jul 6 10:04:58 2017 +0200
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.
https://bugzilla.gnome.org/show_bug.cgi?id=777489
retro-gtk/core.vala | 6 ------
retro-gtk/retro-core.h | 8 +++++++-
retro-gtk/retro-environment.c | 39 ++++++++++++++++++++++++++-------------
3 files changed, 33 insertions(+), 20 deletions(-)
---
diff --git a/retro-gtk/core.vala b/retro-gtk/core.vala
index c707bc4..9f5ecc2 100644
--- a/retro-gtk/core.vala
+++ b/retro-gtk/core.vala
@@ -216,12 +216,6 @@ public class Core : Object {
internal Module module;
internal Variables variables_interface;
- internal float aspect_ratio;
- internal bool overscan;
- internal PixelFormat pixel_format;
- internal Rotation rotation;
- internal double sample_rate;
-
internal void *environment_internal;
/**
diff --git a/retro-gtk/retro-core.h b/retro-gtk/retro-core.h
index f1819e9..5f92ebd 100644
--- a/retro-gtk/retro-core.h
+++ b/retro-gtk/retro-core.h
@@ -3,7 +3,7 @@
#ifndef RETRO_CORE_H
#define RETRO_CORE_H
-#include <glib-object.h>
+#include "retro-gtk-internal.h"
G_BEGIN_DECLS
@@ -16,6 +16,12 @@ typedef struct {
typedef struct _RetroCoreEnvironmentInternal RetroCoreEnvironmentInternal;
struct _RetroCoreEnvironmentInternal {
+ gfloat aspect_ratio;
+ gboolean overscan;
+ RetroPixelFormat pixel_format;
+ RetroRotation rotation;
+ gdouble sample_rate;
+
RetroKeyboardCallback keyboard_callback;
};
diff --git a/retro-gtk/retro-environment.c b/retro-gtk/retro-environment.c
index 6cc26fc..3d8ade2 100644
--- a/retro-gtk/retro-environment.c
+++ b/retro-gtk/retro-environment.c
@@ -156,7 +156,7 @@ static gboolean
get_overscan (RetroCore *self,
gboolean *overscan)
{
- *overscan = FALSE;
+ *overscan = RETRO_CORE_ENVIRONMENT_INTERNAL (self)->overscan;
return TRUE;
}
@@ -265,7 +265,7 @@ static gboolean
set_pixel_format (RetroCore *self,
const RetroPixelFormat *pixel_format)
{
- self->pixel_format = *pixel_format;
+ RETRO_CORE_ENVIRONMENT_INTERNAL (self)->pixel_format = *pixel_format;
return TRUE;
}
@@ -274,7 +274,7 @@ static gboolean
set_rotation (RetroCore *self,
const RetroRotation *rotation)
{
- self->rotation = *rotation;
+ RETRO_CORE_ENVIRONMENT_INTERNAL (self)->rotation = *rotation;
return TRUE;
}
@@ -436,6 +436,7 @@ on_video_refresh (guint8 *data,
gsize pitch)
{
RetroCore *self;
+ RetroCoreEnvironmentInternal *internal;
if (data == NULL)
return;
@@ -445,9 +446,11 @@ on_video_refresh (guint8 *data,
if (self == NULL)
g_return_if_reached ();
+ internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
g_signal_emit_by_name (self, "video_output", data, pitch * height,
- width, height, pitch, self->pixel_format,
- self->aspect_ratio);
+ width, height, pitch, internal->pixel_format,
+ internal->aspect_ratio);
}
// TODO This is internal, make it private as soon as possible.
@@ -462,6 +465,7 @@ on_audio_sample (gint16 left,
gint16 right)
{
RetroCore *self;
+ RetroCoreEnvironmentInternal *internal;
gint16 samples[] = { left, right };
self = retro_core_get_cb_data ();
@@ -469,10 +473,12 @@ on_audio_sample (gint16 left,
if (self == NULL)
g_return_if_reached ();
- if (self->sample_rate <= 0.0)
+ internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+ if (internal->sample_rate <= 0.0)
return;
- g_signal_emit_by_name (self, "audio_output", samples, 2, self->sample_rate);
+ g_signal_emit_by_name (self, "audio_output", samples, 2, internal->sample_rate);
}
static gsize
@@ -480,16 +486,19 @@ on_audio_sample_batch (gint16 *data,
int frames)
{
RetroCore *self;
+ RetroCoreEnvironmentInternal *internal;
self = retro_core_get_cb_data ();
if (self == NULL)
g_return_val_if_reached (0);
- if (self->sample_rate <= 0.0)
+ internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
+ if (internal->sample_rate <= 0.0)
return 0;
- g_signal_emit_by_name (self, "audio_output", data, frames * 2, self->sample_rate);
+ g_signal_emit_by_name (self, "audio_output", data, frames * 2, internal->sample_rate);
// FIXME What should be returned?
return 0;
@@ -583,14 +592,18 @@ void
retro_core_set_system_av_info (RetroCore *self,
RetroSystemAvInfo *system_av_info)
{
+ RetroCoreEnvironmentInternal *internal;
+
+ internal = RETRO_CORE_ENVIRONMENT_INTERNAL (self);
+
if (self->_frames_per_second != system_av_info->timing.fps) {
self->_frames_per_second = system_av_info->timing.fps;
g_object_notify (G_OBJECT (self), "frames-per-second");
}
if (system_av_info->geometry.aspect_ratio > 0.f)
- self->aspect_ratio = system_av_info->geometry.aspect_ratio;
+ internal->aspect_ratio = system_av_info->geometry.aspect_ratio;
else
- self->aspect_ratio = (float) system_av_info->geometry.base_width /
- (float) system_av_info->geometry.base_height;
- self->sample_rate = system_av_info->timing.sample_rate;
+ internal->aspect_ratio = (float) system_av_info->geometry.base_width /
+ (float) system_av_info->geometry.base_height;
+ internal->sample_rate = system_av_info->timing.sample_rate;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]