root/sweep/trunk/src/sweep_app.h

Revision 698, 6.3 kB (checked in by erikd, 2 years ago)

Further reduce memory leaks.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  * Sweep, a sound wave editor.
3  *
4  * Copyright (C) 2000 Conrad Parker
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; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef __SWEEP_APP_H__
22 #define __SWEEP_APP_H__
23
24 #include <gtk/gtk.h>
25 #include <pthread.h>
26
27 /* #include "i18n.h" */
28
29 typedef struct _sw_perform_data sw_perform_data;
30
31 struct _sw_perform_data {
32   SweepFunction func;
33   sw_param_set pset;
34   gpointer custom_data;
35 };
36
37 /* Tools */
38 typedef enum {
39   TOOL_NONE = 0,
40   TOOL_SELECT,
41   TOOL_MOVE,
42   TOOL_ZOOM,
43   TOOL_CROP,
44   TOOL_SCRUB,
45   TOOL_PENCIL,
46   TOOL_NOISE,
47   TOOL_HAND
48 } sw_tool_t;
49
50 /* View colors */
51 enum {
52   VIEW_COLOR_BLACK,
53   VIEW_COLOR_RED,
54   VIEW_COLOR_ORANGE,
55   VIEW_COLOR_YELLOW,
56   VIEW_COLOR_BLUE,
57   VIEW_COLOR_WHITE,
58   VIEW_COLOR_RADAR,
59   VIEW_COLOR_DEFAULT_MAX=VIEW_COLOR_RADAR,
60   VIEW_COLOR_BLUESCREEN,
61   VIEW_COLOR_MAX
62 };
63
64 typedef enum {
65   SW_TOOLBAR_BUTTON,
66   SW_TOOLBAR_TOGGLE_BUTTON,
67   SW_TOOLBAR_RADIO_BUTTON,
68 } sw_toolbar_button_type;
69
70 typedef struct {
71   sw_framecount_t start, end;
72 } sw_view_bounds;
73
74 typedef struct _sw_view sw_view;
75
76 struct _sw_view {
77   sw_sample * sample;
78
79   sw_framecount_t start, end; /* bounds of visible frames */
80   sw_audio_t vlow, vhigh; /* bounds of vertical zoom */
81   /*  gfloat gain;*/
82   /*gfloat rate;*/
83
84   sw_tool_t current_tool;
85
86   gint repeater_tag;
87
88   gboolean following; /* whether or not to follow playmarker */
89
90   gint hand_offset;
91
92   GtkWidget * window;
93   GtkWidget * time_ruler;
94   GtkWidget * display;
95   GtkWidget * pos;
96   GtkWidget * status;
97   GtkWidget * menubar;
98   GtkWidget * menu;
99   GtkWidget * zoom_combo;
100   GtkWidget * progress;
101
102   GtkWidget * follow_toggle;
103   GtkWidget * play_pos;
104   GtkWidget * loop_toggle;
105   GtkWidget * playrev_toggle;
106   GtkWidget * play_toggle;
107   GtkWidget * play_sel_toggle;
108   GtkWidget * mute_toggle;
109   GtkWidget * monitor_toggle;
110
111   GtkWidget * menu_sel;
112   GtkWidget * menu_point;
113
114   GtkWidget * channelops_menuitem;
115   GtkWidget * channelops_submenu;
116   GList * channelops_widgets;
117
118   GtkWidget * follow_checkmenu;
119   GtkWidget * color_menuitems[VIEW_COLOR_MAX];
120   GtkWidget * loop_checkmenu;
121   GtkWidget * playrev_checkmenu;
122   GtkWidget * mute_checkmenu;
123   GtkWidget * monitor_checkmenu;
124
125   GtkObject * adj;
126   GtkObject * gain_adj;
127   GtkObject * rate_adj;
128
129   GtkWidget * db_rulers_vbox;
130   GList * db_rulers;
131
132   GList * tool_buttons;
133
134   GList * noready_widgets; /* Widgets to set insensitive on READY only */
135   GList * nomodify_widgets; /* Widgets to set insensitive on MODIFY or ALLOC */
136   GList * noalloc_widgets;  /* Widgets to set insensitive on ALLOC only */
137 };
138
139 typedef struct _sw_head sw_head;
140 typedef struct _sw_head_controller sw_head_controller;
141
142 typedef enum {
143   SWEEP_HEAD_PLAY,
144   SWEEP_HEAD_RECORD
145 } sw_head_t;
146
147 struct _sw_head_controller {
148   sw_head * head;
149
150   GtkWidget * follow_toggle;
151   GtkWidget * pos_label;
152   GtkWidget * loop_toggle;
153   GtkWidget * reverse_toggle;
154   GtkWidget * go_toggle;
155   GtkWidget * go_sel_toggle;
156   GtkWidget * mute_toggle;
157   GtkObject * gain_adj;
158 };
159
160 struct _sw_head {
161   sw_sample * sample;
162
163   GMutex * head_mutex;
164   sw_head_t type; /* SWEEP_HEAD_PLAY or SWEEP_HEAD_RECORD */
165   /*  sw_transport_type transport_mode;*/
166   sw_framecount_t stop_offset;
167   gdouble offset;
168   sw_framecount_t realoffset; /* offset according to device */
169   gboolean going; /* stopped or going? */
170   gboolean restricted; /* restricted to sample->sounddata->sels ? */
171   gboolean looping;
172   gboolean previewing;
173   gboolean reverse;
174   gboolean mute;
175   gboolean monitor;
176   gfloat delta; /* current motion delta */
177   gfloat gain;
178   gfloat rate;
179   gfloat mix; /* record mixing level */
180  
181   sw_head * scrub_master; /* another head this is being scrubbed by */
182   gboolean scrubbing; /* if this head is a scrub master, is it scrubbing ? */
183
184   gint repeater_tag;
185   GList * controllers;
186 };
187
188 typedef enum {
189   SWEEP_FILE_METHOD_BY_EXTENSION=0, /* Guess */
190   SWEEP_FILE_METHOD_LIBSNDFILE,
191   SWEEP_FILE_METHOD_OGGVORBIS,
192   SWEEP_FILE_METHOD_SPEEX,
193   SWEEP_FILE_METHOD_MP3=1000666 /* Random high number -- unsupported */
194 } sw_file_method_t;
195
196 /*
197  * sw_sample
198  */
199 struct _sw_sample {
200   sw_sounddata * sounddata;
201   GList * views;
202
203   sw_view_bounds stored_views[10];
204
205   gchar * pathname;
206
207   time_t last_mtime;
208   gboolean edit_ignore_mtime;
209
210   sw_file_method_t file_method; /* file handler; eg. libsndfile, libvorbis */
211   int file_format; /* format within handler, eg. WAV */
212   gpointer file_info; /* parameters of original file or last save */
213
214   sw_sel * tmp_sel; /* Temporary selection, used while selecting */
215
216   /* Operations; lock on scheduling */
217
218   pthread_t ops_thread;
219
220   GMutex * ops_mutex;
221   GList * registered_ops;
222   GList * current_undo;
223   GList * current_redo;
224   sw_op_instance * active_op;
225   gint op_progress_tag;
226
227   /* Per-edit locking */
228
229   GMutex * edit_mutex; /* Mutex for access to edit state */
230   sw_edit_mode edit_mode; /* READY/MODIFYING/ALLOC */
231   sw_edit_state edit_state; /* IDLE/BUSY/DONE/CANCEL */
232   gboolean modified; /* modified since last save ? */
233
234   GCond * pending_cond; /* held with edit_mutex */
235   GList * pending_ops;
236
237   /* Playback, recording, scrubbing */
238
239   sw_framecount_t user_offset; /* XXX: Actual offset of driver (frames) */
240   gboolean by_user; /* Offset was last changed by user */
241
242   GMutex * play_mutex; /* Mutex for access to play state */
243   sw_head * play_head;
244
245   sw_head * rec_head;
246
247   gfloat rate; /* XXX: */
248
249   gint color;
250
251   GtkWidget * info_clist;
252
253   gint progress_percent; /* completion percentage of current op */
254
255   gint playmarker_tag; /* gtk_timeout tag for playmarkers */
256
257   gboolean tmp_message_active;
258   gchar * last_tmp_message;
259   gint tmp_message_tag;
260   gint progress_ready_tag;
261 };
262
263 void
264 sweep_quit (void);
265
266 guint
267 sweep_timeout_add (guint32 interval, GtkFunction function, gpointer data);
268
269 void
270 sweep_timeout_remove (guint sweep_timeout_handler_id);
271
272 #endif /* __SWEEP_APP_H__ */
Note: See TracBrowser for help on using the browser.