Merge pull request #15980 from mrcdk/audio_stream_get_length
Expose audio streams get_length()
This commit is contained in:
commit
ed6bf28014
6 changed files with 49 additions and 39 deletions
|
|
@ -115,7 +115,7 @@ void AudioStreamPlaybackOGGVorbis::seek(float p_time) {
|
|||
if (!active)
|
||||
return;
|
||||
|
||||
if (p_time >= get_length()) {
|
||||
if (p_time >= vorbis_stream->get_length()) {
|
||||
p_time = 0;
|
||||
}
|
||||
frames_mixed = uint32_t(vorbis_stream->sample_rate * p_time);
|
||||
|
|
@ -123,11 +123,6 @@ void AudioStreamPlaybackOGGVorbis::seek(float p_time) {
|
|||
stb_vorbis_seek(ogg_stream, frames_mixed);
|
||||
}
|
||||
|
||||
float AudioStreamPlaybackOGGVorbis::get_length() const {
|
||||
|
||||
return vorbis_stream->length;
|
||||
}
|
||||
|
||||
AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() {
|
||||
if (ogg_alloc.alloc_buffer) {
|
||||
stb_vorbis_close(ogg_stream);
|
||||
|
|
@ -261,6 +256,11 @@ float AudioStreamOGGVorbis::get_loop_offset() const {
|
|||
return loop_offset;
|
||||
}
|
||||
|
||||
float AudioStreamOGGVorbis::get_length() const {
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
void AudioStreamOGGVorbis::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_set_data", "data"), &AudioStreamOGGVorbis::set_data);
|
||||
|
|
|
|||
|
|
@ -71,8 +71,6 @@ public:
|
|||
virtual float get_playback_position() const;
|
||||
virtual void seek(float p_time);
|
||||
|
||||
virtual float get_length() const; //if supported, otherwise return 0
|
||||
|
||||
AudioStreamPlaybackOGGVorbis() {}
|
||||
~AudioStreamPlaybackOGGVorbis();
|
||||
};
|
||||
|
|
@ -112,6 +110,8 @@ public:
|
|||
void set_data(const PoolVector<uint8_t> &p_data);
|
||||
PoolVector<uint8_t> get_data() const;
|
||||
|
||||
virtual float get_length() const; //if supported, otherwise return 0
|
||||
|
||||
AudioStreamOGGVorbis();
|
||||
virtual ~AudioStreamOGGVorbis();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue