Main.cxx 16 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright 2003-2017 The Music Player Daemon Project
3
 * http://www.musicpd.org
Warren Dukes's avatar
Warren Dukes committed
4 5 6 7 8 9 10 11 12 13
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
14 15 16 17
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Warren Dukes's avatar
Warren Dukes committed
18 19
 */

20
#include "config.h"
Max Kellermann's avatar
Max Kellermann committed
21
#include "Main.hxx"
22
#include "Instance.hxx"
Max Kellermann's avatar
Max Kellermann committed
23
#include "CommandLine.hxx"
Max Kellermann's avatar
Max Kellermann committed
24
#include "PlaylistFile.hxx"
25
#include "MusicChunk.hxx"
26
#include "StateFile.hxx"
27
#include "player/Thread.hxx"
Max Kellermann's avatar
Max Kellermann committed
28
#include "Mapper.hxx"
29
#include "Permission.hxx"
Max Kellermann's avatar
Max Kellermann committed
30
#include "Listen.hxx"
31 32
#include "client/Client.hxx"
#include "client/ClientList.hxx"
33
#include "command/AllCommands.hxx"
34
#include "Partition.hxx"
35
#include "tag/Config.hxx"
36
#include "ReplayGainGlobal.hxx"
Max Kellermann's avatar
Max Kellermann committed
37
#include "Idle.hxx"
38
#include "Log.hxx"
39
#include "LogInit.hxx"
Max Kellermann's avatar
Max Kellermann committed
40
#include "input/Init.hxx"
41
#include "event/Loop.hxx"
42
#include "fs/AllocatedPath.hxx"
43
#include "fs/Config.hxx"
44
#include "playlist/PlaylistRegistry.hxx"
45
#include "zeroconf/ZeroconfGlue.hxx"
46
#include "decoder/DecoderList.hxx"
47
#include "AudioParser.hxx"
48
#include "pcm/PcmConvert.hxx"
49
#include "unix/SignalHandlers.hxx"
50
#include "system/FatalError.hxx"
51
#include "thread/Slack.hxx"
52
#include "lib/icu/Init.hxx"
53
#include "config/ConfigGlobal.hxx"
54
#include "config/Param.hxx"
55 56
#include "config/ConfigDefaults.hxx"
#include "config/ConfigOption.hxx"
57
#include "config/ConfigError.hxx"
58
#include "util/RuntimeError.hxx"
Max Kellermann's avatar
Max Kellermann committed
59

60 61 62 63
#ifdef ENABLE_DAEMON
#include "unix/Daemon.hxx"
#endif

64 65
#ifdef ENABLE_DATABASE
#include "db/update/Service.hxx"
66
#include "db/Configured.hxx"
67
#include "db/DatabasePlugin.hxx"
68
#include "db/plugins/simple/SimpleDatabasePlugin.hxx"
69
#include "storage/Configured.hxx"
70
#include "storage/CompositeStorage.hxx"
71 72 73
#ifdef ENABLE_INOTIFY
#include "db/update/InotifyUpdate.hxx"
#endif
74 75
#endif

76 77 78 79
#ifdef ENABLE_NEIGHBOR_PLUGINS
#include "neighbor/Glue.hxx"
#endif

80
#ifdef ENABLE_SQLITE
81
#include "sticker/StickerDatabase.hxx"
82 83
#endif

84
#ifdef ENABLE_ARCHIVE
85
#include "archive/ArchiveList.hxx"
86
#endif
Max Kellermann's avatar
Max Kellermann committed
87

Max Kellermann's avatar
Max Kellermann committed
88
#ifdef ANDROID
89 90
#include "java/Global.hxx"
#include "java/File.hxx"
91
#include "android/Environment.hxx"
92
#include "android/Context.hxx"
93
#include "fs/StandardDirectory.hxx"
94
#include "fs/FileSystem.hxx"
Max Kellermann's avatar
Max Kellermann committed
95 96 97
#include "org_musicpd_Bridge.h"
#endif

98 99 100 101
#ifdef ENABLE_SYSTEMD_DAEMON
#include <systemd/sd-daemon.h>
#endif

Max Kellermann's avatar
Max Kellermann committed
102
#include <stdlib.h>
103

104
#ifdef HAVE_LOCALE_H
105 106 107
#include <locale.h>
#endif

108 109 110 111 112
#ifdef WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#endif

113
#ifdef __BLOCKS__
114 115 116
#include <dispatch/dispatch.h>
#endif

117 118
#include <limits.h>

119
static constexpr unsigned DEFAULT_BUFFER_SIZE = 4096;
120
static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10;
Max Kellermann's avatar
Max Kellermann committed
121

122 123 124 125
#ifdef ANDROID
Context *context;
#endif

126
Instance *instance;
127

128
struct Config {
129
	ReplayGainConfig replay_gain;
130 131 132 133 134 135
};

gcc_const
static Config
LoadConfig()
{
136
	return {LoadReplayGainConfig()};
137 138
}

139
#ifdef ENABLE_DAEMON
140

141 142
static void
glue_daemonize_init(const struct options *options)
143
{
144 145
	daemonize_init(config_get_string(ConfigOption::USER, nullptr),
		       config_get_string(ConfigOption::GROUP, nullptr),
146
		       config_get_path(ConfigOption::PID_FILE));
147 148 149 150 151

	if (options->kill)
		daemonize_kill();
}

152 153
#endif

154 155
static void
glue_mapper_init()
156
{
157
	mapper_init(config_get_path(ConfigOption::PLAYLIST_DIR));
158
}
159

160 161
#ifdef ENABLE_DATABASE

162
static void
163
InitStorage(EventLoop &event_loop)
164
{
165
	Storage *storage = CreateConfiguredStorage(event_loop);
166
	if (storage == nullptr)
167
		return;
168 169 170 171

	CompositeStorage *composite = new CompositeStorage();
	instance->storage = composite;
	composite->Mount("", storage);
172 173
}

174 175 176 177 178 179
/**
 * Returns the database.  If this function returns false, this has not
 * succeeded, and the caller should create the database after the
 * process has been daemonized.
 */
static bool
180
glue_db_init_and_load(void)
181
{
182
	instance->database =
183 184 185
		CreateConfiguredDatabase(instance->event_loop, *instance);
	if (instance->database == nullptr)
		return true;
186

187
	if (instance->database->GetPlugin().flags & DatabasePlugin::FLAG_REQUIRE_STORAGE) {
188
		InitStorage(instance->io_thread.GetEventLoop());
189

190 191 192 193 194 195 196 197 198 199 200 201 202
		if (instance->storage == nullptr) {
			delete instance->database;
			instance->database = nullptr;
			LogDefault(config_domain,
				   "Found database setting without "
				   "music_directory - disabling database");
			return true;
		}
	} else {
		if (IsStorageConfigured())
			LogDefault(config_domain,
				   "Ignoring the storage configuration "
				   "because the database does not need it");
203 204
	}

205 206 207 208 209
	try {
		instance->database->Open();
	} catch (...) {
		std::throw_with_nested(std::runtime_error("Failed to open database plugin"));
	}
210

211
	if (!instance->database->IsPlugin(simple_db_plugin))
212 213
		return true;

214
	SimpleDatabase &db = *(SimpleDatabase *)instance->database;
215
	instance->update = new UpdateService(instance->event_loop, db,
Max Kellermann's avatar
Max Kellermann committed
216
					     static_cast<CompositeStorage &>(*instance->storage),
217
					     *instance);
218

219
	/* run database update after daemonization? */
220
	return db.FileExists();
Warren Dukes's avatar
Warren Dukes committed
221
}
Warren Dukes's avatar
Warren Dukes committed
222

223 224 225 226 227 228 229
static bool
InitDatabaseAndStorage()
{
	const bool create_db = !glue_db_init_and_load();
	return create_db;
}

230 231
#endif

232 233 234 235
/**
 * Configure and initialize the sticker subsystem.
 */
static void
236
glue_sticker_init()
237 238
{
#ifdef ENABLE_SQLITE
239 240
	auto sticker_file = config_get_path(ConfigOption::STICKER_FILE);
	if (sticker_file.IsNull())
241
		return;
242

243
	sticker_global_init(std::move(sticker_file));
244 245 246
#endif
}

247 248
static void
glue_state_file_init()
249
{
250
	auto path_fs = config_get_path(ConfigOption::STATE_FILE);
251 252 253 254
	if (path_fs.IsNull()) {
#ifdef ANDROID
		const auto cache_dir = GetUserCacheDir();
		if (cache_dir.IsNull())
255
			return;
256 257 258

		path_fs = AllocatedPath::Build(cache_dir, "state");
#else
259
		return;
260 261
#endif
	}
262

263
	const auto interval =
264 265
		config_get_unsigned(ConfigOption::STATE_FILE_INTERVAL,
				    StateFile::DEFAULT_INTERVAL);
266

267
	instance->state_file = new StateFile(std::move(path_fs), interval,
268
					     instance->partitions.front(),
269 270
					     instance->event_loop);
	instance->state_file->Read();
271 272
}

273 274 275 276 277
/**
 * Windows-only initialization of the Winsock2 library.
 */
static void winsock_init(void)
{
278
#ifdef WIN32
279 280
	WSADATA sockinfo;

281
	int retval = WSAStartup(MAKEWORD(2, 2), &sockinfo);
282
	if(retval != 0)
283 284
		FormatFatalError("Attempt to open Winsock2 failed; error code %d",
				 retval);
285 286

	if (LOBYTE(sockinfo.wVersion) != 2)
287 288
		FatalError("We use Winsock2 but your version is either too new "
			   "or old; please install Winsock 2.x");
289
#endif
290
}
291

Max Kellermann's avatar
Max Kellermann committed
292 293 294 295
/**
 * Initialize the decoder and player core, including the music pipe.
 */
static void
296
initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config)
Max Kellermann's avatar
Max Kellermann committed
297
{
298
	const ConfigParam *param;
Max Kellermann's avatar
Max Kellermann committed
299

300
	size_t buffer_size;
301
	param = config_get_param(ConfigOption::AUDIO_BUFFER_SIZE);
302
	if (param != nullptr) {
303
		char *test;
304
		long tmp = strtol(param->value.c_str(), &test, 10);
305
		if (*test != '\0' || tmp <= 0 || tmp == LONG_MAX)
306 307
			FormatFatalError("buffer size \"%s\" is not a "
					 "positive integer, line %i",
308
					 param->value.c_str(), param->line);
309
		buffer_size = tmp;
Max Kellermann's avatar
Max Kellermann committed
310 311 312 313 314
	} else
		buffer_size = DEFAULT_BUFFER_SIZE;

	buffer_size *= 1024;

315
	const unsigned buffered_chunks = buffer_size / CHUNK_SIZE;
Max Kellermann's avatar
Max Kellermann committed
316 317

	if (buffered_chunks >= 1 << 15)
318 319
		FormatFatalError("buffer size \"%lu\" is too big",
				 (unsigned long)buffer_size);
Max Kellermann's avatar
Max Kellermann committed
320

321
	float perc;
322
	param = config_get_param(ConfigOption::BUFFER_BEFORE_PLAY);
323
	if (param != nullptr) {
324
		char *test;
325
		perc = strtod(param->value.c_str(), &test);
Max Kellermann's avatar
Max Kellermann committed
326
		if (*test != '%' || perc < 0 || perc > 100) {
327 328 329
			FormatFatalError("buffered before play \"%s\" is not "
					 "a positive percentage and less "
					 "than 100 percent, line %i",
330
					 param->value.c_str(), param->line);
Max Kellermann's avatar
Max Kellermann committed
331 332 333 334
		}
	} else
		perc = DEFAULT_BUFFER_BEFORE_PLAY;

335
	unsigned buffered_before_play = (perc / 100) * buffered_chunks;
Max Kellermann's avatar
Max Kellermann committed
336 337 338
	if (buffered_before_play > buffered_chunks)
		buffered_before_play = buffered_chunks;

339
	const unsigned max_length =
340
		config_get_positive(ConfigOption::MAX_PLAYLIST_LENGTH,
341 342
				    DEFAULT_PLAYLIST_MAX_LENGTH);

343 344 345 346 347 348 349 350 351 352 353 354
	AudioFormat configured_audio_format = AudioFormat::Undefined();
	param = config_get_param(ConfigOption::AUDIO_OUTPUT_FORMAT);
	if (param != nullptr) {
		try {
			configured_audio_format = ParseAudioFormat(param->value.c_str(),
								   true);
		} catch (const std::runtime_error &) {
			std::throw_with_nested(FormatRuntimeError("error parsing line %i",
								  param->line));
		}
	}

355 356 357 358 359 360 361 362
	instance->partitions.emplace_back(*instance,
					  "default",
					  max_length,
					  buffered_chunks,
					  buffered_before_play,
					  configured_audio_format,
					  replay_gain_config);
	auto &partition = instance->partitions.back();
363 364 365 366

	try {
		param = config_get_param(ConfigOption::REPLAYGAIN);
		if (param != nullptr)
367
			partition.replay_gain_mode =
368 369 370 371 372
				FromString(param->value.c_str());
	} catch (...) {
		std::throw_with_nested(FormatRuntimeError("Failed to parse line %i",
							  param->line));
	}
Max Kellermann's avatar
Max Kellermann committed
373 374
}

375 376
void
Instance::OnIdle(unsigned flags)
377
{
Max Kellermann's avatar
Max Kellermann committed
378
	/* send "idle" notifications to all subscribed
379
	   clients */
380
	client_list->IdleAdd(flags);
381

382
	if (flags & (IDLE_PLAYLIST|IDLE_PLAYER|IDLE_MIXER|IDLE_OUTPUT) &&
383 384
	    state_file != nullptr)
		state_file->CheckModified();
385 386
}

Max Kellermann's avatar
Max Kellermann committed
387 388
#ifndef ANDROID

389
int main(int argc, char *argv[])
390 391 392 393 394 395 396 397
{
#ifdef WIN32
	return win32_main(argc, argv);
#else
	return mpd_main(argc, argv);
#endif
}

Max Kellermann's avatar
Max Kellermann committed
398 399
#endif

400
static int
401
mpd_main_after_fork(const Config &config);
402

403 404 405
#ifdef ANDROID
static inline
#endif
406
int mpd_main(int argc, char *argv[])
407
try {
Max Kellermann's avatar
Max Kellermann committed
408
	struct options options;
Warren Dukes's avatar
Warren Dukes committed
409

410
#ifdef ENABLE_DAEMON
411
	daemonize_close_stdin();
412
#endif
413

414
#ifndef ANDROID
415
#ifdef HAVE_LOCALE_H
416 417
	/* initialize locale */
	setlocale(LC_CTYPE,"");
418
	setlocale(LC_COLLATE, "");
419
#endif
420
#endif
Max Kellermann's avatar
Max Kellermann committed
421

422
	IcuInit();
423

424
	winsock_init();
425
	config_global_init();
Warren Dukes's avatar
Warren Dukes committed
426

427
#ifdef ANDROID
428 429 430 431 432 433 434 435 436 437
	(void)argc;
	(void)argv;

	const auto sdcard = Environment::getExternalStorageDirectory();
	if (!sdcard.IsNull()) {
		const auto config_path =
			AllocatedPath::Build(sdcard, "mpd.conf");
		if (FileExists(config_path))
			ReadConfigFile(config_path);
	}
438
#else
439
	ParseCommandLine(argc, argv, &options);
440
#endif
Warren Dukes's avatar
Warren Dukes committed
441

442 443
	const auto config = LoadConfig();

444
#ifdef ENABLE_DAEMON
445
	glue_daemonize_init(&options);
446
#endif
447

448
	TagLoadConfig();
449

450
	log_init(options.verbose, options.log_stderr);
451

452 453
	instance = new Instance();

454 455
#ifdef ENABLE_NEIGHBOR_PLUGINS
	instance->neighbors = new NeighborGlue();
456 457
	instance->neighbors->Init(instance->io_thread.GetEventLoop(),
				  *instance);
458 459 460 461 462 463 464

	if (instance->neighbors->IsEmpty()) {
		delete instance->neighbors;
		instance->neighbors = nullptr;
	}
#endif

465 466
	const unsigned max_clients =
		config_get_positive(ConfigOption::MAX_CONN, 10);
467
	instance->client_list = new ClientList(max_clients);
468

469
	initialize_decoder_and_player(config.replay_gain);
470

471
	listen_global_init(instance->event_loop, instance->partitions.front());
472

473
#ifdef ENABLE_DAEMON
474
	daemonize_set_user();
475
	daemonize_begin(options.daemon);
476
#endif
Warren Dukes's avatar
Warren Dukes committed
477

478
#ifdef __BLOCKS__
479 480 481 482 483 484 485
	/* Runs the OS X native event loop in the main thread, and runs
	   the rest of mpd_main on a new thread. This lets CoreAudio receive
	   route change notifications (e.g. plugging or unplugging headphones).
	   All hardware output on OS X ultimately uses CoreAudio internally.
	   This must be run after forking; if dispatch is called before forking,
	   the child process will have a broken internal dispatch state. */
	dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
486
		exit(mpd_main_after_fork(config));
487 488 489 490
	});
	dispatch_main();
	return EXIT_FAILURE; // unreachable, because dispatch_main never returns
#else
491
	return mpd_main_after_fork(config);
492
#endif
493 494 495
} catch (const std::exception &e) {
	LogError(e);
	return EXIT_FAILURE;
496 497
}

498
static int
499
mpd_main_after_fork(const Config &config)
500
try {
501
	ConfigureFS();
502

503
	glue_mapper_init();
504

505
	initPermissions();
506
	spl_global_init();
507
#ifdef ENABLE_ARCHIVE
508
	archive_plugin_init_all();
509
#endif
510

511
	pcm_convert_global_init();
512

513
	decoder_plugin_init_all();
514

515
#ifdef ENABLE_DATABASE
516
	const bool create_db = InitDatabaseAndStorage();
517
#endif
518

519
	glue_sticker_init();
520

Max Kellermann's avatar
Max Kellermann committed
521
	command_init();
522

523 524 525 526 527 528
	for (auto &partition : instance->partitions) {
		partition.outputs.Configure(instance->io_thread.GetEventLoop(),
					    config.replay_gain,
					    partition.pc);
		partition.UpdateEffectiveReplayGainMode();
	}
529

530
	client_manager_init();
531
	input_stream_global_init(instance->io_thread.GetEventLoop());
532
	playlist_list_global_init();
533

534
#ifdef ENABLE_DAEMON
535
	daemonize_commit();
536
#endif
537

538
#ifndef ANDROID
539
	setup_log_output();
Warren Dukes's avatar
Warren Dukes committed
540

541
	SignalHandlersInit(instance->event_loop);
542
#endif
543

544
	instance->io_thread.Start();
545

546
#ifdef ENABLE_NEIGHBOR_PLUGINS
547 548
	if (instance->neighbors != nullptr)
		instance->neighbors->Open();
549 550
#endif

551
	ZeroconfInit(instance->event_loop);
552

553 554
	for (auto &partition : instance->partitions)
		StartPlayerThread(partition.pc);
555

556
#ifdef ENABLE_DATABASE
557
	if (create_db) {
558 559
		/* the database failed to load: recreate the
		   database */
560
		unsigned job = instance->update->Enqueue("", true);
561
		if (job == 0)
562
			FatalError("directory update failed");
563
	}
564
#endif
565

566
	glue_state_file_init();
567

568
#ifdef ENABLE_DATABASE
569
	if (config_get_bool(ConfigOption::AUTO_UPDATE, false)) {
570
#ifdef ENABLE_INOTIFY
571
		if (instance->storage != nullptr &&
572
		    instance->update != nullptr)
573
			mpd_inotify_init(instance->event_loop,
574 575
					 *instance->storage,
					 *instance->update,
576
					 config_get_unsigned(ConfigOption::AUTO_UPDATE_DEPTH,
577
							     INT_MAX));
578
#else
579
		FormatWarning(config_domain,
580
			      "inotify: auto_update was disabled. enable during compilation phase");
581
#endif
582
	}
583
#endif
584

585 586
	config_global_check();

587 588
	/* enable all audio outputs (if not already done by
	   playlist_state_restore() */
589 590
	for (auto &partition : instance->partitions)
		partition.pc.LockUpdateAudio();
591

592 593 594
#ifdef WIN32
	win32_app_started();
#endif
595

596 597 598 599
	/* the MPD frontend does not care about timer slack; set it to
	   a huge value to allow the kernel to reduce CPU wakeups */
	SetThreadTimerSlackMS(100);

600 601 602 603
#ifdef ENABLE_SYSTEMD_DAEMON
	sd_notify(0, "READY=1");
#endif

604
	/* run the main loop */
605
	instance->event_loop.Run();
606

607 608 609 610
#ifdef WIN32
	win32_app_stopping();
#endif

611 612
	/* cleanup */

613
#if defined(ENABLE_DATABASE) && defined(ENABLE_INOTIFY)
614
	mpd_inotify_finish();
615 616 617

	if (instance->update != nullptr)
		instance->update->CancelAllAsync();
618
#endif
619

620 621 622
	if (instance->state_file != nullptr) {
		instance->state_file->Write();
		delete instance->state_file;
623 624
	}

625 626 627
	for (auto &partition : instance->partitions)
		partition.pc.Kill();

628
	ZeroconfDeinit();
Max Kellermann's avatar
Max Kellermann committed
629
	listen_global_finish();
630
	delete instance->client_list;
631

632 633 634 635 636 637 638
#ifdef ENABLE_NEIGHBOR_PLUGINS
	if (instance->neighbors != nullptr) {
		instance->neighbors->Close();
		delete instance->neighbors;
	}
#endif

639
#ifdef ENABLE_DATABASE
640
	delete instance->update;
641 642 643 644 645

	if (instance->database != nullptr) {
		instance->database->Close();
		delete instance->database;
	}
646 647

	delete instance->storage;
648
#endif
649

650 651 652 653
#ifdef ENABLE_SQLITE
	sticker_global_finish();
#endif

654
	playlist_list_global_finish();
655
	input_stream_global_finish();
656 657

#ifdef ENABLE_DATABASE
658
	mapper_finish();
659 660
#endif

661 662
	DeinitFS();

663
	instance->partitions.clear();
Max Kellermann's avatar
Max Kellermann committed
664
	command_finish();
665
	decoder_plugin_deinit_all();
666
#ifdef ENABLE_ARCHIVE
667
	archive_plugin_deinit_all();
668
#endif
669
	config_global_finish();
670
	instance->io_thread.Stop();
671
#ifndef ANDROID
672
	SignalHandlersFinish();
673
#endif
674
	delete instance;
675
	instance = nullptr;
676 677

#ifdef ENABLE_DAEMON
678
	daemonize_finish();
679
#endif
680

681 682 683
#ifdef WIN32
	WSACleanup();
#endif
684

685
	IcuFinish();
686

687
	log_deinit();
688
	return EXIT_SUCCESS;
689 690 691
} catch (const std::exception &e) {
	LogError(e);
	return EXIT_FAILURE;
Warren Dukes's avatar
Warren Dukes committed
692
}
Max Kellermann's avatar
Max Kellermann committed
693 694 695 696 697

#ifdef ANDROID

gcc_visibility_default
JNIEXPORT void JNICALL
698
Java_org_musicpd_Bridge_run(JNIEnv *env, jclass, jobject _context)
Max Kellermann's avatar
Max Kellermann committed
699
{
700 701
	Java::Init(env);
	Java::File::Initialise(env);
702
	Environment::Initialise(env);
703

704 705
	context = new Context(env, _context);

Max Kellermann's avatar
Max Kellermann committed
706
	mpd_main(0, nullptr);
707

708
	delete context;
709
	Environment::Deinitialise(env);
Max Kellermann's avatar
Max Kellermann committed
710 711
}

712 713 714 715 716
gcc_visibility_default
JNIEXPORT void JNICALL
Java_org_musicpd_Bridge_shutdown(JNIEnv *, jclass)
{
	if (instance != nullptr)
717
		instance->Shutdown();
718 719
}

Max Kellermann's avatar
Max Kellermann committed
720
#endif