[5318] | 1 | //discard.c: |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011 |
---|
| 5 | * |
---|
| 6 | * This file is part of roard a part of RoarAudio, |
---|
| 7 | * a cross-platform sound system for both, home and professional use. |
---|
| 8 | * See README for details. |
---|
| 9 | * |
---|
| 10 | * This file is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * RoarAudio is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
| 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
| 23 | * |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | #include <roard/include/roard.h> |
---|
| 27 | |
---|
| 28 | static int static_counter = 0; |
---|
| 29 | int nonstatic_counter = 0; |
---|
| 30 | |
---|
| 31 | static int global_data_init = 0; |
---|
| 32 | static int * global_data; |
---|
| 33 | |
---|
| 34 | static void print_counter (void) { |
---|
| 35 | static int static_func_counter = 0; |
---|
| 36 | |
---|
| 37 | printf("static_counter=%i, nonstatic_counter=%i, static_func_counter=%i, *global_data=%i\n", |
---|
| 38 | static_counter, nonstatic_counter, static_func_counter, *global_data); |
---|
| 39 | |
---|
| 40 | static_counter++; |
---|
| 41 | nonstatic_counter++; |
---|
| 42 | static_func_counter++; |
---|
| 43 | (*global_data)++; |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | static void print_parameter(struct roar_dl_librarypara * para) { |
---|
| 47 | size_t i; |
---|
| 48 | char c; |
---|
| 49 | |
---|
| 50 | roar_vio_printf(roar_stdout, "version = %i (%smatching)\n", |
---|
| 51 | para->version, para->version == ROAR_DL_LIBPARA_VERSION ? "" : "not "); |
---|
| 52 | roar_vio_printf(roar_stdout, "length = %zu (%smatching)\n", |
---|
| 53 | para->len, para->len == sizeof(*para) ? "" : "not "); |
---|
| 54 | |
---|
| 55 | if ( para->version != ROAR_DL_LIBPARA_VERSION || para->len != sizeof(*para) ) { |
---|
| 56 | roar_vio_printf(roar_stdout, "Warning: Unsupported para block. Version or length missmatch.\n"); |
---|
| 57 | return; |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | roar_vio_printf(roar_stdout, "refc = %zu\n", para->refc); |
---|
| 61 | if ( para->argv == NULL ) { |
---|
| 62 | roar_vio_printf(roar_stdout, "argv[] = <not set>\n"); |
---|
| 63 | } else { |
---|
| 64 | roar_vio_printf(roar_stdout, "argv[] = <kv array>\n"); |
---|
| 65 | for (i = 0; i < para->argc; i++) { |
---|
| 66 | c = i == (para->argc - 1) ? '\\' : '|'; |
---|
| 67 | if ( para->argv[i].value == NULL ) { |
---|
| 68 | roar_vio_printf(roar_stdout, " %c- \"%s\" has no value.\n", c, para->argv[i].key); |
---|
| 69 | } else { |
---|
| 70 | roar_vio_printf(roar_stdout, " %c- \"%s\" has value \"%s\".\n", c, para->argv[i].key, para->argv[i].value); |
---|
| 71 | } |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | roar_vio_printf(roar_stdout, para->binargv == NULL ? "binargv = <not set>\n" : "binargv = %p\n", para->binargv); |
---|
| 76 | roar_vio_printf(roar_stdout, para->appname == NULL ? "appname = <not set>\n" : "appname = \"%s\"\n", para->appname); |
---|
| 77 | roar_vio_printf(roar_stdout, para->abiversion == NULL ? "abiversion = <not set>\n" : "abiversion = \"%s\"\n", para->abiversion); |
---|
| 78 | roar_vio_printf(roar_stdout, para->notifycore == NULL ? "notifycore = <not set>\n" : "notifycore = \"%s\"\n", para->notifycore); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | static void print_notifycore (struct roar_dl_librarypara * para) { |
---|
| 82 | struct roar_notify_core * tmp; |
---|
| 83 | |
---|
| 84 | tmp = roar_notify_core_swap_global(NULL); |
---|
| 85 | roar_notify_core_swap_global(tmp); |
---|
| 86 | |
---|
| 87 | if ( para->notifycore == NULL || para->notifycore == tmp ) { |
---|
| 88 | roar_vio_printf(roar_stdout, |
---|
| 89 | tmp == NULL ? "global notify core= <not set> (matching)\n" : "global notify core= %p (matching)\n", |
---|
| 90 | tmp); |
---|
| 91 | } else { |
---|
| 92 | roar_vio_printf(roar_stdout, |
---|
| 93 | tmp == NULL ? "global notify core= <not set> (not matching)\n" : |
---|
| 94 | "global notify core= %p (not matching)\n", |
---|
| 95 | tmp); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | roar_notify_core_unref(tmp); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | static int init (struct roar_dl_librarypara * para) { |
---|
| 102 | print_parameter(para); |
---|
| 103 | print_notifycore(para); |
---|
| 104 | print_counter(); |
---|
| 105 | return 0; |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | static struct roar_dl_appsched sched = { |
---|
| 109 | .init = init, |
---|
| 110 | .free = NULL, |
---|
| 111 | .update = NULL |
---|
| 112 | }; |
---|
| 113 | |
---|
| 114 | ROAR_DL_PLUGIN_START(roard_plugin_info) { |
---|
| 115 | // ROARD_DL_CHECK_VERSIONS(); |
---|
| 116 | |
---|
| 117 | libname.license = "GPL-3.0"; |
---|
| 118 | |
---|
| 119 | ROAR_DL_PLUGIN_REG_GLOBAL_DATA(global_data, global_data_init); |
---|
| 120 | ROAR_DL_PLUGIN_REG_APPSCHED(&sched); |
---|
| 121 | |
---|
| 122 | // ROAR_DL_PLUGIN_ABORT_LOADING(ROAR_ERROR_CAUSALITY); |
---|
| 123 | } ROAR_DL_PLUGIN_END |
---|
| 124 | |
---|
| 125 | //ll |
---|