]> git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia/sndfrag.h
1. typos corrected in ftp/protocol/url (Members is no longer a hyperlink
[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 wxBUFFER_PLAYING
37 } BufState;
38 public:
39 ///
40 typedef struct {
41 // Local stream buffer for this fragment.
42 wxStreamBuffer *sndbuf;
43 // Data the driver would like to pass to the callback.
44 char *user_data;
45 // Buffers included in this fragment.
46 wxList *buffers;
47 // State of the fragment.
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 //
58 wxSoundDataFormat m_drvformat;
59 public:
60 wxFragmentBuffer(wxSound& io_drv);
61 virtual ~wxFragmentBuffer();
62
63 // These functions initializes the fragments. They must initialize
64 // m_lstoptrs, m_lstiptrs, m_maxoq, m_maxiq.
65 virtual void AllocIOBuffer() = 0;
66 virtual void FreeIOBuffer() = 0;
67
68 void AbortBuffer(wxSndBuffer *buf);
69
70 // Find a free (or partly free) fragment.
71 wxFragBufPtr *FindFreeBuffer(wxFragBufPtr *list, wxUint8 max_queue);
72 // Add this sound buffer to an "OUTPUT" fragment.
73 bool NotifyOutputBuffer(wxSndBuffer *buf);
74 // Add this sound buffer to an "INPUT" fragment.
75 bool NotifyInputBuffer(wxSndBuffer *buf);
76
77 // Called when a fragment is finished.
78 void OnBufferFinished(wxFragBufPtr *ptr);
79
80 // Called when a fragment is full and it should be flushed in the sound card.
81 virtual bool OnBufferFilled(wxFragBufPtr *ptr, wxSndMode mode) = 0;
82
83 inline wxSndBuffer *LastBuffer() {
84 wxNode *node = m_iodrv->m_buffers.Last();
85
86 if (!node) return NULL;
87 return (wxSndBuffer *)node->Data();
88 }
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