A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2024 - Tsiry Sandratraina
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "config.h"
22#include "system.h"
23#include "kernel.h"
24#include "logf.h"
25#include "appevents.h"
26
27bool server_is_initialized = false;
28
29/* Server thread */
30static long server_stack[(DEFAULT_STACK_SIZE * 4)/sizeof(long)];
31static const char server_thread_name[] = "server";
32unsigned int server_thread_id = 0;
33
34extern void start_server(void);
35extern void start_servers(void);
36
37static void server_thread(void) {
38 start_server();
39}
40
41/** -- Startup -- **/
42
43/* Initialize the server - called from init() in main.c */
44void INIT_ATTR server_init(void)
45{
46 /* Can never do this twice */
47 if (server_is_initialized)
48 {
49 logf("server: already initialized");
50 return;
51 }
52
53 logf("server: initializing");
54
55 /* Initialize queues before giving control elsewhere in case it likes
56 to send messages. Thread creation will be delayed however so nothing
57 starts running until ready if something yields such as talk_init. */
58 // queue_init(&server_queue, true);
59 server_thread_id = create_thread(server_thread, server_stack,
60 sizeof(server_stack), 0, server_thread_name
61 IF_PRIO(, PRIORITY_USER_INTERFACE)
62 IF_COP(, CPU));
63
64 sleep(HZ); /* Give it a chance to start */
65
66 start_servers();
67
68 /* Probably safe to say */
69 server_is_initialized = true;
70}