]> git.saurik.com Git - wxWidgets.git/blame - contrib/include/wx/mmedia/sndbase.h
Tweaks to install guide
[wxWidgets.git] / contrib / include / wx / mmedia / sndbase.h
CommitLineData
e8482f24
GL
1// --------------------------------------------------------------------------
2// Name: sndbase.h
3// Purpose:
4// Date: 08/11/1999
5// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999
6// CVSID: $Id$
05aa8cf3 7// License: wxWindows license
e8482f24
GL
8// --------------------------------------------------------------------------
9#ifndef _WX_SNDBASE_H
10#define _WX_SNDBASE_H
11
12#ifdef __GNUG__
13#pragma interface "sndbase.h"
14#endif
15
16#include "wx/defs.h"
15e8daec 17#include "wx/mmedia/defs.h"
e8482f24
GL
18
19// ------------------------------------------------------------------------
20// DEFINITIONS
21
22// ---------------------
23// Sound streaming mode:
24// - wxSOUND_INPUT: simple recording mode
25// - wxSOUND_OUTPUT: simple playing mode
26// - wxSOUND_DUPLEX: full duplex record/play at the same time
27// ---------------------
28enum {
29 wxSOUND_INPUT = 1,
30 wxSOUND_OUTPUT = 2,
31 wxSOUND_DUPLEX = wxSOUND_INPUT | wxSOUND_OUTPUT,
32};
33
34// ---------------------
35// wxSoundFormatType: it specifies the format family of the sound data
36// which will be passed to the stream.
37// ---------------------
38typedef enum {
39 wxSOUND_NOFORMAT,
40 wxSOUND_PCM,
41 wxSOUND_ULAW,
42 wxSOUND_G72X,
43 wxSOUND_MSADPCM
44} wxSoundFormatType;
45
46// ---------------------
47// wxSoundError:
48// - wxSOUND_NOERR: No error occured
49// - wxSOUND_IOERR: an input/output error occured, it may concern either
50// a driver or a file
51// - wxSOUND_INVFRMT: the sound format passed to the function is invalid.
52// Generally, it means that you passed out of range values
53// to the codec stream or you don't pass the right sound
54// format object to the right sound codec stream.
55// - wxSOUND_INVDEV: Invalid device. Generally, it means that the sound stream
56// didn't manage to open the device driver due to an invalid// parameter or to the fact that sound is not supported on
57// this computer.
58// - wxSOUND_NOEXACT: No exact matching sound codec has been found for
59// this sound format. It means that the sound driver didn't
60// manage to setup the sound card with the specified
61// values.
62// - wxSOUND_NOCODEC: No matching codec has been found. Generally, it
63// may happen when you call
64// wxSoundRouterStream::SetSoundFormat().
65// - wxSOUND_MEMERR: Not enough memory.
66// - wxSOUND_NOTSTARTED: You did not start the production using
67// StartProduction()
68// ---------------------
69typedef enum {
70 wxSOUND_NOERROR,
71 wxSOUND_IOERROR,
72 wxSOUND_INVFRMT,
73 wxSOUND_INVDEV,
74 wxSOUND_NOEXACT,
75 wxSOUND_INVSTRM,
76 wxSOUND_NOCODEC,
77 wxSOUND_MEMERROR,
78 wxSOUND_NOTSTARTED
79} wxSoundError;
80
15e8daec 81class WXDLLIMPEXP_MMEDIA wxSoundStream;
e8482f24
GL
82
83// ---------------------
84// wxSoundCallback(stream, evt, cdata): C callback for sound event.
85// - stream: current wxSoundStream
86// - evt: the sound event which has occured, it may be wxSOUND_INPUT,
87// wxSOUND_OUTPUT or wxSOUND_DUPLEX
88// - cdata: User callback data
89// ---------------------
90typedef void (*wxSoundCallback)(wxSoundStream *stream, int evt,
91 void *cdata);
92
93//
94// Base class for sound format specification
95//
96
15e8daec 97class WXDLLIMPEXP_MMEDIA wxSoundFormatBase {
e8482f24
GL
98 public:
99 wxSoundFormatBase();
100 virtual ~wxSoundFormatBase();
101
102 // It returns a "standard" format type.
103 virtual wxSoundFormatType GetType() const { return wxSOUND_NOFORMAT; }
104 // It clones the current format.
105 virtual wxSoundFormatBase *Clone() const;
106
107 virtual wxUint32 GetTimeFromBytes(wxUint32 bytes) const = 0;
108 virtual wxUint32 GetBytesFromTime(wxUint32 time) const = 0;
109
110 virtual bool operator !=(const wxSoundFormatBase& frmt2) const;
111};
112
113//
114// Base class for sound streams
115//
116
15e8daec 117class WXDLLIMPEXP_MMEDIA wxSoundStream {
e8482f24
GL
118 public:
119 wxSoundStream();
120 virtual ~wxSoundStream();
121
122 // Reads "len" bytes from the sound stream.
123 virtual wxSoundStream& Read(void *buffer, wxUint32 len) = 0;
124 // Writes "len" byte to the sound stream.
125 virtual wxSoundStream& Write(const void *buffer, wxUint32 len) = 0;
126 // Returns the best size for IO calls
127 virtual wxUint32 GetBestSize() const { return 1024; }
128
dea7e44a 129 // SetSoundFormat returns true when the format can be handled.
e8482f24
GL
130 virtual bool SetSoundFormat(const wxSoundFormatBase& format);
131
132 // GetSoundFormat returns the current sound format.
133 wxSoundFormatBase& GetSoundFormat() const { return *m_sndformat; }
134
135 // Register a callback for a specified async event.
136 void SetCallback(int evt, wxSoundCallback cbk, void *cdata);
137
138 // Starts the async notifier. After this call, the stream begins either
139 // recording or playing or the two at the same time.
140 virtual bool StartProduction(int evt) = 0;
141 // Stops the async notifier.
142 virtual bool StopProduction() = 0;
143 // Sets the event handler: if it is non-null, all events are routed to it.
144 void SetEventHandler(wxSoundStream *handler) { m_handler = handler; }
145
146 wxSoundError GetError() const { return m_snderror; }
147 wxUint32 GetLastAccess() const { return m_lastcount; }
148
149 // This is only useful for device (I think).
dea7e44a 150 virtual bool QueueFilled() const { return true; }
e8482f24
GL
151
152 protected:
153 // Current sound format
154 wxSoundFormatBase *m_sndformat;
155
156 // Last error
157 wxSoundError m_snderror;
158
159 // Last access
160 wxUint32 m_lastcount;
161
162 // Event handler
163 wxSoundStream *m_handler;
164
165 wxSoundCallback m_callback[2];
166 void *m_cdata[2];
167
168 protected:
169 // Handles event
170 virtual void OnSoundEvent(int evt);
171};
172
173#endif