distinguish between end of stream and end of data
svn-id: r11756
This commit is contained in:
parent
0cddca5f43
commit
d8903123b0
8 changed files with 34 additions and 13 deletions
|
@ -82,7 +82,7 @@ public:
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
bool isStereo() const { return stereo; }
|
bool isStereo() const { return stereo; }
|
||||||
bool eos() const { return eosIntern(); }
|
bool endOfData() const { return eosIntern(); }
|
||||||
|
|
||||||
int getRate() const { return _rate; }
|
int getRate() const { return _rate; }
|
||||||
};
|
};
|
||||||
|
@ -131,7 +131,8 @@ public:
|
||||||
|
|
||||||
int16 read();
|
int16 read();
|
||||||
bool isStereo() const { return stereo; }
|
bool isStereo() const { return stereo; }
|
||||||
bool eos() const { return _finalized && eosIntern(); }
|
bool endOfStream() const { return _finalized && eosIntern(); }
|
||||||
|
bool endOfData() const { return eosIntern(); }
|
||||||
|
|
||||||
int getRate() const { return _rate; }
|
int getRate() const { return _rate; }
|
||||||
|
|
||||||
|
@ -276,7 +277,7 @@ public:
|
||||||
return *_pos++;
|
return *_pos++;
|
||||||
}
|
}
|
||||||
bool isStereo() const { return _isStereo; }
|
bool isStereo() const { return _isStereo; }
|
||||||
bool eos() const { return false; }
|
bool endOfData() const { return false; }
|
||||||
|
|
||||||
int getRate() const { return _rate; }
|
int getRate() const { return _rate; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,8 +53,24 @@ public:
|
||||||
/** Is this a stereo stream? */
|
/** Is this a stereo stream? */
|
||||||
virtual bool isStereo() const = 0;
|
virtual bool isStereo() const = 0;
|
||||||
|
|
||||||
/** End of stream reached? */
|
/**
|
||||||
virtual bool eos() const = 0;
|
* End of data reached? If this returns true, it means that at this
|
||||||
|
* time there is no data available in the stream. However there may be
|
||||||
|
* more data in the future.
|
||||||
|
* This is used by e.g. a rate converter to decide whether to keep on
|
||||||
|
* converting data or stop.
|
||||||
|
*/
|
||||||
|
virtual bool endOfData() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End of stream reached? If this returns true, it means that all data
|
||||||
|
* in this stream is used up and no additional data will appear in it
|
||||||
|
* in the future.
|
||||||
|
* This is used by the mixer to decide whether a given stream shall be
|
||||||
|
* removed from the list of active streams (and thus be destroyed).
|
||||||
|
* By default this maps to endOfData()
|
||||||
|
*/
|
||||||
|
virtual bool endOfStream() const { return endOfData(); }
|
||||||
|
|
||||||
/** Sample rate of the stream. */
|
/** Sample rate of the stream. */
|
||||||
virtual int getRate() const = 0;
|
virtual int getRate() const = 0;
|
||||||
|
|
|
@ -485,9 +485,11 @@ void Channel::destroy() {
|
||||||
*/
|
*/
|
||||||
void Channel::mix(int16 *data, uint len) {
|
void Channel::mix(int16 *data, uint len) {
|
||||||
assert(_input);
|
assert(_input);
|
||||||
if (_input->eos()) {
|
|
||||||
// TODO: call drain method
|
if (_input->endOfStream()) {
|
||||||
destroy();
|
destroy();
|
||||||
|
} else if (_input->endOfData()) {
|
||||||
|
// TODO: call drain method
|
||||||
} else {
|
} else {
|
||||||
assert(_converter);
|
assert(_converter);
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ public:
|
||||||
int readBuffer(int16 *buffer, const int numSamples);
|
int readBuffer(int16 *buffer, const int numSamples);
|
||||||
|
|
||||||
int16 read();
|
int16 read();
|
||||||
bool eos() const { return eosIntern(); }
|
bool endOfData() const { return eosIntern(); }
|
||||||
bool isStereo() const { return _isStereo; }
|
bool isStereo() const { return _isStereo; }
|
||||||
|
|
||||||
int getRate() const { return _frame.header.samplerate; }
|
int getRate() const { return _frame.header.samplerate; }
|
||||||
|
|
|
@ -200,7 +200,7 @@ public:
|
||||||
int16 tmp[2];
|
int16 tmp[2];
|
||||||
st_size_t len = osamp;
|
st_size_t len = osamp;
|
||||||
assert(input.isStereo() == stereo);
|
assert(input.isStereo() == stereo);
|
||||||
while (!input.eos() && len--) {
|
while (!input.endOfData() && len--) {
|
||||||
tmp[0] = tmp[1] = input.read();
|
tmp[0] = tmp[1] = input.read();
|
||||||
if (stereo)
|
if (stereo)
|
||||||
tmp[reverseStereo ? 0 : 1] = input.read();
|
tmp[reverseStereo ? 0 : 1] = input.read();
|
||||||
|
|
|
@ -166,7 +166,7 @@ public:
|
||||||
int readBuffer(int16 *buffer, const int numSamples);
|
int readBuffer(int16 *buffer, const int numSamples);
|
||||||
|
|
||||||
int16 read();
|
int16 read();
|
||||||
bool eos() const { return eosIntern(); }
|
bool endOfData() const { return eosIntern(); }
|
||||||
bool isStereo() const { return _numChannels >= 2; }
|
bool isStereo() const { return _numChannels >= 2; }
|
||||||
|
|
||||||
int getRate() const { return ov_info(_ov_file, -1)->rate; }
|
int getRate() const { return ov_info(_ov_file, -1)->rate; }
|
||||||
|
|
|
@ -105,7 +105,7 @@ int16 MusicHandle::read() {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MusicHandle::eos() const {
|
bool MusicHandle::endOfData() const {
|
||||||
return (!_streaming || _filePos >= _fileEnd);
|
return (!_streaming || _filePos >= _fileEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,14 +61,16 @@ public:
|
||||||
|
|
||||||
virtual int readBuffer(int16 *buffer, const int numSamples) {
|
virtual int readBuffer(int16 *buffer, const int numSamples) {
|
||||||
int samples;
|
int samples;
|
||||||
for (samples = 0; samples < numSamples && !eos(); samples++) {
|
for (samples = 0; samples < numSamples && !endOfData(); samples++) {
|
||||||
*buffer++ = read();
|
*buffer++ = read();
|
||||||
}
|
}
|
||||||
return samples;
|
return samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16 read();
|
int16 read();
|
||||||
bool eos() const;
|
bool endOfData() const;
|
||||||
|
// This stream never 'ends'
|
||||||
|
bool endOfStream() const { return false; }
|
||||||
|
|
||||||
MusicHandle() : _firstTime(false),
|
MusicHandle() : _firstTime(false),
|
||||||
_streaming(false), _paused(false), _looping(false),
|
_streaming(false), _paused(false), _looping(false),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue