wvdbusserver: implement NameHasOwner request.
[wvstreams.git] / include / wvdsp.h
blob01b9d633075a261018ff7a4f7279cfac38d3a405
1 /* -*- Mode: C++ -*-
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.
7 */
8 #ifndef __WVDSP_H
9 #define __WVDSP_H
11 #include "wvmagiccircle.h"
12 #include "wvloopback.h"
13 #include "wvlog.h"
14 #include "wvrateadjust.h"
16 /**
17 * Class to access the /dev/dsp device in a way that's sane enough for
18 * full-duplex access.
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
26 public:
28 /**
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);
41 virtual ~WvDsp();
43 size_t ispace();
44 size_t ospace();
45 void realtime();
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;
54 virtual void close();
56 private:
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;
64 WvLog log;
65 WvMagicCircle rcircle, wcircle;
66 WvDynBuf rbuf, wbuf;
67 WvLoopback rloop, wloop;
68 WvRateAdjust inrate, outrate;
69 int fd;
70 bool is_realtime;
72 public:
73 const char *wstype() const { return "WvDsp"; }
77 #endif // __WVDSP_H