Specifications

number as previously. This resets the file handler back to the start of the file, ready to
play from the start when play is pressed.
The results of this test were very puzzling. Stop did indeed stop the music but when
play was pressed the music began playing, from where it was stopped for about one
second then the song would start from the beginning again. This meant that old data
from before stop was pressed was still being stored somewhere. This could have been
somewhere in the TCP system (either on the sender or receiver) or something to do with
the buffer management. It was decided that there was a delay between when the decoder
was stopped from receiving data and when the server actually stops sending data.
Button pressed
Decoder transfer
stopped
immediately buffer
stops empting
Stop message
sent to server
Stop message
received by server
Main loop told to
disable sending
Main loop has to
finish current send
before checking if
sending is enabled
Transfer
stopped buffer
stops filling
D
e
l
a
y
Figure 22 Buffer control delays
The delay in controlling the buffer means data will keep going into the buffer after the
button is pressed. Hence, when play is resumed and the new file is received it gets
added after the old data that has not been played yet. It was decided to prevent the delay
by also disabling the TCP receive at the same time the decoder is disabled. The testing
of this actually did not change anything; somehow the old data was still being received
or stored somewhere. Therefore the disabling of the TCP receive was removed.
It was decided that it had to be somewhere in the TCP system because the buffer
management was rather simple. The buffer management reset the pointers back to the
beginning of the buffer space when stop was pressed; therefore, what ever came in
through the network after this would be written over the old data. To investigate further,
a program was written to display the number of bytes each TCP receive actually
received. In these tests, it was found that the TCP receive function never received data
48