Specifications

long or intense, indicating that the clicks were definitely something to do with the
pointers at the end of the allocated space.
The second problem with the TCP receive function and the buffer was that the buffer
should not be able to store data outside the space allocated to it. That space could be
assigned to other variables or data, therefore the buffer could cause errors with other
parts of the program or the program could corrupt the buffer. The solution to this was to
consider that the most the TCP receive could receive could be 1.5Kbytes of data as this
is what the function was passed as a limit to the packet size. Therefore, after a receive
has happened and the pointer is incremented by the number of byte actually received, it
is determined whether the pointer is within 1.5Kbytes of the end of the allocated space
for the buffer. If it is within this space, the pointer is reset to the beginning of the
allocated space and the address before it was reset is recorded as before. The transmit
pointer then uses this same variable as before to determine when it should be reset to the
beginning of the buffer. The tests of this implementation were very successful. For the
first time, the MP3 player was able to play an MP3 from beginning to end without any
anomalies.
5.3.8 Playing more than one song.
An MP3 player that only plays one song is not very useful. Next the device had to be
given some features, so the first was to enable it to play more than one song. To do this
no change required on the MP3 player. All the code changes were made on the server
program.
The first stage was to be able to detect when the current file being read is finished. This
was achieved by looking at the value the ReadFile function returns showing how many
bytes were read. If it equalled zero the program was at the end of the file. This was
tested by printing an indicator to the screen when this condition was true. The next step
was letting the server know the name and path of the other files are to open and send.
The design decisions for this are mostly discussed in the GUI section (section 5.3.9 in
this chapter) but some are relevant to this section. The decision was to use a play list file
to contain all the information required to open the required file. Initially this play list
42