Kelsidavis-WoWee/include/audio/music_manager.hpp
Kelsi 6bf3fa4ed4 Add Windows cross-platform support alongside Linux
Replace POSIX-specific socket and process APIs with portable
abstractions so the project builds on both Windows and Linux.

- Add include/network/net_platform.hpp: Winsock2/POSIX socket
  abstraction (socket types, non-blocking, error handling,
  WSAStartup lifecycle)
- Add include/platform/process.hpp: CreateProcess/fork+exec
  abstraction for spawning ffplay subprocesses
- Update network module (tcp_socket, world_socket) to use
  portable socket helpers instead of raw POSIX calls
- Update audio module (music_manager, footstep_manager,
  activity_sound_manager) to use portable process helpers
  instead of fork/exec/kill/waitpid
- Replace hardcoded /tmp/ paths with std::filesystem::temp_directory_path()
- Link ws2_32 and SDL2main on Windows in CMakeLists.txt
2026-02-03 22:25:41 -08:00

46 lines
1.1 KiB
C++

#pragma once
#include "platform/process.hpp"
#include <string>
#include <vector>
namespace wowee {
namespace pipeline { class AssetManager; }
namespace audio {
class MusicManager {
public:
MusicManager();
~MusicManager();
bool initialize(pipeline::AssetManager* assets);
void shutdown();
void playMusic(const std::string& mpqPath, bool loop = true);
void stopMusic(float fadeMs = 2000.0f);
void crossfadeTo(const std::string& mpqPath, float fadeMs = 3000.0f);
void update(float deltaTime);
bool isPlaying() const { return playing; }
bool isInitialized() const { return assetManager != nullptr; }
const std::string& getCurrentTrack() const { return currentTrack; }
private:
void stopCurrentProcess();
pipeline::AssetManager* assetManager = nullptr;
std::string currentTrack;
std::string tempFilePath;
ProcessHandle playerPid = INVALID_PROCESS;
bool playing = false;
// Crossfade state
bool crossfading = false;
std::string pendingTrack;
float fadeTimer = 0.0f;
float fadeDuration = 0.0f;
};
} // namespace audio
} // namespace wowee