Skip to content

Commit

Permalink
add sdl to cmake via package find
Browse files Browse the repository at this point in the history
  • Loading branch information
Crylia committed Mar 26, 2024
1 parent bcc2c1f commit 934b10d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET
libavutil
)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
find_package(SDL2 REQUIRED CONFIG)

file(GLOB_RECURSE PROJECT_SOURCES src/*.cpp)
file(GLOB_RECURSE PROJECT_HEADERS src/*.h)
Expand All @@ -47,6 +48,7 @@ target_link_libraries(CryliaPlayer PRIVATE
${SDL_IMAGE_LIBRARY}
${SDL_MIXER_LIBRARY}
PkgConfig::LIBAV
${SDL2}
)

install(TARGETS CryliaPlayer
Expand Down
5 changes: 4 additions & 1 deletion src/core/audio/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ void Audio::StopMusic( ) {
}

void Audio::PlaySong(const std::string path) {
if (music)
Mix_FreeMusic(music);

this->path = path;

music = Mix_LoadMUS(path.c_str( ));
Expand All @@ -55,7 +58,7 @@ void Audio::ResumeMusic( ) {
}

bool Audio::IsMusicPlaying( ) {
return Mix_PlayingMusic( );
return (Mix_PlayingMusic( ) != 0);
}

std::string Audio::GetTitle( ) {
Expand Down

0 comments on commit 934b10d

Please sign in to comment.