mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.7 KiB
C
81 lines
2.7 KiB
C
4 years ago
|
/**
|
||
6 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
6 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
6 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
6 years ago
|
*
|
||
|
*/
|
||
8 years ago
|
|
||
4 years ago
|
#ifndef SRSRAN_RINGBUFFER_H
|
||
|
#define SRSRAN_RINGBUFFER_H
|
||
8 years ago
|
|
||
4 years ago
|
#include "srsran/config.h"
|
||
8 years ago
|
#include <pthread.h>
|
||
7 years ago
|
#include <stdbool.h>
|
||
5 years ago
|
#include <stdint.h>
|
||
8 years ago
|
|
||
|
typedef struct {
|
||
5 years ago
|
uint8_t* buffer;
|
||
|
bool active;
|
||
6 years ago
|
int capacity;
|
||
|
int count;
|
||
|
int wpm;
|
||
|
int rpm;
|
||
|
pthread_mutex_t mutex;
|
||
5 years ago
|
pthread_cond_t write_cvar;
|
||
|
pthread_cond_t read_cvar;
|
||
4 years ago
|
} srsran_ringbuffer_t;
|
||
8 years ago
|
|
||
6 years ago
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
8 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_ringbuffer_init(srsran_ringbuffer_t* q, int capacity);
|
||
8 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_ringbuffer_free(srsran_ringbuffer_t* q);
|
||
7 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_ringbuffer_reset(srsran_ringbuffer_t* q);
|
||
8 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_ringbuffer_status(srsran_ringbuffer_t* q);
|
||
7 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_ringbuffer_space(srsran_ringbuffer_t* q);
|
||
7 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_ringbuffer_resize(srsran_ringbuffer_t* q, int capacity);
|
||
5 years ago
|
|
||
|
// write to the buffer immediately, if there isnt enough space it will overflow
|
||
4 years ago
|
SRSRAN_API int srsran_ringbuffer_write(srsran_ringbuffer_t* q, void* ptr, int nof_bytes);
|
||
8 years ago
|
|
||
5 years ago
|
// block forever until there is enough space then write to buffer
|
||
4 years ago
|
SRSRAN_API int srsran_ringbuffer_write_block(srsran_ringbuffer_t* q, void* ptr, int nof_bytes);
|
||
5 years ago
|
|
||
|
// block for timeout_ms milliseconds, then either write to buffer if there is space or return an error without writing
|
||
4 years ago
|
SRSRAN_API int srsran_ringbuffer_write_timed(srsran_ringbuffer_t* q, void* ptr, int nof_bytes, int32_t timeout_ms);
|
||
5 years ago
|
|
||
4 years ago
|
SRSRAN_API int
|
||
|
srsran_ringbuffer_write_timed_block(srsran_ringbuffer_t* q, void* ptr, int nof_bytes, int32_t timeout_ms);
|
||
5 years ago
|
|
||
|
// read from buffer, blocking until there is enough samples
|
||
4 years ago
|
SRSRAN_API int srsran_ringbuffer_read(srsran_ringbuffer_t* q, void* ptr, int nof_bytes);
|
||
8 years ago
|
|
||
5 years ago
|
// read from buffer, blocking for timeout_ms milliseconds until there is enough samples or return an error
|
||
4 years ago
|
SRSRAN_API int srsran_ringbuffer_read_timed(srsran_ringbuffer_t* q, void* p, int nof_bytes, int32_t timeout_ms);
|
||
5 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_ringbuffer_read_timed_block(srsran_ringbuffer_t* q, void* p, int nof_bytes, int32_t timeout_ms);
|
||
6 years ago
|
|
||
5 years ago
|
// read samples from the buffer, convert them from uint16_t to cplx float and get the conjugate
|
||
4 years ago
|
SRSRAN_API int srsran_ringbuffer_read_convert_conj(srsran_ringbuffer_t* q, cf_t* dst_ptr, float norm, int nof_samples);
|
||
6 years ago
|
|
||
4 years ago
|
SRSRAN_API int srsran_ringbuffer_read_block(srsran_ringbuffer_t* q, void** p, int nof_bytes, int32_t timeout_ms);
|
||
6 years ago
|
|
||
4 years ago
|
SRSRAN_API void srsran_ringbuffer_stop(srsran_ringbuffer_t* q);
|
||
8 years ago
|
|
||
6 years ago
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
4 years ago
|
#endif // SRSRAN_RINGBUFFER_H
|