From 6b88330540fe00f6a6d691c624e465511eaf516d Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Thu, 29 Mar 2012 14:17:03 +0200 Subject: [PATCH] (Griffin) Griffin function override hooks --- console/griffin/func_hooks.h | 54 ++++++++++++++++++++++++++++++++++++ console/griffin/hook.h | 11 ++++++-- ssnes.c | 6 ++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 console/griffin/func_hooks.h diff --git a/console/griffin/func_hooks.h b/console/griffin/func_hooks.h new file mode 100644 index 0000000000..8bd9d56909 --- /dev/null +++ b/console/griffin/func_hooks.h @@ -0,0 +1,54 @@ +/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. + * Copyright (C) 2010-2012 - Hans-Kristian Arntzen + * Copyright (C) 2011-2012 - Daniel De Matteis + * + * Some code herein may be based on code found in BSNES. + * + * SSNES is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * SSNES is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with SSNES. + * If not, see . + */ + +/*============================================================ + PLAYSTATION3 +============================================================ */ + +#ifdef __CELLOS_LV2__ + +#define HAVE_GRIFFIN_OVERRIDE_AUDIO_FLUSH_FUNC 1 + +static bool audio_flush(const int16_t *data, size_t samples) +{ + const float *output_data = NULL; + unsigned output_frames = 0; + + audio_convert_s16_to_float(g_extern.audio_data.data, data, samples); + + struct resampler_data src_data = {0}; + src_data.data_in = g_extern.audio_data.data; + src_data.data_out = g_extern.audio_data.outsamples; + src_data.input_frames = (samples / 2); + + src_data.ratio = g_extern.audio_data.src_ratio; + if (g_extern.is_slowmotion) + src_data.ratio *= g_settings.slowmotion_ratio; + + resampler_process(g_extern.audio_data.source, &src_data); + + output_data = g_extern.audio_data.outsamples; + output_frames = src_data.output_frames; + + if (audio_write_func(output_data, output_frames * sizeof(float) * 2) < 0) + return false; + + return true; +} + +#endif diff --git a/console/griffin/hook.h b/console/griffin/hook.h index 655811e629..56bb4195dd 100644 --- a/console/griffin/hook.h +++ b/console/griffin/hook.h @@ -25,7 +25,9 @@ #define audio_write_avail_func() driver.audio->write_avail(driver.audio_data) #define audio_buffer_size_func() driver.audio->buffer_size(driver.audio_data) -/* PlayStation3 */ +/*============================================================ + PLAYSTATION3 +============================================================ */ #ifdef __CELLOS_LV2__ #define video_init_func(video_info, input, input_data) \ @@ -45,7 +47,12 @@ #define input_key_pressed_func(key) ps3_key_pressed(driver.input_data, key) #define input_free_func() ps3_free_input(driver.input_data) -#elif defined(_XBOX) /* Xbox 360 */ +/*============================================================ + XBOX 360 +============================================================ */ + +#elif defined(_XBOX) + #define video_init_func(video_info, input, input_data) \ xdk360_gfx_init(video_info, input, input_data) #define video_frame_func(data, width, height, pitch, msg) \ diff --git a/ssnes.c b/ssnes.c index e03383b485..6019dfdf08 100644 --- a/ssnes.c +++ b/ssnes.c @@ -269,6 +269,11 @@ void ssnes_render_cached_frame(void) #endif } +#ifdef HAVE_GRIFFIN +#include "console/griffin/func_hooks.h" +#endif + +#ifndef HAVE_GRIFFIN_OVERRIDE_AUDIO_FLUSH_FUNC static bool audio_flush(const int16_t *data, size_t samples) { #ifdef HAVE_FFMPEG @@ -367,6 +372,7 @@ static bool audio_flush(const int16_t *data, size_t samples) return true; } +#endif static void audio_sample_rewind(uint16_t left, uint16_t right) {