]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia2/sample/test_med.cpp
1 // --------------------------------------------------------------------------
5 // Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999
7 // --------------------------------------------------------------------------
9 #include <wx/wfstream.h>
11 #include "../lib/sndoss.h"
12 #include "../lib/sndwav.h"
13 #include "../lib/sndaiff.h"
14 #include "../lib/sndulaw.h"
16 wxSoundStreamOSS
*oss_dev
;
17 wxInputStream
*f_input
;
18 wxSoundStreamUlaw
*ulaw_codec
;
20 class MySoundStream
: public wxSoundStream
{
22 wxSoundStream
& Read(void *buffer
, size_t len
) { return *this; }
23 wxSoundStream
& Write(const void *buffer
, size_t len
) { return *this; }
25 bool StartProduction(int evt
) { return FALSE
; }
26 bool StopProduction() { return FALSE
; }
28 void SetDuplexMode(bool on
) {}
30 void OnSoundEvent(int evt
) {
33 f_input
->Read(buffer
, sizeof(buffer
));
34 ulaw_codec
->Write(buffer
, sizeof(buffer
));
38 class MyApp
: public wxApp
{
40 wxSoundFormatUlaw ulaw
;
43 oss_dev
= new wxSoundStreamOSS();
44 f_input
= new wxFileInputStream(argv
[1]);
46 if (oss_dev
->GetError() != wxSOUND_NOERR
) {
47 wxPrintf("No device\n");
51 ulaw
.SetSampleRate(8000);
52 ulaw_codec
= new wxSoundStreamUlaw(*oss_dev
);
53 ulaw_codec
->SetSoundFormat(ulaw
);
55 oss_dev
->SetEventHandler(&strm
);
56 oss_dev
->StartProduction(wxSOUND_OUTPUT
);