Specifications

Receive MP3
data from
server
Increment the
receive
pointer
Reset the
po inter if it is
past the buffer
boundary
Is the
buffer set
to refill
Is it full
Start the
decoder
Calculate the
buffer size
If buffer is empty
set the buffer to
refill
Is the
buffer
full
Wait for there to be
room in the buffer
for another receive.
No
Yes
No
Yes
Yes
No
Play/Pause
button ISR
Toggle between
play and pause
states
If play
Disable
transfer to the
decoder
Send PAUSE
to the server
Send
UNPAUSE to
the server
Play
Pause
Main thread
Disable button
interrupt
The player
Is send
enabled
Read file into
buffer
If at end of file
call openMP3 to
open the next
song
Send MP3 data
Main thread
Receive command
from player
Decode the
message
If
UNPAUSE
If PAUSE
Enable
send
Disaable
send
Thread 2
Server
Yes
No
Yes
Yes
No
No
Enable transfer
to the decoder
Software
trigger the
decoder ISR
Figure 21 Play/pause implementation
When the pause/play button is pressed, it simply toggles between a pause state and a
play state. In the pause state, it sets the global variables that stop the transfer to the
decoder, and sends a PAUSE command to the server. In the play state is sets the global
variable to enable the transfer, sends an UNPAUSE command to the server and also
triggers the software interrupt to start the decoder transfer again. On the server side, a
global variable was used to either enable or disable the cycle of reading the MP3 data
from the file and the sending of it to the MP3 player. When the command thread
receives a command telling it to pause, it disables the above cycle. If it receives a un-
pause command it enables the cycle.
The test of this was to start the program in its usual start up state of filling the buffer and
then the initiation of the transfer of data to the decoder. This stage worked as before - no
problem in playing audio - then the pause button was pressed. The audio stopped, as
was hoped, and the network transfer was stopped without the send from the server
46