From: Juho Vähä-Herttua Date: Mon, 19 Mar 2012 07:54:06 +0000 (+0200) Subject: Fix python bindings to hold a reference to sessions X-Git-Tag: upstream/0.9.0~4^2~97 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1f0de05c95f17c1040596b01a47a07de4a3d3767;p=deb_shairplay.git Fix python bindings to hold a reference to sessions --- 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