1 /* PROJECT:         ReactOS sndrec32
2  * LICENSE:         GPL - See COPYING in the top level directory
3  * FILE:            base/applications/sndrec32/audio_producer.hpp
4  * PURPOSE:         Audio producer
5  * PROGRAMMERS:     Marco Pagliaricci (irc: rendar)
6  */
7 
8 #ifndef _AUDIOAUDBUF__H_
9 #define _AUDIOAUDBUF__H_
10 
11 #include "audio_def.hpp"
12 
13 _AUDIO_NAMESPACE_START_
14 
15 class audio_producer
16 {
17     protected:
18         unsigned int bytes_played_;
19 
20     public:
21         /* Ctors */
22         audio_producer() : bytes_played_(0), play_finished(0)
23         {
24         }
25 
26         /* Dtor */
27         virtual ~audio_producer(void)
28         {
29         }
30 
31         /* Public Functions */
32 
33         /* reads N bytes from the buffer */
34         virtual unsigned int read(BYTE *, unsigned int) = 0;
35 
36         virtual bool finished(void) = 0;
37 
38         unsigned int bytes_played(void) const
39         {
40             return bytes_played_;
41         }
42 
43         void set_position(unsigned int pos)
44         {
45             bytes_played_ = pos;
46         }
47 
48         void set_position_start(void)
49         {
50             bytes_played_ = 0;
51         }
52 
53         void forward(unsigned int bytes)
54         {
55             bytes_played_ += bytes;
56         }
57 
58         void backward(unsigned int bytes)
59         {
60             bytes_played_ += bytes;
61         }
62 
63         void (* play_finished)(void);
64 };
65 
66 _AUDIO_NAMESPACE_END_
67 
68 #endif /* _AUDIOAUDBUF__H_ */
69