mirror of
https://github.com/OpenTTD/OpenTTD
synced 2025-12-10 06:52:05 +01:00
Codechange: Auto-reformat fluidsynth.cpp.
This commit is contained in:
committed by
Peter Nelson
parent
8e35553208
commit
2162983054
@@ -8,14 +8,16 @@
|
||||
/** @file fluidsynth.cpp Playing music via the fluidsynth library. */
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../openttd.h"
|
||||
#include "../sound_type.h"
|
||||
#include "../debug.h"
|
||||
|
||||
#include "fluidsynth.h"
|
||||
#include "midifile.hpp"
|
||||
|
||||
#include <fluidsynth.h>
|
||||
#include "../mixer.h"
|
||||
#include <mutex>
|
||||
|
||||
#include "../debug.h"
|
||||
#include "../mixer.h"
|
||||
#include "midifile.hpp"
|
||||
|
||||
#include "../safeguards.h"
|
||||
|
||||
static struct {
|
||||
@@ -53,7 +55,7 @@ static const char *default_sf[] = {
|
||||
|
||||
static void RenderMusicStream(int16_t *buffer, size_t samples)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock{ _midi.synth_mutex, std::try_to_lock };
|
||||
std::unique_lock<std::mutex> lock{_midi.synth_mutex, std::try_to_lock};
|
||||
|
||||
if (!lock.owns_lock() || _midi.synth == nullptr || _midi.player == nullptr) return;
|
||||
fluid_synth_write_s16(_midi.synth, samples, buffer, 0, 2, buffer, 1, 2);
|
||||
@@ -61,7 +63,7 @@ static void RenderMusicStream(int16_t *buffer, size_t samples)
|
||||
|
||||
std::optional<std::string_view> MusicDriver_FluidSynth::Start(const StringList ¶m)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock{ _midi.synth_mutex };
|
||||
std::lock_guard<std::mutex> lock{_midi.synth_mutex};
|
||||
|
||||
auto sfont_name = GetDriverParam(param, "soundfont");
|
||||
int sfont_id;
|
||||
@@ -119,7 +121,7 @@ void MusicDriver_FluidSynth::Stop()
|
||||
{
|
||||
MxSetMusicSource(nullptr);
|
||||
|
||||
std::lock_guard<std::mutex> lock{ _midi.synth_mutex };
|
||||
std::lock_guard<std::mutex> lock{_midi.synth_mutex};
|
||||
|
||||
if (_midi.player != nullptr) delete_fluid_player(_midi.player);
|
||||
_midi.player = nullptr;
|
||||
@@ -141,7 +143,7 @@ void MusicDriver_FluidSynth::PlaySong(const MusicSongInfo &song)
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock{ _midi.synth_mutex };
|
||||
std::lock_guard<std::mutex> lock{_midi.synth_mutex};
|
||||
|
||||
_midi.player = new_fluid_player(_midi.synth);
|
||||
if (_midi.player == nullptr) {
|
||||
@@ -165,7 +167,7 @@ void MusicDriver_FluidSynth::PlaySong(const MusicSongInfo &song)
|
||||
|
||||
void MusicDriver_FluidSynth::StopSong()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock{ _midi.synth_mutex };
|
||||
std::lock_guard<std::mutex> lock{_midi.synth_mutex};
|
||||
|
||||
if (_midi.player == nullptr) return;
|
||||
|
||||
@@ -179,7 +181,7 @@ void MusicDriver_FluidSynth::StopSong()
|
||||
|
||||
bool MusicDriver_FluidSynth::IsSongPlaying()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock{ _midi.synth_mutex };
|
||||
std::lock_guard<std::mutex> lock{_midi.synth_mutex};
|
||||
if (_midi.player == nullptr) return false;
|
||||
|
||||
return fluid_player_get_status(_midi.player) == FLUID_PLAYER_PLAYING;
|
||||
@@ -187,7 +189,7 @@ bool MusicDriver_FluidSynth::IsSongPlaying()
|
||||
|
||||
void MusicDriver_FluidSynth::SetVolume(uint8_t vol)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock{ _midi.synth_mutex };
|
||||
std::lock_guard<std::mutex> lock{_midi.synth_mutex};
|
||||
if (_midi.settings == nullptr) return;
|
||||
|
||||
/* Allowed range of synth.gain is 0.0 to 10.0 */
|
||||
|
||||
Reference in New Issue
Block a user