From 1f0de05c95f17c1040596b01a47a07de4a3d3767 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Juho=20V=C3=A4h=C3=A4-Herttua?= Date: Mon, 19 Mar 2012 09:54:06 +0200 Subject: [PATCH] Fix python bindings to hold a reference to sessions --- src/bindings/python/Shairplay.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bindings/python/Shairplay.py b/src/bindings/python/Shairplay.py index 35142f1..f9dc919 100644 --- a/src/bindings/python/Shairplay.py +++ b/src/bindings/python/Shairplay.py @@ -1,3 +1,4 @@ +# coding=utf-8 ''' Copyright (C) 2012 Juho Vähä-Herttua @@ -122,7 +123,8 @@ class RaopCallbacks: class RaopService: def audio_init_cb(self, cls, bits, channels, samplerate): session = self.callbacks.audio_init(bits, channels, samplerate) - return py_object(session) + self.sessions.append(session) + return session def audio_set_volume_cb(self, cls, sessionptr, volume): session = cast(sessionptr, py_object).value @@ -140,11 +142,14 @@ class RaopService: def audio_destroy_cb(self, cls, sessionptr): session = cast(sessionptr, py_object).value self.callbacks.audio_destroy(session) + if session in self.sessions: + self.sessions.remove(session) def __init__(self, libshairplay, callbacks): self.libshairplay = libshairplay self.callbacks = callbacks + self.sessions = [] self.instance = None # We need to hold a reference to native_callbacks -- 2.34.1