| 1 |
/* Libvisual-plugins - Standard plugins for libvisual |
| 2 |
* |
| 3 |
* Copyright (C) 2005 Dennis Smit <[email protected]> |
| 4 |
* |
| 5 |
* Authors: Dennis Smit <[email protected]> |
| 6 |
* |
| 7 |
* $Id: input_debug.c,v 1.3 2005/12/22 21:50:10 synap Exp $ |
| 8 |
* |
| 9 |
* This program is free software; you can redistribute it and/or modify |
| 10 |
* it under the terms of the GNU Lesser General Public License as |
| 11 |
* published by the Free Software Foundation; either version 2.1 |
| 12 |
* of the License, or (at your option) any later version. |
| 13 |
* |
| 14 |
* This program 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 Lesser General Public License |
| 20 |
* along with this program; if not, write to the Free Software |
| 21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 |
*/ |
| 23 |
|
| 24 |
#include <config.h> |
| 25 |
|
| 26 |
#include <stdio.h> |
| 27 |
#include <stdlib.h> |
| 28 |
#include <unistd.h> |
| 29 |
#include <fcntl.h> |
| 30 |
#include <string.h> |
| 31 |
#include <gettext.h> |
| 32 |
|
| 33 |
#include <libvisual/libvisual.h> |
| 34 |
|
| 35 |
static int inp_debug_init (VisPluginData *plugin); |
| 36 |
static int inp_debug_cleanup (VisPluginData *plugin); |
| 37 |
static int inp_debug_upload (VisPluginData *plugin, VisAudio *audio); |
| 38 |
|
| 39 |
VISUAL_PLUGIN_API_VERSION_VALIDATOR |
| 40 |
|
| 41 |
const VisPluginInfo *get_plugin_info (int *count) |
| 42 |
{ |
| 43 |
static VisInputPlugin input[] = {{ |
| 44 |
.upload = inp_debug_upload |
| 45 |
}}; |
| 46 |
|
| 47 |
static VisPluginInfo info[] = {{ |
| 48 |
.type = VISUAL_PLUGIN_TYPE_INPUT, |
| 49 |
|
| 50 |
.plugname = "debug", |
| 51 |
.name = "debug", |
| 52 |
.author = "Vitaly V. Bursov <[email protected]>", |
| 53 |
.version = "0.1", |
| 54 |
.about = N_("debug input plugin"), |
| 55 |
.help = N_("this will generate random PCM data for debugging purposes"), |
| 56 |
.license = VISUAL_PLUGIN_LICENSE_LGPL, |
| 57 |
|
| 58 |
.init = inp_debug_init, |
| 59 |
.cleanup = inp_debug_cleanup, |
| 60 |
|
| 61 |
.plugin = VISUAL_OBJECT (&input[0]) |
| 62 |
}}; |
| 63 |
|
| 64 |
*count = sizeof (info) / sizeof (*info); |
| 65 |
|
| 66 |
return info; |
| 67 |
} |
| 68 |
|
| 69 |
int inp_debug_init (VisPluginData *plugin) |
| 70 |
{ |
| 71 |
return 0; |
| 72 |
} |
| 73 |
|
| 74 |
int inp_debug_cleanup (VisPluginData *plugin) |
| 75 |
{ |
| 76 |
return 0; |
| 77 |
} |
| 78 |
|
| 79 |
int inp_debug_upload (VisPluginData *plugin, VisAudio *audio) |
| 80 |
{ |
| 81 |
int16_t data[32768]; |
| 82 |
int i; |
| 83 |
|
| 84 |
for (i = 0; i < 32768; i++) |
| 85 |
data[i] = visual_random_int (); |
| 86 |
|
| 87 |
VisBuffer buffer; |
| 88 |
visual_buffer_init (&buffer, data, (visual_random_int () % 16384) * 2, NULL); |
| 89 |
|
| 90 |
visual_audio_samplepool_input (audio->samplepool, &buffer, VISUAL_AUDIO_SAMPLE_RATE_44100, |
| 91 |
VISUAL_AUDIO_SAMPLE_FORMAT_S16, VISUAL_AUDIO_SAMPLE_CHANNEL_STEREO); |
| 92 |
|
| 93 |
return 0; |
| 94 |
} |
| 95 |
|