Add audio callback profiling
This commit is contained in:
parent
a80487abbc
commit
81fabbbf02
3 changed files with 11 additions and 1 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
#include <psemek/util/to_string.hpp>
|
#include <psemek/util/to_string.hpp>
|
||||||
#include <psemek/geom/constants.hpp>
|
#include <psemek/geom/constants.hpp>
|
||||||
#include <psemek/geom/camera.hpp>
|
#include <psemek/geom/camera.hpp>
|
||||||
|
#include <psemek/prof/profiler.hpp>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
@ -121,6 +122,11 @@ struct audio_app
|
||||||
painter_.render(geom::window_camera{width(), height()}.transform());
|
painter_.render(geom::window_camera{width(), height()}.transform());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void on_scene_exit() override
|
||||||
|
{
|
||||||
|
prof::dump();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
audio::engine engine_;
|
audio::engine engine_;
|
||||||
audio::mixer_ptr mixer_;
|
audio::mixer_ptr mixer_;
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@ file(GLOB_RECURSE PSEMEK_AUDIO_SOURCES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "s
|
||||||
|
|
||||||
psemek_add_library(psemek-audio ${PSEMEK_AUDIO_HEADERS} ${PSEMEK_AUDIO_SOURCES})
|
psemek_add_library(psemek-audio ${PSEMEK_AUDIO_HEADERS} ${PSEMEK_AUDIO_SOURCES})
|
||||||
target_include_directories(psemek-audio PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
target_include_directories(psemek-audio PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||||
target_link_libraries(psemek-audio PUBLIC psemek-sdl2 psemek-geom psemek-util psemek-log SDL2_mixer)
|
target_link_libraries(psemek-audio PUBLIC psemek-sdl2 psemek-geom psemek-util psemek-log psemek-prof SDL2_mixer)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include <psemek/audio/constants.hpp>
|
#include <psemek/audio/constants.hpp>
|
||||||
#include <psemek/sdl2/init.hpp>
|
#include <psemek/sdl2/init.hpp>
|
||||||
#include <psemek/log/log.hpp>
|
#include <psemek/log/log.hpp>
|
||||||
|
#include <psemek/prof/profiler.hpp>
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
|
|
@ -60,6 +61,9 @@ namespace psemek::audio
|
||||||
|
|
||||||
void engine::impl::callback(void * userdata, std::uint8_t * dst_u8, int len)
|
void engine::impl::callback(void * userdata, std::uint8_t * dst_u8, int len)
|
||||||
{
|
{
|
||||||
|
static std::string const profiler_str = "audio";
|
||||||
|
prof::profiler prof(profiler_str);
|
||||||
|
|
||||||
auto self = static_cast<impl *>(userdata);
|
auto self = static_cast<impl *>(userdata);
|
||||||
stream_ptr output = self->output->stream();
|
stream_ptr output = self->output->stream();
|
||||||
std::int16_t * dst = reinterpret_cast<std::int16_t *>(dst_u8);
|
std::int16_t * dst = reinterpret_cast<std::int16_t *>(dst_u8);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue