[Player-dev] CR: player_kit_python_hxrecord - Fixes for various memory leaks
Peter Krenesky peter at osuosl.orgModified by: Peter Krenesky <peter at osuosl.org> Project: player_kit_python_hxrecord Synopsis: This patch is a collection of bug fixes for memory leaks and other bugs. The memory leaks are causing parts of all objects in the python api to remain after the python objects are destroyed. 1) At creation time the function that creates the IUnknown objects does not release the IUnknown after calling the function that wraps the object. The Wrapper function also AddRef()'s the IUnknown because it may be called by multiple places. As a result when the python wrapper is destroyed the IUnknown has a reference remaining. 2) When a PyFilter is created it contains a reference to a PyHxFilter. The PyHxFilter was not being AddRef()'d. When it is released it causes an integer rollover when the counter is decremented (counter is a uint). The PyHxFilter is not destroyed, which in turn would result in the wrapped IUnknown never being released and so on. 3) Functions that returned wrapped classes did not have return statements resulting in crashes if called 4) Functions for retrieving child objects were not checking for nulls resulting in crashes if the child did not exist 5) pyjob.hxjob_set_input() was not allowing a NULL (Py_None) preventing the job from releasing the input without destroying the IHXTJob 6) Removed unnecessary whitespace and tabs Files Modified: /player/kit/python/hxrecord/hxfilter.cpp /player/kit/python/hxrecord/hxfilter.h /player/kit/python/hxrecord/hxinput.cpp /player/kit/python/hxrecord/hxjob.cpp /player/kit/python/hxrecord/pyaudience.cpp /player/kit/python/hxrecord/pydestination.cpp /player/kit/python/hxrecord/pyfilter.cpp /player/kit/python/hxrecord/pyfilter.h /player/kit/python/hxrecord/pyinput.cpp /player/kit/python/hxrecord/pyjob.cpp /player/kit/python/hxrecord/pymediaprofile.cpp /player/kit/python/hxrecord/pyoutputprofile.cpp /player/kit/python/hxrecord/pypostfilter.cpp /player/kit/python/hxrecord/pyprefilter.cpp /player/kit/python/hxrecord/pyrecord.cpp /player/kit/python/hxrecord/pystreamconfig.cpp /player/kit/python/hxrecord/pytime.cpp /player/kit/python/hxrecord/samples/pygtk-producer.py Details: pyaudience.cpp, pydestination.cpp, pymediaprofile.cpp, pyoutputprofile.cpp, pypostfilter.cpp, pyprefilter.cpp, pystreamconfig.cpp, pytime.cpp * Functions returning wrapper objects now check for null IHXT objects * hxfilter addref() when creating new instance pyinput.cpp * Functions returning wrapper objects now check for null IHXT objects * hxfilter addref() when creating new instance * Removed unneeded code that was commented out pyjob.cpp * hxjob_set_input() now accepts a null (Py_None) * Functions returning wrapper objects now check for null IHXT objects pyrecord.cpp * all functions for creating new wrapped IHXT objects now release all IHXT objects and report failures with a human readable error hxfilter.cpp, hxfilter.h, hxinput.cpp, hxjob.cpp * Removed whitespace and tabs pygtk-producer.py * rearrange file so job creation is a function * added button for clearing existing job and creating a new one Platforms and Profiles Functionality verified: x86 helix-client-OLPC Branch: HEAD Atlas-310 Copyright assignment: In consideration for RealNetworks' hosting and maintenance of my modification, I agree to assign to RealNetworks full copyright ownership of the code included in the attached patch, and agree that RealNetworks has no duty of accounting to me for it. I warrant that this code is entirely original to and owned by me, that I can legally grant the copyright assignment, and that my contribution does not violate any other person's rights, and laws or breach any contract. I understand that RealNetworks may license this code under RPSL, RCSL, and/or any other license at RealNetworks' discretion, and use the code in any way. QA Instructions: -------------- next part -------------- A non-text attachment was scrubbed... Name: memoryleaks.patch Type: text/x-patch Size: 30706 bytes Desc: not available Url : http://lists.helixcommunity.org/pipermail/player-dev/attachments/20080303/a574abcf/memoryleaks-0001.bin