1 // --------------------------------------------------------------------------
5 // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999
7 // --------------------------------------------------------------------------
12 #include <wx/stream.h>
17 #define wxSOUND_INFINITE_TIME ((unsigned long)-1)
23 class WXDLLEXPORT wxSoundRouterStream
: public wxSoundStreamCodec
{
25 wxSoundRouterStream(wxSoundStream
& sndio
);
26 ~wxSoundRouterStream();
28 wxSoundStream
& Read(void *buffer
, wxUint32 len
);
29 wxSoundStream
& Write(const void *buffer
, wxUint32 len
);
31 bool SetSoundFormat(const wxSoundFormatBase
& format
);
33 bool StartProduction(int evt
);
34 bool StopProduction();
37 wxSoundStream
*m_router
;
44 wxSOUND_FILE_RECORDING
48 // Base class for file coders/decoders
51 class wxSoundFileStream
: public wxSoundStream
{
53 wxSoundFileStream(wxInputStream
& stream
, wxSoundStream
& io_sound
);
54 wxSoundFileStream(wxOutputStream
& stream
, wxSoundStream
& io_sound
);
58 bool Record(unsigned long time
);
63 bool IsStopped() const { return m_state
== wxSOUND_FILE_STOPPED
; }
65 bool StartProduction(int evt
);
66 bool StopProduction();
68 unsigned long GetLength() const;
70 wxSoundStream
& Read(void *buffer
, wxUint32 len
);
71 wxSoundStream
& Write(const void *buffer
, wxUint32 len
);
73 void SetDuplexMode(bool duplex
);
75 bool SetSoundFormat(const wxSoundFormatBase
& format
);
77 virtual bool CanRead() { return TRUE
; }
80 wxSoundRouterStream m_codec
;
81 wxSoundStream
*m_sndio
;
82 wxInputStream
*m_input
;
83 wxOutputStream
*m_output
;
85 wxSoundFileState m_state
, m_oldstate
;
89 virtual bool PrepareToPlay() = 0;
90 virtual bool PrepareToRecord(unsigned long time
) = 0;
91 virtual bool FinishRecording() = 0;
93 virtual wxUint32
GetData(void *buffer
, wxUint32 len
) = 0;
94 virtual wxUint32
PutData(const void *buffer
, wxUint32 len
) = 0;
96 void OnSoundEvent(int evt
);