Code explanation please 
Author Message
 Code explanation please

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()



Tue, 22 Jun 2004 05:33:22 GMT  
 Code explanation please
I believe the most reasonable explaination (a guess) would be the same
reason you use glFlush() in opengl. To feed a buffer. Whether or not
that applies I do not know.

Regards,
jptd



Quote:
>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()



Tue, 22 Jun 2004 05:43:26 GMT  
 Code explanation please

Quote:
> 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?

Pipes, sockets, and physical files on the filesystem have a buffering
behavior for performance reasons. For example, they flush automatically
only at, say, EOL, EOF, or after a certain number of bytes. The flush
call flushes the buffer explicitly.

HTH
Tim Hammerquist
--
E Pluribus Unix



Tue, 22 Jun 2004 11:01:52 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VAST Web Connection: how to download/ upload a file from a webserver ?(please read my explanation)

2. Explanation needed please!

3. Programming, Compiling, Bebugging Explanation Please

4. Explanation please?

5. Pentomino solutions code, explanation

6. Pentomino solutions code, explanation

7. explanation of udp error codes

8. Wanted: Explanation or Source Code (C) for Radix Sort

9. newbie needs explanation on inline asm codes

10. Need code/detailed explanation of non-standard MVBITS call

11. Please Help - Need to Convert Fortran Code to C Code

12. Please check my code (long code)

 

 
Powered by phpBB® Forum Software