}intring_buffer_out(RING_BUFFER_Typedef *ring,char*c){if(ring->cnt>0) {if(ring->out>=ring->size) ring->out=0; *c = ring->buffer[ring->out]; ring->out++; ring->cnt--;return0; }return-1; }intmain(){ RING_BUFFER_Typedef ring;chari =0;charc; ring_buffer_init(&ring, bu...
bool circular_buf_empty(cbuf_handle_t cbuf); /// Returns true if the buffer is full bool circular_buf_full(cbuf_handle_t cbuf); /// Returns the maximum capacity of the buffer size_t circular_buf_capacity(cbuf_handle_t cbuf); /// Returns the current number of elements in the buffer ...
} ring_buffer; void ring_buffer_init(ring_buffer* rb, uint8_t* buf, unsigned int size) { rb->buffer = buf; rb->head = buf; rb->tail = buf; rb->size = size; rb->full = false; } bool ring_buffer_is_empty(const ring_buffer* rb) { return (rb->head == rb->t...
error_codefilelib_write_show(char*buf, u_long size){if((int)size > m_ringbuf.Size()) { CLog::Log(LOGERROR,"Shoutcast chunk too big: %lu", size);returnSR_ERROR_BUFFER_FULL; }while(m_ringbuf.GetMaxWriteSize() < (int)size) Sleep(10); m_ringbuf.WriteBinary(buf, size); m_rip...
void* write_data_task(void* args) //线程1 往循环buffer中写数据{ FILE *fp = fopen('../src.dat', 'rb'); if(!fp){ printf('open src.dat error!\n'); is_runing=0; return NULL; } uint8_t buf[1024]={0}; ringbuffer_t *rb = (ringbuffer_t*)args; //获取传入进来的循环buffe...
视频中的分享的代码、C/C++后台开发 学习资料、教程视频、笔记 以及系统性学习课程咨询+ Q 群:973961276 上课地址:https://ke.qq.com/course/417774?flowToken=1031343 程序员的书单 科技 计算机技术 高性能 C/C++ 后台开发 c++ 编程开发 高并发 中间件 无锁列队 ...
int32_t RingBuffer_ReadByte(RingBuff_t*ringBuff);//-1 0~255 //写入一个字节int32_t RingBuffer_WriteByte(RingBuff_t *ringBuff,uint8_tbyte); //伪读取,因为真的读取的话,会清空读取到的缓存的. 这里是读取到后依然不清除缓存 uint32_t RingBuffer_PseudoReadBuf(RingBuff_t*ringBuff,uin...
(validlen+length>RINGBUFSIZE){movelen=validlen+length-RINGBUFSIZE;if(pValid+movelen>pTail){len1=pTail-pValid;len2=movelen-len1;pValid=pHead+len2;}else{pValid+=movelen;}validlen=RINGBUFSIZE;}else{validlen+=length;}return0;}/***//***功能:从缓冲区读取指定长度的数据 ***//***pa...
清空ringBuffer 函数 代码语言:javascript 复制 voidclear_ringBuffer(ringbuffer_t*ringBuf){ringBuf->br=0;ringBuf->bw=0;ringBuf->btoRead=0;//no need do this casue r_ptr and w_prt has change// memset((uint8_t *)ringBuf->source, 0, ringBuf->length);} ...
This distribution includes source for a test program executable (ringbuf-test.c), which runs extensive unit tests on thec-ringbufimplementation. On most platforms (other than Windows, which is not supported), you should be able to typemaketo run the unit tests. Note that theMakefileuses the...