2
* gtk.cpp - GTK interface plugin main file
3
* Copyright (C) 2001 Andy Lo A Foe <andy@alsaplayer.org>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
#include <sys/types.h>
30
#include <sys/ioctl.h>
38
#include "AlsaPlayer.h"
39
#include "SampleBuffer.h"
40
#include "CorePlayer.h"
42
#include "ScopesWindow.h"
43
#include "gtk_interface.h"
44
#include "utilities.h"
45
#include "interface_plugin.h"
46
#include "alsaplayer_error.h"
48
static char addon_dir[1024];
50
static AlsaSubscriber *scopes = NULL;
52
static CorePlayer *the_coreplayer = NULL;
54
void unload_scope_addons()
58
apUnregiserScopePlugins();
61
void load_scope_addons()
67
scope_plugin_info_type scope_plugin_info;
69
snprintf(path, sizeof(path)-1, "%s/scopes", addon_dir);
71
DIR *dir = opendir(path);
75
while ((entry = readdir(dir)) != NULL) { // For each file in scopes
76
if (strcmp(entry->d_name, ".") == 0 ||
77
strcmp(entry->d_name, "..") == 0) {
80
sprintf(path, "%s/scopes/%s", addon_dir, entry->d_name);
81
//alsaplayer_error(path);
82
if (stat(path, &buf)) continue;
83
if (S_ISREG(buf.st_mode)) {
86
char *ext = strrchr(path, '.');
90
if (strcasecmp(ext, "so"))
92
if ((handle = dlopen(path, RTLD_NOW |RTLD_GLOBAL))) {
93
scope_plugin_info = (scope_plugin_info_type) dlsym(handle, "scope_plugin_info");
94
if (scope_plugin_info) {
96
alsaplayer_error("Loading scope addon: %s\n", path);
98
tmp = scope_plugin_info();
100
tmp->handle = handle;
101
if (apRegisterScopePlugin(tmp) == -1) {
102
alsaplayer_error("%s is deprecated", path);
109
printf("%s\n", dlerror());
117
int interface_gtk_init()
119
strcpy(addon_dir, ADDON_DIR);
124
int interface_gtk_running()
130
int interface_gtk_stop()
137
gtk_exit(0); // This is *NOT* clean :-(
142
void interface_gtk_close()
148
void dl_close_scopes();
150
int interface_gtk_start(Playlist *playlist, int argc, char **argv)
155
the_coreplayer = playlist->GetCorePlayer();
158
if (!g_thread_supported()) {
159
alsaplayer_error("Sorry - this interface requires working threads.\n");
164
scopes = new AlsaSubscriber();
165
scopes->Subscribe(the_coreplayer->GetNode(), POS_END);
166
scopes->EnterStream(scope_feeder_func, the_coreplayer);
169
gtk_init(&argc, &argv);
172
home = getenv("HOME");
174
snprintf(path, 255, "%s/.gtkrc", home);
178
if (playlist->Length())
183
init_main_window(playlist);
189
unload_scope_addons();
190
destroy_scopes_window();
202
interface_plugin default_plugin =
204
INTERFACE_PLUGIN_VERSION,
205
"GTK+ interface v1.2",
210
interface_gtk_running,
217
interface_plugin *interface_plugin_info()
219
return &default_plugin;