Commit 7f6b62ce by Rémi Verschelde

opus/vorbis: Remove dead code not used since 3.0

Since the new audio system in 3.0 we switched the OGG support to stb_vorbis, and the Opus stream support was disabled as incompatible (see #7496). We still build the libraries as they are needed by the theora and webm modules, but we don't need any Godot code apart from `register_types`. Fixes #7496.
parent a2d3ba33
......@@ -3,6 +3,9 @@
Import('env')
Import('env_modules')
# Only kept to build the thirdparty library used by the theora and webm
# modules.
env_ogg = env_modules.Clone()
# Thirdparty source files
......
......@@ -3,7 +3,9 @@
Import('env')
Import('env_modules')
stub = True
# Only kept to build the thirdparty library used by the webm module.
# AudioStreamOpus was dropped in 3.0 due to incompatibility with the new audio
# engine. If you want to port it, fetch it from the Git history.
env_opus = env_modules.Clone()
......@@ -235,9 +237,5 @@ if env['builtin_opus']:
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)
if not stub:
# Module files
env_opus.add_source_files(env.modules_sources, "*.cpp")
else:
# Module files
env_opus.add_source_files(env.modules_sources, "stub/register_types.cpp")
# Module files
env_opus.add_source_files(env.modules_sources, "register_types.cpp")
/*************************************************************************/
/* audio_stream_opus.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef AUDIO_STREAM_OPUS_H
#define AUDIO_STREAM_OPUS_H
#include "core/io/resource_loader.h"
#include "core/os/file_access.h"
#include "scene/resources/audio_stream.h"
#include <opus/opusfile.h>
/**
@author George Marques <george@gmarqu.es>
*/
class AudioStreamPlaybackOpus : public AudioStreamPlayback {
GDCLASS(AudioStreamPlaybackOpus, AudioStreamPlayback);
enum {
MIN_MIX = 1024
};
FileAccess *f;
OpusFileCallbacks _op_callbacks;
float length;
static int _op_read_func(void *_stream, unsigned char *_ptr, int _nbytes);
static int _op_seek_func(void *_stream, opus_int64 _offset, int _whence);
static int _op_close_func(void *_stream);
static opus_int64 _op_tell_func(void *_stream);
static const float osrate;
String file;
int64_t frames_mixed;
bool stream_loaded;
volatile bool playing;
OggOpusFile *opus_file;
int stream_channels;
int current_section;
int pre_skip;
bool paused;
bool loops;
int repeats;
Error _load_stream();
void _clear_stream();
void _close_file();
bool stream_valid;
float loop_restart_time;
public:
Error set_file(const String &p_file);
virtual void play(float p_from = 0);
virtual void stop();
virtual bool is_playing() const { return playing; }
virtual void set_loop_restart_time(float p_time) { loop_restart_time = p_time; }
virtual void set_paused(bool p_paused) { paused = p_paused; }
virtual bool is_paused() const { return paused; }
virtual void set_loop(bool p_enable) { loops = p_enable; }
virtual bool has_loop() const { return loops; }
virtual float get_length() const;
virtual String get_stream_name() const { return ""; }
virtual int get_loop_count() const { return repeats; }
virtual float get_playback_position() const;
virtual void seek(float p_time);
virtual int get_channels() const { return stream_channels; }
virtual int get_mix_rate() const { return osrate; }
virtual int get_minimum_buffer_size() const;
virtual int mix(int16_t *p_buffer, int p_frames);
AudioStreamPlaybackOpus();
~AudioStreamPlaybackOpus();
};
class AudioStreamOpus : public AudioStream {
GDCLASS(AudioStreamOpus, AudioStream);
String file;
public:
Ref<AudioStreamPlayback> instance_playback() {
Ref<AudioStreamPlaybackOpus> pb = memnew(AudioStreamPlaybackOpus);
pb->set_file(file);
return pb;
}
void set_file(const String &p_file) { file = p_file; }
};
class ResourceFormatLoaderAudioStreamOpus : public ResourceFormatLoader {
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
};
#endif // AUDIO_STREAM_OPUS_H
......@@ -3,11 +3,3 @@ def can_build(env, platform):
def configure(env):
pass
def get_doc_classes():
return [
"AudioStreamOpus",
]
def get_doc_path():
return "doc_classes"
......@@ -30,23 +30,8 @@
#include "register_types.h"
#include "audio_stream_opus.h"
// Dummy module as libvorbis is needed by other modules (theora ...)
static Ref<ResourceFormatLoaderAudioStreamOpus> opus_stream_loader;
void register_opus_types() {}
void register_opus_types() {
// Sorry guys, do not enable this unless you can figure out a way
// to get Opus to not do any memory allocation or system calls
// in the audio thread.
// Currently the implementation even reads files from the audio thread,
// and this is not how audio programming works.
//opus_stream_loader = memnew(ResourceFormatLoaderAudioStreamOpus);
//ResourceLoader::add_resource_format_loader(opus_stream_loader);
//ClassDB::register_class<AudioStreamOpus>();
}
void unregister_opus_types() {
//memdelete(opus_stream_loader);
}
void unregister_opus_types() {}
/*************************************************************************/
/* register_types.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_types.h"
// Dummy module as libvorbis is needed by other modules (theora ...)
void register_opus_types() {}
void unregister_opus_types() {}
/*************************************************************************/
/* register_types.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
void register_opus_types();
void unregister_opus_types();
......@@ -3,6 +3,9 @@
Import('env')
Import('env_modules')
# Only kept to build the thirdparty library used by the theora and webm
# modules. We now use stb_vorbis for AudioStreamOGGVorbis.
env_vorbis = env_modules.Clone()
stub = True
......@@ -50,9 +53,5 @@ if env['builtin_libvorbis']:
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources)
if not stub:
# Module files
env_vorbis.add_source_files(env.modules_sources, "*.cpp")
else:
# Module files
env_vorbis.add_source_files(env.modules_sources, "stub/register_types.cpp")
# Module files
env_vorbis.add_source_files(env.modules_sources, "register_types.cpp")
/*************************************************************************/
/* audio_stream_ogg_vorbis.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef AUDIO_STREAM_OGG_VORBIS_H
#define AUDIO_STREAM_OGG_VORBIS_H
#include "core/io/resource_loader.h"
#include "core/os/file_access.h"
#include "core/os/thread_safe.h"
#include "scene/resources/audio_stream.h"
#include <vorbis/vorbisfile.h>
class AudioStreamPlaybackOGGVorbis : public AudioStreamPlayback {
GDCLASS(AudioStreamPlaybackOGGVorbis, AudioStreamPlayback);
enum {
MIN_MIX = 1024
};
FileAccess *f;
ov_callbacks _ov_callbacks;
float length;
static size_t _ov_read_func(void *p_dst, size_t p_data, size_t p_count, void *_f);
static int _ov_seek_func(void *_f, ogg_int64_t offs, int whence);
static int _ov_close_func(void *_f);
static long _ov_tell_func(void *_f);
String file;
int64_t frames_mixed;
bool stream_loaded;
volatile bool playing;
OggVorbis_File vf;
int stream_channels;
int stream_srate;
int current_section;
bool paused;
bool loops;
int repeats;
Error _load_stream();
void _clear_stream();
void _close_file();
bool stream_valid;
float loop_restart_time;
public:
Error set_file(const String &p_file);
virtual void play(float p_from = 0);
virtual void stop();
virtual bool is_playing() const;
virtual void set_loop_restart_time(float p_time) { loop_restart_time = p_time; }
virtual void set_paused(bool p_paused);
virtual bool is_paused() const;
virtual void set_loop(bool p_enable);
virtual bool has_loop() const;
virtual float get_length() const;
virtual String get_stream_name() const;
virtual int get_loop_count() const;
virtual float get_playback_position() const;
virtual void seek(float p_time);
virtual int get_channels() const { return stream_channels; }
virtual int get_mix_rate() const { return stream_srate; }
virtual int get_minimum_buffer_size() const { return 0; }
virtual int mix(int16_t *p_buffer, int p_frames);
AudioStreamPlaybackOGGVorbis();
~AudioStreamPlaybackOGGVorbis();
};
class AudioStreamOGGVorbis : public AudioStream {
GDCLASS(AudioStreamOGGVorbis, AudioStream);
String file;
public:
Ref<AudioStreamPlayback> instance_playback() {
Ref<AudioStreamPlaybackOGGVorbis> pb = memnew(AudioStreamPlaybackOGGVorbis);
pb->set_file(file);
return pb;
}
void set_file(const String &p_file) { file = p_file; }
};
class ResourceFormatLoaderAudioStreamOGGVorbis : public ResourceFormatLoader {
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
};
#endif // AUDIO_STREAM_OGG_H
......@@ -30,19 +30,8 @@
#include "register_types.h"
#include "audio_stream_ogg_vorbis.h"
// Dummy module as libvorbis is needed by other modules (theora ...)
static Ref<ResourceFormatLoaderAudioStreamOGGVorbis> vorbis_stream_loader;
void register_vorbis_types() {}
void register_vorbis_types() {
vorbis_stream_loader.instance();
ResourceLoader::add_resource_format_loader(vorbis_stream_loader);
ClassDB::register_class<AudioStreamOGGVorbis>();
}
void unregister_vorbis_types() {
ResourceLoader::remove_resource_format_loader(vorbis_stream_loader);
vorbis_stream_loader.unref();
}
void unregister_vorbis_types() {}
/*************************************************************************/
/* register_types.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_types.h"
// Dummy module as libvorbis is needed by other modules (theora ...)
void register_vorbis_types() {}
void unregister_vorbis_types() {}
/*************************************************************************/
/* register_types.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
void register_vorbis_types();
void unregister_vorbis_types();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment