| 1 | = Example plugin helloworld.c = |
| 2 | This page contains an example plugin for libroar. It can be loaded into all hosts supporting AppSched. |
| 3 | |
| 4 | == Code == |
| 5 | {{{#!c |
| 6 | //helloworld.c: |
| 7 | |
| 8 | /* |
| 9 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2012 |
| 10 | * |
| 11 | * This file is part of roard a part of RoarAudio, |
| 12 | * a cross-platform sound system for both, home and professional use. |
| 13 | * See README for details. |
| 14 | * |
| 15 | * This file is free software; you can redistribute it and/or modify |
| 16 | * it under the terms of the GNU General Public License version 3 |
| 17 | * as published by the Free Software Foundation. |
| 18 | * |
| 19 | * RoarAudio is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this software; see the file COPYING. If not, write to |
| 26 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
| 27 | * Boston, MA 02110-1301, USA. |
| 28 | * |
| 29 | */ |
| 30 | |
| 31 | #include <roaraudio.h> |
| 32 | |
| 33 | // A simple function printing our message. |
| 34 | static int hw_init (struct roar_dl_librarypara * para) { |
| 35 | (void)para; // We ignore all parameters passed to us. |
| 36 | |
| 37 | roar_vio_printf(roar_stdout, "Hello world!\n"); |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | // This struct contains the AppSched pointers. |
| 43 | static struct roar_dl_appsched sched = { |
| 44 | .init = hw_init, |
| 45 | .free = NULL, |
| 46 | .update = NULL, |
| 47 | .tick = NULL, |
| 48 | .wait = NULL |
| 49 | }; |
| 50 | |
| 51 | // This is the plugin control block. |
| 52 | ROAR_DL_PLUGIN_START(helloworld) { |
| 53 | // Here we set the name and vendor of our plugin. |
| 54 | // If you have no Vendor ID you need to use ROAR_DL_PLUGIN_META_PRODUCT_NV(). |
| 55 | ROAR_DL_PLUGIN_META_PRODUCT_NIV("helloworld", ROAR_VID_ROARAUDIO, ROAR_VNAME_ROARAUDIO); |
| 56 | |
| 57 | // This sets the version of your plugin. |
| 58 | ROAR_DL_PLUGIN_META_VERSION(ROAR_VERSION_STRING); |
| 59 | |
| 60 | // This sets the license of your plugin. |
| 61 | // If there is no tag for the license you use you can just |
| 62 | // use ROAR_DL_PLUGIN_META_LICENSE(). |
| 63 | ROAR_DL_PLUGIN_META_LICENSE_TAG(GPLv3_0); |
| 64 | |
| 65 | // This sets the author and contact infos. |
| 66 | // There are several other macros to do this with other parameters. |
| 67 | // See ROAR_DL_PLUGIN_META_CONTACT*() in the header or documentation. |
| 68 | ROAR_DL_PLUGIN_META_CONTACT_FLNE("Philipp", "Schafft", "ph3-der-loewe", "lion@lion.leolix.org"); |
| 69 | |
| 70 | // This sets the description for your plugin. |
| 71 | ROAR_DL_PLUGIN_META_DESC("This plugin prints the string \"Hello world!\"."); |
| 72 | |
| 73 | // Here the AppSched block from above is registered. |
| 74 | ROAR_DL_PLUGIN_REG_APPSCHED(&sched); |
| 75 | |
| 76 | // This is the end of the control block. |
| 77 | } ROAR_DL_PLUGIN_END |
| 78 | |
| 79 | //ll |
| 80 | }}} |