Code explanation please

Craig E. Smith craigesmith at hotmail.com
Thu Jan 3 22:33:22 CET 2002


The piece of code below is taken from the Myp3 project. Can someone
explain to me the need/reason for the flush() call after each write()
to pin? Thanks in advance.



def play(self, filename):
		# play a file
		
		self.initvars()

		self.debug("PLAY " + filename)
		
		self.state = "play"

		# stop the player, then flush to send the command
		if self.state == "play":
			self.pin.write("stop\012")
			self.pin.flush()


		# as long as the file is present, then open the file, and start to
play it
		if (len(filename) > 0):
			self.pin.write("input_open " + filename + "\012play\012")
			
		#between commenting this and the timeout value of 0.1 in
handle_audio (see below)
		#considerable speedups and timer accuracy can be had
		#self.pin.write("input_position_range 1\012")
		        self.pin.flush()



More information about the Python-list mailing list