mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-06-20 19:56:37 +02:00
initial import, >900commits predate this
This commit is contained in:
44
framework/sound/src/mm/services/sound_service.cpp
Normal file
44
framework/sound/src/mm/services/sound_service.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "./sound_service.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <mm/logger.hpp>
|
||||
#define LOG_CRIT(...) __LOG_CRIT( "Sound", __VA_ARGS__)
|
||||
#define LOG_ERROR(...) __LOG_ERROR("Sound", __VA_ARGS__)
|
||||
#define LOG_WARN(...) __LOG_WARN( "Sound", __VA_ARGS__)
|
||||
#define LOG_INFO(...) __LOG_INFO( "Sound", __VA_ARGS__)
|
||||
#define LOG_DEBUG(...) __LOG_DEBUG("Sound", __VA_ARGS__)
|
||||
#define LOG_TRACE(...) __LOG_TRACE("Sound", __VA_ARGS__)
|
||||
|
||||
namespace MM::Services {
|
||||
|
||||
SoundService::SoundService(void) : engine() {
|
||||
MM::Logger::initSectionLogger("Sound");
|
||||
}
|
||||
|
||||
SoundService::~SoundService(void) {
|
||||
}
|
||||
|
||||
bool SoundService::enable(Engine&) {
|
||||
unsigned int flags = SoLoud::Soloud::CLIP_ROUNDOFF;
|
||||
auto r = engine.init(flags);
|
||||
if (r != 0) {
|
||||
LOG_ERROR("SoLoud initialization failed: {}", r);
|
||||
return false;
|
||||
}
|
||||
|
||||
LOG_INFO("SoLoud v{} backend: {}", engine.getVersion(), engine.getBackendString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SoundService::disable(Engine&) {
|
||||
engine.deinit();
|
||||
}
|
||||
|
||||
void SoundService::printErrorString(SoLoud::result errorCode) {
|
||||
LOG_ERROR("error string: {}", engine.getErrorString(errorCode));
|
||||
}
|
||||
|
||||
} // MM::Services
|
||||
|
27
framework/sound/src/mm/services/sound_service.hpp
Normal file
27
framework/sound/src/mm/services/sound_service.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <soloud.h>
|
||||
|
||||
#include <mm/engine.hpp>
|
||||
|
||||
namespace MM::Services {
|
||||
|
||||
class SoundService : public Service {
|
||||
public:
|
||||
SoLoud::Soloud engine;
|
||||
|
||||
public:
|
||||
bool enable(Engine&) override;
|
||||
void disable(Engine&) override;
|
||||
|
||||
const char* name(void) override { return "SoundService"; }
|
||||
|
||||
public:
|
||||
SoundService(void);
|
||||
~SoundService(void);
|
||||
|
||||
void printErrorString(SoLoud::result errorCode);
|
||||
};
|
||||
|
||||
} // MM::Services
|
||||
|
Reference in New Issue
Block a user