⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 streambuffer.h

📁 ARM嵌入式应用开发实例USB项目控制器的实现源代码
💻 H
字号:
#ifndef __STREAMBUFFER_H__
#define __STREAMBUFFER_H__

#define SYNCWORD				0xF0010000

#define	STREAMBUF_BLKSIZE		(4*1000)
#define	STREAMBUF_TOTAL_BLKS	256

#define	STREAMBUF_TOTAL_SIZE	(STREAMBUF_BLKSIZE*STREAMBUF_TOTAL_BLKS)

#define	MAX_FRAMES				1024

/*


			     Index (link table)

			  +---------+
pFirstIndex-->|	        |----+
			  |---------|	 |
			  |			|	 |
		      |---------|	 |
		      |    .	|	 |
		      |    .	|	 |
		      |    .	|	 |
		      |---------|	 |
pLastIndex -->|	        |----+------------+
		      +---------+	 |			  |
		      			     |			  |     Tail
		                     |			  |		  |
						     V			  v		  v
			   				 +-+-+-+-+-+-+-+-+----------------------------+
			  pBuf (cycle)   | | | | | | | | |          ......  	      |
							 +-+-+-+-+-+-+-+-+----------------------------+
				  

*/

typedef struct tagINDEX_ITEM
{
	int Head;
	struct tagINDEX_ITEM *pNextIndex;
} INDEX_ITEM, *PINDEX_ITEM;

typedef struct frame_info_t
{
	int		offset;
	int		len;
} FRAMEINFO, *PFRAMEINFO;

typedef struct tagSTREAM_BUFFER
{
	char			cachename[64];

	/* Buffer pool */
	kmem_cache_t	*bufblk_cache;
	unsigned char	*bufblk_pool[STREAMBUF_TOTAL_BLKS];

	int				bufblk_ready;

	/* Frame informantion table */
	FRAMEINFO		finfo_pool[MAX_FRAMES];

	int				finfo_head;
	int				finfo_tail;

	int				buf_head;
	int				buf_tail;

	int				least_freespace;

	/* Obsolete item */
#if 0
	unsigned char	*pBuf;
	PINDEX_ITEM pFirstIndex;
	PINDEX_ITEM pLastIndex;	

	int Tail;
	int LastFrameHead;	// for re-get
	int LastFrameTail;	// for re-get
#endif

	spinlock_t spinlock; 
	struct	semaphore	mutex;
	unsigned long lock_flags;

//	HANDLE DumpFileHandle;
} STREAM_BUFFER, *PSTREAM_BUFFER;

#ifdef __cplusplus
extern "C" {
#endif

int  StreamBuffer_Init(PSTREAM_BUFFER psb);
void StreamBuffer_Uninit(PSTREAM_BUFFER psb);

int  StreamBuffer_Reset(PSTREAM_BUFFER psb);

int  StreamBuffer_AddBlock(PSTREAM_BUFFER psb, unsigned char *pBlock, int Size);
int  StreamBuffer_GetFrame(PSTREAM_BUFFER psb, unsigned char *pDstBuf,int *DstBufLen);

#ifdef __cplusplus
};
#endif

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -