]> git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia2/lib/sndbase.cpp
Added utils/Makefile.in for utils makefiles
[wxWidgets.git] / utils / wxMMedia2 / lib / sndbase.cpp
1 // --------------------------------------------------------------------------
2 // Name: sndbase.cpp
3 // Purpose:
4 // Date: 08/11/1999
5 // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999
6 // CVSID: $Id$
7 // --------------------------------------------------------------------------
8 #ifdef __GNUG__
9 #pragma implementation "sndbase.cpp"
10 #endif
11
12 #include "sndbase.h"
13
14
15 // ---------------------------------------------------------------------------
16 // wxSoundFormatBase
17 // ---------------------------------------------------------------------------
18
19 wxSoundFormatBase::wxSoundFormatBase()
20 {
21 }
22
23 wxSoundFormatBase::~wxSoundFormatBase()
24 {
25 }
26
27 wxSoundFormatBase *wxSoundFormatBase::Clone() const
28 {
29 return NULL;
30 }
31
32 bool wxSoundFormatBase::operator!=(const wxSoundFormatBase& frmt2) const
33 {
34 return (GetType() != frmt2.GetType());
35 }
36
37 // ---------------------------------------------------------------------------
38 // wxSoundStream
39 // ---------------------------------------------------------------------------
40
41 wxSoundStream::wxSoundStream()
42 {
43 int i;
44
45 m_sndformat = NULL;
46 m_handler = NULL;
47 m_snderror = wxSOUND_NOERR;
48 m_lastcount = 0;
49 for (i=0;i<2;i++)
50 m_callback[i] = NULL;
51 }
52
53 wxSoundStream::~wxSoundStream()
54 {
55 if (m_sndformat)
56 delete m_sndformat;
57 }
58
59 // SetSoundFormat returns TRUE when the format can be handled.
60 bool wxSoundStream::SetSoundFormat(const wxSoundFormatBase& format)
61 {
62 if (m_sndformat)
63 delete m_sndformat;
64
65 m_sndformat = format.Clone();
66 return TRUE;
67 }
68
69 // Register a callback for a specified async event.
70 void wxSoundStream::Register(int evt, wxSoundCallback cbk, char *cdata)
71 {
72 int c;
73
74 switch (evt) {
75 case wxSOUND_INPUT:
76 c = 0;
77 break;
78 case wxSOUND_OUTPUT:
79 c = 1;
80 break;
81 default:
82 return;
83 }
84 m_callback[c] = cbk;
85 m_cdata[c] = cdata;
86 }
87
88 void wxSoundStream::OnSoundEvent(int evt)
89 {
90 int c;
91
92 if (m_handler) {
93 m_handler->OnSoundEvent(evt);
94 return;
95 }
96
97 switch (evt) {
98 case wxSOUND_INPUT:
99 c = 0;
100 break;
101 case wxSOUND_OUTPUT:
102 c = 1;
103 break;
104 default:
105 return;
106 }
107 if (m_callback[c])
108 m_callback[c](this, evt, m_cdata[c]);
109 }