summaryrefslogtreecommitdiff
path: root/scene/audio
diff options
context:
space:
mode:
Diffstat (limited to 'scene/audio')
-rw-r--r--scene/audio/event_player.cpp12
-rw-r--r--scene/audio/event_player.h2
-rw-r--r--scene/audio/sample_player.cpp2
-rw-r--r--scene/audio/sample_player.h2
-rw-r--r--scene/audio/sound_room_params.cpp2
-rw-r--r--scene/audio/sound_room_params.h2
-rw-r--r--scene/audio/stream_player.cpp16
-rw-r--r--scene/audio/stream_player.h3
8 files changed, 24 insertions, 17 deletions
diff --git a/scene/audio/event_player.cpp b/scene/audio/event_player.cpp
index 1bd692431d..b49b285f76 100644
--- a/scene/audio/event_player.cpp
+++ b/scene/audio/event_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -312,16 +312,14 @@ void EventPlayer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_pos"),&EventPlayer::get_pos);
ObjectTypeDB::bind_method(_MD("seek_pos","time"),&EventPlayer::seek_pos);
+ ObjectTypeDB::bind_method(_MD("get_length"),&EventPlayer::get_length);
+
ObjectTypeDB::bind_method(_MD("set_autoplay","enabled"),&EventPlayer::set_autoplay);
ObjectTypeDB::bind_method(_MD("has_autoplay"),&EventPlayer::has_autoplay);
ObjectTypeDB::bind_method(_MD("set_channel_volume","idx","channel_volume"),&EventPlayer::set_channel_volume);
- ObjectTypeDB::bind_method(_MD("get_channel_volume""idx"),&EventPlayer::get_channel_volume);
-
- ObjectTypeDB::bind_method(_MD("get_length"),&EventPlayer::get_length);
-
-
- ObjectTypeDB::bind_method(_MD("get_channel_last_note_time"),&EventPlayer::get_channel_last_note_time);
+ ObjectTypeDB::bind_method(_MD("get_channel_volume","idx"),&EventPlayer::get_channel_volume);
+ ObjectTypeDB::bind_method(_MD("get_channel_last_note_time","idx"),&EventPlayer::get_channel_last_note_time);
ObjectTypeDB::bind_method(_MD("_set_play","play"),&EventPlayer::_set_play);
ObjectTypeDB::bind_method(_MD("_get_play"),&EventPlayer::_get_play);
diff --git a/scene/audio/event_player.h b/scene/audio/event_player.h
index 05e78040d2..c04e85fe77 100644
--- a/scene/audio/event_player.h
+++ b/scene/audio/event_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/audio/sample_player.cpp b/scene/audio/sample_player.cpp
index 7c0a926324..d7605ed1a9 100644
--- a/scene/audio/sample_player.cpp
+++ b/scene/audio/sample_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/audio/sample_player.h b/scene/audio/sample_player.h
index 75a01aff86..1821c671dc 100644
--- a/scene/audio/sample_player.h
+++ b/scene/audio/sample_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/audio/sound_room_params.cpp b/scene/audio/sound_room_params.cpp
index 8886113e03..bb2285c97f 100644
--- a/scene/audio/sound_room_params.cpp
+++ b/scene/audio/sound_room_params.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/audio/sound_room_params.h b/scene/audio/sound_room_params.h
index 8af2ae8c12..4ca1eae2ce 100644
--- a/scene/audio/sound_room_params.h
+++ b/scene/audio/sound_room_params.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/audio/stream_player.cpp b/scene/audio/stream_player.cpp
index 4cfca0492a..f7cfc31b03 100644
--- a/scene/audio/stream_player.cpp
+++ b/scene/audio/stream_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -58,7 +58,7 @@ void StreamPlayer::sp_set_mix_rate(int p_rate){
bool StreamPlayer::sp_mix(int32_t *p_buffer,int p_frames) {
- if (resampler.is_ready()) {
+ if (resampler.is_ready() && !paused) {
return resampler.mix(p_buffer,p_frames);
}
@@ -75,7 +75,10 @@ void StreamPlayer::sp_update() {
//check that all this audio has been flushed before stopping the stream
int to_mix = resampler.get_total() - resampler.get_todo();
if (to_mix==0) {
- stop();
+ if (!stop_request) {
+ stop_request=true;
+ call_deferred("stop");
+ }
return;
}
@@ -164,8 +167,10 @@ void StreamPlayer::stop() {
//_THREAD_SAFE_METHOD_
AudioServer::get_singleton()->stream_set_active(stream_rid,false);
+ stop_request=false;
playback->stop();
resampler.flush();
+ emit_signal("finished");
//set_idle_process(false);
}
@@ -329,7 +334,7 @@ void StreamPlayer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_stream","stream:Stream"),&StreamPlayer::set_stream);
ObjectTypeDB::bind_method(_MD("get_stream:Stream"),&StreamPlayer::get_stream);
- ObjectTypeDB::bind_method(_MD("play"),&StreamPlayer::play,DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("play","offset"),&StreamPlayer::play,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("stop"),&StreamPlayer::stop);
ObjectTypeDB::bind_method(_MD("is_playing"),&StreamPlayer::is_playing);
@@ -374,6 +379,8 @@ void StreamPlayer::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused") );
ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/loop_restart_time"), _SCS("set_loop_restart_time"), _SCS("get_loop_restart_time") );
ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/buffering_ms"), _SCS("set_buffering_msec"), _SCS("get_buffering_msec") );
+
+ ADD_SIGNAL(MethodInfo("finished"));
}
@@ -389,6 +396,7 @@ StreamPlayer::StreamPlayer() {
stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream);
buffering_ms=500;
loop_point=0;
+ stop_request=false;
}
diff --git a/scene/audio/stream_player.h b/scene/audio/stream_player.h
index be090f50e1..30840137e2 100644
--- a/scene/audio/stream_player.h
+++ b/scene/audio/stream_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -66,6 +66,7 @@ class StreamPlayer : public Node {
float volume;
float loop_point;
int buffering_ms;
+ volatile bool stop_request;
AudioRBResampler resampler;