Anonymous avatar Anonymous committed df5c7a3

Moved initialization into its own method.
Created teardown method (untested).
Added possible fix for set_resolution failing to enact the change.

Comments (0)

Files changed (1)

 	def __init__(self, devnum=0, show_video_window=False):
 		self.devnum = devnum
 		self.show_video_window = show_video_window
+		self.initialize()
+
+	def initialize(self):
 		self.filter_graph = CreateObject(FilterGraph)
 		self.control = self.filter_graph.QueryInterface(IMediaControl)
 		self.graph_builder = CreateObject(CaptureGraphBuilder2)
 		self.grabber.SetBufferSamples(True)
 		self.grabber.SetOneShot(False)
 
+	def teardown(self):
+		if hasattr(self, 'control'):
+			self.control.Stop()
+			self.control.Release()
+			del self.control
+		if hasattr(self, 'grabber'):
+			self.grabber.Release()
+			del self.grabber
+		if hasattr(self, 'graph_builder'):
+			self.graph_builder.Release()
+			del self.graph_builder
+		if hasattr(self, 'filter_graph'):
+			self.filter_graph.Release()
+			del self.filter_graph
+
 	def display_capture_filter_properties(self):
 		self.control.Stop()
 		self._do_property_pages(self.source)
 		hdr.biWidth, hdr.biHeight = width, height
 		stream_config.SetFormat(media_type)
 		DeleteMediaType(media_type)
+		stream_config.Release()
+		#self.teardown()
+		#self.initialize()
 
 	def get_buffer(self):
 		media_type = tag_AMMediaType()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.