Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AudioStreamPlayerInternal to unify stream players #87061

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
262 changes: 50 additions & 212 deletions scene/2d/audio_stream_player_2d.cpp

Large diffs are not rendered by default.

29 changes: 6 additions & 23 deletions scene/2d/audio_stream_player_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
#define AUDIO_STREAM_PLAYER_2D_H

#include "scene/2d/node_2d.h"
#include "scene/scene_string_names.h"
#include "servers/audio/audio_stream.h"
#include "servers/audio_server.h"

struct AudioFrame;
class AudioStream;
class AudioStreamPlayback;
class AudioStreamPlayerInternal;

class AudioStreamPlayer2D : public Node2D {
GDCLASS(AudioStreamPlayer2D, Node2D);
Expand All @@ -52,10 +54,8 @@ class AudioStreamPlayer2D : public Node2D {
Viewport *viewport = nullptr; //pointer only used for reference to previous mix
};

Vector<Ref<AudioStreamPlayback>> stream_playbacks;
Ref<AudioStream> stream;
AudioStreamPlayerInternal *internal = nullptr;

SafeFlag active{ false };
SafeNumeric<float> setplay{ -1.0 };
Ref<AudioStreamPlayback> setplayback;

Expand All @@ -64,21 +64,12 @@ class AudioStreamPlayer2D : public Node2D {
uint64_t last_mix_count = -1;
bool force_update_panning = false;

float volume_db = 0.0;
float pitch_scale = 1.0;
bool autoplay = false;
StringName default_bus = SceneStringNames::get_singleton()->Master;
int max_polyphony = 1;

void _set_playing(bool p_enable);
bool _is_active() const;

KoBeWi marked this conversation as resolved.
Show resolved Hide resolved
StringName _get_actual_bus();
void _update_panning();

void _on_bus_layout_changed();
void _on_bus_renamed(int p_bus_index, const StringName &p_old_name, const StringName &p_new_name);

static void _listener_changed_cb(void *self) { reinterpret_cast<AudioStreamPlayer2D *>(self)->force_update_panning = true; }

uint32_t area_mask = 1;
Expand All @@ -89,14 +80,6 @@ class AudioStreamPlayer2D : public Node2D {
float panning_strength = 1.0f;
float cached_global_panning_strength = 0.5f;

struct ParameterData {
StringName path;
Variant value;
};

HashMap<StringName, ParameterData> playback_parameters;
void _update_stream_parameters();

protected:
void _validate_property(PropertyInfo &p_property) const;
void _notification(int p_what);
Expand Down
Loading
Loading