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 broker_is_initialized = false;
28
29/* Broker thread */
30static long broker_stack[(DEFAULT_STACK_SIZE * 4)/sizeof(long)];
31static const char broker_thread_name[] = "broker";
32unsigned int broker_thread_id = 0;
33
34extern void start_broker(void);
35
36static void broker_thread(void) {
37 start_broker();
38}
39
40/** -- Startup -- **/
41
42/* Initialize the broker - called from init() in main.c */
43void INIT_ATTR broker_init(void)
44{
45 /* Can never do this twice */
46 if (broker_is_initialized)
47 {
48 logf("broker: already initialized");
49 return;
50 }
51
52 logf("broker: initializing");
53
54 /* Initialize queues before giving control elsewhere in case it likes
55 to send messages. Thread creation will be delayed however so nothing
56 starts running until ready if something yields such as talk_init. */
57 // queue_init(&server_queue, true);
58 broker_thread_id = create_thread(broker_thread, broker_stack,
59 sizeof(broker_stack), 0, broker_thread_name
60 IF_PRIO(, PRIORITY_USER_INTERFACE)
61 IF_COP(, CPU));
62
63 sleep(HZ); /* Give it a chance to start */
64
65 /* Probably safe to say */
66 broker_is_initialized = true;
67}