Skip to content

Commit 4e11fad

Browse files
committed
More refcount edits
1 parent eae8383 commit 4e11fad

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src_c/mixer.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ endsound_callback(int channel)
299299
PyGILState_STATE gstate = PyGILState_Ensure();
300300
int channelnum;
301301
Mix_Chunk *sound = pgSound_AsChunk(channeldata[channel].queue);
302+
Py_DECREF(channeldata[channel].sound);
302303
channeldata[channel].sound = channeldata[channel].queue;
303304
channeldata[channel].queue = NULL;
304305
PyGILState_Release(gstate);
@@ -309,6 +310,7 @@ endsound_callback(int channel)
309310
}
310311
else {
311312
PyGILState_STATE gstate = PyGILState_Ensure();
313+
Py_DECREF(channeldata[channel].sound);
312314
channeldata[channel].sound = NULL;
313315
PyGILState_Release(gstate);
314316
Mix_GroupChannel(channel, -1);
@@ -676,7 +678,11 @@ pgSound_Play(PyObject *self, PyObject *args, PyObject *kwargs)
676678
Py_RETURN_NONE;
677679
}
678680

679-
Py_XDECREF(channeldata[channelnum].sound);
681+
if (channeldata[channelnum].sound) {
682+
Mix_HaltGroup(
683+
(int)(intptr_t)pgSound_AsChunk(channeldata[channelnum].sound));
684+
}
685+
680686
Py_XDECREF(channeldata[channelnum].queue);
681687
channeldata[channelnum].queue = NULL;
682688
channeldata[channelnum].sound = self;

0 commit comments

Comments
 (0)