1 // --------------------------------------------------------------------------
5 // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999
7 // --------------------------------------------------------------------------
12 #pragma interface "sndbase.h"
20 wxSOUND_DUPLEX
= wxSOUND_INPUT
| wxSOUND_OUTPUT
,
41 class WXDLLEXPORT wxSoundStream
;
43 typedef void (*wxSoundCallback
)(wxSoundStream
*stream
, int evt
,
47 // Base class for sound format specification
50 class WXDLLEXPORT wxSoundFormatBase
{
53 virtual ~wxSoundFormatBase();
55 virtual wxSoundFormatType
GetType() const { return wxSOUND_NOFORMAT
; }
56 virtual wxSoundFormatBase
*Clone() const;
58 virtual wxUint32
GetTimeFromBytes(wxUint32 bytes
) const = 0;
59 virtual wxUint32
GetBytesFromTime(wxUint32 time
) const = 0;
61 virtual bool operator !=(const wxSoundFormatBase
& frmt2
) const;
65 // Base class for sound streams
71 virtual ~wxSoundStream();
73 // Reads "len" bytes from the sound stream.
74 virtual wxSoundStream
& Read(void *buffer
, wxUint32 len
) = 0;
75 // Writes "len" byte to the sound stream.
76 virtual wxSoundStream
& Write(const void *buffer
, wxUint32 len
) = 0;
77 // Returns the best size for IO calls
78 virtual wxUint32
GetBestSize() const { return 1024; }
80 // SetSoundFormat returns TRUE when the format can be handled.
81 virtual bool SetSoundFormat(const wxSoundFormatBase
& format
);
83 // GetSoundFormat returns the current sound format.
84 wxSoundFormatBase
& GetSoundFormat() const { return *m_sndformat
; }
86 // Register a callback for a specified async event.
87 void Register(int evt
, wxSoundCallback cbk
, char *cdata
);
89 // Starts the async notifier.
90 virtual bool StartProduction(int evt
) = 0;
91 // Stops the async notifier.
92 virtual bool StopProduction() = 0;
93 // Sets the event handler: if it is non-null, all events are routed to it.
94 void SetEventHandler(wxSoundStream
*handler
) { m_handler
= handler
; }
96 // Initializes the full duplex mode.
97 virtual void SetDuplexMode(bool duplex
) = 0;
99 wxSoundError
GetError() const { return m_snderror
; }
100 wxUint32
GetLastAccess() const { return m_lastcount
; }
102 // This is only useful for device (I think).
103 virtual bool QueueFilled() const { return TRUE
; }
106 // Current sound format
107 wxSoundFormatBase
*m_sndformat
;
110 wxSoundError m_snderror
;
113 wxUint32 m_lastcount
;
116 wxSoundStream
*m_handler
;
118 wxSoundCallback m_callback
[2];
122 // Do the async stuff.
123 void DoAsyncStuff(int evt
);
126 virtual void OnSoundEvent(int evt
);