1 // /////////////////////////////////////////////////////////////////////////////
4 // Author: Guilhem Lavaux
7 // Copyright: (C) 1997, 1998, Guilhem Lavaux
8 // License: wxWindows license
9 // /////////////////////////////////////////////////////////////////////////////
10 #ifndef __SND_frag_H__
11 #define __SND_frag_H__
24 class wxFragmentBuffer
{
29 wxUint8 m_maxoq
, m_maxiq
;
41 // Local stream buffer for this fragment.
42 wxStreamBuffer
*sndbuf
;
43 // Data the driver would like to pass to the callback.
45 // Buffers included in this fragment.
47 // State of the fragment.
52 wxFragBufPtr
*m_optrs
, *m_iptrs
;
54 wxFragBufPtr
*m_lstoptrs
, *m_lstiptrs
;
56 bool m_buf2free
, m_dontq
, m_freeing
;
58 wxSoundDataFormat m_drvformat
;
60 wxFragmentBuffer(wxSound
& io_drv
);
61 virtual ~wxFragmentBuffer();
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;
68 void AbortBuffer(wxSndBuffer
*buf
);
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
);
77 // Called when a fragment is finished.
78 void OnBufferFinished(wxFragBufPtr
*ptr
);
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;
83 inline wxSndBuffer
*LastBuffer() {
84 wxNode
*node
= m_iodrv
->m_buffers
.Last();
86 if (!node
) return NULL
;
87 return (wxSndBuffer
*)node
->Data();
89 inline wxSndBuffer
*FirstBuffer() {
90 wxNode
*node
= m_iodrv
->m_buffers
.First();
92 if (!node
) return NULL
;
93 return (wxSndBuffer
*)node
->Data();
96 void FreeBufToFree(bool force
= FALSE
);
97 void ClearBuffer(wxFragBufPtr
*ptr
);