xpra icon
Bug tracker and wiki

Ticket #533: osx-sound-autoreleasepool.patch

File osx-sound-autoreleasepool.patch, 2.4 KB (added by Antoine Martin, 5 years ago)

my attempts at getting rid of the warnings

  • src/xpra/net/subprocess_wrapper.py

     
    3636#avoids showing a new console window on win32:
    3737WIN32_SHOWWINDOW = os.environ.get("XPRA_WIN32_SHOWWINDOW", "0")=="1"
    3838
     39import gtk
     40gtk.threads_init()
     41class mainloop(object):
     42    def run(self):
     43        gtk.main()
     44    def quit(self):
     45        gtk.main_quit()
    3946
     47
    4048class subprocess_callee(object):
    4149    """
    4250    This is the callee side, wrapping the gobject we want to interact with.
     
    4755    (there is no validation of which signals are valid or not)
    4856    """
    4957    def __init__(self, input_filename="-", output_filename="-", wrapped_object=None, method_whitelist=None):
    50         self.mainloop = gobject.MainLoop()
     58        self.mainloop = mainloop()
    5159        self.name = ""
    5260        self.input_filename = input_filename
    5361        self.output_filename = output_filename
  • src/xpra/sound/wrapper.py

     
    33# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
    44# later version. See the file COPYING for details.
    55
     6import sys
    67import os
    78import time
    89
     
    103104    else:
    104105        raise Exception("unknown mode: %s" % mode)
    105106
     107    #ugly OSX code to avoid auto-release warnings
     108    auto_release_pool = None
     109    if sys.platform.startswith("darwin"):
     110        try:
     111            import objc             #@UnresolvedImport
     112            NSAutoreleasePool = objc.lookUpClass("NSAutoreleasePool")
     113            auto_release_pool = NSAutoreleasePool.alloc()
     114            auto_release_pool.init()
     115            log("autorelease pool=%s", auto_release_pool)
     116        except:
     117            log.warn("failed to allocate autorelease pool", exc_info=True)
     118            auto_release_pool = None
     119
    106120    #the plugin to use (ie: 'pulsesrc' for src.py or 'autoaudiosink' for sink.py)
    107121    plugin = args[2]
    108122    #plugin options (ie: "device=monitor_device,something=value")
     
    127141        log.error("run_sound%s error", (mode, error_cb, options, args), exc_info=True)
    128142        return 1
    129143    finally:
     144        del auto_release_pool
    130145        if ss:
    131146            ss.stop()
    132147