Kaynağa Gözat

clean code base

mikymod 12 yıl önce
ebeveyn
işleme
b83aa0fb9a

+ 1 - 1
engine/audio/al/ALRenderer.cpp

@@ -146,7 +146,7 @@ void SoundRenderer::frame()
 	// TODO: needs additional works, but it's ok right now
 	for (uint32_t i = 0; i < m_num_sounds; i++)
 	{
-		if (m_backend->m_sounds[i].m_playing)
+		if (m_backend->m_sounds[i].is_playing())
 		{
 			m_backend->m_sounds[i].update();
 		}

+ 13 - 7
engine/audio/sles/SLESRenderer.cpp

@@ -138,6 +138,8 @@ void SoundRenderer::pause()
 			m_backend->m_sounds[i].pause();
 		}
 	}
+
+	m_is_paused = true;
 }
 
 //-----------------------------------------------------------------------------
@@ -150,12 +152,16 @@ void SoundRenderer::unpause()
 			m_backend->m_sounds[i].unpause();
 		}
 	}
+
+	m_is_paused = false;
 }
 
 //-----------------------------------------------------------------------------
 void SoundRenderer::frame()
 {
-	// not needed right now
+	// Not needed because openSL|ES works through a callback mechanism making
+	// streamed-sound's update tricky with frame function. 
+	// When we will manage phisical aspect of sound then we will implement this.
 }
 
 //-----------------------------------------------------------------------------
@@ -339,19 +345,19 @@ float SoundRenderer::sound_rolloff(SoundId /*id*/) const
 }
 
 //-----------------------------------------------------------------------------
-int32_t SoundRenderer::sound_queued_buffers(SoundId id) const
+int32_t SoundRenderer::sound_queued_buffers(SoundId /*id*/) const
 {
-	CE_ASSERT(m_sounds_id_table.has(id), "Sound does not exist");
-
 	Log::w("Stub");
+
+	return 0;
 }
 
 //-----------------------------------------------------------------------------
-int32_t SoundRenderer::sound_processed_buffers(SoundId id) const
+int32_t SoundRenderer::sound_processed_buffers(SoundId /*id*/) const
 {
-	CE_ASSERT(m_sounds_id_table.has(id), "Sound does not exist");
-
 	Log::w("Stub");
+
+	return 0;
 }
 
 

+ 11 - 166
engine/audio/sles/SLESRenderer.h

@@ -51,7 +51,6 @@ static const char* sles_error_to_string(SLresult result)
 	case SL_RESULT_PERMISSION_DENIED: return "SL_RESULT_PERMISSION_DENIED";
 	case SL_RESULT_BUFFER_INSUFFICIENT: return "SL_RESULT_BUFFER_INSUFFICIENT";
 	default: return "SL_RESULT_UNKNOWN";
-
 	}
 }
 
@@ -73,35 +72,12 @@ struct Sound
 	void 			pause();
 	void			unpause();
 	void 			loop(bool loop);
-	void 			set_min_distance(const float min_distance);
-	void 			set_max_distance( const float max_distance);
-	void 			set_position(const Vec3& pos);
-	void 			set_velocity(const Vec3& vel);
-	void 			set_direction(const Vec3& dir);
-	void 			set_pitch(const float pitch);
-	void 			set_gain(const float gain);
-	void 			set_rolloff(const float rolloff);
-	float 			min_distance() const;
-	float 			max_distance() const;
-	Vec3 			position() const;
-	Vec3 			velocity() const;
-	Vec3 			direction() const;
-	float 			pitch() const;
-	float 			gain() const;
-	float 			rolloff() const;
+
 	bool 			is_created() const;
 	bool 			is_playing() const;
-	int32_t 		queued_buffers();
-	int32_t 		processed_buffers();
 
 	static void 	buffer_callback(SLAndroidSimpleBufferQueueItf caller, void* sound);
 
-private:
-
-	void create_stream();
-
-	void update_stream();
-
 public:
 
 	SoundResource*					m_res;
@@ -156,25 +132,10 @@ inline void Sound::buffer_callback(SLAndroidSimpleBufferQueueItf caller, void* s
 }
 
 //-----------------------------------------------------------------------------
-inline Sound::Sound() : 
-	m_res(NULL),
-
-	m_player_obj(NULL),
-	m_player_play(NULL),
-	m_player_bufferqueue(NULL),
-	m_player_volume(NULL),
-
-	m_processed_buffers(0),
-	m_data(NULL),
-	m_size(0),
-	m_sample_rate(0),
-	m_channels(0),
-	m_bits(0),
-
-	m_created(false),
-	m_playing(false),
-	m_looping(false),
-	m_streaming(false)
+inline Sound::Sound() : m_res(NULL), m_player_obj(NULL), m_player_play(NULL),
+						m_player_bufferqueue(NULL), m_player_volume(NULL), m_processed_buffers(0),
+						m_data(NULL), m_size(0), m_sample_rate(0), m_channels(0), m_bits(0),
+						m_created(false), m_playing(false),	m_looping(false), m_streaming(false)
 {
 }
 
@@ -313,7 +274,7 @@ inline void Sound::create(SLEngineItf engine, SLObjectItf out_mix_obj, SoundReso
 //-----------------------------------------------------------------------------
 inline void Sound::update()
 {
-	// nothing
+	// See SLESRenderer.cpp, row 160
 }
 
 //-----------------------------------------------------------------------------
@@ -376,131 +337,15 @@ inline void Sound::loop(bool loop)
 }
 
 //-----------------------------------------------------------------------------
-inline bool Sound::is_playing() const
-{
-	// SLuint32 state;
-	// (*m_player_play)->GetPlayState(m_player_play, &state);
-	// return state == SL_PLAYSTATE_PLAYING;
-
-	return m_playing;
-}
-
-//-----------------------------------------------------------------------------
-inline void Sound::set_min_distance(const float min_distance)
-{
-	Log::w("stub");
-}
-
-//-----------------------------------------------------------------------------
-inline void Sound::set_max_distance( const float max_distance)
-{
-	Log::w("stub");
-}
-
-//-----------------------------------------------------------------------------
-inline void Sound::set_position(const Vec3& pos)
-{
-	Log::w("stub");
-}
-
-//-----------------------------------------------------------------------------
-inline void Sound::set_velocity(const Vec3& vel)
-{
-	Log::w("stub");
-}
-
-//-----------------------------------------------------------------------------
-inline void Sound::set_direction(const Vec3& dir)
-{
-	Log::w("stub");
-}
-
-//-----------------------------------------------------------------------------
-inline void Sound::set_pitch(const float pitch)
-{
-	Log::w("stub");
-}
-
-//-----------------------------------------------------------------------------
-inline void Sound::set_gain(const float gain)
-{
-	Log::w("stub");
-}
-
-//-----------------------------------------------------------------------------
-inline void Sound::set_rolloff(const float rolloff)
-{
-	Log::w("stub");
-}
-
-//-----------------------------------------------------------------------------
-inline float Sound::min_distance() const
-{
-	Log::w("stub");
-
-	return 0;
-}
-
-//-----------------------------------------------------------------------------
-inline float Sound::max_distance() const
-{
-	Log::w("stub");
-
-	return 0;
-}
-
-//-----------------------------------------------------------------------------
-inline Vec3 Sound::position() const
-{
-	Log::w("stub");
-
-	return Vec3::ZERO;
-}
-
-//-----------------------------------------------------------------------------
-inline Vec3 Sound::velocity() const
-{
-	Log::w("stub");
-
-	return Vec3::ZERO;
-}
-
-//-----------------------------------------------------------------------------
-inline Vec3 Sound::direction() const
-{
-	Log::w("stub");
-
-	return Vec3::ZERO;
-}
-
-//-----------------------------------------------------------------------------
-inline float Sound::pitch() const
-{
-	Log::w("stub");
-
-	return 0;
-}
-
-//-----------------------------------------------------------------------------
-inline float Sound::gain() const
-{
-	Log::w("stub");
-
-	return 0;
-}
-
-//-----------------------------------------------------------------------------
-inline float Sound::rolloff() const
+bool Sound::is_created() const
 {
-	Log::w("stub");
-
-	return 0;
+	return m_created;
 }
 
 //-----------------------------------------------------------------------------
-bool Sound::is_created() const
+inline bool Sound::is_playing() const
 {
-	return m_created;
+	return m_playing;
 }
 
-}// namespace crown
+} // namespace crown