]> git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia/sndfrag.h
8acb31f9cf4a34548b71b49a5a13e9bae6f97b04
[wxWidgets.git] / utils / wxMMedia / sndfrag.h
1 // /////////////////////////////////////////////////////////////////////////////
2 // Name: sndfrag.h
3 // Purpose: wxMMedia
4 // Author: Guilhem Lavaux
5 // Created: 1997
6 // Updated: 1998
7 // Copyright: (C) 1997, 1998, Guilhem Lavaux
8 // License: wxWindows license
9 // /////////////////////////////////////////////////////////////////////////////
10 #ifndef __SND_frag_H__
11 #define __SND_frag_H__
12 #ifdef __GNUG__
13 #pragma interface
14 #endif
15
16 #ifdef WX_PRECOMP
17 #include "wx_prec.h"
18 #else
19 #include "wx/wx.h"
20 #endif
21 #include "sndsnd.h"
22
23 ///
24 class wxFragmentBuffer {
25 protected:
26 wxSound *m_iodrv;
27
28 ///
29 wxUint8 m_maxoq, m_maxiq;
30
31 ///
32 typedef enum {
33 wxBUFFER_FREE,
34 wxBUFFER_FFILLED,
35 wxBUFFER_TOFREE
36 } BufState;
37 public:
38 ///
39 typedef struct {
40 char *data;
41 ///
42 char *user_data;
43 ///
44 wxUint32 size, ptr;
45 ///
46 wxList *buffers;
47 ///
48 BufState state;
49 } wxFragBufPtr;
50 protected:
51 ///
52 wxFragBufPtr *m_optrs, *m_iptrs;
53 ///
54 wxFragBufPtr *m_lstoptrs, *m_lstiptrs;
55 ///
56 bool m_buf2free, m_dontq, m_freeing;
57 public:
58 ///
59 wxFragmentBuffer(wxSound& io_drv);
60 ///
61 virtual ~wxFragmentBuffer();
62
63 ///
64 virtual void AllocIOBuffer() = 0;
65 ///
66 virtual void FreeIOBuffer() = 0;
67
68 ///
69 void AbortBuffer(wxSndBuffer *buf);
70
71 ///
72 wxFragBufPtr *FindFreeBuffer(wxFragBufPtr *list, wxUint8 max_queue);
73 ///
74 bool NotifyOutputBuffer(wxSndBuffer *buf);
75 ///
76 bool NotifyInputBuffer(wxSndBuffer *buf);
77
78 ///
79 void OnBufferFinished(wxFragBufPtr *ptr);
80
81 ///
82 virtual bool OnBufferFilled(wxFragBufPtr *ptr, wxSndMode mode) = 0;
83
84 ///
85 inline wxSndBuffer *LastBuffer() {
86 wxNode *node = m_iodrv->m_buffers.Last();
87
88 if (!node) return NULL;
89 return (wxSndBuffer *)node->Data();
90 }
91 ///
92 inline wxSndBuffer *FirstBuffer() {
93 wxNode *node = m_iodrv->m_buffers.First();
94
95 if (!node) return NULL;
96 return (wxSndBuffer *)node->Data();
97 }
98 protected:
99 void FreeBufToFree(bool force = FALSE);
100 void ClearBuffer(wxFragBufPtr *ptr);
101 };
102
103 #endif