MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / convert

Method convert

compat/oggstr_loader_compat.cpp:5–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include "modules/vorbis/audio_stream_ogg_vorbis.h"
4
5Ref<Resource> OggStreamConverterCompat::convert(const Ref<MissingResource> &res, ResourceInfo::LoadType p_type, int ver_major, Error *r_error) {
6 String name = get_resource_name(res, ver_major);
7 Vector<uint8_t> data = res->get("data");
8 bool loop = res->get("loop");
9 double loop_offset = res->get("loop_offset");
10 Ref<AudioStreamOggVorbis> sample = AudioStreamOggVorbis::load_from_buffer(data);
11 ERR_FAIL_COND_V_MSG(sample.is_null(), res, "Failed to load Ogg Vorbis stream from buffer.");
12 if (!name.is_empty()) {
13 sample->set_name(name);
14 }
15 sample->set_loop(loop);
16 sample->set_loop_offset(loop_offset);
17 auto info = ResourceInfo::get_info_from_resource(res);
18 ERR_FAIL_COND_V_MSG(!info.is_valid(), res, "Missing resource has no compat metadata??????????? This should have been set by the missing resource instance function(s)!!!!!!!!");
19 if (info.is_valid()) {
20 info->set_on_resource(sample);
21 }
22 return sample;
23}
24
25bool OggStreamConverterCompat::handles_type(const String &p_type, int ver_major) const {
26 return ((p_type == "AudioStreamOGGVorbis" || p_type == "AudioStreamOggVorbis") && ver_major <= 3);

Callers

nothing calls this directly

Calls 4

set_nameMethod · 0.80
set_on_resourceMethod · 0.80
getMethod · 0.45
is_validMethod · 0.45

Tested by

no test coverage detected