From d87e0c174475dfa599b35fa65d3e3f90fd4622aa Mon Sep 17 00:00:00 2001
From: twinaphex <libretro@gmail.com>
Date: Wed, 13 Oct 2021 16:36:38 +0200
Subject: [PATCH] * Fix implicit declaration * Move more code to
 gfx/video_driver.c

---
 audio/audio_driver.h |  4 +++
 gfx/video_driver.c   | 78 ++++++++++++++++++++++++++++++++++++++++++++
 retroarch.c          | 78 --------------------------------------------
 3 files changed, 82 insertions(+), 78 deletions(-)

diff --git a/audio/audio_driver.h b/audio/audio_driver.h
index 18ac70fef7..e6279b17af 100644
--- a/audio/audio_driver.h
+++ b/audio/audio_driver.h
@@ -408,6 +408,10 @@ size_t audio_driver_sample_batch_rewind(
       const int16_t *data, size_t frames);
 #endif
 
+#ifdef HAVE_MENU
+void audio_driver_menu_sample(void);
+#endif
+
 RETRO_END_DECLS
 
 #endif /* __AUDIO_DRIVER__H */
diff --git a/gfx/video_driver.c b/gfx/video_driver.c
index 184da92c21..b1cddb6952 100644
--- a/gfx/video_driver.c
+++ b/gfx/video_driver.c
@@ -2353,3 +2353,81 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp,
    vp->x      = padding_x / 2;
    vp->y      = padding_y / 2;
 }
+
+void video_driver_display_type_set(enum rarch_display_type type)
+{
+   video_driver_state_t *video_st = &video_driver_st;
+   video_st->display_type         = type;
+}
+
+uintptr_t video_driver_display_get(void)
+{
+   video_driver_state_t *video_st = &video_driver_st;
+   return video_st->display;
+}
+
+uintptr_t video_driver_display_userdata_get(void)
+{
+   video_driver_state_t *video_st = &video_driver_st;
+   return video_st->display_userdata;
+}
+
+void video_driver_display_userdata_set(uintptr_t idx)
+{
+   video_driver_state_t *video_st = &video_driver_st;
+   video_st->display_userdata     = idx;
+}
+
+void video_driver_display_set(uintptr_t idx)
+{
+   video_driver_state_t *video_st = &video_driver_st;
+   video_st->display              = idx;
+}
+
+enum rarch_display_type video_driver_display_type_get(void)
+{
+   video_driver_state_t *video_st = &video_driver_st;
+   return video_st->display_type;
+}
+
+void video_driver_window_set(uintptr_t idx)
+{
+   video_driver_state_t *video_st = &video_driver_st;
+   video_st->window               = idx;
+}
+
+uintptr_t video_driver_window_get(void)
+{
+   video_driver_state_t *video_st = &video_driver_st;
+   return video_st->window;
+}
+
+bool video_driver_texture_load(void *data,
+      enum texture_filter_type  filter_type,
+      uintptr_t *id)
+{
+   video_driver_state_t *video_st = &video_driver_st;
+   if (     !id
+         || !video_st->poke
+         || !video_st->poke->load_texture)
+      return false;
+   *id = video_st->poke->load_texture(
+         video_st->data, data,
+         VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st),
+         filter_type);
+   return true;
+}
+
+bool video_driver_texture_unload(uintptr_t *id)
+{
+   video_driver_state_t *video_st = &video_driver_st;
+   if (     !video_st->poke
+         || !video_st->poke->unload_texture)
+      return false;
+   video_st->poke->unload_texture(
+         video_st->data,
+         VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st),
+         *id);
+   *id = 0;
+   return true;
+}
diff --git a/retroarch.c b/retroarch.c
index b02bbd1a38..75cb00395a 100644
--- a/retroarch.c
+++ b/retroarch.c
@@ -15191,84 +15191,6 @@ char* crt_switch_core_name(void)
    return (char*)runloop_state.system.info.library_name;
 }
 
-void video_driver_display_type_set(enum rarch_display_type type)
-{
-   video_driver_state_t *video_st = video_state_get_ptr();
-   video_st->display_type     = type;
-}
-
-uintptr_t video_driver_display_get(void)
-{
-   video_driver_state_t *video_st = video_state_get_ptr();
-   return video_st->display;
-}
-
-uintptr_t video_driver_display_userdata_get(void)
-{
-   video_driver_state_t *video_st = video_state_get_ptr();
-   return video_st->display_userdata;
-}
-
-void video_driver_display_userdata_set(uintptr_t idx)
-{
-   video_driver_state_t *video_st = video_state_get_ptr();
-   video_st->display_userdata = idx;
-}
-
-void video_driver_display_set(uintptr_t idx)
-{
-   video_driver_state_t *video_st = video_state_get_ptr();
-   video_st->display = idx;
-}
-
-enum rarch_display_type video_driver_display_type_get(void)
-{
-   video_driver_state_t *video_st = video_state_get_ptr();
-   return video_st->display_type;
-}
-
-void video_driver_window_set(uintptr_t idx)
-{
-   video_driver_state_t *video_st = video_state_get_ptr();
-   video_st->window = idx;
-}
-
-uintptr_t video_driver_window_get(void)
-{
-   video_driver_state_t *video_st = video_state_get_ptr();
-   return video_st->window;
-}
-
-bool video_driver_texture_load(void *data,
-      enum texture_filter_type  filter_type,
-      uintptr_t *id)
-{
-   video_driver_state_t *video_st = video_state_get_ptr();
-   if (     !id
-         || !video_st->poke
-         || !video_st->poke->load_texture)
-      return false;
-   *id = video_st->poke->load_texture(
-         video_st->data, data,
-         VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st),
-         filter_type);
-   return true;
-}
-
-bool video_driver_texture_unload(uintptr_t *id)
-{
-   video_driver_state_t *video_st = video_state_get_ptr();
-   if (     !video_st->poke
-         || !video_st->poke->unload_texture)
-      return false;
-   video_st->poke->unload_texture(
-         video_st->data,
-         VIDEO_DRIVER_IS_THREADED_INTERNAL(video_st),
-         *id);
-   *id = 0;
-   return true;
-}
-
 void video_driver_build_info(video_frame_info_t *video_info)
 {
    video_viewport_t *custom_vp             = NULL;