annotate src/audacious/ui_main_evlisteners.c @ 4690:cd1e4d4aa0b9

Take advantage of signalfd if available.
author William Pitcock <nenolod@atheme.org>
date Sat, 05 Jul 2008 16:55:24 -0500
parents 31a4cc265f31
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
1 /*
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
2 * Audacious
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
3 * Copyright (c) 2006-2007 Audacious development team.
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
4 *
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
7 * the Free Software Foundation; under version 3 of the License.
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
8 *
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
12 * GNU General Public License for more details.
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
13 *
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses>.
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
16 *
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
17 * The Audacious team does not consider modular code linking to
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
18 * Audacious or using our public API to be a derived work.
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
19 */
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
20
4504
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
21 #include "ui_playlist_evlisteners.h"
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
22
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
23 #include <glib.h>
3899
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
24 #include <math.h>
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
25
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
26 #include "hook.h"
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
27 #include "playback.h"
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
28 #include "playlist.h"
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
29 #include "playlist_evmessages.h"
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
30 #include "visualization.h"
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
31
4544
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
32 #include "ui_credits.h"
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
33 #include "ui_equalizer.h"
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
34 #include "ui_fileopener.h"
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
35 #include "ui_jumptotrack.h"
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
36 #include "ui_main.h"
4544
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
37 #include "ui_playlist.h"
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
38 #include "ui_preferences.h"
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
39 #include "ui_skinned_playstatus.h"
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
40 #include "ui_skinned_textbox.h"
4513
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
41 #include "ui_skinned_window.h"
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
42
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
43 static gint song_info_timeout_source = 0;
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
44 static gint update_vis_timeout_source = 0;
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
45
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
46 /* XXX: there has to be a better way than polling here! */
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
47 /* also: where should this function go? should it stay here? --mf0102 */
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
48 static gboolean
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
49 update_vis_func(gpointer unused)
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
50 {
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
51 if (!playback_get_playing())
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
52 return FALSE;
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
53
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
54 input_update_vis(playback_get_time());
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
55
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
56 return TRUE;
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
57 }
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
58
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
59 static void
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
60 ui_main_evlistener_title_change(gpointer hook_data, gpointer user_data)
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
61 {
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
62 gchar *text = (gchar *) hook_data;
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
63
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
64 ui_skinned_textbox_set_text(mainwin_info, text);
3248
3cf247e4508c fix not updating playlist on title change
Tomasz Mon <desowin@gmail.com>
parents: 3197
diff changeset
65 playlistwin_update_list(playlist_get_active());
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
66 }
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
67
3197
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
68 static void
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
69 ui_main_evlistener_hide_seekbar(gpointer hook_data, gpointer user_data)
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
70 {
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
71 mainwin_disable_seekbar();
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
72 }
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
73
3899
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
74 static void
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
75 ui_main_evlistener_volume_change(gpointer hook_data, gpointer user_data)
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
76 {
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
77 gint *h_vol = (gint *) hook_data;
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
78 gint vl, vr, b, v;
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
79
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
80 vl = CLAMP(h_vol[0], 0, 100);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
81 vr = CLAMP(h_vol[1], 0, 100);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
82 v = MAX(vl, vr);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
83 if (vl > vr)
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
84 b = (gint) rint(((gdouble) vr / vl) * 100) - 100;
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
85 else if (vl < vr)
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
86 b = 100 - (gint) rint(((gdouble) vl / vr) * 100);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
87 else
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
88 b = 0;
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
89
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
90 mainwin_set_volume_slider(v);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
91 equalizerwin_set_volume_slider(v);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
92 mainwin_set_balance_slider(b);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
93 equalizerwin_set_balance_slider(b);
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
94 }
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
95
4026
17bf734f8187 avoid crash when audacious is launched with -p option.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3899
diff changeset
96 static void
4584
41400d8a5dc9 Backed out changeset 25ec507c23bc
Tomasz Mon <desowin@gmail.com>
parents: 4580
diff changeset
97 ui_main_evlistener_playback_initiate(gpointer hook_data, gpointer user_data)
41400d8a5dc9 Backed out changeset 25ec507c23bc
Tomasz Mon <desowin@gmail.com>
parents: 4580
diff changeset
98 {
41400d8a5dc9 Backed out changeset 25ec507c23bc
Tomasz Mon <desowin@gmail.com>
parents: 4580
diff changeset
99 playback_initiate();
41400d8a5dc9 Backed out changeset 25ec507c23bc
Tomasz Mon <desowin@gmail.com>
parents: 4580
diff changeset
100 }
41400d8a5dc9 Backed out changeset 25ec507c23bc
Tomasz Mon <desowin@gmail.com>
parents: 4580
diff changeset
101
41400d8a5dc9 Backed out changeset 25ec507c23bc
Tomasz Mon <desowin@gmail.com>
parents: 4580
diff changeset
102 static void
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
103 ui_main_evlistener_playback_begin(gpointer hook_data, gpointer user_data)
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
104 {
4360
313dd79a2d24 move some more GUI functions
mf0102 <0102@gmx.at>
parents: 4359
diff changeset
105 PlaylistEntry *entry = (PlaylistEntry*)hook_data;
313dd79a2d24 move some more GUI functions
mf0102 <0102@gmx.at>
parents: 4359
diff changeset
106 g_return_if_fail(entry != NULL);
313dd79a2d24 move some more GUI functions
mf0102 <0102@gmx.at>
parents: 4359
diff changeset
107
313dd79a2d24 move some more GUI functions
mf0102 <0102@gmx.at>
parents: 4359
diff changeset
108 equalizerwin_load_auto_preset(entry->filename);
4586
5fa09aa0b14a add equalizer changed hook
Tomasz Mon <desowin@gmail.com>
parents: 4585
diff changeset
109 hook_call("equalizer changed", NULL);
4360
313dd79a2d24 move some more GUI functions
mf0102 <0102@gmx.at>
parents: 4359
diff changeset
110
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
111 ui_vis_clear_data(mainwin_vis);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
112 ui_svis_clear_data(mainwin_svis);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
113 mainwin_disable_seekbar();
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
114 mainwin_update_song_info();
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
115
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
116 if (cfg.player_shaded) {
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
117 gtk_widget_show(mainwin_stime_min);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
118 gtk_widget_show(mainwin_stime_sec);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
119 gtk_widget_show(mainwin_sposition);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
120 } else {
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
121 gtk_widget_show(mainwin_minus_num);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
122 gtk_widget_show(mainwin_10min_num);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
123 gtk_widget_show(mainwin_min_num);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
124 gtk_widget_show(mainwin_10sec_num);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
125 gtk_widget_show(mainwin_sec_num);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
126 gtk_widget_show(mainwin_position);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
127 }
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
128
4360
313dd79a2d24 move some more GUI functions
mf0102 <0102@gmx.at>
parents: 4359
diff changeset
129 song_info_timeout_source =
313dd79a2d24 move some more GUI functions
mf0102 <0102@gmx.at>
parents: 4359
diff changeset
130 g_timeout_add_seconds(1, (GSourceFunc) mainwin_update_song_info, NULL);
313dd79a2d24 move some more GUI functions
mf0102 <0102@gmx.at>
parents: 4359
diff changeset
131
313dd79a2d24 move some more GUI functions
mf0102 <0102@gmx.at>
parents: 4359
diff changeset
132 update_vis_timeout_source =
313dd79a2d24 move some more GUI functions
mf0102 <0102@gmx.at>
parents: 4359
diff changeset
133 g_timeout_add(10, (GSourceFunc) update_vis_func, NULL);
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
134
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
135 vis_playback_start();
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
136
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
137 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
138 }
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
139
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
140 static void
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
141 ui_main_evlistener_playback_stop(gpointer hook_data, gpointer user_data)
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
142 {
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
143 if (song_info_timeout_source)
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
144 g_source_remove(song_info_timeout_source);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
145
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
146 vis_playback_stop();
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
147 free_vis_data();
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
148
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
149 ui_skinned_playstatus_set_buffering(mainwin_playstatus, FALSE);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
150 }
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
151
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
152 static void
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
153 ui_main_evlistener_playback_pause(gpointer hook_data, gpointer user_data)
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
154 {
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
155 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PAUSE);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
156 }
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
157
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
158 static void
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
159 ui_main_evlistener_playback_unpause(gpointer hook_data, gpointer user_data)
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
160 {
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
161 ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
162 }
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
163
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
164 static void
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
165 ui_main_evlistener_playback_seek(gpointer hook_data, gpointer user_data)
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
166 {
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
167 free_vis_data();
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
168 }
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
169
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
170 static void
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
171 ui_main_evlistener_playback_play_file(gpointer hook_data, gpointer user_data)
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
172 {
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
173 if (cfg.random_skin_on_play)
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
174 skin_set_random_skin();
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
175 }
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
176
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
177 static void
4504
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
178 ui_main_evlistener_playlist_end_reached(gpointer hook_data, gpointer user_data)
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
179 {
4510
3429239e22e7 very little intendation cleanup
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
180 mainwin_clear_song_info();
4546
d4c5719d30d1 - rename dock.c to ui_dock.c
mf0102 <0102@gmx.at>
parents: 4544
diff changeset
181
d4c5719d30d1 - rename dock.c to ui_dock.c
mf0102 <0102@gmx.at>
parents: 4544
diff changeset
182 if (cfg.stopaftersong)
d4c5719d30d1 - rename dock.c to ui_dock.c
mf0102 <0102@gmx.at>
parents: 4544
diff changeset
183 mainwin_set_stopaftersong(FALSE);
4504
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
184 }
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
185
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
186 static void
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
187 ui_main_evlistener_playlist_info_change(gpointer hook_data, gpointer user_data)
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
188 {
4510
3429239e22e7 very little intendation cleanup
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
189 PlaylistEventInfoChange *msg = (PlaylistEventInfoChange *) hook_data;
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
190
4510
3429239e22e7 very little intendation cleanup
mf0102 <0102@gmx.at>
parents: 4504
diff changeset
191 mainwin_set_song_info(msg->bitrate, msg->samplerate, msg->channels);
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
192 }
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
193
4513
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
194 static void
4544
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
195 ui_main_evlistener_mainwin_set_always_on_top(gpointer hook_data, gpointer user_data)
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
196 {
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
197 gboolean *ontop = (gboolean*)hook_data;
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
198 mainwin_set_always_on_top(*ontop);
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
199 }
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
200
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
201 static void
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
202 ui_main_evlistener_mainwin_show(gpointer hook_data, gpointer user_data)
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
203 {
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
204 gboolean *show = (gboolean*)hook_data;
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
205 mainwin_show(*show);
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
206 }
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
207
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
208 static void
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
209 ui_main_evlistener_equalizerwin_show(gpointer hook_data, gpointer user_data)
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
210 {
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
211 gboolean *show = (gboolean*)hook_data;
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
212 equalizerwin_show(*show);
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
213 }
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
214
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
215 static void
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
216 ui_main_evlistener_prefswin_show(gpointer hook_data, gpointer user_data)
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
217 {
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
218 gboolean *show = (gboolean*)hook_data;
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
219 if (*show == TRUE)
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
220 show_prefs_window();
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
221 else
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
222 hide_prefs_window();
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
223 }
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
224
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
225 static void
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
226 ui_main_evlistener_aboutwin_show(gpointer hook_data, gpointer user_data)
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
227 {
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
228 gboolean *show = (gboolean*)hook_data;
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
229 if (*show == TRUE)
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
230 show_about_window();
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
231 else
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
232 hide_about_window();
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
233 }
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
234
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
235
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
236 static void
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
237 ui_main_evlistener_ui_jump_to_track_show(gpointer hook_data, gpointer user_data)
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
238 {
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
239 gboolean *show = (gboolean*)hook_data;
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
240 if (*show == TRUE)
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
241 ui_jump_to_track();
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
242 else
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
243 ui_jump_to_track_hide();
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
244 }
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
245
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
246 static void
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
247 ui_main_evlistener_filebrowser_show(gpointer hook_data, gpointer user_data)
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
248 {
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
249 gboolean *play_button = (gboolean*)hook_data;
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
250 run_filebrowser(*play_button);
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
251 }
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
252
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
253 static void
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
254 ui_main_evlistener_filebrowser_hide(gpointer hook_data, gpointer user_data)
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
255 {
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
256 hide_filebrowser();
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
257 }
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
258
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
259 static void
4553
47cc110bef0c Hookify a visualization function
mf0102 <0102@gmx.at>
parents: 4546
diff changeset
260 ui_main_evlistener_visualization_timeout(gpointer hook_data, gpointer user_data)
47cc110bef0c Hookify a visualization function
mf0102 <0102@gmx.at>
parents: 4546
diff changeset
261 {
4596
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
262 if (hook_data == NULL) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
263 if (cfg.player_shaded && cfg.player_visible)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
264 ui_svis_timeout_func(mainwin_svis, NULL);
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
265 else
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
266 ui_vis_timeout_func(mainwin_vis, NULL);
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
267 return;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
268 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
269
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
270 VisNode *vis = (VisNode*) hook_data;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
271
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
272 guint8 intern_vis_data[512];
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
273 gint16 mono_freq[2][256];
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
274 gboolean mono_freq_calced = FALSE;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
275 gint16 mono_pcm[2][512], stereo_pcm[2][512];
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
276 gboolean mono_pcm_calced = FALSE, stereo_pcm_calced = FALSE;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
277 gint i;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
278
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
279 if (cfg.vis_type == VIS_OFF)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
280 return;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
281
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
282 if (cfg.vis_type == VIS_ANALYZER) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
283 /* Spectrum analyzer */
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
284 /* 76 values */
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
285 const gint long_xscale[] =
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
286 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
287 17, 18,
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
288 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
289 34,
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
290 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
291 50, 51,
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
292 52, 53, 54, 55, 56, 57, 58, 61, 66, 71, 76, 81, 87, 93,
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
293 100, 107,
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
294 114, 122, 131, 140, 150, 161, 172, 184, 255
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
295 };
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
296 /* 20 values */
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
297 const int short_xscale[] =
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
298 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 15, 20, 27,
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
299 36, 47, 62, 82, 107, 141, 184, 255
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
300 };
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
301 const double y_scale = 3.60673760222; /* 20.0 / log(256) */
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
302 const int *xscale;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
303 gint j, y, max;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
304
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
305 if (!mono_freq_calced)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
306 calc_mono_freq(mono_freq, vis->data, vis->nch);
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
307
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
308 memset(intern_vis_data, 0, 75);
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
309
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
310 if (cfg.analyzer_type == ANALYZER_BARS) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
311 if (cfg.player_shaded) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
312 max = 13;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
313 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
314 else {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
315 max = 19;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
316 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
317 xscale = short_xscale;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
318 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
319 else {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
320 if (cfg.player_shaded) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
321 max = 37;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
322 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
323 else {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
324 max = 75;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
325 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
326 xscale = long_xscale;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
327 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
328
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
329 for (i = 0; i < max; i++) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
330 for (j = xscale[i], y = 0; j < xscale[i + 1]; j++) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
331 if (mono_freq[0][j] > y)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
332 y = mono_freq[0][j];
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
333 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
334 y >>= 7;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
335 if (y != 0) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
336 intern_vis_data[i] = log(y) * y_scale;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
337 if (intern_vis_data[i] > 15)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
338 intern_vis_data[i] = 15;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
339 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
340 else
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
341 intern_vis_data[i] = 0;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
342 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
343
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
344 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
345 else if(cfg.vis_type == VIS_VOICEPRINT){
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
346 if (cfg.player_shaded && cfg.player_visible) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
347 /* VU */
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
348 gint vu, val;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
349
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
350 if (!stereo_pcm_calced)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
351 calc_stereo_pcm(stereo_pcm, vis->data, vis->nch);
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
352 vu = 0;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
353 for (i = 0; i < 512; i++) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
354 val = abs(stereo_pcm[0][i]);
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
355 if (val > vu)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
356 vu = val;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
357 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
358 intern_vis_data[0] = (vu * 37) >> 15;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
359 if (intern_vis_data[0] > 37)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
360 intern_vis_data[0] = 37;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
361 if (vis->nch == 2) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
362 vu = 0;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
363 for (i = 0; i < 512; i++) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
364 val = abs(stereo_pcm[1][i]);
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
365 if (val > vu)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
366 vu = val;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
367 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
368 intern_vis_data[1] = (vu * 37) >> 15;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
369 if (intern_vis_data[1] > 37)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
370 intern_vis_data[1] = 37;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
371 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
372 else
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
373 intern_vis_data[1] = intern_vis_data[0];
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
374 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
375 else { /*Voiceprint*/
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
376 if (!mono_freq_calced)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
377 calc_mono_freq(mono_freq, vis->data, vis->nch);
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
378 memset(intern_vis_data, 0, 256);
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
379
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
380 /* For the values [0-16] we use the frequency that's 3/2 as much.
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
381 If we assume the 512 values calculated by calc_mono_freq to
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
382 cover 0-22kHz linearly we get a range of
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
383 [0-16] * 3/2 * 22000/512 = [0-1,031] Hz.
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
384 Most stuff above that is harmonics and we want to utilize the
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
385 16 samples we have to the max[tm]
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
386 */
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
387 for (i = 0; i < 50 ; i+=3){
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
388 intern_vis_data[i/3] += (mono_freq[0][i/2] >> 5);
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
389
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
390 /*Boost frequencies above 257Hz a little*/
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
391 //if(i > 4 * 3)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
392 // intern_vis_data[i/3] += 8;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
393 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
394 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
395 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
396 else { /* (cfg.vis_type == VIS_SCOPE) */
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
397
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
398 /* Oscilloscope */
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
399 gint pos, step;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
400
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
401 if (!mono_pcm_calced)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
402 calc_mono_pcm(mono_pcm, vis->data, vis->nch);
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
403
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
404 step = (vis->length << 8) / 74;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
405 for (i = 0, pos = 0; i < 75; i++, pos += step) {
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
406 intern_vis_data[i] = ((mono_pcm[0][pos >> 8]) >> 12) + 7;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
407 if (intern_vis_data[i] == 255)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
408 intern_vis_data[i] = 0;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
409 else if (intern_vis_data[i] > 12)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
410 intern_vis_data[i] = 12;
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
411 /* Do not see the point of that? (comparison always false) -larne.
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
412 if (intern_vis_data[i] < 0)
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
413 intern_vis_data[i] = 0; */
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
414 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
415 }
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
416
4553
47cc110bef0c Hookify a visualization function
mf0102 <0102@gmx.at>
parents: 4546
diff changeset
417 if (cfg.player_shaded && cfg.player_visible)
4596
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
418 ui_svis_timeout_func(mainwin_svis, intern_vis_data);
4553
47cc110bef0c Hookify a visualization function
mf0102 <0102@gmx.at>
parents: 4546
diff changeset
419 else
4596
a77d02342ee1 change visualization timeout; export calc_stereo_pcm, calc_mono_pcm and calc_mono_freq to PAPI
Tomasz Mon <desowin@gmail.com>
parents: 4586
diff changeset
420 ui_vis_timeout_func(mainwin_vis, intern_vis_data);
4553
47cc110bef0c Hookify a visualization function
mf0102 <0102@gmx.at>
parents: 4546
diff changeset
421 }
47cc110bef0c Hookify a visualization function
mf0102 <0102@gmx.at>
parents: 4546
diff changeset
422
47cc110bef0c Hookify a visualization function
mf0102 <0102@gmx.at>
parents: 4546
diff changeset
423 static void
4513
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
424 ui_main_evlistener_config_save(gpointer hook_data, gpointer user_data)
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
425 {
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
426 ConfigDb *db = (ConfigDb *) hook_data;
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
427
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
428 if (SKINNED_WINDOW(mainwin)->x != -1 &&
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
429 SKINNED_WINDOW(mainwin)->y != -1 )
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
430 {
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
431 cfg_db_set_int(db, NULL, "player_x", SKINNED_WINDOW(mainwin)->x);
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
432 cfg_db_set_int(db, NULL, "player_y", SKINNED_WINDOW(mainwin)->y);
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
433 }
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
434
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
435 cfg_db_set_bool(db, NULL, "mainwin_use_bitmapfont",
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
436 cfg.mainwin_use_bitmapfont);
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
437 }
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
438
4586
5fa09aa0b14a add equalizer changed hook
Tomasz Mon <desowin@gmail.com>
parents: 4585
diff changeset
439 static void
5fa09aa0b14a add equalizer changed hook
Tomasz Mon <desowin@gmail.com>
parents: 4585
diff changeset
440 ui_main_evlistener_equalizer_changed(gpointer hook_data, gpointer user_data)
5fa09aa0b14a add equalizer changed hook
Tomasz Mon <desowin@gmail.com>
parents: 4585
diff changeset
441 {
5fa09aa0b14a add equalizer changed hook
Tomasz Mon <desowin@gmail.com>
parents: 4585
diff changeset
442 output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp,
5fa09aa0b14a add equalizer changed hook
Tomasz Mon <desowin@gmail.com>
parents: 4585
diff changeset
443 cfg.equalizer_bands);
5fa09aa0b14a add equalizer changed hook
Tomasz Mon <desowin@gmail.com>
parents: 4585
diff changeset
444 }
5fa09aa0b14a add equalizer changed hook
Tomasz Mon <desowin@gmail.com>
parents: 4585
diff changeset
445
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
446 void
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
447 ui_main_evlistener_init(void)
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
448 {
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
449 hook_associate("title change", ui_main_evlistener_title_change, NULL);
3197
5dd8bc77a590 now "hide seekbar on streaming" uses message passing.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 3165
diff changeset
450 hook_associate("hide seekbar", ui_main_evlistener_hide_seekbar, NULL);
3899
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
451 hook_associate("volume set", ui_main_evlistener_volume_change, NULL);
4584
41400d8a5dc9 Backed out changeset 25ec507c23bc
Tomasz Mon <desowin@gmail.com>
parents: 4580
diff changeset
452 hook_associate("playback initiate", ui_main_evlistener_playback_initiate, NULL);
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
453 hook_associate("playback begin", ui_main_evlistener_playback_begin, NULL);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
454 hook_associate("playback stop", ui_main_evlistener_playback_stop, NULL);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
455 hook_associate("playback pause", ui_main_evlistener_playback_pause, NULL);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
456 hook_associate("playback unpause", ui_main_evlistener_playback_unpause, NULL);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
457 hook_associate("playback seek", ui_main_evlistener_playback_seek, NULL);
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
458 hook_associate("playback play file", ui_main_evlistener_playback_play_file, NULL);
4504
a47288ced5d5 - renamed some files to reflect their UI contents
mf0102 <0102@gmx.at>
parents: 4360
diff changeset
459 hook_associate("playlist end reached", ui_main_evlistener_playlist_end_reached, NULL);
4359
0becb809bdc9 moved most GUI-related functions from playback.c to ui_main_evlisteners.c
mf0102 <0102@gmx.at>
parents: 4026
diff changeset
460 hook_associate("playlist info change", ui_main_evlistener_playlist_info_change, NULL);
4544
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
461 hook_associate("mainwin set always on top", ui_main_evlistener_mainwin_set_always_on_top, NULL);
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
462 hook_associate("mainwin show", ui_main_evlistener_mainwin_show, NULL);
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
463 hook_associate("equalizerwin show", ui_main_evlistener_equalizerwin_show, NULL);
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
464 hook_associate("prefswin show", ui_main_evlistener_prefswin_show, NULL);
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
465 hook_associate("aboutwin show", ui_main_evlistener_aboutwin_show, NULL);
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
466 hook_associate("ui jump to track show", ui_main_evlistener_ui_jump_to_track_show, NULL);
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
467 hook_associate("filebrowser show", ui_main_evlistener_filebrowser_show, NULL);
084dbc8d23da removed variable "has_x11_connection" from main.c, needed to hookify some functions therefore
mf0102 <0102@gmx.at>
parents: 4513
diff changeset
468 hook_associate("filebrowser hide", ui_main_evlistener_filebrowser_hide, NULL);
4553
47cc110bef0c Hookify a visualization function
mf0102 <0102@gmx.at>
parents: 4546
diff changeset
469 hook_associate("visualization timeout", ui_main_evlistener_visualization_timeout, NULL);
4513
867d7caeb95b - indentation of ui_main.c
mf0102 <0102@gmx.at>
parents: 4510
diff changeset
470 hook_associate("config save", ui_main_evlistener_config_save, NULL);
4586
5fa09aa0b14a add equalizer changed hook
Tomasz Mon <desowin@gmail.com>
parents: 4585
diff changeset
471
5fa09aa0b14a add equalizer changed hook
Tomasz Mon <desowin@gmail.com>
parents: 4585
diff changeset
472 hook_associate("equalizer changed", ui_main_evlistener_equalizer_changed, NULL);
3165
8775dfc57ead Remove mainwin_set_info_text() craq. Still some work to do.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
473 }
3899
2c768d923bcf Add an event listener for volume changes.
William Pitcock <nenolod@atheme.org>
parents: 3248
diff changeset
474