Rename every instance of "OGG" to "Ogg"

This commit is contained in:
DeeJayLSP 2022-07-28 15:34:41 -03:00
parent 14d021287b
commit c8f3b02fcf
20 changed files with 161 additions and 158 deletions

View File

@ -4,7 +4,7 @@
Base class for audio streams. Base class for audio streams.
</brief_description> </brief_description>
<description> <description>
Base class for audio streams. Audio streams are used for sound effects and music playback, and support WAV (via [AudioStreamWAV]) and OGG (via [AudioStreamOGGVorbis]) file formats. Base class for audio streams. Audio streams are used for sound effects and music playback, and support WAV (via [AudioStreamWAV]) and Ogg (via [AudioStreamOggVorbis]) file formats.
</description> </description>
<tutorials> <tutorials>
<link title="Audio streams">$DOCS_URL/tutorials/audio/audio_streams.html</link> <link title="Audio streams">$DOCS_URL/tutorials/audio/audio_streams.html</link>

View File

@ -4,7 +4,7 @@
Meta class for playing back audio. Meta class for playing back audio.
</brief_description> </brief_description>
<description> <description>
Can play, loop, pause a scroll through audio. See [AudioStream] and [AudioStreamOGGVorbis] for usage. Can play, loop, pause a scroll through audio. See [AudioStream] and [AudioStreamOggVorbis] for usage.
</description> </description>
<tutorials> <tutorials>
<link title="Audio Generator Demo">https://godotengine.org/asset-library/asset/526</link> <link title="Audio Generator Demo">https://godotengine.org/asset-library/asset/526</link>

View File

@ -101,7 +101,7 @@ void EditorAssetInstaller::open(const String &p_path, int p_depth) {
extension_guess["webp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons")); extension_guess["webp"] = tree->get_theme_icon(SNAME("ImageTexture"), SNAME("EditorIcons"));
extension_guess["wav"] = tree->get_theme_icon(SNAME("AudioStreamWAV"), SNAME("EditorIcons")); extension_guess["wav"] = tree->get_theme_icon(SNAME("AudioStreamWAV"), SNAME("EditorIcons"));
extension_guess["ogg"] = tree->get_theme_icon(SNAME("AudioStreamOGGVorbis"), SNAME("EditorIcons")); extension_guess["ogg"] = tree->get_theme_icon(SNAME("AudioStreamOggVorbis"), SNAME("EditorIcons"));
extension_guess["mp3"] = tree->get_theme_icon(SNAME("AudioStreamMP3"), SNAME("EditorIcons")); extension_guess["mp3"] = tree->get_theme_icon(SNAME("AudioStreamMP3"), SNAME("EditorIcons"));
extension_guess["scn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons")); extension_guess["scn"] = tree->get_theme_icon(SNAME("PackedScene"), SNAME("EditorIcons"));

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1250,6 +1250,7 @@ static const char *class_renames[][2] = {
{ "AnimatedSprite", "AnimatedSprite2D" }, { "AnimatedSprite", "AnimatedSprite2D" },
{ "AnimationTreePlayer", "AnimationTree" }, { "AnimationTreePlayer", "AnimationTree" },
{ "Area", "Area3D" }, // Be careful, this will be used everywhere { "Area", "Area3D" }, // Be careful, this will be used everywhere
{ "AudioStreamOGGVorbis", "AudioStreamOggVorbis" },
{ "AudioStreamRandomPitch", "AudioStreamRandomizer" }, { "AudioStreamRandomPitch", "AudioStreamRandomizer" },
{ "AudioStreamSample", "AudioStreamWAV" }, { "AudioStreamSample", "AudioStreamWAV" },
{ "BakedLightmap", "LightmapGI" }, { "BakedLightmap", "LightmapGI" },

View File

@ -8,8 +8,8 @@ def configure(env):
def get_doc_classes(): def get_doc_classes():
return [ return [
"OGGPacketSequence", "OggPacketSequence",
"OGGPacketSequencePlayback", "OggPacketSequencePlayback",
] ]

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="OGGPacketSequence" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> <class name="OggPacketSequence" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description> <brief_description>
A sequence of OGG packets. A sequence of Ogg packets.
</brief_description> </brief_description>
<description> <description>
A sequence of OGG packets. A sequence of Ogg packets.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -21,7 +21,7 @@
Contains the granule positions for each page in this packet sequence. Contains the granule positions for each page in this packet sequence.
</member> </member>
<member name="packet_data" type="Array" setter="set_packet_data" getter="get_packet_data" default="[]"> <member name="packet_data" type="Array" setter="set_packet_data" getter="get_packet_data" default="[]">
Contains the raw packets that make up this OGGPacketSequence. Contains the raw packets that make up this OggPacketSequence.
</member> </member>
<member name="sampling_rate" type="float" setter="set_sampling_rate" getter="get_sampling_rate" default="0.0"> <member name="sampling_rate" type="float" setter="set_sampling_rate" getter="get_sampling_rate" default="0.0">
Holds sample rate information about this sequence. Must be set by another class that actually understands the codec. Holds sample rate information about this sequence. Must be set by another class that actually understands the codec.

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="OGGPacketSequencePlayback" inherits="RefCounted" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> <class name="OggPacketSequencePlayback" inherits="RefCounted" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View File

@ -31,7 +31,7 @@
#include "ogg_packet_sequence.h" #include "ogg_packet_sequence.h"
#include "core/variant/typed_array.h" #include "core/variant/typed_array.h"
void OGGPacketSequence::push_page(int64_t p_granule_pos, const Vector<PackedByteArray> &p_data) { void OggPacketSequence::push_page(int64_t p_granule_pos, const Vector<PackedByteArray> &p_data) {
Vector<PackedByteArray> data_stored; Vector<PackedByteArray> data_stored;
for (int i = 0; i < p_data.size(); i++) { for (int i = 0; i < p_data.size(); i++) {
data_stored.push_back(p_data[i]); data_stored.push_back(p_data[i]);
@ -41,7 +41,7 @@ void OGGPacketSequence::push_page(int64_t p_granule_pos, const Vector<PackedByte
data_version++; data_version++;
} }
void OGGPacketSequence::set_packet_data(const Array &p_data) { void OggPacketSequence::set_packet_data(const Array &p_data) {
data_version++; // Update the data version so old playbacks know that they can't rely on us anymore. data_version++; // Update the data version so old playbacks know that they can't rely on us anymore.
page_data.clear(); page_data.clear();
for (int page_idx = 0; page_idx < p_data.size(); page_idx++) { for (int page_idx = 0; page_idx < p_data.size(); page_idx++) {
@ -54,7 +54,7 @@ void OGGPacketSequence::set_packet_data(const Array &p_data) {
} }
} }
Array OGGPacketSequence::get_packet_data() const { Array OggPacketSequence::get_packet_data() const {
Array ret; Array ret;
for (const Vector<PackedByteArray> &page : page_data) { for (const Vector<PackedByteArray> &page : page_data) {
Array page_variant; Array page_variant;
@ -66,7 +66,7 @@ Array OGGPacketSequence::get_packet_data() const {
return ret; return ret;
} }
void OGGPacketSequence::set_packet_granule_positions(const Array &p_granule_positions) { void OggPacketSequence::set_packet_granule_positions(const Array &p_granule_positions) {
data_version++; // Update the data version so old playbacks know that they can't rely on us anymore. data_version++; // Update the data version so old playbacks know that they can't rely on us anymore.
page_granule_positions.clear(); page_granule_positions.clear();
for (int page_idx = 0; page_idx < p_granule_positions.size(); page_idx++) { for (int page_idx = 0; page_idx < p_granule_positions.size(); page_idx++) {
@ -75,7 +75,7 @@ void OGGPacketSequence::set_packet_granule_positions(const Array &p_granule_posi
} }
} }
Array OGGPacketSequence::get_packet_granule_positions() const { Array OggPacketSequence::get_packet_granule_positions() const {
Array ret; Array ret;
for (int64_t granule_pos : page_granule_positions) { for (int64_t granule_pos : page_granule_positions) {
ret.push_back(granule_pos); ret.push_back(granule_pos);
@ -83,22 +83,22 @@ Array OGGPacketSequence::get_packet_granule_positions() const {
return ret; return ret;
} }
void OGGPacketSequence::set_sampling_rate(float p_sampling_rate) { void OggPacketSequence::set_sampling_rate(float p_sampling_rate) {
sampling_rate = p_sampling_rate; sampling_rate = p_sampling_rate;
} }
float OGGPacketSequence::get_sampling_rate() const { float OggPacketSequence::get_sampling_rate() const {
return sampling_rate; return sampling_rate;
} }
int64_t OGGPacketSequence::get_final_granule_pos() const { int64_t OggPacketSequence::get_final_granule_pos() const {
if (!page_granule_positions.is_empty()) { if (!page_granule_positions.is_empty()) {
return page_granule_positions[page_granule_positions.size() - 1]; return page_granule_positions[page_granule_positions.size() - 1];
} }
return -1; return -1;
} }
float OGGPacketSequence::get_length() const { float OggPacketSequence::get_length() const {
int64_t granule_pos = get_final_granule_pos(); int64_t granule_pos = get_final_granule_pos();
if (granule_pos < 0) { if (granule_pos < 0) {
return 0; return 0;
@ -106,33 +106,33 @@ float OGGPacketSequence::get_length() const {
return granule_pos / sampling_rate; return granule_pos / sampling_rate;
} }
Ref<OGGPacketSequencePlayback> OGGPacketSequence::instantiate_playback() { Ref<OggPacketSequencePlayback> OggPacketSequence::instantiate_playback() {
Ref<OGGPacketSequencePlayback> playback; Ref<OggPacketSequencePlayback> playback;
playback.instantiate(); playback.instantiate();
playback->ogg_packet_sequence = Ref<OGGPacketSequence>(this); playback->ogg_packet_sequence = Ref<OggPacketSequence>(this);
playback->data_version = data_version; playback->data_version = data_version;
return playback; return playback;
} }
void OGGPacketSequence::_bind_methods() { void OggPacketSequence::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_packet_data", "packet_data"), &OGGPacketSequence::set_packet_data); ClassDB::bind_method(D_METHOD("set_packet_data", "packet_data"), &OggPacketSequence::set_packet_data);
ClassDB::bind_method(D_METHOD("get_packet_data"), &OGGPacketSequence::get_packet_data); ClassDB::bind_method(D_METHOD("get_packet_data"), &OggPacketSequence::get_packet_data);
ClassDB::bind_method(D_METHOD("set_packet_granule_positions", "granule_positions"), &OGGPacketSequence::set_packet_granule_positions); ClassDB::bind_method(D_METHOD("set_packet_granule_positions", "granule_positions"), &OggPacketSequence::set_packet_granule_positions);
ClassDB::bind_method(D_METHOD("get_packet_granule_positions"), &OGGPacketSequence::get_packet_granule_positions); ClassDB::bind_method(D_METHOD("get_packet_granule_positions"), &OggPacketSequence::get_packet_granule_positions);
ClassDB::bind_method(D_METHOD("set_sampling_rate", "sampling_rate"), &OGGPacketSequence::set_sampling_rate); ClassDB::bind_method(D_METHOD("set_sampling_rate", "sampling_rate"), &OggPacketSequence::set_sampling_rate);
ClassDB::bind_method(D_METHOD("get_sampling_rate"), &OGGPacketSequence::get_sampling_rate); ClassDB::bind_method(D_METHOD("get_sampling_rate"), &OggPacketSequence::get_sampling_rate);
ClassDB::bind_method(D_METHOD("get_length"), &OGGPacketSequence::get_length); ClassDB::bind_method(D_METHOD("get_length"), &OggPacketSequence::get_length);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "packet_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_packet_data", "get_packet_data"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "packet_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_packet_data", "get_packet_data");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "granule_positions", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_packet_granule_positions", "get_packet_granule_positions"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "granule_positions", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_packet_granule_positions", "get_packet_granule_positions");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sampling_rate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_sampling_rate", "get_sampling_rate"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sampling_rate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_sampling_rate", "get_sampling_rate");
} }
bool OGGPacketSequencePlayback::next_ogg_packet(ogg_packet **p_packet) const { bool OggPacketSequencePlayback::next_ogg_packet(ogg_packet **p_packet) const {
ERR_FAIL_COND_V(data_version != ogg_packet_sequence->data_version, false); ERR_FAIL_COND_V(data_version != ogg_packet_sequence->data_version, false);
ERR_FAIL_COND_V(ogg_packet_sequence->page_data.is_empty(), false); ERR_FAIL_COND_V(ogg_packet_sequence->page_data.is_empty(), false);
ERR_FAIL_COND_V(ogg_packet_sequence->page_granule_positions.is_empty(), false); ERR_FAIL_COND_V(ogg_packet_sequence->page_granule_positions.is_empty(), false);
@ -161,7 +161,7 @@ bool OGGPacketSequencePlayback::next_ogg_packet(ogg_packet **p_packet) const {
return true; return true;
} }
uint32_t OGGPacketSequencePlayback::seek_page_internal(int64_t granule, uint32_t after_page_inclusive, uint32_t before_page_inclusive) { uint32_t OggPacketSequencePlayback::seek_page_internal(int64_t granule, uint32_t after_page_inclusive, uint32_t before_page_inclusive) {
// FIXME: This function needs better corner case handling. // FIXME: This function needs better corner case handling.
if (before_page_inclusive == after_page_inclusive) { if (before_page_inclusive == after_page_inclusive) {
return before_page_inclusive; return before_page_inclusive;
@ -198,7 +198,7 @@ uint32_t OGGPacketSequencePlayback::seek_page_internal(int64_t granule, uint32_t
} }
} }
bool OGGPacketSequencePlayback::seek_page(int64_t p_granule_pos) { bool OggPacketSequencePlayback::seek_page(int64_t p_granule_pos) {
int correct_page = seek_page_internal(p_granule_pos, 0, ogg_packet_sequence->page_data.size() - 1); int correct_page = seek_page_internal(p_granule_pos, 0, ogg_packet_sequence->page_data.size() - 1);
if (correct_page == -1) { if (correct_page == -1) {
return false; return false;
@ -213,10 +213,10 @@ bool OGGPacketSequencePlayback::seek_page(int64_t p_granule_pos) {
return true; return true;
} }
OGGPacketSequencePlayback::OGGPacketSequencePlayback() { OggPacketSequencePlayback::OggPacketSequencePlayback() {
packet = new ogg_packet(); packet = new ogg_packet();
} }
OGGPacketSequencePlayback::~OGGPacketSequencePlayback() { OggPacketSequencePlayback::~OggPacketSequencePlayback() {
delete packet; delete packet;
} }

View File

@ -38,12 +38,12 @@
#include "core/variant/variant.h" #include "core/variant/variant.h"
#include "thirdparty/libogg/ogg/ogg.h" #include "thirdparty/libogg/ogg/ogg.h"
class OGGPacketSequencePlayback; class OggPacketSequencePlayback;
class OGGPacketSequence : public Resource { class OggPacketSequence : public Resource {
GDCLASS(OGGPacketSequence, Resource); GDCLASS(OggPacketSequence, Resource);
friend class OGGPacketSequencePlayback; friend class OggPacketSequencePlayback;
// List of pages, each of which is a list of packets on that page. The innermost PackedByteArrays contain complete ogg packets. // List of pages, each of which is a list of packets on that page. The innermost PackedByteArrays contain complete ogg packets.
Vector<Vector<PackedByteArray>> page_data; Vector<Vector<PackedByteArray>> page_data;
@ -73,7 +73,7 @@ public:
void set_packet_granule_positions(const Array &p_granule_positions); void set_packet_granule_positions(const Array &p_granule_positions);
Array get_packet_granule_positions() const; Array get_packet_granule_positions() const;
// Sets a sampling rate associated with this object. OGGPacketSequence doesn't understand codecs, // Sets a sampling rate associated with this object. OggPacketSequence doesn't understand codecs,
// so this value is naively stored as a convenience. // so this value is naively stored as a convenience.
void set_sampling_rate(float p_sampling_rate); void set_sampling_rate(float p_sampling_rate);
@ -86,18 +86,18 @@ public:
// Returns the granule position of the last page in this sequence. // Returns the granule position of the last page in this sequence.
int64_t get_final_granule_pos() const; int64_t get_final_granule_pos() const;
Ref<OGGPacketSequencePlayback> instantiate_playback(); Ref<OggPacketSequencePlayback> instantiate_playback();
OGGPacketSequence() {} OggPacketSequence() {}
virtual ~OGGPacketSequence() {} virtual ~OggPacketSequence() {}
}; };
class OGGPacketSequencePlayback : public RefCounted { class OggPacketSequencePlayback : public RefCounted {
GDCLASS(OGGPacketSequencePlayback, RefCounted); GDCLASS(OggPacketSequencePlayback, RefCounted);
friend class OGGPacketSequence; friend class OggPacketSequence;
Ref<OGGPacketSequence> ogg_packet_sequence; Ref<OggPacketSequence> ogg_packet_sequence;
mutable int64_t page_cursor = 0; mutable int64_t page_cursor = 0;
mutable int32_t packet_cursor = 0; mutable int32_t packet_cursor = 0;
@ -121,8 +121,8 @@ public:
// Returns true on success, false on failure. // Returns true on success, false on failure.
bool seek_page(int64_t p_granule_pos); bool seek_page(int64_t p_granule_pos);
OGGPacketSequencePlayback(); OggPacketSequencePlayback();
virtual ~OGGPacketSequencePlayback(); virtual ~OggPacketSequencePlayback();
}; };
#endif // OGG_PACKET_SEQUENCE_H #endif // OGG_PACKET_SEQUENCE_H

View File

@ -37,8 +37,8 @@ void initialize_ogg_module(ModuleInitializationLevel p_level) {
return; return;
} }
GDREGISTER_CLASS(OGGPacketSequence); GDREGISTER_CLASS(OggPacketSequence);
GDREGISTER_CLASS(OGGPacketSequencePlayback); GDREGISTER_CLASS(OggPacketSequencePlayback);
} }
void uninitialize_ogg_module(ModuleInitializationLevel p_level) { void uninitialize_ogg_module(ModuleInitializationLevel p_level) {

View File

@ -34,7 +34,7 @@
#include "core/variant/typed_array.h" #include "core/variant/typed_array.h"
#include "thirdparty/libogg/ogg/ogg.h" #include "thirdparty/libogg/ogg/ogg.h"
int AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_frames) { int AudioStreamPlaybackOggVorbis::_mix_internal(AudioFrame *p_buffer, int p_frames) {
ERR_FAIL_COND_V(!ready, 0); ERR_FAIL_COND_V(!ready, 0);
if (!active) { if (!active) {
@ -141,7 +141,7 @@ int AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fram
return p_frames - todo; return p_frames - todo;
} }
int AudioStreamPlaybackOGGVorbis::_mix_frames_vorbis(AudioFrame *p_buffer, int p_frames) { int AudioStreamPlaybackOggVorbis::_mix_frames_vorbis(AudioFrame *p_buffer, int p_frames) {
ERR_FAIL_COND_V(!ready, 0); ERR_FAIL_COND_V(!ready, 0);
if (!have_samples_left) { if (!have_samples_left) {
ogg_packet *packet = nullptr; ogg_packet *packet = nullptr;
@ -184,11 +184,11 @@ int AudioStreamPlaybackOGGVorbis::_mix_frames_vorbis(AudioFrame *p_buffer, int p
return frames; return frames;
} }
float AudioStreamPlaybackOGGVorbis::get_stream_sampling_rate() { float AudioStreamPlaybackOggVorbis::get_stream_sampling_rate() {
return vorbis_data->get_sampling_rate(); return vorbis_data->get_sampling_rate();
} }
bool AudioStreamPlaybackOGGVorbis::_alloc_vorbis() { bool AudioStreamPlaybackOggVorbis::_alloc_vorbis() {
vorbis_info_init(&info); vorbis_info_init(&info);
info_is_allocated = true; info_is_allocated = true;
vorbis_comment_init(&comment); vorbis_comment_init(&comment);
@ -223,7 +223,7 @@ bool AudioStreamPlaybackOGGVorbis::_alloc_vorbis() {
return true; return true;
} }
void AudioStreamPlaybackOGGVorbis::start(float p_from_pos) { void AudioStreamPlaybackOggVorbis::start(float p_from_pos) {
ERR_FAIL_COND(!ready); ERR_FAIL_COND(!ready);
loop_fade_remaining = FADE_SIZE; loop_fade_remaining = FADE_SIZE;
active = true; active = true;
@ -232,27 +232,27 @@ void AudioStreamPlaybackOGGVorbis::start(float p_from_pos) {
begin_resample(); begin_resample();
} }
void AudioStreamPlaybackOGGVorbis::stop() { void AudioStreamPlaybackOggVorbis::stop() {
active = false; active = false;
} }
bool AudioStreamPlaybackOGGVorbis::is_playing() const { bool AudioStreamPlaybackOggVorbis::is_playing() const {
return active; return active;
} }
int AudioStreamPlaybackOGGVorbis::get_loop_count() const { int AudioStreamPlaybackOggVorbis::get_loop_count() const {
return loops; return loops;
} }
float AudioStreamPlaybackOGGVorbis::get_playback_position() const { float AudioStreamPlaybackOggVorbis::get_playback_position() const {
return float(frames_mixed) / vorbis_data->get_sampling_rate(); return float(frames_mixed) / vorbis_data->get_sampling_rate();
} }
void AudioStreamPlaybackOGGVorbis::tag_used_streams() { void AudioStreamPlaybackOggVorbis::tag_used_streams() {
vorbis_stream->tag_used(get_playback_position()); vorbis_stream->tag_used(get_playback_position());
} }
void AudioStreamPlaybackOGGVorbis::seek(float p_time) { void AudioStreamPlaybackOggVorbis::seek(float p_time) {
ERR_FAIL_COND(!ready); ERR_FAIL_COND(!ready);
ERR_FAIL_COND(vorbis_stream.is_null()); ERR_FAIL_COND(vorbis_stream.is_null());
if (!active) { if (!active) {
@ -370,7 +370,7 @@ void AudioStreamPlaybackOGGVorbis::seek(float p_time) {
} }
} }
AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() { AudioStreamPlaybackOggVorbis::~AudioStreamPlaybackOggVorbis() {
if (block_is_allocated) { if (block_is_allocated) {
vorbis_block_clear(&block); vorbis_block_clear(&block);
} }
@ -385,13 +385,13 @@ AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() {
} }
} }
Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instantiate_playback() { Ref<AudioStreamPlayback> AudioStreamOggVorbis::instantiate_playback() {
Ref<AudioStreamPlaybackOGGVorbis> ovs; Ref<AudioStreamPlaybackOggVorbis> ovs;
ERR_FAIL_COND_V(packet_sequence.is_null(), nullptr); ERR_FAIL_COND_V(packet_sequence.is_null(), nullptr);
ovs.instantiate(); ovs.instantiate();
ovs->vorbis_stream = Ref<AudioStreamOGGVorbis>(this); ovs->vorbis_stream = Ref<AudioStreamOggVorbis>(this);
ovs->vorbis_data = packet_sequence; ovs->vorbis_data = packet_sequence;
ovs->frames_mixed = 0; ovs->frames_mixed = 0;
ovs->active = false; ovs->active = false;
@ -403,11 +403,11 @@ Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instantiate_playback() {
return nullptr; return nullptr;
} }
String AudioStreamOGGVorbis::get_stream_name() const { String AudioStreamOggVorbis::get_stream_name() const {
return ""; //return stream_name; return ""; //return stream_name;
} }
void AudioStreamOGGVorbis::maybe_update_info() { void AudioStreamOggVorbis::maybe_update_info() {
ERR_FAIL_COND(packet_sequence.is_null()); ERR_FAIL_COND(packet_sequence.is_null());
vorbis_info info; vorbis_info info;
@ -417,7 +417,7 @@ void AudioStreamOGGVorbis::maybe_update_info() {
vorbis_info_init(&info); vorbis_info_init(&info);
vorbis_comment_init(&comment); vorbis_comment_init(&comment);
Ref<OGGPacketSequencePlayback> packet_sequence_playback = packet_sequence->instantiate_playback(); Ref<OggPacketSequencePlayback> packet_sequence_playback = packet_sequence->instantiate_playback();
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
ogg_packet *packet; ogg_packet *packet;
@ -443,90 +443,90 @@ void AudioStreamOGGVorbis::maybe_update_info() {
vorbis_info_clear(&info); vorbis_info_clear(&info);
} }
void AudioStreamOGGVorbis::set_packet_sequence(Ref<OGGPacketSequence> p_packet_sequence) { void AudioStreamOggVorbis::set_packet_sequence(Ref<OggPacketSequence> p_packet_sequence) {
packet_sequence = p_packet_sequence; packet_sequence = p_packet_sequence;
if (packet_sequence.is_valid()) { if (packet_sequence.is_valid()) {
maybe_update_info(); maybe_update_info();
} }
} }
Ref<OGGPacketSequence> AudioStreamOGGVorbis::get_packet_sequence() const { Ref<OggPacketSequence> AudioStreamOggVorbis::get_packet_sequence() const {
return packet_sequence; return packet_sequence;
} }
void AudioStreamOGGVorbis::set_loop(bool p_enable) { void AudioStreamOggVorbis::set_loop(bool p_enable) {
loop = p_enable; loop = p_enable;
} }
bool AudioStreamOGGVorbis::has_loop() const { bool AudioStreamOggVorbis::has_loop() const {
return loop; return loop;
} }
void AudioStreamOGGVorbis::set_loop_offset(float p_seconds) { void AudioStreamOggVorbis::set_loop_offset(float p_seconds) {
loop_offset = p_seconds; loop_offset = p_seconds;
} }
float AudioStreamOGGVorbis::get_loop_offset() const { float AudioStreamOggVorbis::get_loop_offset() const {
return loop_offset; return loop_offset;
} }
float AudioStreamOGGVorbis::get_length() const { float AudioStreamOggVorbis::get_length() const {
ERR_FAIL_COND_V(packet_sequence.is_null(), 0); ERR_FAIL_COND_V(packet_sequence.is_null(), 0);
return packet_sequence->get_length(); return packet_sequence->get_length();
} }
void AudioStreamOGGVorbis::set_bpm(double p_bpm) { void AudioStreamOggVorbis::set_bpm(double p_bpm) {
ERR_FAIL_COND(p_bpm < 0); ERR_FAIL_COND(p_bpm < 0);
bpm = p_bpm; bpm = p_bpm;
emit_changed(); emit_changed();
} }
double AudioStreamOGGVorbis::get_bpm() const { double AudioStreamOggVorbis::get_bpm() const {
return bpm; return bpm;
} }
void AudioStreamOGGVorbis::set_beat_count(int p_beat_count) { void AudioStreamOggVorbis::set_beat_count(int p_beat_count) {
ERR_FAIL_COND(p_beat_count < 0); ERR_FAIL_COND(p_beat_count < 0);
beat_count = p_beat_count; beat_count = p_beat_count;
emit_changed(); emit_changed();
} }
int AudioStreamOGGVorbis::get_beat_count() const { int AudioStreamOggVorbis::get_beat_count() const {
return beat_count; return beat_count;
} }
void AudioStreamOGGVorbis::set_bar_beats(int p_bar_beats) { void AudioStreamOggVorbis::set_bar_beats(int p_bar_beats) {
ERR_FAIL_COND(p_bar_beats < 2); ERR_FAIL_COND(p_bar_beats < 2);
bar_beats = p_bar_beats; bar_beats = p_bar_beats;
emit_changed(); emit_changed();
} }
int AudioStreamOGGVorbis::get_bar_beats() const { int AudioStreamOggVorbis::get_bar_beats() const {
return bar_beats; return bar_beats;
} }
bool AudioStreamOGGVorbis::is_monophonic() const { bool AudioStreamOggVorbis::is_monophonic() const {
return false; return false;
} }
void AudioStreamOGGVorbis::_bind_methods() { void AudioStreamOggVorbis::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_packet_sequence", "packet_sequence"), &AudioStreamOGGVorbis::set_packet_sequence); ClassDB::bind_method(D_METHOD("set_packet_sequence", "packet_sequence"), &AudioStreamOggVorbis::set_packet_sequence);
ClassDB::bind_method(D_METHOD("get_packet_sequence"), &AudioStreamOGGVorbis::get_packet_sequence); ClassDB::bind_method(D_METHOD("get_packet_sequence"), &AudioStreamOggVorbis::get_packet_sequence);
ClassDB::bind_method(D_METHOD("set_loop", "enable"), &AudioStreamOGGVorbis::set_loop); ClassDB::bind_method(D_METHOD("set_loop", "enable"), &AudioStreamOggVorbis::set_loop);
ClassDB::bind_method(D_METHOD("has_loop"), &AudioStreamOGGVorbis::has_loop); ClassDB::bind_method(D_METHOD("has_loop"), &AudioStreamOggVorbis::has_loop);
ClassDB::bind_method(D_METHOD("set_loop_offset", "seconds"), &AudioStreamOGGVorbis::set_loop_offset); 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); ClassDB::bind_method(D_METHOD("get_loop_offset"), &AudioStreamOggVorbis::get_loop_offset);
ClassDB::bind_method(D_METHOD("set_bpm", "bpm"), &AudioStreamOGGVorbis::set_bpm); ClassDB::bind_method(D_METHOD("set_bpm", "bpm"), &AudioStreamOggVorbis::set_bpm);
ClassDB::bind_method(D_METHOD("get_bpm"), &AudioStreamOGGVorbis::get_bpm); ClassDB::bind_method(D_METHOD("get_bpm"), &AudioStreamOggVorbis::get_bpm);
ClassDB::bind_method(D_METHOD("set_beat_count", "count"), &AudioStreamOGGVorbis::set_beat_count); ClassDB::bind_method(D_METHOD("set_beat_count", "count"), &AudioStreamOggVorbis::set_beat_count);
ClassDB::bind_method(D_METHOD("get_beat_count"), &AudioStreamOGGVorbis::get_beat_count); ClassDB::bind_method(D_METHOD("get_beat_count"), &AudioStreamOggVorbis::get_beat_count);
ClassDB::bind_method(D_METHOD("set_bar_beats", "count"), &AudioStreamOGGVorbis::set_bar_beats); ClassDB::bind_method(D_METHOD("set_bar_beats", "count"), &AudioStreamOggVorbis::set_bar_beats);
ClassDB::bind_method(D_METHOD("get_bar_beats"), &AudioStreamOGGVorbis::get_bar_beats); ClassDB::bind_method(D_METHOD("get_bar_beats"), &AudioStreamOggVorbis::get_bar_beats);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "packet_sequence", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_packet_sequence", "get_packet_sequence"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "packet_sequence", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_packet_sequence", "get_packet_sequence");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bpm", PROPERTY_HINT_RANGE, "0,400,0.01,or_greater"), "set_bpm", "get_bpm"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bpm", PROPERTY_HINT_RANGE, "0,400,0.01,or_greater"), "set_bpm", "get_bpm");
@ -536,6 +536,6 @@ void AudioStreamOGGVorbis::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "loop_offset"), "set_loop_offset", "get_loop_offset"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "loop_offset"), "set_loop_offset", "get_loop_offset");
} }
AudioStreamOGGVorbis::AudioStreamOGGVorbis() {} AudioStreamOggVorbis::AudioStreamOggVorbis() {}
AudioStreamOGGVorbis::~AudioStreamOGGVorbis() {} AudioStreamOggVorbis::~AudioStreamOggVorbis() {}

View File

@ -36,10 +36,10 @@
#include "servers/audio/audio_stream.h" #include "servers/audio/audio_stream.h"
#include "thirdparty/libvorbis/vorbis/codec.h" #include "thirdparty/libvorbis/vorbis/codec.h"
class AudioStreamOGGVorbis; class AudioStreamOggVorbis;
class AudioStreamPlaybackOGGVorbis : public AudioStreamPlaybackResampled { class AudioStreamPlaybackOggVorbis : public AudioStreamPlaybackResampled {
GDCLASS(AudioStreamPlaybackOGGVorbis, AudioStreamPlaybackResampled); GDCLASS(AudioStreamPlaybackOggVorbis, AudioStreamPlaybackResampled);
uint32_t frames_mixed = 0; uint32_t frames_mixed = 0;
bool active = false; bool active = false;
@ -66,11 +66,11 @@ class AudioStreamPlaybackOGGVorbis : public AudioStreamPlaybackResampled {
bool have_samples_left = false; bool have_samples_left = false;
bool have_packets_left = false; bool have_packets_left = false;
friend class AudioStreamOGGVorbis; friend class AudioStreamOggVorbis;
Ref<OGGPacketSequence> vorbis_data; Ref<OggPacketSequence> vorbis_data;
Ref<OGGPacketSequencePlayback> vorbis_data_playback; Ref<OggPacketSequencePlayback> vorbis_data_playback;
Ref<AudioStreamOGGVorbis> vorbis_stream; Ref<AudioStreamOggVorbis> vorbis_stream;
int _mix_frames(AudioFrame *p_buffer, int p_frames); int _mix_frames(AudioFrame *p_buffer, int p_frames);
int _mix_frames_vorbis(AudioFrame *p_buffer, int p_frames); int _mix_frames_vorbis(AudioFrame *p_buffer, int p_frames);
@ -94,16 +94,16 @@ public:
virtual void tag_used_streams() override; virtual void tag_used_streams() override;
AudioStreamPlaybackOGGVorbis() {} AudioStreamPlaybackOggVorbis() {}
~AudioStreamPlaybackOGGVorbis(); ~AudioStreamPlaybackOggVorbis();
}; };
class AudioStreamOGGVorbis : public AudioStream { class AudioStreamOggVorbis : public AudioStream {
GDCLASS(AudioStreamOGGVorbis, AudioStream); GDCLASS(AudioStreamOggVorbis, AudioStream);
OBJ_SAVE_TYPE(AudioStream); // Saves derived classes with common type so they can be interchanged. OBJ_SAVE_TYPE(AudioStream); // Saves derived classes with common type so they can be interchanged.
RES_BASE_EXTENSION("oggvorbisstr"); RES_BASE_EXTENSION("oggvorbisstr");
friend class AudioStreamPlaybackOGGVorbis; friend class AudioStreamPlaybackOggVorbis;
int channels = 1; int channels = 1;
float length = 0.0; float length = 0.0;
@ -114,7 +114,7 @@ class AudioStreamOGGVorbis : public AudioStream {
// Also causes allocation and deallocation. // Also causes allocation and deallocation.
void maybe_update_info(); void maybe_update_info();
Ref<OGGPacketSequence> packet_sequence; Ref<OggPacketSequence> packet_sequence;
double bpm = 0; double bpm = 0;
int beat_count = 0; int beat_count = 0;
@ -142,15 +142,15 @@ public:
virtual Ref<AudioStreamPlayback> instantiate_playback() override; virtual Ref<AudioStreamPlayback> instantiate_playback() override;
virtual String get_stream_name() const override; virtual String get_stream_name() const override;
void set_packet_sequence(Ref<OGGPacketSequence> p_packet_sequence); void set_packet_sequence(Ref<OggPacketSequence> p_packet_sequence);
Ref<OGGPacketSequence> get_packet_sequence() const; Ref<OggPacketSequence> get_packet_sequence() const;
virtual float get_length() const override; //if supported, otherwise return 0 virtual float get_length() const override; //if supported, otherwise return 0
virtual bool is_monophonic() const override; virtual bool is_monophonic() const override;
AudioStreamOGGVorbis(); AudioStreamOggVorbis();
virtual ~AudioStreamOGGVorbis(); virtual ~AudioStreamOggVorbis();
}; };
#endif // AUDIO_STREAM_OGG_VORBIS_H #endif // AUDIO_STREAM_OGG_VORBIS_H

View File

@ -8,8 +8,8 @@ def configure(env):
def get_doc_classes(): def get_doc_classes():
return [ return [
"AudioStreamOGGVorbis", "AudioStreamOggVorbis",
"AudioStreamPlaybackOGGVorbis", "AudioStreamPlaybackOggVorbis",
] ]

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="AudioStreamOGGVorbis" inherits="AudioStream" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> <class name="AudioStreamOggVorbis" inherits="AudioStream" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>
@ -19,8 +19,8 @@
<member name="loop_offset" type="float" setter="set_loop_offset" getter="get_loop_offset" default="0.0"> <member name="loop_offset" type="float" setter="set_loop_offset" getter="get_loop_offset" default="0.0">
Time in seconds at which the stream starts after being looped. Time in seconds at which the stream starts after being looped.
</member> </member>
<member name="packet_sequence" type="OGGPacketSequence" setter="set_packet_sequence" getter="get_packet_sequence"> <member name="packet_sequence" type="OggPacketSequence" setter="set_packet_sequence" getter="get_packet_sequence">
Contains the raw OGG data for this stream. Contains the raw Ogg data for this stream.
</member> </member>
</members> </members>
</class> </class>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="AudioStreamPlaybackOGGVorbis" inherits="AudioStreamPlaybackResampled" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> <class name="AudioStreamPlaybackOggVorbis" inherits="AudioStreamPlaybackResampled" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description> <brief_description>
</brief_description> </brief_description>
<description> <description>

View File

@ -40,13 +40,13 @@ void initialize_vorbis_module(ModuleInitializationLevel p_level) {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
if (Engine::get_singleton()->is_editor_hint()) { if (Engine::get_singleton()->is_editor_hint()) {
Ref<ResourceImporterOGGVorbis> ogg_vorbis_importer; Ref<ResourceImporterOggVorbis> ogg_vorbis_importer;
ogg_vorbis_importer.instantiate(); ogg_vorbis_importer.instantiate();
ResourceFormatImporter::get_singleton()->add_importer(ogg_vorbis_importer); ResourceFormatImporter::get_singleton()->add_importer(ogg_vorbis_importer);
} }
#endif #endif
GDREGISTER_CLASS(AudioStreamOGGVorbis); GDREGISTER_CLASS(AudioStreamOggVorbis);
GDREGISTER_CLASS(AudioStreamPlaybackOGGVorbis); GDREGISTER_CLASS(AudioStreamPlaybackOggVorbis);
} }
void uninitialize_vorbis_module(ModuleInitializationLevel p_level) { void uninitialize_vorbis_module(ModuleInitializationLevel p_level) {

View File

@ -40,39 +40,39 @@
#include "editor/import/audio_stream_import_settings.h" #include "editor/import/audio_stream_import_settings.h"
#endif #endif
String ResourceImporterOGGVorbis::get_importer_name() const { String ResourceImporterOggVorbis::get_importer_name() const {
return "oggvorbisstr"; return "oggvorbisstr";
} }
String ResourceImporterOGGVorbis::get_visible_name() const { String ResourceImporterOggVorbis::get_visible_name() const {
return "oggvorbisstr"; return "oggvorbisstr";
} }
void ResourceImporterOGGVorbis::get_recognized_extensions(List<String> *p_extensions) const { void ResourceImporterOggVorbis::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("ogg"); p_extensions->push_back("ogg");
} }
String ResourceImporterOGGVorbis::get_save_extension() const { String ResourceImporterOggVorbis::get_save_extension() const {
return "oggvorbisstr"; return "oggvorbisstr";
} }
String ResourceImporterOGGVorbis::get_resource_type() const { String ResourceImporterOggVorbis::get_resource_type() const {
return "AudioStreamOGGVorbis"; return "AudioStreamOggVorbis";
} }
bool ResourceImporterOGGVorbis::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const { bool ResourceImporterOggVorbis::get_option_visibility(const String &p_path, const String &p_option, const HashMap<StringName, Variant> &p_options) const {
return true; return true;
} }
int ResourceImporterOGGVorbis::get_preset_count() const { int ResourceImporterOggVorbis::get_preset_count() const {
return 0; return 0;
} }
String ResourceImporterOGGVorbis::get_preset_name(int p_idx) const { String ResourceImporterOggVorbis::get_preset_name(int p_idx) const {
return String(); return String();
} }
void ResourceImporterOGGVorbis::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const { void ResourceImporterOggVorbis::get_import_options(const String &p_path, List<ImportOption> *r_options, int p_preset) const {
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "loop"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "loop"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "loop_offset"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "loop_offset"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "bpm", PROPERTY_HINT_RANGE, "0,400,0.01,or_greater"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "bpm", PROPERTY_HINT_RANGE, "0,400,0.01,or_greater"), 0));
@ -80,9 +80,9 @@ void ResourceImporterOGGVorbis::get_import_options(const String &p_path, List<Im
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "bar_beats", PROPERTY_HINT_RANGE, "2,32,or_greater"), 4)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "bar_beats", PROPERTY_HINT_RANGE, "2,32,or_greater"), 4));
} }
Ref<AudioStreamOGGVorbis> ResourceImporterOGGVorbis::import_ogg_vorbis(const String &p_path) { Ref<AudioStreamOggVorbis> ResourceImporterOggVorbis::import_ogg_vorbis(const String &p_path) {
Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ); Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V_MSG(f.is_null(), Ref<AudioStreamOGGVorbis>(), "Cannot open file '" + p_path + "'."); ERR_FAIL_COND_V_MSG(f.is_null(), Ref<AudioStreamOggVorbis>(), "Cannot open file '" + p_path + "'.");
uint64_t len = f->get_length(); uint64_t len = f->get_length();
@ -92,10 +92,10 @@ Ref<AudioStreamOGGVorbis> ResourceImporterOGGVorbis::import_ogg_vorbis(const Str
f->get_buffer(w, len); f->get_buffer(w, len);
Ref<AudioStreamOGGVorbis> ogg_vorbis_stream; Ref<AudioStreamOggVorbis> ogg_vorbis_stream;
ogg_vorbis_stream.instantiate(); ogg_vorbis_stream.instantiate();
Ref<OGGPacketSequence> ogg_packet_sequence; Ref<OggPacketSequence> ogg_packet_sequence;
ogg_packet_sequence.instantiate(); ogg_packet_sequence.instantiate();
ogg_stream_state stream_state; ogg_stream_state stream_state;
@ -110,16 +110,16 @@ Ref<AudioStreamOGGVorbis> ResourceImporterOGGVorbis::import_ogg_vorbis(const Str
size_t packet_count = 0; size_t packet_count = 0;
bool done = false; bool done = false;
while (!done) { while (!done) {
ERR_FAIL_COND_V_MSG((err = ogg_sync_check(&sync_state)), Ref<AudioStreamOGGVorbis>(), "Ogg sync error " + itos(err)); ERR_FAIL_COND_V_MSG((err = ogg_sync_check(&sync_state)), Ref<AudioStreamOggVorbis>(), "Ogg sync error " + itos(err));
while (ogg_sync_pageout(&sync_state, &page) != 1) { while (ogg_sync_pageout(&sync_state, &page) != 1) {
if (cursor >= len) { if (cursor >= len) {
done = true; done = true;
break; break;
} }
ERR_FAIL_COND_V_MSG((err = ogg_sync_check(&sync_state)), Ref<AudioStreamOGGVorbis>(), "Ogg sync error " + itos(err)); ERR_FAIL_COND_V_MSG((err = ogg_sync_check(&sync_state)), Ref<AudioStreamOggVorbis>(), "Ogg sync error " + itos(err));
char *sync_buf = ogg_sync_buffer(&sync_state, OGG_SYNC_BUFFER_SIZE); char *sync_buf = ogg_sync_buffer(&sync_state, OGG_SYNC_BUFFER_SIZE);
ERR_FAIL_COND_V_MSG((err = ogg_sync_check(&sync_state)), Ref<AudioStreamOGGVorbis>(), "Ogg sync error " + itos(err)); ERR_FAIL_COND_V_MSG((err = ogg_sync_check(&sync_state)), Ref<AudioStreamOggVorbis>(), "Ogg sync error " + itos(err));
ERR_FAIL_COND_V(cursor > len, Ref<AudioStreamOGGVorbis>()); ERR_FAIL_COND_V(cursor > len, Ref<AudioStreamOggVorbis>());
size_t copy_size = len - cursor; size_t copy_size = len - cursor;
if (copy_size > OGG_SYNC_BUFFER_SIZE) { if (copy_size > OGG_SYNC_BUFFER_SIZE) {
copy_size = OGG_SYNC_BUFFER_SIZE; copy_size = OGG_SYNC_BUFFER_SIZE;
@ -127,22 +127,22 @@ Ref<AudioStreamOGGVorbis> ResourceImporterOGGVorbis::import_ogg_vorbis(const Str
memcpy(sync_buf, &file_data[cursor], copy_size); memcpy(sync_buf, &file_data[cursor], copy_size);
ogg_sync_wrote(&sync_state, copy_size); ogg_sync_wrote(&sync_state, copy_size);
cursor += copy_size; cursor += copy_size;
ERR_FAIL_COND_V_MSG((err = ogg_sync_check(&sync_state)), Ref<AudioStreamOGGVorbis>(), "Ogg sync error " + itos(err)); ERR_FAIL_COND_V_MSG((err = ogg_sync_check(&sync_state)), Ref<AudioStreamOggVorbis>(), "Ogg sync error " + itos(err));
} }
if (done) { if (done) {
break; break;
} }
ERR_FAIL_COND_V_MSG((err = ogg_sync_check(&sync_state)), Ref<AudioStreamOGGVorbis>(), "Ogg sync error " + itos(err)); ERR_FAIL_COND_V_MSG((err = ogg_sync_check(&sync_state)), Ref<AudioStreamOggVorbis>(), "Ogg sync error " + itos(err));
// Have a page now. // Have a page now.
if (!initialized_stream) { if (!initialized_stream) {
if (ogg_stream_init(&stream_state, ogg_page_serialno(&page))) { if (ogg_stream_init(&stream_state, ogg_page_serialno(&page))) {
ERR_FAIL_V_MSG(Ref<AudioStreamOGGVorbis>(), "Failed allocating memory for OGG Vorbis stream."); ERR_FAIL_V_MSG(Ref<AudioStreamOggVorbis>(), "Failed allocating memory for Ogg Vorbis stream.");
} }
initialized_stream = true; initialized_stream = true;
} }
ogg_stream_pagein(&stream_state, &page); ogg_stream_pagein(&stream_state, &page);
ERR_FAIL_COND_V_MSG((err = ogg_stream_check(&stream_state)), Ref<AudioStreamOGGVorbis>(), "Ogg stream error " + itos(err)); ERR_FAIL_COND_V_MSG((err = ogg_stream_check(&stream_state)), Ref<AudioStreamOggVorbis>(), "Ogg stream error " + itos(err));
int desync_iters = 0; int desync_iters = 0;
Vector<Vector<uint8_t>> packet_data; Vector<Vector<uint8_t>> packet_data;
@ -153,7 +153,7 @@ Ref<AudioStreamOGGVorbis> ResourceImporterOGGVorbis::import_ogg_vorbis(const Str
if (err == -1) { if (err == -1) {
// According to the docs this is usually recoverable, but don't sit here spinning forever. // According to the docs this is usually recoverable, but don't sit here spinning forever.
desync_iters++; desync_iters++;
ERR_FAIL_COND_V_MSG(desync_iters > 100, Ref<AudioStreamOGGVorbis>(), "Packet sync issue during ogg import"); ERR_FAIL_COND_V_MSG(desync_iters > 100, Ref<AudioStreamOggVorbis>(), "Packet sync issue during Ogg import");
continue; continue;
} else if (err == 0) { } else if (err == 0) {
// Not enough data to fully reconstruct a packet. Go on to the next page. // Not enough data to fully reconstruct a packet. Go on to the next page.
@ -186,7 +186,7 @@ Ref<AudioStreamOGGVorbis> ResourceImporterOGGVorbis::import_ogg_vorbis(const Str
ogg_sync_clear(&sync_state); ogg_sync_clear(&sync_state);
if (ogg_packet_sequence->get_packet_granule_positions().is_empty()) { if (ogg_packet_sequence->get_packet_granule_positions().is_empty()) {
ERR_FAIL_V_MSG(Ref<AudioStreamOGGVorbis>(), "OGG Vorbis decoding failed. Check that your data is a valid OGG Vorbis audio stream."); ERR_FAIL_V_MSG(Ref<AudioStreamOggVorbis>(), "Ogg Vorbis decoding failed. Check that your data is a valid Ogg Vorbis audio stream.");
} }
ogg_vorbis_stream->set_packet_sequence(ogg_packet_sequence); ogg_vorbis_stream->set_packet_sequence(ogg_packet_sequence);
@ -196,26 +196,26 @@ Ref<AudioStreamOGGVorbis> ResourceImporterOGGVorbis::import_ogg_vorbis(const Str
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
bool ResourceImporterOGGVorbis::has_advanced_options() const { bool ResourceImporterOggVorbis::has_advanced_options() const {
return true; return true;
} }
void ResourceImporterOGGVorbis::show_advanced_options(const String &p_path) { void ResourceImporterOggVorbis::show_advanced_options(const String &p_path) {
Ref<AudioStreamOGGVorbis> ogg_stream = import_ogg_vorbis(p_path); Ref<AudioStreamOggVorbis> ogg_stream = import_ogg_vorbis(p_path);
if (ogg_stream.is_valid()) { if (ogg_stream.is_valid()) {
AudioStreamImportSettings::get_singleton()->edit(p_path, "oggvorbisstr", ogg_stream); AudioStreamImportSettings::get_singleton()->edit(p_path, "oggvorbisstr", ogg_stream);
} }
} }
#endif #endif
Error ResourceImporterOGGVorbis::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) { Error ResourceImporterOggVorbis::import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files, Variant *r_metadata) {
bool loop = p_options["loop"]; bool loop = p_options["loop"];
float loop_offset = p_options["loop_offset"]; float loop_offset = p_options["loop_offset"];
double bpm = p_options["bpm"]; double bpm = p_options["bpm"];
int beat_count = p_options["beat_count"]; int beat_count = p_options["beat_count"];
int bar_beats = p_options["bar_beats"]; int bar_beats = p_options["bar_beats"];
Ref<AudioStreamOGGVorbis> ogg_vorbis_stream = import_ogg_vorbis(p_source_file); Ref<AudioStreamOggVorbis> ogg_vorbis_stream = import_ogg_vorbis(p_source_file);
if (ogg_vorbis_stream.is_null()) { if (ogg_vorbis_stream.is_null()) {
return ERR_CANT_OPEN; return ERR_CANT_OPEN;
} }
@ -229,5 +229,5 @@ Error ResourceImporterOGGVorbis::import(const String &p_source_file, const Strin
return ResourceSaver::save(p_save_path + ".oggvorbisstr", ogg_vorbis_stream); return ResourceSaver::save(p_save_path + ".oggvorbisstr", ogg_vorbis_stream);
} }
ResourceImporterOGGVorbis::ResourceImporterOGGVorbis() { ResourceImporterOggVorbis::ResourceImporterOggVorbis() {
} }

View File

@ -34,8 +34,8 @@
#include "audio_stream_ogg_vorbis.h" #include "audio_stream_ogg_vorbis.h"
#include "core/io/resource_importer.h" #include "core/io/resource_importer.h"
class ResourceImporterOGGVorbis : public ResourceImporter { class ResourceImporterOggVorbis : public ResourceImporter {
GDCLASS(ResourceImporterOGGVorbis, ResourceImporter); GDCLASS(ResourceImporterOggVorbis, ResourceImporter);
enum { enum {
OGG_SYNC_BUFFER_SIZE = 8192, OGG_SYNC_BUFFER_SIZE = 8192,
@ -44,7 +44,7 @@ class ResourceImporterOGGVorbis : public ResourceImporter {
private: private:
// virtual int get_samples_in_packet(Vector<uint8_t> p_packet) = 0; // virtual int get_samples_in_packet(Vector<uint8_t> p_packet) = 0;
static Ref<AudioStreamOGGVorbis> import_ogg_vorbis(const String &p_path); static Ref<AudioStreamOggVorbis> import_ogg_vorbis(const String &p_path);
public: public:
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
@ -63,7 +63,7 @@ public:
virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override; virtual Error import(const String &p_source_file, const String &p_save_path, const HashMap<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) override;
ResourceImporterOGGVorbis(); ResourceImporterOggVorbis();
}; };
#endif // RESOURCE_IMPORTER_OGG_VORBIS_H #endif // RESOURCE_IMPORTER_OGG_VORBIS_H

View File

@ -1089,7 +1089,9 @@ void register_scene_types() {
ClassDB::add_compatibility_class("World", "World3D"); ClassDB::add_compatibility_class("World", "World3D");
// Renamed during 4.0 alpha, added to ease transition between alphas. // Renamed during 4.0 alpha, added to ease transition between alphas.
ClassDB::add_compatibility_class("AudioStreamOGGVorbis", "AudioStreamOggVorbis");
ClassDB::add_compatibility_class("AudioStreamSample", "AudioStreamWAV"); ClassDB::add_compatibility_class("AudioStreamSample", "AudioStreamWAV");
ClassDB::add_compatibility_class("OGGPacketSequence", "OggPacketSequence");
ClassDB::add_compatibility_class("StreamCubemap", "CompressedCubemap"); ClassDB::add_compatibility_class("StreamCubemap", "CompressedCubemap");
ClassDB::add_compatibility_class("StreamCubemapArray", "CompressedCubemapArray"); ClassDB::add_compatibility_class("StreamCubemapArray", "CompressedCubemapArray");
ClassDB::add_compatibility_class("StreamTexture2D", "CompressedTexture2D"); ClassDB::add_compatibility_class("StreamTexture2D", "CompressedTexture2D");