sndoperation.h

来自「linux下用c++编写的录音放音程序」· C头文件 代码 · 共 45 行

H
45
字号
// SndOperation.h: interface for the CSndOperation class.
//
//////////////////////////////////////////////////////////////////////

#ifndef _SNDOPERATION_H_
#define _SNDOPERATION_H_

#include <sys/ioctl.h>
#include <linux/soundcard.h>
#include <unistd.h>

#define FMT8BITS AFMT_U8 /*unsigned 8 bits(for almost PC) */
#define FMT16BITS AFMT_S16_LE /*signed 16 bits,little endian */

#define DFT_SND_FMT  FMT16BITS
#define DFT_SND_SPD  FMT48K
#define DFT_SND_CHN  STEREO

#define TRUE  1
#define FALSE  0

#define FMT8K    8000 /*default sampling rate */
#define FMT11K   11025 /*11,22,44,48 are three pop rate */
#define FMT22K   22050
#define FMT44K   44100
#define FMT48K  48000

#define MONO     1
#define STEREO   2

class CSndOperation  
{
public:
	CSndOperation();
	virtual ~CSndOperation();
	bool OpenDev(unsigned int flag);
	bool CloseDev();
	bool SetFormat(unsigned int bits, unsigned int chn,unsigned int hz);
	int Record(char *buf, int size);
	int Play(char *buf, int size);

	unsigned int m_devfd;
};

#endif

⌨️ 快捷键说明

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