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

📄 basic_mai.hh

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 HH
字号:
////#ifndef BASIC_MAI_MM#define BASIC_MAI_MM#include "mai_component.h"/** @file   basic_mai.hh    @author Darrell Stam    @date   Thur Feb 24 12:57:03 2005    @brief  MAI  buffer abstraction layer. *//** @brief MAI  interface via stream buffers.     This module of classes defines an abstraction layer over    the MAI framework. */namespace MAI{  /** @class basic_mai basic.mai.hh <MAI/basic_mai.hh>      @brief MAI  buffer abstraction layer.       @param Char_Type the character type to use  @c char       @param Traits The character traits to use.  Per default this is      std::char_traits <tt>&lt;Char_Type&gt;</tt>      @ingroup MAIMM  */  template <typename Char_Type, typename Traits=std::char_traits<Char_Type> >  class basic_mai   {  public:    /// The type of the buffers     typedef Char_Type char_type;    /// The type of the traits     typedef Traits traits_type;    /// Integer type    typedef typename traits_type::int_type  int_type;    /// The position type     typedef typename traits_type::pos_type  pos_type;    /// The offset type     typedef typename traits_type::off_type  off_type;    /// Pointer to MAI abstraction layer.   MAICompBufferPool_t _handle;    /// Did we create the handle?     bool _created;    unsigned int numBytesRead;    /** write a character to output. 	@param c The character to write. 	@return EOF on failure or @p c on success. */    int_type overflow(int_type c=EOF);    /** Read the pending character from the stream and put it back. 	@return the next pending input. */    int_type underflow();    /** Read the pending character from the stream. 	@return the next pending input. */    int_type uflow();    /** Put back one character to the input stream. 	@param c the character to put back. 	@return EOF on failure, otherwise @p c */    int_type pbackfail(int_type c=EOF);    /** Read a block of characters from the file. 	@param buf Buffer to read into. 	@param n Size of the buffer to fill. 	@return # of characters read. */    std::streamsize xsgetn(char_type* buf, std::streamsize n);    /** Put back a block of characters to the MAI stream. 	@param buf Buffer to read from. 	@param n Size of the buffer to write out. 	@return # of characters writen. */    std::streamsize xsputn(char_type* buf, std::streamsize n);    /** Syncronise the stream. 	@return EOF on error. */    int sync();    /** Seek to an offset in the buffer in the stream. 	@param pos The position to seek to. 	@param dir The direction to seek in. 	@param mode The open mode. 	@return new offset in the file. */    pos_type seekoff(off_type pos, 		     std::ios::seekdir dir,		     std::ios::openmode mode=std::ios::in|std::ios::out);    /** Seek to a position in the stream. 	@param pos The position to seek to. 	@param mode The open mode. 	@return new offset in the stream. */    pos_type seekpos(pos_type pos, 		     std::ios::openmode mode=std::ios::in|std::ios::out);    /** Default constructor. */    basic_mai();    /** Construct from MAI  pointer (not standard). 	@param handle MAI Buffer Pool  pointer. */    basic_mai(MAICompBufferPool_t handle);    /** Destructor. */    virtual ~basic_mai();    /** open a MAI stream. 	@param name the stream  to open. 	@param mode What mode to open in. 	@return A pointer to this if succesful, otherwise 0. */    basic_mai* open(const char* name, std::ios_base::openmode mode);    /** Close the stream.	@return A pointer to this if succesful, otherwise 0. */    basic_mai* close();    /** Test if stream  is open. 	@return true if stream is open, otherwise false. */        bool is_open() const { return _handle != 0; }    /** Conversion operator. */    operator MAICompBufferPool_t () { return _handle; }  };#ifdef __GLOBAL_MAI_NAMESPACE_  //__________________________________________________________________  basic_mai<char>::int_type  basic_mai<char>::overflow(basic_mai::int_type c)   {      printf("Basic_MAI - overflow\n");      return c;  }  //__________________________________________________________________  basic_mai<char>::int_type  basic_mai<char>::underflow()   {    MAICompBuffer_t *pBuf=NULL;    MAICompBufferPoolPeek(_handle,&pBuf,MAI_TIMEOUT_INFINITE);    if( !pBuf )         return EOF;    return 0;  }  //__________________________________________________________________  basic_mai<char>::int_type  basic_mai<char>::uflow()   {     MAIStatus_e eStatus;    // Read one byte of data    MAICompBuffer_t BufferInfo;    unsigned char x;    BufferInfo.pBuffer=&x;    BufferInfo.uiBufSize = 1;    eStatus = MAICompBufferPoolRead(_handle,&BufferInfo, MAI_TIMEOUT_INFINITE);    if(eStatus != MAI_STATUS_OK)    {//      printf("Returning EOF status is %x\n",eStatus);        return EOF;    }    numBytesRead +=BufferInfo.uiDataSize;    return x;  }  //__________________________________________________________________  basic_mai<char>::int_type  basic_mai<char>::pbackfail(basic_mai::int_type c)   {      return c;  }  //__________________________________________________________________  template <typename Char_Type, typename Traits>  int  basic_mai<Char_Type, Traits>::sync()   {      return 0;  }  //__________________________________________________________________  template <typename Char_Type, typename Traits>  std::streamsize   basic_mai<Char_Type, Traits>::xsgetn(basic_mai::char_type* buf, 					std::streamsize n)   {    // Read one byte of data                                                        MAICompBuffer_t BufferInfo;                           BufferInfo.pBuffer = (unsigned char *)buf;    BufferInfo.uiBufSize = n;    MAICompBufferPoolRead(_handle,&BufferInfo, MAI_TIMEOUT_INFINITE);    numBytesRead += BufferInfo.uiDataSize;    return BufferInfo.uiDataSize;  }  //__________________________________________________________________  template <typename Char_Type, typename Traits>  std::streamsize   basic_mai<Char_Type, Traits>::xsputn(basic_mai::char_type* buf, 					std::streamsize n)   {    return 0;  }  //__________________________________________________________________  template <typename Char_Type, typename Traits>  typename basic_mai<Char_Type, Traits>::pos_type  basic_mai<Char_Type, Traits>::seekoff(basic_mai<Char_Type, Traits>::off_type off, 					 std::ios::seekdir dir, 					 std::ios::openmode)  {    return numBytesRead; // position in stream  }  //__________________________________________________________________  template <typename Char_Type, typename Traits>  typename basic_mai<Char_Type, Traits>::pos_type  basic_mai<Char_Type, Traits>::seekpos(basic_mai<Char_Type, Traits>::pos_type pos, 					 std::ios::openmode)   {    return 0;  }    //__________________________________________________________________  template <typename Char_Type, typename Traits>  basic_mai<Char_Type, Traits>::basic_mai()    : _handle(NULL), _created(false), numBytesRead(0)  {  }  //__________________________________________________________________  template <typename Char_Type, typename Traits>  basic_mai<Char_Type, Traits>::basic_mai(MAICompBufferPool_t handle)    : _handle(handle), _created(true), numBytesRead(0)  {   }  //__________________________________________________________________  template <typename Char_Type, typename Traits>  basic_mai<Char_Type, Traits>::~basic_mai()  {    if (!is_open())      return;  }  //__________________________________________________________________  template <typename Char_Type, typename Traits>  basic_mai<Char_Type, Traits>*   basic_mai<Char_Type, Traits>::open(const char* name,				      std::ios_base::openmode mode)   {    if (is_open()) return 0;    _created = true;     return this;   }  //__________________________________________________________________  template <typename Char_Type, typename Traits>  basic_mai<Char_Type, Traits>*   basic_mai<Char_Type, Traits>::close()   {    if (!_created)      return 0;    _created=false;    return this;  }}#undef __GLOBAL_MAI_NAMESPACE_#endif // __GLOBAL_MAI_NAMESPACE_#endif//____________________________________________________________________//// EOF//

⌨️ 快捷键说明

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