AudioRenderer.h
上传用户:lusi_8715
上传日期:2007-01-08
资源大小:199k
文件大小:2k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

Visual C++

  1. /**************************************************************************************
  2.  *                                                                                    *
  3.  * This application contains code from OpenDivX and is released as a "Larger Work"    *
  4.  * under that license. Consistant with that license, this application is released     *
  5.  * under the GNU General Public License.                                              *
  6.  *                                                                                    *
  7.  * The OpenDivX license can be found at: http://www.projectmayo.com/opendivx/docs.php *
  8.  * The GPL can be found at: http://www.gnu.org/copyleft/gpl.html                      *
  9.  *                                                                                    *
  10.  * Copyright (c) 2001 - Project Mayo                                                  *
  11.  *                                                                                    *
  12.  * Authors: Damien Chavarria <adrc at projectmayo.com>                                *
  13.  *                                                                                    *
  14.  **************************************************************************************/
  15. #ifndef AUDIO_RENDERER_H
  16. #define AUDIO_RENDERER_H
  17. #include <dsound.h>
  18. #include <windows.h>
  19. #include <stdio.h>
  20. #include <math.h>
  21. /*
  22.  * Audio Callback Type
  23.  *
  24.  */
  25. typedef void (*AudioCallback)(void *lpData, void *buffer, unsigned int size);
  26. /*
  27.  * Audio Renderer Class
  28.  */
  29. class AudioRenderer {
  30. public:
  31. LPDIRECTSOUND       lpDirectSound;
  32. LPDIRECTSOUNDBUFFER lpBuffer;
  33. WAVEFORMATEX       *ourFormat;
  34.     DWORD               dwBufferSize;     
  35.     DWORD               dwNextWriteOffset; 
  36.     DWORD               dwProgress;
  37. unsigned long       dwPlayed;
  38. DWORD               dwLastPlayPos;
  39. HANDLE              audioThread;
  40. UINT                uTimerID;
  41. LONG                lInTimer;
  42. DWORD               id;
  43. AudioCallback       callback;
  44. void               *lpData;
  45. int                 paused;
  46. AudioRenderer(WAVEFORMATEX *inFormat, HWND hwnd);
  47. ~AudioRenderer();
  48. int SetCallback(void *lpData, AudioCallback callback);
  49. int SetVolume(int volume);
  50. unsigned long AudioTime();
  51. int Bufferize();
  52. int Start();
  53. int Pause();
  54. int Stop();
  55. int Close();
  56. };
  57. #endif