]>
Commit | Line | Data |
---|---|---|
4d6306eb GL |
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, | |
9fc0fe37 GL |
35 | wxBUFFER_TOFREE, |
36 | wxBUFFER_PLAYING | |
4d6306eb GL |
37 | } BufState; |
38 | public: | |
39 | /// | |
40 | typedef struct { | |
9fc0fe37 GL |
41 | // Local stream buffer for this fragment. |
42 | wxStreamBuffer *sndbuf; | |
43 | // Data the driver would like to pass to the callback. | |
4d6306eb | 44 | char *user_data; |
9fc0fe37 | 45 | // Buffers included in this fragment. |
4d6306eb | 46 | wxList *buffers; |
9fc0fe37 | 47 | // State of the fragment. |
4d6306eb GL |
48 | BufState state; |
49 | } wxFragBufPtr; | |
50 | protected: | |
9fc0fe37 | 51 | // |
4d6306eb | 52 | wxFragBufPtr *m_optrs, *m_iptrs; |
9fc0fe37 | 53 | // |
4d6306eb | 54 | wxFragBufPtr *m_lstoptrs, *m_lstiptrs; |
9fc0fe37 | 55 | // |
4d6306eb | 56 | bool m_buf2free, m_dontq, m_freeing; |
9fc0fe37 | 57 | // |
926c550d | 58 | wxSoundDataFormat m_drvformat; |
4d6306eb | 59 | public: |
4d6306eb | 60 | wxFragmentBuffer(wxSound& io_drv); |
4d6306eb GL |
61 | virtual ~wxFragmentBuffer(); |
62 | ||
9fc0fe37 GL |
63 | // These functions initializes the fragments. They must initialize |
64 | // m_lstoptrs, m_lstiptrs, m_maxoq, m_maxiq. | |
4d6306eb | 65 | virtual void AllocIOBuffer() = 0; |
4d6306eb GL |
66 | virtual void FreeIOBuffer() = 0; |
67 | ||
4d6306eb GL |
68 | void AbortBuffer(wxSndBuffer *buf); |
69 | ||
9fc0fe37 | 70 | // Find a free (or partly free) fragment. |
4d6306eb | 71 | wxFragBufPtr *FindFreeBuffer(wxFragBufPtr *list, wxUint8 max_queue); |
9fc0fe37 | 72 | // Add this sound buffer to an "OUTPUT" fragment. |
4d6306eb | 73 | bool NotifyOutputBuffer(wxSndBuffer *buf); |
9fc0fe37 | 74 | // Add this sound buffer to an "INPUT" fragment. |
4d6306eb GL |
75 | bool NotifyInputBuffer(wxSndBuffer *buf); |
76 | ||
9fc0fe37 | 77 | // Called when a fragment is finished. |
4d6306eb GL |
78 | void OnBufferFinished(wxFragBufPtr *ptr); |
79 | ||
9fc0fe37 | 80 | // Called when a fragment is full and it should be flushed in the sound card. |
4d6306eb GL |
81 | virtual bool OnBufferFilled(wxFragBufPtr *ptr, wxSndMode mode) = 0; |
82 | ||
4d6306eb GL |
83 | inline wxSndBuffer *LastBuffer() { |
84 | wxNode *node = m_iodrv->m_buffers.Last(); | |
85 | ||
86 | if (!node) return NULL; | |
87 | return (wxSndBuffer *)node->Data(); | |
88 | } | |
4d6306eb GL |
89 | inline wxSndBuffer *FirstBuffer() { |
90 | wxNode *node = m_iodrv->m_buffers.First(); | |
91 | ||
92 | if (!node) return NULL; | |
93 | return (wxSndBuffer *)node->Data(); | |
94 | } | |
95 | protected: | |
96 | void FreeBufToFree(bool force = FALSE); | |
97 | void ClearBuffer(wxFragBufPtr *ptr); | |
98 | }; | |
99 | ||
100 | #endif |