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

📄 isolistener.h

📁 VHPD1394 V1.15驅動程序源碼
💻 H
字号:
/************************************************************************
 *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 *  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
 *  PURPOSE.
 ************************************************************************/

/************************************************************************
 *
 *  Module:       IsoListener.h
 *  Long name:    Isochronous Listener class definition
 *  Description:  Class that handles data reception over an 
 *                isochronous channel.
 *                Optionally, data may be written to a file.
 *
 *  Runtime Env.: Win32
 *  Author(s):    Frank Senf
 *  Company:      Thesycon GmbH, Ilmenau
 ************************************************************************/

#if !defined(_IsoListener_h_)
#define _IsoListener_h_


// get base class definition
#include "CVhpdIsoListener.h"


//
// CIsoListener class
// The class is derived from the CVhpdIsoListener class contained in the
// VHPDLib C++ class library.
// Thus, it has an embeded worker thread that handles data reception.
// The class mainly implements the PreProcessBuffer and PostProcessBuffer
// functions defined by the base class.
//
class CIsoListener : public CVhpdIsoListener {

public:
  // Construction
  CIsoListener();
  // destructor
  ~CIsoListener();

  // ----------------
  // interface

  // destination file handling
  // opens the specified file
  // returns 0 for success, 1 if a file was already opened or an specific
  // error code if opening the file failed
  unsigned long
  OpenFile(const char* Filename);
  // closes the output file, no-op if no file is currently opened
  void
  CloseFile();

  // return current number of buffers completed with error
  unsigned long
  GetErrorCount() { return m_BufferError; }

  // return status code of last buffer completed with error
  unsigned long
  GetLastError() { return m_LastError; }

  // returns true if the thread is about to terminate
  bool
  ThreadExited() { return m_ThreadExited; }

  // ----------------
  // CVhpdThread overloaded functions

  // function is called before the worker thread terminates itself
  // NOTE: It is called in the context of the worker thread.
  virtual
  void
  OnThreadExit();

  // overloaded CVhpdThread::TerminateThread() function
  // NOTE 1: called in the context of the main thread
  // NOTE 2: TerminateThread() is overloaded to ensure that the
  // thread will exit. This is done by trying to terminate the
  // thread until it really terminates. For future version of VHPDLib
  // this will be implemented by the base class
  virtual
  void 
  TerminateThread();


// implementation
protected:

  // ----------------
  // CVhpdIsoListener overloaded functions

  // function is called with each buffer before it is submitted to the driver
  // may be used to initialize the buffer and to set special parameters within
  // the associated VHPD_ISOCH_SUBMIT_BUFFER structure
  virtual
  void
  PreProcessBuffer(
    CVhpdBuf* Buf,
    VHPD_ISOCH_SUBMIT_BUFFER* Submit);

  // function is called after a buffer is completed by the driver
  // returns FALSE if buffer processing should be stopped, TRUE to continue
  // function is called with every buffer, even if it was completed with error
  virtual
  BOOL
  PostProcessBuffer(
    CVhpdBuf* Buf,
    VHPD_ISOCH_SUBMIT_BUFFER* Submit);

  // --------------
  // member variables

  // output file, NULL if not valid
  HANDLE m_File;

  // flag is set to true if OnThreadExit is called
  bool m_ThreadExited;

  // error handling
  // counter increases every time a buffer is completed with an error status
  unsigned long m_BufferError;
  // last error received from the Buf->mStatus member, only valid if
  // m_BufferError != 0
  unsigned long m_LastError;

}; // class CIsoListener


#endif // !defined(_IsoListener_h_)

/*************************** EOF **************************************/

⌨️ 快捷键说明

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