From de7c068e7ea980a334d2fcf3e89dcd1f00d49bc7 Mon Sep 17 00:00:00 2001 From: Andrew Coffey Date: Mon, 20 May 2024 15:29:21 -0500 Subject: [PATCH 1/2] Added shim to fix portmidi break --- src_c/cython/pygame/pypm.pyx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src_c/cython/pygame/pypm.pyx b/src_c/cython/pygame/pypm.pyx index f2c16c9e2b..605200c7af 100644 --- a/src_c/cython/pygame/pypm.pyx +++ b/src_c/cython/pygame/pypm.pyx @@ -106,14 +106,13 @@ cdef extern from "portmidi.h": PmDeviceID inputDevice, void *inputDriverInfo, long bufferSize, - long (*PmPtr) (), # long = PtTimestamp + PmTimeProcPtr time_proc, # long = PtTimestamp void *time_info) PmError Pm_OpenOutput(PortMidiStream** stream, PmDeviceID outputDevice, void *outputDriverInfo, long bufferSize, - #long (*PmPtr) (), # long = PtTimestamp PmTimeProcPtr time_proc, # long = PtTimestamp void *time_info, long latency) @@ -521,6 +520,11 @@ cdef class Output: while Pt_Time() == cur_time: pass +# in commit 64314cc3d1a6fdddfc6ff5408a3f83af685b8cea +# portmidi changed the signature of Pt_Time from `PMEXPORT PtTimestamp Pt_Time()` to `PMEXPORT PtTimestamp Pt_Time(void)` +# this change is significant in that no args in a C function declaration is treated differently than void +cdef PtTimestamp compatShimDueToMidiChange(void* arg) noexcept: + return Pt_Time() cdef class Input: """Represents an input MIDI stream device. @@ -542,7 +546,7 @@ cdef class Input: self.debug = 0 err = Pm_OpenInput(&(self.midi), input_device, NULL, buffersize, - &Pt_Time, NULL) + &compatShimDueToMidiChange, NULL) if err < 0: raise Exception(Pm_GetErrorText(err)) From 985514fc2dcf81fac55cc4194a473fafb6e7db4a Mon Sep 17 00:00:00 2001 From: Andrew Coffey Date: Tue, 21 May 2024 06:28:34 -0500 Subject: [PATCH 2/2] Renamed portmidi shim --- src_c/cython/pygame/pypm.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src_c/cython/pygame/pypm.pyx b/src_c/cython/pygame/pypm.pyx index 605200c7af..45f8cbe3ea 100644 --- a/src_c/cython/pygame/pypm.pyx +++ b/src_c/cython/pygame/pypm.pyx @@ -523,7 +523,7 @@ cdef class Output: # in commit 64314cc3d1a6fdddfc6ff5408a3f83af685b8cea # portmidi changed the signature of Pt_Time from `PMEXPORT PtTimestamp Pt_Time()` to `PMEXPORT PtTimestamp Pt_Time(void)` # this change is significant in that no args in a C function declaration is treated differently than void -cdef PtTimestamp compatShimDueToMidiChange(void* arg) noexcept: +cdef PtTimestamp pgCompat_Pt_Time(void* arg) noexcept: return Pt_Time() cdef class Input: @@ -546,7 +546,7 @@ cdef class Input: self.debug = 0 err = Pm_OpenInput(&(self.midi), input_device, NULL, buffersize, - &compatShimDueToMidiChange, NULL) + &pgCompat_Pt_Time, NULL) if err < 0: raise Exception(Pm_GetErrorText(err))