| 1 | /* -*- Mode: C ; c-basic-offset: 2 -*- */ |
|---|
| 2 | /***************************************************************************** |
|---|
| 3 | * |
|---|
| 4 | * Copyright (C) 2006,2007,2008,2009 Nedko Arnaudov <nedko@arnaudov.name> |
|---|
| 5 | * |
|---|
| 6 | * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation; version 2 of the License |
|---|
| 9 | * |
|---|
| 10 | * This program is distributed in the hope that it will be useful, |
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | * GNU General Public License for more details. |
|---|
| 14 | * |
|---|
| 15 | * You should have received a copy of the GNU General Public License |
|---|
| 16 | * along with this program; if not, write to the Free Software |
|---|
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|---|
| 18 | * |
|---|
| 19 | *****************************************************************************/ |
|---|
| 20 | |
|---|
| 21 | #include <stdlib.h> |
|---|
| 22 | #include <lv2.h> |
|---|
| 23 | |
|---|
| 24 | #include "lv2filter.h" |
|---|
| 25 | //#define LOG_LEVEL LOG_LEVEL_DEBUG |
|---|
| 26 | #include "log.h" |
|---|
| 27 | |
|---|
| 28 | static LV2_Descriptor g_lv2_plugins[] = |
|---|
| 29 | { |
|---|
| 30 | { |
|---|
| 31 | .URI = LV2FILTER_MONO_URI, |
|---|
| 32 | .instantiate = lv2filter_instantiate, |
|---|
| 33 | .connect_port = lv2filter_connect_port, |
|---|
| 34 | .run = lv2filter_run, |
|---|
| 35 | .cleanup = lv2filter_cleanup, |
|---|
| 36 | .extension_data = lv2filter_extension_data |
|---|
| 37 | }, |
|---|
| 38 | { |
|---|
| 39 | .URI = LV2FILTER_STEREO_URI, |
|---|
| 40 | .instantiate = lv2filter_instantiate, |
|---|
| 41 | .connect_port = lv2filter_connect_port, |
|---|
| 42 | .run = lv2filter_run, |
|---|
| 43 | .cleanup = lv2filter_cleanup, |
|---|
| 44 | .extension_data = lv2filter_extension_data |
|---|
| 45 | }, |
|---|
| 46 | { |
|---|
| 47 | .URI = NULL |
|---|
| 48 | } |
|---|
| 49 | }; |
|---|
| 50 | |
|---|
| 51 | static int g_lv2_plugins_count; |
|---|
| 52 | |
|---|
| 53 | void lv2_initialise() __attribute__((constructor)); |
|---|
| 54 | void lv2_initialise() |
|---|
| 55 | { |
|---|
| 56 | const LV2_Descriptor * descr_ptr; |
|---|
| 57 | |
|---|
| 58 | LOG_DEBUG("lv2_initialise() called."); |
|---|
| 59 | |
|---|
| 60 | descr_ptr = g_lv2_plugins; |
|---|
| 61 | |
|---|
| 62 | while (descr_ptr->URI != NULL) |
|---|
| 63 | { |
|---|
| 64 | g_lv2_plugins_count++; |
|---|
| 65 | descr_ptr++; |
|---|
| 66 | } |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | const LV2_Descriptor* lv2_descriptor(uint32_t index) |
|---|
| 70 | { |
|---|
| 71 | LOG_DEBUG("lv2_descriptor(%u) called.", (unsigned int)index); |
|---|
| 72 | |
|---|
| 73 | if (index >= g_lv2_plugins_count) |
|---|
| 74 | { |
|---|
| 75 | LOG_DEBUG("plugin at index %u not found.", (unsigned int)index); |
|---|
| 76 | return NULL; |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | LOG_DEBUG("<%s> found.", g_lv2_plugins[index].URI); |
|---|
| 80 | return g_lv2_plugins + index; |
|---|
| 81 | } |
|---|