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