vfs: check userland buffers before reading them.
[haiku.git] / src / apps / cortex / addons / common / IAudioOp.h
bloba699e6dbf844a135585a23a141b2ff479debe78e
1 /*
2 * Copyright (c) 1999-2000, Eric Moon.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions, and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // IAudioOp.h
33 // * PURPOSE
34 // Abstract audio-operation interface. Each implementation
35 // of IAudioOp represents an algorithm for processing
36 // streaming media.
38 // IAudioOp instances are returned by implementations of
39 // IAudioOpFactory, responsible for finding the
40 // appropriate algorithm for a given format combination.
42 // * NOTES
43 // 7sep99:
44 // +++++ moving back towards a raw interface approach; the host node
45 // can provide the state/parameter/event-queue access.
46 // See IAudioOpHost for the operations that the host node needs
47 // to provide.
49 // * HISTORY
50 // e.moon 26aug99 Begun
52 #ifndef __IAudioOp_H__
53 #define __IAudioOp_H__
55 #include "AudioBuffer.h"
57 class IAudioOpHost;
58 class ParameterSet;
60 class IAudioOp {
62 public: // *** HOST (NODE)
63 IAudioOpHost* const host;
65 public: // *** ctor/dtor
66 IAudioOp(
67 IAudioOpHost* _host) : host(_host) {}
69 virtual ~IAudioOp() {}
71 public: // *** REQUIRED INTERFACE
73 // Process a given source buffer to produce framesRequired
74 // frames of output (this may differ from the number of frames
75 // read from input if this is a resampling operation,
76 // or if the operation requires some amount of 'lookahead'.)
77 // The time at which the first destination frame should reach
78 // its destination is given by performanceTime (this should help
79 // wrt/ accurate parameter-change response.)
81 // Return the number of frames produced (if insufficient source
82 // frames were available, this may be less than framesRequired;
83 // it must never be greater.)
84 // NOTE
85 // If the formats are identical, source and destination
86 // may reference the same buffer.
88 // ANOTHER NOTE
89 // This method may well be called multiple times in response to
90 // a single call to the functor method (operator()) if one or
91 // more events occur midway through the buffer.
93 virtual uint32 process(
94 const AudioBuffer& source,
95 AudioBuffer& destination,
96 double& sourceFrame,
97 uint32& destinationFrame,
98 uint32 framesRequired,
99 bigtime_t performanceTime) =0;
101 // Replace the given filter operation (responsibility for deleting
102 // it is yours, in case you want to keep it around for a while.)
104 virtual void replace(
105 IAudioOp* oldOp) =0;
107 public: // *** OPTIONAL INTERFACE
109 // Called when the host node is started, before any calls to
110 // process().
112 virtual void init() {}
114 // Return the number of input frames required before an output
115 // frame can be produced.
117 virtual uint32 bufferLatency() const { return 0; }
121 #endif /*__IAudioOp_H__*/