summaryrefslogtreecommitdiff
path: root/modules/stb_vorbis
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-02-18 11:27:04 +0100
committerGitHub <noreply@github.com>2020-02-18 11:27:04 +0100
commitef5891091bceef2800b4fae4cd85af219e791467 (patch)
tree8d58cca8cae2c34d408450cfb5ceb198543147b7 /modules/stb_vorbis
parentc7faf2e16b684f3dd0246dbdb662b1826dd24571 (diff)
parent3205a92ad872f918c8322cdcd1434c231a1fd251 (diff)
Merge pull request #36311 from reduz/poolvector-deprecation
Convert all references and instances of PoolVector to Vector
Diffstat (limited to 'modules/stb_vorbis')
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp28
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.h4
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.cpp6
3 files changed, 19 insertions, 19 deletions
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index f2d0f5c9a6..6224db90e7 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -163,32 +163,32 @@ void AudioStreamOGGVorbis::clear_data() {
}
}
-void AudioStreamOGGVorbis::set_data(const PoolVector<uint8_t> &p_data) {
+void AudioStreamOGGVorbis::set_data(const Vector<uint8_t> &p_data) {
int src_data_len = p_data.size();
#define MAX_TEST_MEM (1 << 20)
uint32_t alloc_try = 1024;
- PoolVector<char> alloc_mem;
- PoolVector<char>::Write w;
+ Vector<char> alloc_mem;
+ char *w;
stb_vorbis *ogg_stream = NULL;
stb_vorbis_alloc ogg_alloc;
while (alloc_try < MAX_TEST_MEM) {
alloc_mem.resize(alloc_try);
- w = alloc_mem.write();
+ w = alloc_mem.ptrw();
- ogg_alloc.alloc_buffer = w.ptr();
+ ogg_alloc.alloc_buffer = w;
ogg_alloc.alloc_buffer_length_in_bytes = alloc_try;
- PoolVector<uint8_t>::Read src_datar = p_data.read();
+ const uint8_t *src_datar = p_data.ptr();
int error;
- ogg_stream = stb_vorbis_open_memory((const unsigned char *)src_datar.ptr(), src_data_len, &error, &ogg_alloc);
+ ogg_stream = stb_vorbis_open_memory((const unsigned char *)src_datar, src_data_len, &error, &ogg_alloc);
if (!ogg_stream && error == VORBIS_outofmem) {
- w.release();
+
alloc_try *= 2;
} else {
@@ -209,7 +209,7 @@ void AudioStreamOGGVorbis::set_data(const PoolVector<uint8_t> &p_data) {
// free any existing data
clear_data();
- data = AudioServer::get_singleton()->audio_data_alloc(src_data_len, src_datar.ptr());
+ data = AudioServer::get_singleton()->audio_data_alloc(src_data_len, src_datar);
data_len = src_data_len;
break;
@@ -217,15 +217,15 @@ void AudioStreamOGGVorbis::set_data(const PoolVector<uint8_t> &p_data) {
}
}
-PoolVector<uint8_t> AudioStreamOGGVorbis::get_data() const {
+Vector<uint8_t> AudioStreamOGGVorbis::get_data() const {
- PoolVector<uint8_t> vdata;
+ Vector<uint8_t> vdata;
if (data_len && data) {
vdata.resize(data_len);
{
- PoolVector<uint8_t>::Write w = vdata.write();
- copymem(w.ptr(), data, data_len);
+ uint8_t *w = vdata.ptrw();
+ copymem(w, data, data_len);
}
}
@@ -265,7 +265,7 @@ void AudioStreamOGGVorbis::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_loop_offset", "seconds"), &AudioStreamOGGVorbis::set_loop_offset);
ClassDB::bind_method(D_METHOD("get_loop_offset"), &AudioStreamOGGVorbis::get_loop_offset);
- ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_data", "get_data");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_data", "get_data");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop"), "set_loop", "has_loop");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "loop_offset"), "set_loop_offset", "get_loop_offset");
}
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
index e909759acb..f296e8c19f 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.h
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
@@ -102,8 +102,8 @@ public:
virtual Ref<AudioStreamPlayback> instance_playback();
virtual String get_stream_name() const;
- void set_data(const PoolVector<uint8_t> &p_data);
- PoolVector<uint8_t> get_data() const;
+ void set_data(const Vector<uint8_t> &p_data);
+ Vector<uint8_t> get_data() const;
virtual float get_length() const; //if supported, otherwise return 0
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
index 06399f4005..ec89f2ac76 100644
--- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
@@ -87,11 +87,11 @@ Error ResourceImporterOGGVorbis::import(const String &p_source_file, const Strin
size_t len = f->get_len();
- PoolVector<uint8_t> data;
+ Vector<uint8_t> data;
data.resize(len);
- PoolVector<uint8_t>::Write w = data.write();
+ uint8_t *w = data.ptrw();
- f->get_buffer(w.ptr(), len);
+ f->get_buffer(w, len);
memdelete(f);