1 // --------------------------------------------------------------------------
5 // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999
7 // --------------------------------------------------------------------------
12 #pragma interface "sndbase.h"
20 wxSOUND_DUPLEX
= wxSOUND_INPUT
| wxSOUND_OUTPUT
,
40 class WXDLLEXPORT wxSoundStream
;
42 typedef void (*wxSoundCallback
)(wxSoundStream
*stream
, int evt
,
46 // Base class for sound format specification
49 class WXDLLEXPORT wxSoundFormatBase
{
52 virtual ~wxSoundFormatBase();
54 virtual wxSoundFormatType
GetType() const { return wxSOUND_NOFORMAT
; }
55 virtual wxSoundFormatBase
*Clone() const;
57 virtual wxUint32
GetTimeFromByte(wxUint32 bytes
) const = 0;
58 virtual wxUint32
GetByteFromTime(wxUint32 time
) const = 0;
60 virtual bool operator !=(const wxSoundFormatBase
& frmt2
) const;
64 // Base class for sound streams
70 virtual ~wxSoundStream();
72 // Reads "len" bytes from the sound stream.
73 virtual wxSoundStream
& Read(void *buffer
, size_t len
) = 0;
74 // Writes "len" byte to the sound stream.
75 virtual wxSoundStream
& Write(const void *buffer
, size_t len
) = 0;
76 // Returns the best size for IO calls
77 virtual wxUint32
GetBestSize() const { return 1024; }
79 // SetSoundFormat returns TRUE when the format can be handled.
80 virtual bool SetSoundFormat(const wxSoundFormatBase
& format
);
82 // GetSoundFormat returns the current sound format.
83 wxSoundFormatBase
& GetSoundFormat() const { return *m_sndformat
; }
85 // Register a callback for a specified async event.
86 void Register(int evt
, wxSoundCallback cbk
, char *cdata
);
88 // Starts the async notifier.
89 virtual bool StartProduction(int evt
) = 0;
90 // Stops the async notifier.
91 virtual bool StopProduction() = 0;
92 // Sets the event handler: if it is non-null, all events are routed to it.
93 void SetEventHandler(wxSoundStream
*handler
) { m_handler
= handler
; }
95 // Initializes the full duplex mode.
96 virtual void SetDuplexMode(bool duplex
) = 0;
98 wxSoundError
GetError() const { return m_snderror
; }
99 size_t GetLastAccess() const { return m_lastcount
; }
102 // Current sound format
103 wxSoundFormatBase
*m_sndformat
;
106 wxSoundError m_snderror
;
112 wxSoundStream
*m_handler
;
114 wxSoundCallback m_callback
[2];
118 // Do the async stuff.
119 void DoAsyncStuff(int evt
);
122 virtual void OnSoundEvent(int evt
);