diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-09-09 18:50:52 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-09-09 18:50:52 -0300 |
commit | 97413746173b4f872e8c72eba0e58d7092a93269 (patch) | |
tree | 576708292cc3e39f8acc3047441aaeb23e952164 /drivers/vorbis/audio_stream_ogg_vorbis.h | |
parent | b0aa49accbd7e45dae38f1bd43b0fbdd11714211 (diff) |
Rewrite of the AudioStream API
-Fixes long-standing issues regarding to playing a single stream multiple times simultanteously
-Fixes wrong-looping, starting, caching, etc. Issues resulting from bad original design
-Allows more interesting kinds of streams (stream graphs with streams inside streams!) in the future
Diffstat (limited to 'drivers/vorbis/audio_stream_ogg_vorbis.h')
-rw-r--r-- | drivers/vorbis/audio_stream_ogg_vorbis.h | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/drivers/vorbis/audio_stream_ogg_vorbis.h b/drivers/vorbis/audio_stream_ogg_vorbis.h index 5e3649d980..827d8b0be3 100644 --- a/drivers/vorbis/audio_stream_ogg_vorbis.h +++ b/drivers/vorbis/audio_stream_ogg_vorbis.h @@ -29,17 +29,16 @@ #ifndef AUDIO_STREAM_OGG_VORBIS_H #define AUDIO_STREAM_OGG_VORBIS_H -#include "scene/resources/audio_stream_resampled.h" +#include "scene/resources/audio_stream.h" #include "vorbis/vorbisfile.h" #include "os/file_access.h" #include "io/resource_loader.h" #include "os/thread_safe.h" -class AudioStreamOGGVorbis : public AudioStreamResampled { - OBJ_TYPE(AudioStreamOGGVorbis,AudioStreamResampled); - _THREAD_SAFE_CLASS_ +class AudioStreamPlaybackOGGVorbis : public AudioStreamPlayback { + OBJ_TYPE(AudioStreamPlaybackOGGVorbis,AudioStreamPlayback); enum { MIN_MIX=1024 @@ -54,9 +53,6 @@ class AudioStreamOGGVorbis : public AudioStreamResampled { static int _ov_close_func(void *_f); static long _ov_tell_func(void *_f); - - virtual bool _can_mix() const; - String file; int64_t frames_mixed; @@ -67,7 +63,7 @@ class AudioStreamOGGVorbis : public AudioStreamResampled { int stream_srate; int current_section; - volatile bool setting_up; + bool paused; bool loops; int repeats; @@ -76,17 +72,21 @@ class AudioStreamOGGVorbis : public AudioStreamResampled { void _clear_stream(); void _close_file(); + bool stream_valid; + float loop_restart_time; -public: +public: - void set_file(const String& p_file); + Error set_file(const String& p_file); - virtual void play(); + 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=0; } + virtual void set_paused(bool p_paused); virtual bool is_paused(bool p_paused) const; @@ -102,11 +102,32 @@ public: virtual float get_pos() const; virtual void seek_pos(float p_time); - virtual UpdateMode get_update_mode() const; - virtual void update(); + 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_bufer,int p_frames); + + AudioStreamPlaybackOGGVorbis(); + ~AudioStreamPlaybackOGGVorbis(); +}; + + +class AudioStreamOGGVorbis : public AudioStream { + + OBJ_TYPE(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; } - AudioStreamOGGVorbis(); - ~AudioStreamOGGVorbis(); }; class ResourceFormatLoaderAudioStreamOGGVorbis : public ResourceFormatLoader { |