Skip to content

Commit

Permalink
Fix stopping midi timer on midi.quit()
Browse files Browse the repository at this point in the history
& undo test changes
  • Loading branch information
MyreMylar committed Sep 29, 2024
1 parent ff88969 commit 8b8766b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src_c/cython/pygame/pypm.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ cdef extern from "porttime.h":
ctypedef long PtTimestamp
ctypedef void (* PtCallback)(PtTimestamp timestamp, void *userData)
PtError Pt_Start(int resolution, PtCallback *callback, void *userData)
PtError Pt_Stop()
PtTimestamp Pt_Time()

cdef long _pypm_initialized
Expand All @@ -171,6 +172,7 @@ def Terminate():
your system may crash.
"""
Pt_Stop()
Pm_Terminate()
_pypm_initialized = 0

Expand Down
11 changes: 2 additions & 9 deletions test/midi_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import unittest
import sys


import pygame
Expand Down Expand Up @@ -320,14 +319,8 @@ def test_get_init(self):
def test_time(self):
mtime = pygame.midi.time()
self.assertIsInstance(mtime, int)
if "pytest" in sys.modules:
# under pytest the midi module takes a couple of seconds to init
# instead of milliseconds
self.assertGreaterEqual(mtime, 0)
self.assertLess(mtime, 3000)
else:
self.assertGreaterEqual(mtime, 0)
self.assertLess(mtime, 100)
# should be close to 2-3... since the timer is just init'd.
self.assertTrue(0 <= mtime < 100)


class MidiModuleNonInteractiveTest(unittest.TestCase):
Expand Down

0 comments on commit 8b8766b

Please sign in to comment.