2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 * One more attempt at making a decent stream for Linux /dev/dsp. This is
6 * apparently much trickier than it looks.
11 #include "wvmagiccircle.h"
12 #include "wvloopback.h"
14 #include "wvrateadjust.h"
17 * Class to access the /dev/dsp device in a way that's sane enough for
20 * This is still rather heavily under construction at this time, so
21 * please don't count on any side-effects to make anything
22 * built with this class to work.
24 class WvDsp
: public WvStream
29 * Construct a /dev/dsp accessor object
30 * msec_latency = number of milliseconds of latency that are permissible
31 * srate = sampling rate ( 44, 22, 11, or 8 Hz )
32 * bits = bits per sample ( 8 or 16 )
33 * stereo = should this be a stereo stream?
34 * readable/writeable = should this stream be readable and/or writeable
35 * realtime = should the stream give itself realtime priority (needs root)
36 * oss = is this a real OSS driver (not ALSA's OSS emulation)?
38 WvDsp(int msec_latency
, int srate
, int bits
, bool stereo
,
39 bool readable
= true, bool writable
= true,
40 bool _realtime
= false, bool _oss
= false);
47 /*** Overridden members ***/
49 virtual void pre_select(SelectInfo
&si
);
50 virtual bool post_select(SelectInfo
&si
);
51 virtual size_t uread(void *buf
, size_t len
);
52 virtual size_t uwrite(const void *buf
, size_t len
);
53 virtual bool isok() const;
57 bool setioctl(int ctl
, int param
);
58 void subproc(bool reading
, bool writing
);
60 size_t do_uread(void *buf
, size_t len
);
61 size_t do_uwrite(const void *buf
, size_t len
);
63 size_t frag_size
, num_frags
;
65 WvMagicCircle rcircle
, wcircle
;
67 WvLoopback rloop
, wloop
;
68 WvRateAdjust inrate
, outrate
;
73 const char *wstype() const { return "WvDsp"; }