]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/mmedia/sndbase.cpp
d0c96431da5eb27919e29103c34ea8a9dc756960
1 // --------------------------------------------------------------------------
5 // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999, 2000
7 // --------------------------------------------------------------------------
9 #pragma implementation "sndbase.cpp"
12 #include "wx/wxprec.h"
16 #include "wx/string.h"
20 #include "wx/mmedia/sndbase.h"
23 // ---------------------------------------------------------------------------
25 // ---------------------------------------------------------------------------
27 wxSoundFormatBase::wxSoundFormatBase()
31 wxSoundFormatBase::~wxSoundFormatBase()
35 wxSoundFormatBase
*wxSoundFormatBase::Clone() const
37 wxLogFatalError(wxT("In wxSoundFormatBase::Clone() but I should")
38 wxT(" not be there"));
42 bool wxSoundFormatBase::operator!=(const wxSoundFormatBase
& frmt2
) const
44 return (GetType() != frmt2
.GetType());
47 // ---------------------------------------------------------------------------
49 // ---------------------------------------------------------------------------
51 wxSoundStream::wxSoundStream()
55 // Reset all variables to their neutral value.
58 m_snderror
= wxSOUND_NOERROR
;
64 wxSoundStream::~wxSoundStream()
70 // --------------------------------------------------------------------------
71 // SetSoundFormat(const wxSoundFormatBase& format) is one of the most
72 // important function of the wxSoundStream class. It prepares the stream to
73 // receive or send the data in a strict format. Normally, the sound stream
74 // should be ready to accept any format it is asked to manage but in certain
75 // cases, it really cannot: in that case it returns false. To have more
76 // details in the functionnalities of SetSoundFormat see
77 // wxSoundRouterStream::SetSoundFormat()
78 // --------------------------------------------------------------------------
79 bool wxSoundStream::SetSoundFormat(const wxSoundFormatBase
& format
)
81 // delete the previous prepared format
85 // create a new one by cloning the format passed in parameter
86 m_sndformat
= format
.Clone();
91 // --------------------------------------------------------------------------
92 // Register(int evt, ...) registers the callback for a specified async event.
93 // Warning ! Only one callback by event is supported. It means that if you
94 // call twice this function the previous registered callback is absolutely
96 // --------------------------------------------------------------------------
97 void wxSoundStream::SetCallback(int evt
, wxSoundCallback cbk
, void *cdata
)
115 // --------------------------------------------------------------------------
116 // OnSoundEvent(int evt) is called either when the driver is ready to receive
117 // a new block to play or when the driver has a new recorded buffer. You
118 // must be careful here and try not to spend a lot of time: this is a
119 // real-time call. In the case, an "event handler" was specified previously,
120 // it called him before everything.
121 // --------------------------------------------------------------------------
122 void wxSoundStream::OnSoundEvent(int evt
)
127 m_handler
->OnSoundEvent(evt
);
142 m_callback
[c
](this, evt
, m_cdata
[c
]);