2023-04-24 13:45:06 -07:00
|
|
|
#pragma once
|
2023-07-10 12:45:24 -07:00
|
|
|
#include "SDL_mixer.h"
|
2023-04-24 13:45:06 -07:00
|
|
|
#include <thread>
|
|
|
|
#include <string>
|
|
|
|
#include <atomic>
|
|
|
|
#include <mutex>
|
|
|
|
class Playback {
|
|
|
|
private:
|
|
|
|
std::string filePath;
|
|
|
|
std::atomic_bool running;
|
|
|
|
std::atomic_bool file_changed;
|
|
|
|
std::atomic_bool seeking;
|
|
|
|
std::atomic_bool update;
|
|
|
|
std::mutex flag_mutex;
|
|
|
|
std::thread thread;
|
|
|
|
double position;
|
|
|
|
double length;
|
|
|
|
bool paused;
|
2023-07-10 12:45:24 -07:00
|
|
|
Uint8 *buf;
|
|
|
|
size_t bufsize;
|
|
|
|
Mix_Music *Load(const char* file);
|
|
|
|
void Unload(Mix_Music* music);
|
2023-04-24 13:45:06 -07:00
|
|
|
void ThreadFunc();
|
|
|
|
public:
|
|
|
|
Playback();
|
|
|
|
~Playback();
|
|
|
|
double GetPosition();
|
|
|
|
double GetLength();
|
|
|
|
void Seek(double position);
|
|
|
|
void Start(std::string filePath);
|
|
|
|
bool IsPaused();
|
|
|
|
void Pause();
|
|
|
|
void Stop();
|
|
|
|
void Update();
|
|
|
|
bool IsStopped();
|
|
|
|
float volume;
|
|
|
|
float speed;
|
|
|
|
};
|