global.c 1.4 KB
Newer Older
1 2 3 4 5
/* Icecast
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
6
 * Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
7 8 9 10 11 12
 *                      Michael Smith <msmith@xiph.org>,
 *                      oddsock <oddsock@xiph.org>,
 *                      Karl Heyes <karl@xiph.org>
 *                      and others (see AUTHORS for details).
 */

13
/* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- */
14 15 16 17
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

18 19
#include <string.h>

20 21
#include "common/thread/thread.h"
#include "common/avl/avl.h"
Jack Moffitt's avatar
Jack Moffitt committed
22 23

#include "global.h"
24 25
#include "refobject.h"
#include "module.h"
26
#include "source.h"
Jack Moffitt's avatar
Jack Moffitt committed
27 28 29 30 31 32 33

ice_global_t global;

static mutex_t _global_mutex;

void global_initialize(void)
{
34
    global.listensockets = NULL;
35 36
    global.relays = NULL;
    global.master_relays = NULL;
37 38 39 40
    global.running = 0;
    global.clients = 0;
    global.sources = 0;
    global.source_tree = avl_tree_new(source_compare_sources, NULL);
41
    global.modulecontainer = refobject_new(module_container_t);
42
    thread_mutex_create(&_global_mutex);
Jack Moffitt's avatar
Jack Moffitt committed
43 44 45 46
}

void global_shutdown(void)
{
47
    thread_mutex_destroy(&_global_mutex);
48
    refobject_unref(global.modulecontainer);
49
    avl_tree_free(global.source_tree, NULL);
Jack Moffitt's avatar
Jack Moffitt committed
50 51 52 53
}

void global_lock(void)
{
54
    thread_mutex_lock(&_global_mutex);
Jack Moffitt's avatar
Jack Moffitt committed
55 56 57 58
}

void global_unlock(void)
{
59
    thread_mutex_unlock(&_global_mutex);
Jack Moffitt's avatar
Jack Moffitt committed
60
}