Main.cxx 15.7 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright (C) 2003-2014 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 "PlaylistGlobal.hxx"
26
#include "MusicChunk.hxx"
27
#include "StateFile.hxx"
28
#include "PlayerThread.hxx"
Max Kellermann's avatar
Max Kellermann committed
29
#include "Mapper.hxx"
30
#include "Permission.hxx"
Max Kellermann's avatar
Max Kellermann committed
31
#include "Listen.hxx"
32 33
#include "client/Client.hxx"
#include "client/ClientList.hxx"
34
#include "command/AllCommands.hxx"
35
#include "Partition.hxx"
36
#include "tag/TagConfig.hxx"
37
#include "ReplayGainConfig.hxx"
Max Kellermann's avatar
Max Kellermann committed
38
#include "Idle.hxx"
39
#include "Log.hxx"
40
#include "LogInit.hxx"
41
#include "GlobalEvents.hxx"
Max Kellermann's avatar
Max Kellermann committed
42
#include "input/Init.hxx"
43
#include "event/Loop.hxx"
44
#include "IOThread.hxx"
45
#include "fs/AllocatedPath.hxx"
46
#include "fs/Config.hxx"
47
#include "playlist/PlaylistRegistry.hxx"
48
#include "zeroconf/ZeroconfGlue.hxx"
49
#include "decoder/DecoderList.hxx"
50
#include "AudioConfig.hxx"
51
#include "pcm/PcmConvert.hxx"
52 53
#include "unix/SignalHandlers.hxx"
#include "unix/Daemon.hxx"
54
#include "system/FatalError.hxx"
55
#include "util/UriUtil.hxx"
56
#include "util/Error.hxx"
57
#include "util/Domain.hxx"
58
#include "thread/Id.hxx"
59
#include "thread/Slack.hxx"
60
#include "lib/icu/Init.hxx"
61 62 63 64
#include "config/ConfigGlobal.hxx"
#include "config/ConfigData.hxx"
#include "config/ConfigDefaults.hxx"
#include "config/ConfigOption.hxx"
65
#include "config/ConfigError.hxx"
66
#include "Stats.hxx"
Max Kellermann's avatar
Max Kellermann committed
67

68 69
#ifdef ENABLE_DATABASE
#include "db/update/Service.hxx"
70
#include "db/Configured.hxx"
71
#include "db/DatabasePlugin.hxx"
72
#include "db/plugins/simple/SimpleDatabasePlugin.hxx"
73
#include "storage/Configured.hxx"
74
#include "storage/CompositeStorage.hxx"
75 76 77
#ifdef ENABLE_INOTIFY
#include "db/update/InotifyUpdate.hxx"
#endif
78 79
#endif

80 81 82 83
#ifdef ENABLE_NEIGHBOR_PLUGINS
#include "neighbor/Glue.hxx"
#endif

84
#ifdef ENABLE_SQLITE
85
#include "sticker/StickerDatabase.hxx"
86 87
#endif

88
#ifdef ENABLE_ARCHIVE
89
#include "archive/ArchiveList.hxx"
90
#endif
Max Kellermann's avatar
Max Kellermann committed
91

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

102
#ifdef HAVE_GLIB
103
#include <glib.h>
104
#endif
105

Max Kellermann's avatar
Max Kellermann committed
106
#include <stdlib.h>
107

108
#ifdef HAVE_LOCALE_H
109 110 111
#include <locale.h>
#endif

112 113 114 115 116
#ifdef WIN32
#include <winsock2.h>
#include <ws2tcpip.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
static constexpr Domain main_domain("main");

124 125 126 127
#ifdef ANDROID
Context *context;
#endif

128
Instance *instance;
129

130 131
static StateFile *state_file;

132 133
#ifndef ANDROID

134
static bool
135
glue_daemonize_init(const struct options *options, Error &error)
136
{
137
	auto pid_file = config_get_path(CONF_PID_FILE, error);
138
	if (pid_file.IsNull() && error.IsDefined())
139 140
		return false;

141 142
	daemonize_init(config_get_string(CONF_USER, nullptr),
		       config_get_string(CONF_GROUP, nullptr),
143
		       std::move(pid_file));
144 145 146

	if (options->kill)
		daemonize_kill();
147 148

	return true;
149 150
}

151 152
#endif

153
static bool
154
glue_mapper_init(Error &error)
155
{
156
	auto playlist_dir = config_get_path(CONF_PLAYLIST_DIR, error);
157
	if (playlist_dir.IsNull() && error.IsDefined())
158
		return false;
159

160 161 162
	mapper_init(std::move(playlist_dir));
	return true;
}
163

164 165
#ifdef ENABLE_DATABASE

166 167 168
static bool
InitStorage(Error &error)
{
169 170 171 172 173 174 175 176 177 178
	Storage *storage = CreateConfiguredStorage(error);
	if (storage == nullptr)
		return !error.IsDefined();

	assert(!error.IsDefined());

	CompositeStorage *composite = new CompositeStorage();
	instance->storage = composite;
	composite->Mount("", storage);
	return true;
179 180
}

181 182 183 184 185 186
/**
 * 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
187
glue_db_init_and_load(void)
188
{
189
	Error error;
190 191
	instance->database =
		CreateConfiguredDatabase(*instance->event_loop, *instance,
192
					 error);
193 194 195 196 197 198
	if (instance->database == nullptr) {
		if (error.IsDefined())
			FatalError(error);
		else
			return true;
	}
199

200 201 202
	if (instance->database->GetPlugin().flags & DatabasePlugin::FLAG_REQUIRE_STORAGE) {
		if (!InitStorage(error))
			FatalError(error);
203

204 205 206 207 208 209 210 211 212 213 214 215 216
		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");
217 218
	}

219
	if (!instance->database->Open(error))
220
		FatalError(error);
221

222
	if (!instance->database->IsPlugin(simple_db_plugin))
223 224
		return true;

225
	SimpleDatabase &db = *(SimpleDatabase *)instance->database;
226
	instance->update = new UpdateService(*instance->event_loop, db,
Max Kellermann's avatar
Max Kellermann committed
227
					     static_cast<CompositeStorage &>(*instance->storage),
228
					     *instance);
229

230
	/* run database update after daemonization? */
231
	return db.FileExists();
Warren Dukes's avatar
Warren Dukes committed
232
}
Warren Dukes's avatar
Warren Dukes committed
233

234 235 236 237 238 239 240
static bool
InitDatabaseAndStorage()
{
	const bool create_db = !glue_db_init_and_load();
	return create_db;
}

241 242
#endif

243 244 245 246 247 248 249
/**
 * Configure and initialize the sticker subsystem.
 */
static void
glue_sticker_init(void)
{
#ifdef ENABLE_SQLITE
250
	Error error;
251 252 253 254 255 256
	auto sticker_file = config_get_path(CONF_STICKER_FILE, error);
	if (sticker_file.IsNull()) {
		if (error.IsDefined())
			FatalError(error);
		return;
	}
257

258
	if (!sticker_global_init(std::move(sticker_file), error))
259
		FatalError(error);
260 261 262
#endif
}

263
static bool
264
glue_state_file_init(Error &error)
265
{
266
	auto path_fs = config_get_path(CONF_STATE_FILE, error);
267 268 269 270 271 272 273 274 275 276 277 278 279 280
	if (path_fs.IsNull()) {
		if (error.IsDefined())
			return false;

#ifdef ANDROID
		const auto cache_dir = GetUserCacheDir();
		if (cache_dir.IsNull())
			return true;

		path_fs = AllocatedPath::Build(cache_dir, "state");
#else
		return true;
#endif
	}
281

282 283 284 285
	unsigned interval = config_get_unsigned(CONF_STATE_FILE_INTERVAL,
						StateFile::DEFAULT_INTERVAL);

	state_file = new StateFile(std::move(path_fs), interval,
286 287
				   *instance->partition,
				   *instance->event_loop);
288
	state_file->Read();
289
	return true;
290 291
}

292 293 294 295 296
/**
 * Windows-only initialization of the Winsock2 library.
 */
static void winsock_init(void)
{
297
#ifdef WIN32
298 299
	WSADATA sockinfo;

300
	int retval = WSAStartup(MAKEWORD(2, 2), &sockinfo);
301
	if(retval != 0)
302 303
		FormatFatalError("Attempt to open Winsock2 failed; error code %d",
				 retval);
304 305

	if (LOBYTE(sockinfo.wVersion) != 2)
306 307
		FatalError("We use Winsock2 but your version is either too new "
			   "or old; please install Winsock 2.x");
308
#endif
309
}
310

Max Kellermann's avatar
Max Kellermann committed
311 312 313 314 315 316
/**
 * Initialize the decoder and player core, including the music pipe.
 */
static void
initialize_decoder_and_player(void)
{
317
	const struct config_param *param;
Max Kellermann's avatar
Max Kellermann committed
318

319
	size_t buffer_size;
Max Kellermann's avatar
Max Kellermann committed
320
	param = config_get_param(CONF_AUDIO_BUFFER_SIZE);
321
	if (param != nullptr) {
322
		char *test;
323
		long tmp = strtol(param->value.c_str(), &test, 10);
324
		if (*test != '\0' || tmp <= 0 || tmp == LONG_MAX)
325 326
			FormatFatalError("buffer size \"%s\" is not a "
					 "positive integer, line %i",
327
					 param->value.c_str(), param->line);
328
		buffer_size = tmp;
Max Kellermann's avatar
Max Kellermann committed
329 330 331 332 333
	} else
		buffer_size = DEFAULT_BUFFER_SIZE;

	buffer_size *= 1024;

334
	const unsigned buffered_chunks = buffer_size / CHUNK_SIZE;
Max Kellermann's avatar
Max Kellermann committed
335 336

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

340
	float perc;
Max Kellermann's avatar
Max Kellermann committed
341
	param = config_get_param(CONF_BUFFER_BEFORE_PLAY);
342
	if (param != nullptr) {
343
		char *test;
344
		perc = strtod(param->value.c_str(), &test);
Max Kellermann's avatar
Max Kellermann committed
345
		if (*test != '%' || perc < 0 || perc > 100) {
346 347 348
			FormatFatalError("buffered before play \"%s\" is not "
					 "a positive percentage and less "
					 "than 100 percent, line %i",
349
					 param->value.c_str(), param->line);
Max Kellermann's avatar
Max Kellermann committed
350 351 352 353
		}
	} else
		perc = DEFAULT_BUFFER_BEFORE_PLAY;

354
	unsigned buffered_before_play = (perc / 100) * buffered_chunks;
Max Kellermann's avatar
Max Kellermann committed
355 356 357
	if (buffered_before_play > buffered_chunks)
		buffered_before_play = buffered_chunks;

358 359 360 361
	const unsigned max_length =
		config_get_positive(CONF_MAX_PLAYLIST_LENGTH,
				    DEFAULT_PLAYLIST_MAX_LENGTH);

362 363 364 365
	instance->partition = new Partition(*instance,
					    max_length,
					    buffered_chunks,
					    buffered_before_play);
Max Kellermann's avatar
Max Kellermann committed
366 367
}

368
/**
369
 * Handler for GlobalEvents::IDLE.
370 371 372
 */
static void
idle_event_emitted(void)
373
{
Max Kellermann's avatar
Max Kellermann committed
374
	/* send "idle" notifications to all subscribed
375
	   clients */
376
	unsigned flags = idle_get();
377
	if (flags != 0)
378
		instance->client_list->IdleAdd(flags);
379

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

385 386
#ifdef WIN32

387
/**
388
 * Handler for GlobalEvents::SHUTDOWN.
389 390 391 392
 */
static void
shutdown_event_emitted(void)
{
393
	instance->event_loop->Break();
394 395
}

396 397
#endif

Max Kellermann's avatar
Max Kellermann committed
398 399
#ifndef ANDROID

400
int main(int argc, char *argv[])
401 402 403 404 405 406 407 408
{
#ifdef WIN32
	return win32_main(argc, argv);
#else
	return mpd_main(argc, argv);
#endif
}

Max Kellermann's avatar
Max Kellermann committed
409 410
#endif

411 412 413
#ifdef ANDROID
static inline
#endif
414
int mpd_main(int argc, char *argv[])
415
{
Max Kellermann's avatar
Max Kellermann committed
416
	struct options options;
417
	Error error;
Warren Dukes's avatar
Warren Dukes committed
418

419
#ifndef ANDROID
420 421
	daemonize_close_stdin();

422
#ifdef HAVE_LOCALE_H
423 424 425 426
	/* initialize locale */
	setlocale(LC_CTYPE,"");
#endif

427
#ifdef HAVE_GLIB
428 429
	g_set_application_name("Music Player Daemon");

430
#if !GLIB_CHECK_VERSION(2,32,0)
Max Kellermann's avatar
Max Kellermann committed
431
	/* enable GLib's thread safety code */
432
	g_thread_init(nullptr);
433
#endif
434
#endif
435
#endif
Max Kellermann's avatar
Max Kellermann committed
436

437
	if (!IcuInit(error)) {
438 439 440 441
		LogError(error);
		return EXIT_FAILURE;
	}

442
	winsock_init();
443
	io_thread_init();
444
	config_global_init();
Warren Dukes's avatar
Warren Dukes committed
445

446 447 448
#ifdef ANDROID
	(void)argc;
	(void)argv;
449

450 451 452 453 454
	{
		const auto sdcard = Environment::getExternalStorageDirectory();
		if (!sdcard.IsNull()) {
			const auto config_path =
				AllocatedPath::Build(sdcard, "mpd.conf");
455 456
			if (FileExists(config_path) &&
			    !ReadConfigFile(config_path, error)) {
457 458 459 460 461
				LogError(error);
				return EXIT_FAILURE;
			}
		}
	}
462
#else
463
	if (!parse_cmdline(argc, argv, &options, error)) {
464
		LogError(error);
465 466
		return EXIT_FAILURE;
	}
Warren Dukes's avatar
Warren Dukes committed
467

468
	if (!glue_daemonize_init(&options, error)) {
469
		LogError(error);
470 471
		return EXIT_FAILURE;
	}
472
#endif
473

Max Kellermann's avatar
Max Kellermann committed
474
	stats_global_init();
475
	TagLoadConfig();
476

477
	if (!log_init(options.verbose, options.log_stderr, error)) {
478
		LogError(error);
479 480
		return EXIT_FAILURE;
	}
481

482
	instance = new Instance();
483
	instance->event_loop = new EventLoop();
484

485 486 487 488 489 490 491 492 493 494 495 496 497
#ifdef ENABLE_NEIGHBOR_PLUGINS
	instance->neighbors = new NeighborGlue();
	if (!instance->neighbors->Init(io_thread_get(), *instance, error)) {
		LogError(error);
		return EXIT_FAILURE;
	}

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

498
	const unsigned max_clients = config_get_positive(CONF_MAX_CONN, 10);
499
	instance->client_list = new ClientList(max_clients);
500

501 502
	initialize_decoder_and_player();

503 504
	if (!listen_global_init(*instance->event_loop, *instance->partition,
				error)) {
505
		LogError(error);
506 507
		return EXIT_FAILURE;
	}
508

509
#ifndef ANDROID
510
	daemonize_set_user();
511
	daemonize_begin(options.daemon);
512
#endif
Warren Dukes's avatar
Warren Dukes committed
513

514
	GlobalEvents::Initialize(*instance->event_loop);
515
	GlobalEvents::Register(GlobalEvents::IDLE, idle_event_emitted);
516
#ifdef WIN32
517
	GlobalEvents::Register(GlobalEvents::SHUTDOWN, shutdown_event_emitted);
518
#endif
519

520
	ConfigureFS();
521

522
	if (!glue_mapper_init(error)) {
523
		LogError(error);
524 525 526
		return EXIT_FAILURE;
	}

527
	initPermissions();
528
	playlist_global_init();
529
	spl_global_init();
530
#ifdef ENABLE_ARCHIVE
531
	archive_plugin_init_all();
532
#endif
533

534
	if (!pcm_convert_global_init(error)) {
535
		LogError(error);
536 537 538
		return EXIT_FAILURE;
	}

539
	decoder_plugin_init_all();
540

541
#ifdef ENABLE_DATABASE
542
	const bool create_db = InitDatabaseAndStorage();
543
#endif
544

545
	glue_sticker_init();
546

Max Kellermann's avatar
Max Kellermann committed
547
	command_init();
548
	initAudioConfig();
549
	instance->partition->outputs.Configure(*instance->event_loop,
550
					       instance->partition->pc);
551
	client_manager_init();
552
	replay_gain_global_init();
553

554
	if (!input_stream_global_init(error)) {
555
		LogError(error);
556 557 558
		return EXIT_FAILURE;
	}

559
	playlist_list_global_init();
560

561
#ifndef ANDROID
562
	daemonize_commit();
563

564
	setup_log_output(options.log_stderr);
Warren Dukes's avatar
Warren Dukes committed
565

566
	SignalHandlersInit(*instance->event_loop);
567
#endif
568

569
	io_thread_start();
570

571 572 573 574 575 576
#ifdef ENABLE_NEIGHBOR_PLUGINS
	if (instance->neighbors != nullptr &&
	    !instance->neighbors->Open(error))
		FatalError(error);
#endif

577
	ZeroconfInit(*instance->event_loop);
578

579
	StartPlayerThread(instance->partition->pc);
580

581
#ifdef ENABLE_DATABASE
582
	if (create_db) {
583 584
		/* the database failed to load: recreate the
		   database */
585
		unsigned job = instance->update->Enqueue("", true);
586
		if (job == 0)
587
			FatalError("directory update failed");
588
	}
589
#endif
590

591
	if (!glue_state_file_init(error)) {
592
		LogError(error);
593 594
		return EXIT_FAILURE;
	}
595

596
	instance->partition->outputs.SetReplayGainMode(replay_gain_get_real_mode(instance->partition->playlist.queue.random));
597

598
#ifdef ENABLE_DATABASE
599
	if (config_get_bool(CONF_AUTO_UPDATE, false)) {
600
#ifdef ENABLE_INOTIFY
601
		if (instance->storage != nullptr &&
602
		    instance->update != nullptr)
603 604 605
			mpd_inotify_init(*instance->event_loop,
					 *instance->storage,
					 *instance->update,
606
					 config_get_unsigned(CONF_AUTO_UPDATE_DEPTH,
607
							     INT_MAX));
608
#else
609 610
		FormatWarning(main_domain,
			      "inotify: auto_update was disabled. enable during compilation phase");
611
#endif
612
	}
613
#endif
614

615 616
	config_global_check();

617 618
	/* enable all audio outputs (if not already done by
	   playlist_state_restore() */
619
	instance->partition->pc.UpdateAudio();
620

621 622 623
#ifdef WIN32
	win32_app_started();
#endif
624

625 626 627 628
	/* 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);

629
	/* run the main loop */
630
	instance->event_loop->Run();
631

632 633 634 635
#ifdef WIN32
	win32_app_stopping();
#endif

636 637
	/* cleanup */

638
#if defined(ENABLE_DATABASE) && defined(ENABLE_INOTIFY)
639
	mpd_inotify_finish();
640 641 642

	if (instance->update != nullptr)
		instance->update->CancelAllAsync();
643
#endif
644

645 646 647 648 649
	if (state_file != nullptr) {
		state_file->Write();
		delete state_file;
	}

650
	instance->partition->pc.Kill();
651
	ZeroconfDeinit();
Max Kellermann's avatar
Max Kellermann committed
652
	listen_global_finish();
653
	delete instance->client_list;
654

655 656 657 658 659 660 661
#ifdef ENABLE_NEIGHBOR_PLUGINS
	if (instance->neighbors != nullptr) {
		instance->neighbors->Close();
		delete instance->neighbors;
	}
#endif

662
#ifdef ENABLE_DATABASE
663
	delete instance->update;
664 665 666 667 668

	if (instance->database != nullptr) {
		instance->database->Close();
		delete instance->database;
	}
669 670

	delete instance->storage;
671
#endif
672

673 674 675 676
#ifdef ENABLE_SQLITE
	sticker_global_finish();
#endif

677
	GlobalEvents::Deinitialize();
678

679
	playlist_list_global_finish();
680
	input_stream_global_finish();
681 682

#ifdef ENABLE_DATABASE
683
	mapper_finish();
684 685
#endif

686
	delete instance->partition;
Max Kellermann's avatar
Max Kellermann committed
687
	command_finish();
688
	decoder_plugin_deinit_all();
689
#ifdef ENABLE_ARCHIVE
690
	archive_plugin_deinit_all();
691
#endif
692
	config_global_finish();
693
	io_thread_deinit();
694
#ifndef ANDROID
695
	SignalHandlersFinish();
696
#endif
697
	delete instance->event_loop;
698
	delete instance;
699
	instance = nullptr;
700
#ifndef ANDROID
701
	daemonize_finish();
702
#endif
703 704 705
#ifdef WIN32
	WSACleanup();
#endif
706

707
	IcuFinish();
708

709
	log_deinit();
710
	return EXIT_SUCCESS;
Warren Dukes's avatar
Warren Dukes committed
711
}
Max Kellermann's avatar
Max Kellermann committed
712 713 714 715 716

#ifdef ANDROID

gcc_visibility_default
JNIEXPORT void JNICALL
717
Java_org_musicpd_Bridge_run(JNIEnv *env, jclass, jobject _context)
Max Kellermann's avatar
Max Kellermann committed
718
{
719 720
	Java::Init(env);
	Java::File::Initialise(env);
721
	Environment::Initialise(env);
722

723 724
	context = new Context(env, _context);

Max Kellermann's avatar
Max Kellermann committed
725
	mpd_main(0, nullptr);
726

727
	delete context;
728
	Environment::Deinitialise(env);
Max Kellermann's avatar
Max Kellermann committed
729 730
}

731 732 733 734 735 736 737 738
gcc_visibility_default
JNIEXPORT void JNICALL
Java_org_musicpd_Bridge_shutdown(JNIEnv *, jclass)
{
	if (instance != nullptr)
		instance->event_loop->Break();
}

Max Kellermann's avatar
Max Kellermann committed
739
#endif