Hi Tan.
A FIFO is the same as a stack. As the name implies, first in and first out and it is different from a "Ring Buffer" as used is the "sterio-audio-codedc".
A FIFO is typically implemented as a queue of memory chunks (queue elements) where new elements are linked to the top of the queue and elements are removed from top of the queue.
Simply allocate a chunk of memory, store a pointer to the previous chunk (element) together with a data item you want to push onto your stack. Pop off from stack by removing the topmost element from queue, unlink and free it and return the data item.
Note that you must lock the queue in case you must be thread save.
typedef struct element_tag {
struct elementtag *next;
void* item;
} ELEMENT;
Hope this helps,
Guenter.
Hello Guys, recently I am doing some project which will be using FIFO Buffer, but i have no clues on how should I use it. Can anyone give me some guidance such as like how should write it or is there a example for me to reference? Hope you guys can help me! Thanks