Sei sulla pagina 1di 3

EE5903 – CA3 Exercise Date: 01-Apr-2011

Subodh Joshi (Matriculation No: HT082097A) Page: 1 of 3

Problem Statement:
                                   10 audio streaming packets are required per audio block for successful decoding. Of 
the 10 packets, the last packet must is a block synchronization packet. The audio server sends out packets 
in order with every 10th packet being a block synchronization packet, and they are received in order . The 
server sends out packets at 100 packets/second. However, due to network uncertainties, the packet arrival is 
random   and   is   with   an   average   rate   of   100   packets/second.   Two   consecutive   packets   are   spaced   at   a 
minimum of 2 ms. The decoding of a block requires approximately  5  ms  in steps of 1 ms  to complete. To 
ensure smooth audio playing, the playing device has the capability of holding 1 audio block in its buffer 
while another block is being played, and continue to play the buffered block when the previous audio block 
has finished playing. 

Solution:
Since the packets arrive at an average rate of 100 packets/second. A packet arrives 2ms apart. 
However since a multi threaded solution is not possible, the primary objective is to ensure that the system 
can complete all the required processing in 2 ms and be available to capture the next available packet  . 
The Decode Block function is only called once a Sync Packet is available. The function used completes in a 
total of 5ms but in steps of 1 ms, thus giving a better performance. 
Functions
      
                The following functions have been used:

Main:            This uses an array of 10 packets. The function runs in the Main thread and       
                       collects packets to an array as broadcast. The sync packet is then detected, which is used to  
                       copy the local array to a global array so that it can be used by the Decode Block function. A  
                       sync point variable is set to indicate a that Decode Block function is in use. The sync point is 
          reset after the completion of the Decode Block function.

Decode Block:Thus function uses a copy of the 10 packets which includes the synchronization packet as 
 the last packet in the frame. A soft mutex is used to ensure that the global array passed to 
 this function is not over written. The frame is then passed to a the Decode Block function 
 to either get a  block or an error bit. If there is no error the block is copied to a global block 
 Buffer to pass it to the Play Block function. The function uses a flag to indicate if the intial 
 buffering is complete. Initial buffering is required to ensure that sufficient blocks are 
 available so that there are no breaks in  the audio output. The Play Block function is only 
 called if initial buffering is complete. The initial buffer size is based on the calculation as 
 the solution for assignment 2. Hence a buffer size of 40 blocks has been chosen. The Buffer 
 size is set to 200 blocks to ensure that there are no overflow possibilities 

Play Block: The Play Block function uses a valid block from the Make Block function. The Block is sent to 
                      the buffer is the Buffer is not full. If the block is not playing the play is started. Once the 
         buffer is exhausted, the buffer counter is reinitialized to  start from the beginning.
EE5903 – CA3 Exercise Date: 01-Apr-2011
Subodh Joshi (Matriculation No: HT082097A) Page: 2 of 3

Activity Diagram:
EE5903 – CA3 Exercise Date: 01-Apr-2011
Subodh Joshi (Matriculation No: HT082097A) Page: 3 of 3

State Diagram

Conclusion and Considerations:


Thus it can be seen that the solution to decoding the block and laying the audio has been
converted into a a single threaded, multi state solution. The solution is essentially sequential in nature. However since the
decode block now only takes 1 ms to execute, the performance as compared to the previous solution has improved.

Potrebbero piacerti anche