MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / AudioStream

Class AudioStream

Source/Amiga/audiostream.hpp:32–77  ·  view source on GitHub ↗

* Generic audio input stream. Subclasses of this are used to feed arbitrary * sampled audio data into ScummVM's audio mixer. */

Source from the content-addressed store, hash-verified

30 * sampled audio data into ScummVM's audio mixer.
31 */
32class AudioStream {
33public:
34 int16 mVolume;
35
36 virtual ~AudioStream() {}
37
38 /**
39 * Fill the given buffer with up to numSamples samples. Returns the actual
40 * number of samples read, or -1 if a critical error occurred (note: you
41 * *must* check if this value is less than what you requested, this can
42 * happen when the stream is fully used up).
43 *
44 * Data has to be in native endianess, 16 bit per sample, signed. For stereo
45 * stream, buffer will be filled with interleaved left and right channel
46 * samples, starting with a left sample. Furthermore, the samples in the
47 * left and right are summed up. So if you request 4 samples from a stereo
48 * stream, you will get a total of two left channel and two right channel
49 * samples.
50 */
51 virtual int readBuffer(int16 *buffer, const int numSamples) = 0;
52
53 /** Is this a stereo stream? */
54 virtual bool isStereo() const = 0;
55
56 /** Sample rate of the stream. */
57 virtual int getRate() const = 0;
58
59 /**
60 * End of data reached? If this returns true, it means that at this
61 * time there is no data available in the stream. However there may be
62 * more data in the future.
63 * This is used by e.g. a rate converter to decide whether to keep on
64 * converting data or stop.
65 */
66 virtual bool endOfData() const = 0;
67
68 /**
69 * End of stream reached? If this returns true, it means that all data
70 * in this stream is used up and no additional data will appear in it
71 * in the future.
72 * This is used by the mixer to decide whether a given stream shall be
73 * removed from the list of active streams (and thus be destroyed).
74 * By default this maps to endOfData()
75 */
76 virtual bool endOfStream() const { return endOfData(); }
77};
78
79/**
80 * A rewindable audio stream. This allows for reseting the AudioStream

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected