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();
36 wxUint32
GetBestSize() const;
39 wxSoundStream
*m_router
;
46 wxSOUND_FILE_RECORDING
50 // Base class for file coders/decoders
53 class wxSoundFileStream
: public wxSoundStream
{
55 wxSoundFileStream(wxInputStream
& stream
, wxSoundStream
& io_sound
);
56 wxSoundFileStream(wxOutputStream
& stream
, wxSoundStream
& io_sound
);
60 bool Record(unsigned long time
);
65 bool IsStopped() const { return m_state
== wxSOUND_FILE_STOPPED
; }
67 bool StartProduction(int evt
);
68 bool StopProduction();
70 unsigned long GetLength() const;
72 wxSoundStream
& Read(void *buffer
, wxUint32 len
);
73 wxSoundStream
& Write(const void *buffer
, wxUint32 len
);
75 void SetDuplexMode(bool duplex
);
77 bool SetSoundFormat(const wxSoundFormatBase
& format
);
79 virtual bool CanRead() { return FALSE
; }
82 wxSoundRouterStream m_codec
;
83 wxSoundStream
*m_sndio
;
84 wxInputStream
*m_input
;
85 wxOutputStream
*m_output
;
87 wxSoundFileState m_state
, m_oldstate
;
91 virtual bool PrepareToPlay() = 0;
92 virtual bool PrepareToRecord(unsigned long time
) = 0;
93 virtual bool FinishRecording() = 0;
95 virtual wxUint32
GetData(void *buffer
, wxUint32 len
) = 0;
96 virtual wxUint32
PutData(const void *buffer
, wxUint32 len
) = 0;
98 void OnSoundEvent(int evt
);