2004-01-28 20:02:12 -05:00
|
|
|
/* Icecast
|
|
|
|
*
|
|
|
|
* This program is distributed under the GNU General Public License, version 2.
|
|
|
|
* A copy of this license is included with this source.
|
|
|
|
*
|
2015-01-10 13:53:44 -05:00
|
|
|
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
|
2004-01-28 20:02:12 -05:00
|
|
|
* Michael Smith <msmith@xiph.org>,
|
|
|
|
* oddsock <oddsock@xiph.org>,
|
|
|
|
* Karl Heyes <karl@xiph.org>
|
|
|
|
* and others (see AUTHORS for details).
|
2022-03-01 06:17:28 -05:00
|
|
|
* Copyright 2015-2022, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
|
2004-01-28 20:02:12 -05:00
|
|
|
*/
|
|
|
|
|
2003-03-27 12:10:14 -05:00
|
|
|
/* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- */
|
2003-07-20 21:58:54 -04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2003-03-09 06:27:06 -05:00
|
|
|
#include <string.h>
|
|
|
|
|
2014-12-02 16:50:57 -05:00
|
|
|
#include "common/thread/thread.h"
|
|
|
|
#include "common/avl/avl.h"
|
2001-09-09 22:21:46 -04:00
|
|
|
|
|
|
|
#include "global.h"
|
2018-05-28 07:26:08 -04:00
|
|
|
#include "refobject.h"
|
|
|
|
#include "module.h"
|
2018-05-28 07:27:04 -04:00
|
|
|
#include "source.h"
|
2001-09-09 22:21:46 -04:00
|
|
|
|
|
|
|
ice_global_t global;
|
|
|
|
|
|
|
|
static mutex_t _global_mutex;
|
|
|
|
|
|
|
|
void global_initialize(void)
|
|
|
|
{
|
2018-04-18 01:43:46 -04:00
|
|
|
global.listensockets = NULL;
|
2004-02-19 15:28:21 -05:00
|
|
|
global.relays = NULL;
|
|
|
|
global.master_relays = NULL;
|
2003-03-14 21:10:19 -05:00
|
|
|
global.running = 0;
|
|
|
|
global.clients = 0;
|
|
|
|
global.sources = 0;
|
2022-02-25 07:53:33 -05:00
|
|
|
global.sources_legacy = 0;
|
2003-03-14 21:10:19 -05:00
|
|
|
global.source_tree = avl_tree_new(source_compare_sources, NULL);
|
2018-10-10 11:01:10 -04:00
|
|
|
global.modulecontainer = refobject_new(module_container_t);
|
2003-03-14 21:10:19 -05:00
|
|
|
thread_mutex_create(&_global_mutex);
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void global_shutdown(void)
|
|
|
|
{
|
2003-03-14 21:10:19 -05:00
|
|
|
thread_mutex_destroy(&_global_mutex);
|
2018-05-28 07:26:08 -04:00
|
|
|
refobject_unref(global.modulecontainer);
|
2004-02-19 15:28:21 -05:00
|
|
|
avl_tree_free(global.source_tree, NULL);
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void global_lock(void)
|
|
|
|
{
|
2003-03-14 21:10:19 -05:00
|
|
|
thread_mutex_lock(&_global_mutex);
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void global_unlock(void)
|
|
|
|
{
|
2003-03-14 21:10:19 -05:00
|
|
|
thread_mutex_unlock(&_global_mutex);
|
2001-09-09 22:21:46 -04:00
|
|
|
}
|