]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/mmedia/sndbase.cpp
1 // --------------------------------------------------------------------------
5 // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999, 2000
8 // --------------------------------------------------------------------------
10 #include "wx/wxprec.h"
14 #include "wx/string.h"
18 #include "wx/mmedia/sndbase.h"
21 // ---------------------------------------------------------------------------
23 // ---------------------------------------------------------------------------
25 wxSoundFormatBase::wxSoundFormatBase()
29 wxSoundFormatBase::~wxSoundFormatBase()
33 wxSoundFormatBase
*wxSoundFormatBase::Clone() const
35 wxLogFatalError(wxT("In wxSoundFormatBase::Clone() but I should")
36 wxT(" not be there"));
40 bool wxSoundFormatBase::operator!=(const wxSoundFormatBase
& frmt2
) const
42 return (GetType() != frmt2
.GetType());
45 // ---------------------------------------------------------------------------
47 // ---------------------------------------------------------------------------
49 wxSoundStream::wxSoundStream()
53 // Reset all variables to their neutral value.
56 m_snderror
= wxSOUND_NOERROR
;
62 wxSoundStream::~wxSoundStream()
68 // --------------------------------------------------------------------------
69 // SetSoundFormat(const wxSoundFormatBase& format) is one of the most
70 // important function of the wxSoundStream class. It prepares the stream to
71 // receive or send the data in a strict format. Normally, the sound stream
72 // should be ready to accept any format it is asked to manage but in certain
73 // cases, it really cannot: in that case it returns false. To have more
74 // details in the functionnalities of SetSoundFormat see
75 // wxSoundRouterStream::SetSoundFormat()
76 // --------------------------------------------------------------------------
77 bool wxSoundStream::SetSoundFormat(const wxSoundFormatBase
& format
)
79 // delete the previous prepared format
83 // create a new one by cloning the format passed in parameter
84 m_sndformat
= format
.Clone();
89 // --------------------------------------------------------------------------
90 // Register(int evt, ...) registers the callback for a specified async event.
91 // Warning ! Only one callback by event is supported. It means that if you
92 // call twice this function the previous registered callback is absolutely
94 // --------------------------------------------------------------------------
95 void wxSoundStream::SetCallback(int evt
, wxSoundCallback cbk
, void *cdata
)
113 // --------------------------------------------------------------------------
114 // OnSoundEvent(int evt) is called either when the driver is ready to receive
115 // a new block to play or when the driver has a new recorded buffer. You
116 // must be careful here and try not to spend a lot of time: this is a
117 // real-time call. In the case, an "event handler" was specified previously,
118 // it called him before everything.
119 // --------------------------------------------------------------------------
120 void wxSoundStream::OnSoundEvent(int evt
)
125 m_handler
->OnSoundEvent(evt
);
140 m_callback
[c
](this, evt
, m_cdata
[c
]);