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 ...
}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...
} 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...
length -- 写入的长度*/uint32_t RingBuffer_WriteBuf(RingBuff_t* ringBuff,uint8_t *buf, uint32_t length){ uint32_t i=0;intwriteOffset;staticuint8_t temp=0;//断言CheckArguments(ringBuff, buf, length);//断言:判断接收的数据长度是否已经超过缓存数组中的剩余长度,如果是,返回断言 while(...
m_ringbuf.WriteBinary(buf, size); m_ripFile.Write( buf, size );//will only write, if it has toreturnSR_SUCCESS; } 开发者ID:Avoidnf8,项目名称:xbmc-fork,代码行数:12,代码来源:FileShoutcast.cpp 示例4: Init ▲点赞 0▼ boolCOrganyaCodec::Init(conststd::string& strFile,unsignedintfile...
视频中的分享的代码、C/C++后台开发 学习资料、教程视频、笔记 以及系统性学习课程咨询+ Q 群:973961276 上课地址:https://ke.qq.com/course/417774?flowToken=1031343 程序员的书单 科技 计算机技术 高性能 C/C++ 后台开发 c++ 编程开发 高并发 中间件 无锁列队 ...
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...
(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...