4
Fork 0

Added implementation of RingBuffer to compensate existing issues on RA side

This commit is contained in:
R3ABM Artem 2016-08-06 14:30:27 +03:00
parent 41fe7704b3
commit 52422cebf0
5 changed files with 159 additions and 14 deletions

37
RingBuffer.h Normal file
View file

@ -0,0 +1,37 @@
#ifndef RINGBUFFER_H
#define RINGBUFFER_H
#include <stdint.h>
#include <stddef.h>
#include <arpa/inet.h>
#ifdef __cplusplus
extern "C"
{
#endif
#define DATA_LENGTH 256
#define BUFFER_LENGTH 8
struct BufferRecord
{
size_t length;
uint8_t data[DATA_LENGTH];
};
struct RingBuffer
{
size_t flags;
size_t delay;
size_t pointer;
struct BufferRecord records[BUFFER_LENGTH];
};
void PushData(struct RingBuffer* buffer, uint32_t number, uint8_t* data, size_t length);
void ProcessBuffer(struct RingBuffer* buffer, int handle, struct sockaddr_in* address);
#ifdef __cplusplus
}
#endif
#endif