mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-27 15:30:35 +00:00
4f43cff5ca
* Move and rename file_util/fd_util to Common/File/FileUtil and DirListing Let's also move net while we're at it. Move the ZIM/PNG loaders over to Common. Move the UI framework into Common iOS buildfix * Buildfix * Buildfixes * Apple buildfix * This typo again.. * UWP buildfix * Fix build of PPSSPPQt, such as it is (it's not in good condition...) * Guess what? Another buildfix.
64 lines
1.1 KiB
C++
64 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <mutex>
|
|
#include <vector>
|
|
|
|
#include "Common/UI/Root.h"
|
|
|
|
class AT3PlusReader;
|
|
|
|
class BackgroundAudio {
|
|
public:
|
|
BackgroundAudio();
|
|
~BackgroundAudio();
|
|
|
|
void Clear(bool hard);
|
|
void SetGame(const std::string &path);
|
|
void Update();
|
|
int Play();
|
|
|
|
void LoadSamples();
|
|
void PlaySFX(UI::UISound sfx);
|
|
|
|
private:
|
|
enum {
|
|
BUFSIZE = 44100,
|
|
};
|
|
|
|
std::mutex mutex_;
|
|
std::string bgGamePath_;
|
|
int playbackOffset_ = 0;
|
|
AT3PlusReader *at3Reader_;
|
|
double gameLastChanged_ = 0.0;
|
|
double lastPlaybackTime_ = 0.0;
|
|
int *buffer = nullptr;
|
|
bool fadingOut_ = true;
|
|
float volume_ = 0.0f;
|
|
float delta_ = -0.0001f;
|
|
|
|
struct PlayInstance {
|
|
UI::UISound sound;
|
|
int offset;
|
|
int volume; // 0..255
|
|
bool done;
|
|
};
|
|
|
|
struct Sample {
|
|
// data must be new-ed.
|
|
Sample(int16_t *data, int length) : data_(data), length_(length) {}
|
|
~Sample() {
|
|
delete[] data_;
|
|
}
|
|
int16_t *data_;
|
|
int length_; // stereo samples.
|
|
};
|
|
|
|
static Sample *LoadSample(const std::string &path);
|
|
|
|
std::vector<PlayInstance> plays_;
|
|
std::vector<std::unique_ptr<Sample>> samples_;
|
|
};
|
|
|
|
extern BackgroundAudio g_BackgroundAudio;
|