Merge branch 'master' of git://github.com/skidoo23/MPD

This commit is contained in:
Max Kellermann
2018-08-14 19:01:22 +02:00
3 changed files with 50 additions and 1 deletions

@@ -1,5 +1,5 @@
/*
* Copyright 2003-2017 The Music Player Daemon Project
* Copyright 2003-2018 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -25,6 +25,10 @@
#include "song/DetachedSong.hxx"
#include "fs/Path.hxx"
#include "fs/AllocatedPath.hxx"
#ifdef HAVE_SIDPLAYFP
#include "fs/io/FileReader.cxx"
#include "util/RuntimeError.hxx"
#endif
#include "util/Macros.hxx"
#include "util/StringFormat.hxx"
#include "util/Domain.hxx"
@@ -65,6 +69,21 @@ static unsigned default_songlength;
static bool filter_setting;
#ifdef HAVE_SIDPLAYFP
static constexpr unsigned rom_size = 8192;
static uint8_t *kernal, *basic = nullptr;
static void loadRom(const Path rom_path, uint8_t *dump)
{
FileReader romDump(rom_path);
if (romDump.Read(dump, rom_size) != rom_size)
{
throw FormatRuntimeError
("Could not load rom dump '%s'", rom_path.c_str());
}
}
#endif
static SidDatabase *
sidplay_load_songlength_db(const Path path)
{
@@ -100,6 +119,24 @@ sidplay_init(const ConfigBlock &block)
filter_setting = block.GetBlockValue("filter", true);
#ifdef HAVE_SIDPLAYFP
/* read kernal rom dump file */
const auto kernal_path = block.GetPath("kernal");
if (!kernal_path.IsNull())
{
kernal = new uint8_t[rom_size];
loadRom(kernal_path, kernal);
}
/* read basic rom dump file */
const auto basic_path = block.GetPath("basic");
if (!basic_path.IsNull())
{
basic = new uint8_t[rom_size];
loadRom(basic_path, basic);
}
#endif
return true;
}
@@ -107,6 +144,11 @@ static void
sidplay_finish() noexcept
{
delete songlength_database;
#ifdef HAVE_SIDPLAYFP
delete[] basic;
delete[] kernal;
#endif
}
struct SidplayContainerPath {
@@ -202,6 +244,8 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
#ifdef HAVE_SIDPLAYFP
sidplayfp player;
player.setRoms(kernal, basic, nullptr);
#else
sidplay2 player;
#endif