Skip to content

Commit

Permalink
Merge branch 'libretro:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ljm1017482731 authored Jan 6, 2025
2 parents c3a9083 + 9c6e772 commit e54a0a3
Show file tree
Hide file tree
Showing 184 changed files with 4,488 additions and 4,186 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ gfx/common/wayland/cursor-shape-v1.h
gfx/common/wayland/cursor-shape-v1.c
gfx/common/wayland/tablet-unstable-v2.h
gfx/common/wayland/tablet-unstable-v2.c
gfx/common/wayland/content-type-v1.h
gfx/common/wayland/content-type-v1.c
gfx/common/wayland/single-pixel-buffer-v1.h
gfx/common/wayland/single-pixel-buffer-v1.c

# libretro-common samples
libretro-common/samples/streams/rzip/rzip
Expand Down
10 changes: 9 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Future

# 1.20.0
- AUDIO: Fix audio handling in case of RARCH_NETPLAY_CTL_USE_CORE_PACKET_INTERFACE
- AUDIO: Include missing audio filters on some platforms
- AUDIO/PIPEWIRE: Add PipeWire audio driver
- AUDIO/PIPEWIRE: Add PipeWire microphone driver
- APPLE: Hide threaded video setting
- APPLE: Use mfi joypad driver by default
- APPLE: Include holani, noods, mrboom, yabause core in App Store builds
- APPLE: Include holani, noods, mrboom, yabause, bsnes-jg core in App Store builds
- CHEEVOS: Add rarity and points to achievement unlock widget
- CHEEVOS: Add rank to leaderboard submission notification
- CHEEVOS: Update to rcheevos 11.5
Expand Down Expand Up @@ -35,20 +37,24 @@
- INPUT: Enable Caps, Num, Scroll Lock modifiers on multiple platforms
- INPUT: Autoconfig extension with alternative name/vid/pid
- INPUT: Fix autoconfig profile saving when device is not in the default port
- INPUT: Change classic turbo mode to work independently of which key was pressed first
- INPUT: Pointer and lightgun handling sanitization on Windows and Linux desktop platforms. These input drivers will now report edge and offscreen positions in a harmonized way, and will not return 0 instead.
- INPUT/DINPUT: Fix detection of quick shift key presses
- INPUT/HID: Fix crash on macOS when disconnecting the controller a second time
- INPUT/LINUX: Add illuminance sensor support to the linuxraw, sdl2, udev, and x11 input drivers
- INPUT/Remaps: Sort and apply remaps based on the specific connected controller
- INPUT/UDEV: Enable mouse buttons 4 and 5
- INPUT/WAYLAND: Enable horizontal scroll and mouse buttons 4 and 5
- INPUT/WAYLAND: Simulate lightgun input for cores
- INPUT/WAYLAND: Support for cursor-shape-v1 and content-type-v1 protocol
- INPUT/X11: Enable mouse buttons 4 and 5
- iOS: Enable vibration by default
- iOS: Better handling of physical mice/magic keyboard trackpad
- iOS: Mouse grab fixes
- iOS: Fix mouse cursor movement when button is held down
- iOS: Fix microphone support request and entitlement
- iOS: Enable compilation back to iOS 12
- iOS: Fix OpenGL ES context usage on iOS 9
- iOS/TVOS: Add Opera to App Store build
- iOS/TVOS: Bring NEON defines in line with ARM64
- iOS/TVOS: Flush save files on backgrounding
Expand All @@ -70,6 +76,7 @@
- MENU: Add icons for present / missing firmware on core info page
- MENU: Ignore other hotkeys when menu toggle is pressed
- MENU: Fix menu jumping when using L3+R3 combo
- MENU: System Information now only shows features relevant for the platform
- MENU/GLUI: Make Show Sublabels options effective
- MENU/GLUI: Icon fixes
- MENU/XMB: Allow playlist icons to be individually customized, by looking for images in Named_Logos
Expand Down Expand Up @@ -107,6 +114,7 @@
- VIDEO/VULKAN: Fix Vulkan window freezes when swapchain becomes suboptimal
- VIDEO/VULKAN: Prefer IMMEDIATE mode without vsync
- VIDEO/X11: Support inhibit of Xss screensaver
- VITA: Enable analog L2/R2 triggers when a DS3 controller is used with PS Vita
- WAYLAND: Fix segfault when relative pointer is not supported
- WAYLAND: Use reverse DNS name for desktop file and icon
- WAYLAND: Commit viewport resizes for more responsive display when resizing window
Expand Down
4 changes: 3 additions & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,9 @@ ifeq ($(HAVE_WAYLAND), 1)
gfx/common/wayland/pointer-constraints-unstable-v1.o \
gfx/common/wayland/relative-pointer-unstable-v1.o \
gfx/common/wayland/cursor-shape-v1.o \
gfx/common/wayland/tablet-unstable-v2.o
gfx/common/wayland/tablet-unstable-v2.o \
gfx/common/wayland/content-type-v1.o \
gfx/common/wayland/single-pixel-buffer-v1.o

ifeq ($(HAVE_VULKAN), 1)
OBJ += gfx/drivers_context/wayland_vk_ctx.o
Expand Down
102 changes: 80 additions & 22 deletions audio/common/pipewire.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,46 @@

#include "pipewire.h"

#include <spa/utils/result.h>

#include <pipewire/pipewire.h>

#include <retro_assert.h>

#include "verbosity.h"


static void core_error_cb(void *data, uint32_t id, int seq, int res, const char *message)
{
pipewire_core_t *pw = (pipewire_core_t*)data;

RARCH_ERR("[PipeWire]: error id:%u seq:%d res:%d (%s): %s\n",
id, seq, res, spa_strerror(res), message);

/* stop and exit the thread loop */
pw_thread_loop_stop(pw->thread_loop);
}

static void core_done_cb(void *data, uint32_t id, int seq)
{
pipewire_core_t *pw = (pipewire_core_t*)data;

retro_assert(id == PW_ID_CORE);

pw->last_seq = seq;
if (pw->pending_seq == seq)
{
/* stop and exit the thread loop */
pw_thread_loop_signal(pw->thread_loop, false);
}
}

static const struct pw_core_events core_events = {
PW_VERSION_CORE_EVENTS,
.done = core_done_cb,
.error = core_error_cb,
};

size_t calc_frame_size(enum spa_audio_format fmt, uint32_t nchannels)
{
uint32_t sample_size = 1;
Expand Down Expand Up @@ -80,37 +114,61 @@ void set_position(uint32_t channels, uint32_t position[SPA_AUDIO_MAX_CHANNELS])
}
}

int pipewire_wait_resync(pipewire_core_t *pipewire)
void pipewire_wait_resync(pipewire_core_t *pw)
{
int res;
retro_assert(pipewire != NULL);

pipewire->pending_seq = pw_core_sync(pipewire->core, PW_ID_CORE, pipewire->pending_seq);
retro_assert(pw);
pw->pending_seq = pw_core_sync(pw->core, PW_ID_CORE, pw->pending_seq);

for (;;)
{
pw_thread_loop_wait(pipewire->thread_loop);

res = pipewire->error;
if (res < 0)
{
pipewire->error = 0;
return res;
}
if (pipewire->pending_seq == pipewire->last_seq)
pw_thread_loop_wait(pw->thread_loop);
if (pw->pending_seq == pw->last_seq)
break;
}
return 0;
}

bool pipewire_set_active(pipewire_core_t *pipewire, pipewire_device_handle_t *device, bool active)
bool pipewire_set_active(struct pw_thread_loop *loop, struct pw_stream *stream, bool active)
{
RARCH_LOG("[PipeWire]: %s.\n", active? "Unpausing": "Pausing");
enum pw_stream_state st;
const char *error;

retro_assert(loop);
retro_assert(stream);

pw_thread_loop_lock(loop);
pw_stream_set_active(stream, active);
pw_thread_loop_wait(loop);
pw_thread_loop_unlock(loop);

st = pw_stream_get_state(stream, &error);
return active ? st == PW_STREAM_STATE_STREAMING : st == PW_STREAM_STATE_PAUSED;
}

bool pipewire_core_init(pipewire_core_t *pw, const char *loop_name)
{
retro_assert(pw);

pw->thread_loop = pw_thread_loop_new(loop_name, NULL);
if (!pw->thread_loop)
return false;

pw->ctx = pw_context_new(pw_thread_loop_get_loop(pw->thread_loop), NULL, 0);
if (!pw->ctx)
return false;

if (pw_thread_loop_start(pw->thread_loop) < 0)
return false;

pw_thread_loop_lock(pw->thread_loop);

pw->core = pw_context_connect(pw->ctx, NULL, 0);
if(!pw->core)
return false;

pw_thread_loop_lock(pipewire->thread_loop);
pw_stream_set_active(device->stream, active);
pw_thread_loop_wait(pipewire->thread_loop);
pw_thread_loop_unlock(pipewire->thread_loop);
if (pw_core_add_listener(pw->core,
&pw->core_listener,
&core_events, pw) < 0)
return false;

return device->is_paused != active;
return true;
}
40 changes: 17 additions & 23 deletions audio/common/pipewire.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,25 @@
#include <spa/param/audio/format-utils.h>
#include <spa/utils/ringbuffer.h>

#include <pipewire/pipewire.h>

#define RINGBUFFER_SIZE (1u << 22)
#define RINGBUFFER_MASK (RINGBUFFER_SIZE - 1)
#define PW_RARCH_APPNAME "RetroArch"

typedef struct pipewire
/* String literals are part of the PipeWire specification */
#define PW_RARCH_MEDIA_TYPE_AUDIO "Audio"
#define PW_RARCH_MEDIA_TYPE_VIDEO "Video"
#define PW_RARCH_MEDIA_TYPE_MIDI "Midi"
#define PW_RARCH_MEDIA_CATEGORY_PLAYBACK "Playback"
#define PW_RARCH_MEDIA_CATEGORY_RECORD "Capture"
#define PW_RARCH_MEDIA_ROLE "Game"

typedef struct pipewire_core
{
struct pw_thread_loop *thread_loop;
struct pw_context *context;
struct pw_context *ctx;
struct pw_core *core;
struct spa_hook core_listener;
int last_seq, pending_seq, error;
int last_seq, pending_seq;

struct pw_registry *registry;
struct spa_hook registry_listener;
Expand All @@ -43,28 +51,14 @@ typedef struct pipewire
struct string_list *devicelist;
} pipewire_core_t;

typedef struct pipewire_device_handle
{
pipewire_core_t *pw;

struct pw_stream *stream;
struct spa_hook stream_listener;
struct spa_audio_info_raw info;
uint32_t highwater_mark;
uint32_t frame_size;
uint32_t req;
struct spa_ringbuffer ring;
uint8_t buffer[RINGBUFFER_SIZE];

bool is_paused;
} pipewire_device_handle_t;

size_t calc_frame_size(enum spa_audio_format fmt, uint32_t nchannels);

void set_position(uint32_t channels, uint32_t position[SPA_AUDIO_MAX_CHANNELS]);

int pipewire_wait_resync(pipewire_core_t *pipewire);
void pipewire_wait_resync(pipewire_core_t *pipewire);

bool pipewire_set_active(struct pw_thread_loop *loop, struct pw_stream *stream, bool active);

bool pipewire_set_active(pipewire_core_t *pipewire, pipewire_device_handle_t *device, bool active);
bool pipewire_core_init(pipewire_core_t *pipewire, const char *loop_name);

#endif /* _RETROARCH_PIPEWIRE */
6 changes: 2 additions & 4 deletions audio/drivers/alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,8 @@ void alsa_device_list_free(void *data, void *array_list_data)
{
struct string_list *s = (struct string_list*)array_list_data;

if (!s)
return;

string_list_free(s);
if (s)
string_list_free(s);
}

audio_driver_t audio_alsa = {
Expand Down
Loading

0 comments on commit e54a0a3

Please sign in to comment.