Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

wvdsp.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * One more attempt at making a decent stream for Linux /dev/dsp.  This is
00006  * apparently much trickier than it looks.
00007  */
00008 #ifndef __WVDSP_H
00009 #define __WVDSP_H
00010 
00011 #include "wvmagiccircle.h"
00012 #include "wvloopback.h"
00013 #include "wvlog.h"
00014 #include "wvrateadjust.h"
00015 
00016 /**
00017  * Class to access the /dev/dsp device in a way that's sane enough for
00018  * full-duplex access.
00019  * 
00020  * This is still rather heavily under construction at this time, so
00021  * please don't count on any side-effects to make anything
00022  * built with this class to work.
00023  */
00024 class WvDsp : public WvStream
00025 {
00026 public:
00027 
00028     /**
00029      * Construct a /dev/dsp accessor object
00030      * msec_latency = number of milliseconds of latency that are permissible
00031      * srate = sampling rate ( 44, 22, 11, or 8 Hz )
00032      * bits = bits per sample ( 8 or 16 )
00033      * stereo = should this be a stereo stream?
00034      * readable/writeable = should this stream be readable and/or writeable
00035      * realtime = should the stream give itself realtime priority (needs root)
00036      * oss = is this a real OSS driver (not ALSA's OSS emulation)?
00037      */
00038     WvDsp(int msec_latency, int srate, int bits, bool stereo,
00039           bool readable = true, bool writable = true,
00040           bool _realtime = false, bool _oss = false);
00041     virtual ~WvDsp();
00042 
00043     size_t ispace();
00044     size_t ospace();
00045     void realtime();
00046     
00047     /*** Overridden members ***/
00048     
00049     virtual bool pre_select(SelectInfo &si);
00050     virtual bool post_select(SelectInfo &si);
00051     virtual size_t uread(void *buf, size_t len);
00052     virtual size_t uwrite(const void *buf, size_t len);
00053     virtual bool isok() const;
00054     virtual void close();
00055 
00056 private:
00057     bool setioctl(int ctl, int param);
00058     void subproc(bool reading, bool writing);
00059 
00060     size_t do_uread(void *buf, size_t len);
00061     size_t do_uwrite(const void *buf, size_t len);
00062     
00063     size_t frag_size, num_frags;
00064     WvLog log;
00065     WvMagicCircle rcircle, wcircle;
00066     WvDynBuf rbuf, wbuf;
00067     WvLoopback rloop, wloop;
00068     WvRateAdjust inrate, outrate;
00069     int fd;
00070     bool is_realtime;
00071 };
00072 
00073 
00074 #endif // __WVDSP_H

Generated on Wed Dec 15 15:08:11 2004 for WvStreams by  doxygen 1.3.9.1