summaryrefslogtreecommitdiff
path: root/src/libaudcore/runtime.h
blob: 30ad9503e0561be803b7c7b986c460aa5fbfd92a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
 * runtime.h
 * Copyright 2014 John Lindgren
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions, and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions, and the following disclaimer in the documentation
 *    provided with the distribution.
 *
 * This software is provided "as is" and without any warranty, express or
 * implied. In no event shall the authors be liable for any damages arising from
 * the use of this software.
 */

#ifndef LIBAUDCORE_RUNTIME_H
#define LIBAUDCORE_RUNTIME_H

#include <libaudcore/objects.h>

enum class AudPath {
    BinDir,
    DataDir,
    PluginDir,
    LocaleDir,
    DesktopFile,
    IconFile,
    UserDir,
    PlaylistDir,
    count
};

enum class MainloopType {
    GLib,
    Qt
};

enum class OutputReset {
    EffectsOnly,
    ReopenStream,
    ResetPlugin
};

enum class OutputStream {
    AsDecoded,
    AfterReplayGain,
    AfterEffects,
    AfterEqualizer
};

enum class ReplayGainMode {
    Track,
    Album,
    Automatic
};

namespace audlog
{
    enum Level {
        Debug,
        Info,
        Warning,
        Error
    };

    typedef void (* Handler) (Level level, const char * file, int line,
     const char * func, const char * message);

    void set_stderr_level (Level level);
    void subscribe (Handler handler, Level level);
    void unsubscribe (Handler handler);

#ifdef _WIN32
    void log (Level level, const char * file, int line, const char * func,
     const char * format, ...) __attribute__ ((__format__ (gnu_printf, 5, 6)));
#else
    void log (Level level, const char * file, int line, const char * func,
     const char * format, ...) __attribute__ ((__format__ (__printf__, 5, 6)));
#endif

    const char * get_level_name (Level level);
}

#define AUDERR(...) do { audlog::log (audlog::Error, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__); } while (0)
#define AUDWARN(...) do { audlog::log (audlog::Warning, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__); } while (0)
#define AUDINFO(...) do { audlog::log (audlog::Info, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__); } while (0)
#define AUDDBG(...) do { audlog::log (audlog::Debug, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__); } while (0)

const char * aud_get_path (AudPath id);

void aud_set_headless_mode (bool headless);
bool aud_get_headless_mode ();

// Note that the UserDir and PlaylistDir paths vary depending on the instance
// number.  Therefore, calling aud_set_instance() after these paths have been
// referenced, or after aud_init(), is an error.
void aud_set_instance (int instance);
int aud_get_instance ();

void aud_set_mainloop_type (MainloopType type);
MainloopType aud_get_mainloop_type ();

void aud_init_i18n ();

void aud_config_set_defaults (const char * section, const char * const * entries);

void aud_set_str (const char * section, const char * name, const char * value);
String aud_get_str (const char * section, const char * name);
void aud_set_bool (const char * section, const char * name, bool value);
bool aud_get_bool (const char * section, const char * name);
void aud_toggle_bool (const char * section, const char * name);
void aud_set_int (const char * section, const char * name, int value);
int aud_get_int (const char * section, const char * name);
void aud_set_double (const char * section, const char * name, double value);
double aud_get_double (const char * section, const char * name);

void aud_init ();
void aud_resume ();
void aud_run ();
void aud_quit ();
void aud_cleanup ();

void aud_leak_check ();

String aud_history_get (int entry);
void aud_history_add (const char * path);

void aud_output_reset (OutputReset type);

#endif