]>
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 #pragma implementation "sndbase.cpp"
13 #include "wx/wxprec.h"
17 #include "wx/string.h"
21 #include "wx/mmedia/sndbase.h"
24 // ---------------------------------------------------------------------------
26 // ---------------------------------------------------------------------------
28 wxSoundFormatBase::wxSoundFormatBase()
32 wxSoundFormatBase::~wxSoundFormatBase()
36 wxSoundFormatBase
*wxSoundFormatBase::Clone() const
38 wxLogFatalError(wxT("In wxSoundFormatBase::Clone() but I should")
39 wxT(" not be there"));
43 bool wxSoundFormatBase::operator!=(const wxSoundFormatBase
& frmt2
) const
45 return (GetType() != frmt2
.GetType());
48 // ---------------------------------------------------------------------------
50 // ---------------------------------------------------------------------------
52 wxSoundStream::wxSoundStream()
56 // Reset all variables to their neutral value.
59 m_snderror
= wxSOUND_NOERROR
;
65 wxSoundStream::~wxSoundStream()
71 // --------------------------------------------------------------------------
72 // SetSoundFormat(const wxSoundFormatBase& format) is one of the most
73 // important function of the wxSoundStream class. It prepares the stream to
74 // receive or send the data in a strict format. Normally, the sound stream
75 // should be ready to accept any format it is asked to manage but in certain
76 // cases, it really cannot: in that case it returns false. To have more
77 // details in the functionnalities of SetSoundFormat see
78 // wxSoundRouterStream::SetSoundFormat()
79 // --------------------------------------------------------------------------
80 bool wxSoundStream::SetSoundFormat(const wxSoundFormatBase
& format
)
82 // delete the previous prepared format
86 // create a new one by cloning the format passed in parameter
87 m_sndformat
= format
.Clone();
92 // --------------------------------------------------------------------------
93 // Register(int evt, ...) registers the callback for a specified async event.
94 // Warning ! Only one callback by event is supported. It means that if you
95 // call twice this function the previous registered callback is absolutely
97 // --------------------------------------------------------------------------
98 void wxSoundStream::SetCallback(int evt
, wxSoundCallback cbk
, void *cdata
)
116 // --------------------------------------------------------------------------
117 // OnSoundEvent(int evt) is called either when the driver is ready to receive
118 // a new block to play or when the driver has a new recorded buffer. You
119 // must be careful here and try not to spend a lot of time: this is a
120 // real-time call. In the case, an "event handler" was specified previously,
121 // it called him before everything.
122 // --------------------------------------------------------------------------
123 void wxSoundStream::OnSoundEvent(int evt
)
128 m_handler
->OnSoundEvent(evt
);
143 m_callback
[c
](this, evt
, m_cdata
[c
]);