Changeset 471 for sweep/branches/display-cache
- Timestamp:
- 01/16/07 19:23:06 (5 years ago)
- Files:
-
- sweep/branches/display-cache/include/sweep/sweep.h (modified) (1 diff)
- sweep/branches/display-cache/include/sweep/sweep_filter.h (modified) (1 diff)
- sweep/branches/display-cache/include/sweep/sweep_sample.h (modified) (4 diffs)
- sweep/branches/display-cache/include/sweep/sweep_selection.h (modified) (4 diffs)
- sweep/branches/display-cache/include/sweep/sweep_sounddata.h (modified) (2 diffs)
- sweep/branches/display-cache/include/sweep/sweep_typeconvert.h (modified) (1 diff)
- sweep/branches/display-cache/include/sweep/sweep_types.h (modified) (27 diffs)
- sweep/branches/display-cache/include/sweep/sweep_undo.h (modified) (2 diffs)
- sweep/branches/display-cache/intl/bindtextdom.c (modified) (12 diffs)
- sweep/branches/display-cache/intl/dcgettext.c (modified) (1 diff)
- sweep/branches/display-cache/intl/dcigettext.c (modified) (37 diffs)
- sweep/branches/display-cache/intl/eval-plural.h (modified) (2 diffs)
- sweep/branches/display-cache/intl/explodename.c (modified) (4 diffs)
- sweep/branches/display-cache/intl/finddomain.c (modified) (5 diffs)
- sweep/branches/display-cache/intl/gettextP.h (modified) (3 diffs)
- sweep/branches/display-cache/intl/gmo.h (modified) (2 diffs)
- sweep/branches/display-cache/intl/intl-compat.c (modified) (9 diffs)
- sweep/branches/display-cache/intl/l10nflist.c (modified) (7 diffs)
- sweep/branches/display-cache/intl/langprefs.c (modified) (4 diffs)
- sweep/branches/display-cache/intl/loadinfo.h (modified) (2 diffs)
- sweep/branches/display-cache/intl/loadmsgcat.c (modified) (27 diffs)
- sweep/branches/display-cache/intl/localcharset.c (modified) (6 diffs)
- sweep/branches/display-cache/intl/localcharset.h (modified) (3 diffs)
- sweep/branches/display-cache/intl/localealias.c (modified) (9 diffs)
- sweep/branches/display-cache/intl/localename.c (modified) (16 diffs)
- sweep/branches/display-cache/intl/log.c (modified) (1 diff)
- sweep/branches/display-cache/intl/os2compat.c (modified) (6 diffs)
- sweep/branches/display-cache/intl/plural-exp.c (modified) (2 diffs)
- sweep/branches/display-cache/intl/plural-exp.h (modified) (1 diff)
- sweep/branches/display-cache/intl/plural.c (modified) (35 diffs)
- sweep/branches/display-cache/intl/printf-args.c (modified) (2 diffs)
- sweep/branches/display-cache/intl/printf-args.h (modified) (3 diffs)
- sweep/branches/display-cache/intl/printf-parse.c (modified) (7 diffs)
- sweep/branches/display-cache/intl/printf-parse.h (modified) (2 diffs)
- sweep/branches/display-cache/intl/printf.c (modified) (16 diffs)
- sweep/branches/display-cache/intl/relocatable.c (modified) (7 diffs)
- sweep/branches/display-cache/intl/relocatable.h (modified) (4 diffs)
- sweep/branches/display-cache/intl/textdomain.c (modified) (3 diffs)
- sweep/branches/display-cache/intl/vasnprintf.c (modified) (14 diffs)
- sweep/branches/display-cache/intl/vasnprintf.h (modified) (4 diffs)
- sweep/branches/display-cache/intl/vasnwprintf.h (modified) (3 diffs)
- sweep/branches/display-cache/intl/wprintf-parse.h (modified) (2 diffs)
- sweep/branches/display-cache/intl/xsize.h (modified) (4 diffs)
- sweep/branches/display-cache/plugins/byenergy/byenergy.c (modified) (6 diffs)
- sweep/branches/display-cache/plugins/echo/echo.c (modified) (6 diffs)
- sweep/branches/display-cache/plugins/example/example.c (modified) (5 diffs)
- sweep/branches/display-cache/plugins/fade/fade.c (modified) (7 diffs)
- sweep/branches/display-cache/plugins/ladspa/ladspa.h (modified) (10 diffs)
- sweep/branches/display-cache/plugins/ladspa/ladspameta.c (modified) (24 diffs)
- sweep/branches/display-cache/plugins/normalise/normalise.c (modified) (4 diffs)
- sweep/branches/display-cache/plugins/reverse/reverse.c (modified) (8 diffs)
- sweep/branches/display-cache/po/fr.po (modified) (1 diff)
- sweep/branches/display-cache/po/pl.po (modified) (1 diff)
- sweep/branches/display-cache/src/about_dialog.c (modified) (3 diffs)
- sweep/branches/display-cache/src/about_dialog.h (modified) (1 diff)
- sweep/branches/display-cache/src/callbacks.c (modified) (81 diffs)
- sweep/branches/display-cache/src/callbacks.h (modified) (1 diff)
- sweep/branches/display-cache/src/channelops.c (modified) (35 diffs)
- sweep/branches/display-cache/src/channelops.h (modified) (1 diff)
- sweep/branches/display-cache/src/cursors.c (modified) (3 diffs)
- sweep/branches/display-cache/src/cursors.h (modified) (3 diffs)
- sweep/branches/display-cache/src/db_ruler.c (modified) (25 diffs)
- sweep/branches/display-cache/src/db_ruler.h (modified) (2 diffs)
- sweep/branches/display-cache/src/db_slider.c (modified) (12 diffs)
- sweep/branches/display-cache/src/db_slider.h (modified) (2 diffs)
- sweep/branches/display-cache/src/display-cache.c (modified) (3 diffs)
- sweep/branches/display-cache/src/display-cache.h (modified) (4 diffs)
- sweep/branches/display-cache/src/driver.c (modified) (22 diffs)
- sweep/branches/display-cache/src/driver.h (modified) (5 diffs)
- sweep/branches/display-cache/src/driver_alsa.c (modified) (20 diffs)
- sweep/branches/display-cache/src/driver_oss.c (modified) (18 diffs)
- sweep/branches/display-cache/src/driver_solaris.c (modified) (7 diffs)
- sweep/branches/display-cache/src/edit.c (modified) (84 diffs)
- sweep/branches/display-cache/src/edit.h (modified) (2 diffs)
- sweep/branches/display-cache/src/file_dialogs.c (modified) (29 diffs)
- sweep/branches/display-cache/src/file_dialogs.h (modified) (1 diff)
- sweep/branches/display-cache/src/file_mad.c (modified) (19 diffs)
- sweep/branches/display-cache/src/file_sndfile.h (modified) (1 diff)
- sweep/branches/display-cache/src/file_sndfile1.c (modified) (35 diffs)
- sweep/branches/display-cache/src/file_speex.c (modified) (90 diffs)
- sweep/branches/display-cache/src/file_vorbis.c (modified) (65 diffs)
- sweep/branches/display-cache/src/format.c (modified) (3 diffs)
- sweep/branches/display-cache/src/format.h (modified) (1 diff)
- sweep/branches/display-cache/src/head.c (modified) (45 diffs)
- sweep/branches/display-cache/src/head.h (modified) (1 diff)
- sweep/branches/display-cache/src/interface.c (modified) (15 diffs)
- sweep/branches/display-cache/src/interface.h (modified) (1 diff)
- sweep/branches/display-cache/src/levelmeter.c (modified) (12 diffs)
- sweep/branches/display-cache/src/levelmeter.h (modified) (3 diffs)
- sweep/branches/display-cache/src/main.c (modified) (7 diffs)
- sweep/branches/display-cache/src/notes.c (modified) (2 diffs)
- sweep/branches/display-cache/src/notes.h (modified) (1 diff)
- sweep/branches/display-cache/src/param.c (modified) (25 diffs)
- sweep/branches/display-cache/src/param.h (modified) (1 diff)
- sweep/branches/display-cache/src/paste_dialogs.c (modified) (15 diffs)
- sweep/branches/display-cache/src/paste_dialogs.h (modified) (1 diff)
- sweep/branches/display-cache/src/pcmio.h (modified) (1 diff)
- sweep/branches/display-cache/src/pixmaps.h (modified) (3 diffs)
- sweep/branches/display-cache/src/play.c (modified) (28 diffs)
- sweep/branches/display-cache/src/play.h (modified) (1 diff)
- sweep/branches/display-cache/src/plugin.c (modified) (4 diffs)
- sweep/branches/display-cache/src/plugin.h (modified) (1 diff)
- sweep/branches/display-cache/src/preferences.c (modified) (15 diffs)
- sweep/branches/display-cache/src/preferences.h (modified) (1 diff)
- sweep/branches/display-cache/src/print.c (modified) (4 diffs)
- sweep/branches/display-cache/src/print.h (modified) (1 diff)
- sweep/branches/display-cache/src/question_dialogs.c (modified) (12 diffs)
- sweep/branches/display-cache/src/question_dialogs.h (modified) (1 diff)
- sweep/branches/display-cache/src/record.c (modified) (20 diffs)
- sweep/branches/display-cache/src/record.h (modified) (1 diff)
- sweep/branches/display-cache/src/sample-display.c (modified) (68 diffs)
- sweep/branches/display-cache/src/sample-display.h (modified) (4 diffs)
- sweep/branches/display-cache/src/sample.c (modified) (19 diffs)
- sweep/branches/display-cache/src/sample.h (modified) (3 diffs)
- sweep/branches/display-cache/src/samplerate.c (modified) (36 diffs)
- sweep/branches/display-cache/src/scroll-pane.c (modified) (12 diffs)
- sweep/branches/display-cache/src/scroll-pane.h (modified) (3 diffs)
- sweep/branches/display-cache/src/sw_chooser.c (modified) (15 diffs)
- sweep/branches/display-cache/src/sw_chooser.h (modified) (2 diffs)
- sweep/branches/display-cache/src/sweep_app.h (modified) (11 diffs)
- sweep/branches/display-cache/src/sweep_filter.c (modified) (7 diffs)
- sweep/branches/display-cache/src/sweep_sample.c (modified) (102 diffs)
- sweep/branches/display-cache/src/sweep_selection.c (modified) (12 diffs)
- sweep/branches/display-cache/src/sweep_sounddata.c (modified) (14 diffs)
- sweep/branches/display-cache/src/sweep_typeconvert.c (modified) (4 diffs)
- sweep/branches/display-cache/src/sweep_undo.c (modified) (33 diffs)
- sweep/branches/display-cache/src/tdb/spinlock.c (modified) (6 diffs)
- sweep/branches/display-cache/src/tdb/spinlock.h (modified) (2 diffs)
- sweep/branches/display-cache/src/tdb/tdb.c (modified) (21 diffs)
- sweep/branches/display-cache/src/tdb/tdb.h (modified) (4 diffs)
- sweep/branches/display-cache/src/time_ruler.c (modified) (19 diffs)
- sweep/branches/display-cache/src/time_ruler.h (modified) (2 diffs)
- sweep/branches/display-cache/src/timeouts.c (modified) (6 diffs)
- sweep/branches/display-cache/src/undo_dialog.c (modified) (15 diffs)
- sweep/branches/display-cache/src/undo_dialog.h (modified) (1 diff)
- sweep/branches/display-cache/src/view.c (modified) (142 diffs)
- sweep/branches/display-cache/src/view.h (modified) (2 diffs)
- sweep/branches/display-cache/src/view_pixmaps.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sweep/branches/display-cache/include/sweep/sweep.h
r124 r471 33 33 #include <sweep/sweep_filter.h> 34 34 35 #endif /* __SWEEP_H__ */ 36 37 38 39 40 41 35 #endif /* __SWEEP_H__ */ sweep/branches/display-cache/include/sweep/sweep_filter.h
r124 r471 26 26 sw_framecount_t nr_frames, 27 27 sw_param_set pset, gpointer custom_data); 28 sw_op_instance * 29 perform_filter_region_op (sw_sample * sample, char * desc,30 SweepFilterRegion func,sw_param_set pset,31 gpointer custom_data);28 sw_op_instance *perform_filter_region_op (sw_sample * sample, char *desc, 29 SweepFilterRegion func, 30 sw_param_set pset, 31 gpointer custom_data); 32 32 33 sw_op_instance * 34 perform_filter_op (sw_sample * sample, char * desc, SweepFilter func,35 sw_param_set pset,gpointer custom_data);33 sw_op_instance *perform_filter_op (sw_sample * sample, char *desc, 34 SweepFilter func, sw_param_set pset, 35 gpointer custom_data); 36 36 37 37 sweep/branches/display-cache/include/sweep/sweep_sample.h
r124 r471 24 24 #include <sweep/sweep_types.h> 25 25 26 sw_sample * 27 sample_new_empty(char * pathname, gint nr_channels, gint sample_rate, 28 gint sample_length); 26 sw_sample *sample_new_empty (char *pathname, gint nr_channels, 27 gint sample_rate, gint sample_length); 29 28 30 sw_sample * 31 sample_new_copy(sw_sample * s); 29 sw_sample *sample_new_copy (sw_sample * s); 32 30 33 void 34 sample_destroy (sw_sample * s); 31 void sample_destroy (sw_sample * s); 35 32 36 sw_sounddata * 37 sample_get_sounddata (sw_sample * s); 33 sw_sounddata *sample_get_sounddata (sw_sample * s); 38 34 39 void 40 sample_set_file_format (sw_sample * s, sw_file_format_t file_format); 35 void sample_set_file_format (sw_sample * s, sw_file_format_t file_format); 41 36 42 void 43 sample_set_pathname (sw_sample * s, char * pathname); 37 void sample_set_pathname (sw_sample * s, char *pathname); 44 38 45 GList * 46 sample_bank_list_names (void); 39 GList *sample_bank_list_names (void); 47 40 48 sw_sample * 49 sample_bank_find_byname (const gchar * name); 41 sw_sample *sample_bank_find_byname (const gchar * name); 50 42 51 gboolean 52 sample_bank_contains (sw_sample *s); 43 gboolean sample_bank_contains (sw_sample * s); 53 44 54 void 55 sample_bank_add (sw_sample * s); 45 void sample_bank_add (sw_sample * s); 56 46 57 void 58 sample_bank_remove (sw_sample * s); 47 void sample_bank_remove (sw_sample * s); 59 48 60 void 61 sample_refresh_views (sw_sample * s); 49 void sample_refresh_views (sw_sample * s); 62 50 63 void 64 sample_start_marching_ants (sw_sample * s); 51 void sample_start_marching_ants (sw_sample * s); 65 52 66 void 67 sample_stop_marching_ants (sw_sample * s); 53 void sample_stop_marching_ants (sw_sample * s); 68 54 69 void 70 sample_set_edit_state (sw_sample * s, sw_edit_state edit_state); 55 void sample_set_edit_state (sw_sample * s, sw_edit_state edit_state); 71 56 72 void 73 sample_set_edit_mode (sw_sample * s, sw_edit_mode edit_mode); 57 void sample_set_edit_mode (sw_sample * s, sw_edit_mode edit_mode); 74 58 75 void 76 sample_refresh_playmode (sw_sample * s); 59 void sample_refresh_playmode (sw_sample * s); 77 60 78 void 79 sample_set_previewing (sw_sample * s, gboolean previewing); 61 void sample_set_previewing (sw_sample * s, gboolean previewing); 80 62 81 void 82 sample_set_stop_offset (sw_sample * s); 63 void sample_set_stop_offset (sw_sample * s); 83 64 84 65 void … … 86 67 gboolean by_user); 87 68 88 void 89 sample_set_rec_marker (sw_sample * s, sw_framecount_t offset); 69 void sample_set_rec_marker (sw_sample * s, sw_framecount_t offset); 90 70 91 void 92 sample_set_scrubbing (sw_sample * s, gboolean scrubbing); 71 void sample_set_scrubbing (sw_sample * s, gboolean scrubbing); 93 72 94 void 95 sample_set_looping (sw_sample * s, gboolean looping); 73 void sample_set_looping (sw_sample * s, gboolean looping); 96 74 97 void 98 sample_set_playrev (sw_sample * s, gboolean reverse); 75 void sample_set_playrev (sw_sample * s, gboolean reverse); 99 76 100 void 101 sample_set_mute (sw_sample * s, gboolean mute); 77 void sample_set_mute (sw_sample * s, gboolean mute); 102 78 103 void 104 sample_set_color (sw_sample * s, gint color); 79 void sample_set_color (sw_sample * s, gint color); 105 80 106 void 107 sample_set_progress_text (sw_sample * s, gchar * text); 81 void sample_set_progress_text (sw_sample * s, gchar * text); 108 82 109 void 110 sample_set_progress_percent (sw_sample * s, gint percent); 83 void sample_set_progress_percent (sw_sample * s, gint percent); 111 84 112 void 113 sample_refresh_progress_percent (sw_sample * s); 85 void sample_refresh_progress_percent (sw_sample * s); 114 86 115 int 116 sample_set_progress_ready (sw_sample * s); 87 int sample_set_progress_ready (sw_sample * s); 117 88 118 void 119 sample_set_tmp_message (sw_sample * s, const char * fmt, ...); 89 void sample_set_tmp_message (sw_sample * s, const char *fmt, ...); 120 90 121 91 /* … … 129 99 * 130 100 */ 131 void 132 sample_replace_throughout (sw_sample * os, sw_sample * s); 101 void sample_replace_throughout (sw_sample * os, sw_sample * s); 133 102 134 103 135 104 /* Selection handling */ 136 105 137 gboolean 138 sample_offset_in_sel (sw_sample * s, sw_framecount_t offset); 106 gboolean sample_offset_in_sel (sw_sample * s, sw_framecount_t offset); 139 107 140 guint 141 sample_sel_nr_regions (sw_sample * s); 108 guint sample_sel_nr_regions (sw_sample * s); 142 109 143 void 144 sample_clear_selection (sw_sample * s); 110 void sample_clear_selection (sw_sample * s); 145 111 146 void 147 sample_add_selection (sw_sample * s, sw_sel * sel); 112 void sample_add_selection (sw_sample * s, sw_sel * sel); 148 113 149 sw_sel * 150 sample_add_selection_1 (sw_sample * s, 151 sw_framecount_t start, sw_framecount_t end); 114 sw_sel *sample_add_selection_1 (sw_sample * s, 115 sw_framecount_t start, sw_framecount_t end); 152 116 153 void 154 sample_set_selection (sw_sample * s, GList * gl); 117 void sample_set_selection (sw_sample * s, GList * gl); 155 118 156 sw_sel * 157 sample_set_selection_1 (sw_sample * s, 158 sw_framecount_t start, sw_framecount_t end); 119 sw_sel *sample_set_selection_1 (sw_sample * s, 120 sw_framecount_t start, sw_framecount_t end); 159 121 160 122 … … 164 126 sw_framecount_t new_start, sw_framecount_t new_end); 165 127 166 void 167 sample_selection_invert (sw_sample * s); 128 void sample_selection_invert (sw_sample * s); 168 129 169 void 170 sample_selection_select_all (sw_sample * s); 130 void sample_selection_select_all (sw_sample * s); 171 131 172 void 173 sample_selection_select_none (sw_sample * s); 132 void sample_selection_select_none (sw_sample * s); 174 133 175 void 176 sample_selection_halve (sw_sample * s); 134 void sample_selection_halve (sw_sample * s); 177 135 178 void 179 sample_selection_double (sw_sample * s); 136 void sample_selection_double (sw_sample * s); 180 137 181 void 182 sample_selection_shift_left (sw_sample * s); 138 void sample_selection_shift_left (sw_sample * s); 183 139 184 void 185 sample_selection_shift_right (sw_sample * s); 140 void sample_selection_shift_right (sw_sample * s); 186 141 187 142 /* info dialog */ 188 void 189 sample_show_info_dialog (sw_sample * sample); 143 void sample_show_info_dialog (sw_sample * sample); 190 144 191 145 sweep/branches/display-cache/include/sweep/sweep_selection.h
r124 r471 22 22 #define __SWEEP_SELECTION_H__ 23 23 24 sw_sel * 25 sel_new (sw_framecount_t start, sw_framecount_t end); 24 sw_sel *sel_new (sw_framecount_t start, sw_framecount_t end); 26 25 27 sw_sel * 28 sel_copy (sw_sel * sel); 26 sw_sel *sel_copy (sw_sel * sel); 29 27 30 GList * 31 sels_add_selection (GList * sels, sw_sel * sel); 28 GList *sels_add_selection (GList * sels, sw_sel * sel); 32 29 33 GList * 34 sels_add_selection_1 (GList * sels, sw_framecount_t start,sw_framecount_t end);30 GList *sels_add_selection_1 (GList * sels, sw_framecount_t start, 31 sw_framecount_t end); 35 32 36 33 /* … … 40 37 * return > 0 if s1 comes after s2 in the sort order. 41 38 */ 42 gint 43 sel_cmp (sw_sel * s1, sw_sel * s2); 39 gint sel_cmp (sw_sel * s1, sw_sel * s2); 44 40 45 41 /* … … 48 44 * returns a copy of sels 49 45 */ 50 GList * 51 sels_copy (GList * sels); 46 GList *sels_copy (GList * sels); 52 47 53 48 /* … … 56 51 * inverts sels in place 57 52 */ 58 GList * 59 sels_invert (GList * sels, sw_framecount_t nr_frames); 53 GList *sels_invert (GList * sels, sw_framecount_t nr_frames); 60 54 61 sw_op_instance * 62 perform_selection_op (sw_sample * s, char * desc, SweepFilter func,63 sw_param_set pset,gpointer custom_data);55 sw_op_instance *perform_selection_op (sw_sample * s, char *desc, 56 SweepFilter func, sw_param_set pset, 57 gpointer custom_data); 64 58 65 59 #endif /* __SWEEP_SELECTION_H__ */ sweep/branches/display-cache/include/sweep/sweep_sounddata.h
r124 r471 22 22 #define __SWEEP_SOUNDDATA_H__ 23 23 24 sw_sounddata * 25 sounddata_new_empty(gint nr_channels, gint sample_rate,gint sample_length);24 sw_sounddata *sounddata_new_empty (gint nr_channels, gint sample_rate, 25 gint sample_length); 26 26 27 void 28 sounddata_destroy (sw_sounddata * sounddata); 27 void sounddata_destroy (sw_sounddata * sounddata); 29 28 30 void 31 sounddata_lock_selection (sw_sounddata * sounddata); 29 void sounddata_lock_selection (sw_sounddata * sounddata); 32 30 33 void 34 sounddata_unlock_selection (sw_sounddata * sounddata); 31 void sounddata_unlock_selection (sw_sounddata * sounddata); 35 32 36 void 37 sounddata_clear_selection (sw_sounddata * sounddata); 33 void sounddata_clear_selection (sw_sounddata * sounddata); 38 34 39 35 /* … … 44 40 */ 45 41 46 void 47 sounddata_normalise_selection (sw_sounddata * sounddata); 42 void sounddata_normalise_selection (sw_sounddata * sounddata); 48 43 49 void 50 sounddata_add_selection (sw_sounddata * sounddata, sw_sel * sel); 44 void sounddata_add_selection (sw_sounddata * sounddata, sw_sel * sel); 51 45 52 sw_sel * 53 sounddata_add_selection_1 (sw_sounddata * sounddata,54 sw_framecount_t start,sw_framecount_t end);46 sw_sel *sounddata_add_selection_1 (sw_sounddata * sounddata, 47 sw_framecount_t start, 48 sw_framecount_t end); 55 49 56 sw_sel * 57 sounddata_set_selection_1 (sw_sounddata * sounddata,58 sw_framecount_t start,sw_framecount_t end);50 sw_sel *sounddata_set_selection_1 (sw_sounddata * sounddata, 51 sw_framecount_t start, 52 sw_framecount_t end); 59 53 60 guint 61 sounddata_selection_nr_regions (sw_sounddata * sounddata); 54 guint sounddata_selection_nr_regions (sw_sounddata * sounddata); 62 55 63 gint 64 sounddata_selection_nr_frames (sw_sounddata * sounddata); 56 gint sounddata_selection_nr_frames (sw_sounddata * sounddata); 65 57 66 gint 67 sounddata_selection_width (sw_sounddata * sounddata); 58 gint sounddata_selection_width (sw_sounddata * sounddata); 68 59 69 void 70 sounddata_selection_translate (sw_sounddata * sounddata, gint delta); 60 void sounddata_selection_translate (sw_sounddata * sounddata, gint delta); 71 61 72 void 73 sounddata_selection_scale (sw_sounddata * sounddata, gfloat scale); 62 void sounddata_selection_scale (sw_sounddata * sounddata, gfloat scale); 74 63 75 64 /* sweep/branches/display-cache/include/sweep/sweep_typeconvert.h
r57 r471 26 26 * in a given format. 27 27 */ 28 glong 29 frames_to_samples (sw_format * format, sw_framecount_t nr_frames); 28 glong frames_to_samples (sw_format * format, sw_framecount_t nr_frames); 30 29 31 30 /* 32 31 * Determine the size in bytes of a number of frames of a given format. 33 32 */ 34 glong 35 frames_to_bytes (sw_format * format, sw_framecount_t nr_frames); 33 glong frames_to_bytes (sw_format * format, sw_framecount_t nr_frames); 36 34 37 35 /* 38 36 * Convert a number of frames to seconds 39 37 */ 40 sw_time_t 41 frames_to_time (sw_format * format, sw_framecount_t nr_frames); 38 sw_time_t frames_to_time (sw_format * format, sw_framecount_t nr_frames); 42 39 43 40 /* 44 41 * Convert seconds to frames 45 42 */ 46 sw_framecount_t 47 time_to_frames (sw_format * format, sw_time_t time); 43 sw_framecount_t time_to_frames (sw_format * format, sw_time_t time); 48 44 49 45 #endif /* __SWEEP_TYPE_CONVERT_H__ */ sweep/branches/display-cache/include/sweep/sweep_types.h
r304 r471 23 23 24 24 #include <glib.h> 25 #include <gdk/gdktypes.h> /* XXX: for GdkModifierType */26 #include <gtk/gtk.h> /* XXX: for info_clist widget */25 #include <gdk/gdktypes.h> /* XXX: for GdkModifierType */ 26 #include <gtk/gtk.h> /* XXX: for info_clist widget */ 27 27 28 28 #include <sys/types.h> … … 54 54 #if 0 55 55 56 #if (SIZEOF_OFF_T == 8) 56 #if (SIZEOF_OFF_T == 8) 57 57 /* For libsndfile version 1 */ 58 58 typedef off_t sw_framecount_t; … … 90 90 * 91 91 */ 92 struct _sw_sel { 92 struct _sw_sel 93 { 93 94 sw_framecount_t sel_start; 94 95 sw_framecount_t sel_end; … … 100 101 * Multichannel data is interleaved: Stereo is stored LR. 101 102 */ 102 struct _sw_format { 103 gint channels; /* nr channels per frame */ 104 gint rate; /* sampling rate (Hz) */ 105 }; 106 107 struct _sw_sounddata { 103 struct _sw_format 104 { 105 gint channels; /* nr channels per frame */ 106 gint rate; /* sampling rate (Hz) */ 107 }; 108 109 struct _sw_sounddata 110 { 108 111 int refcount; 109 112 110 sw_format * format;111 sw_framecount_t nr_frames; /* nr frames */113 sw_format *format; 114 sw_framecount_t nr_frames; /* nr frames */ 112 115 113 116 gpointer data; 114 GMutex * data_mutex;/* Mutex for access to sample data */115 116 GList * sels;/* selection: list of sw_sels */117 GMutex * sels_mutex;/* Mutex for access to sels */117 GMutex *data_mutex; /* Mutex for access to sample data */ 118 119 GList *sels; /* selection: list of sw_sels */ 120 GMutex *sels_mutex; /* Mutex for access to sels */ 118 121 }; 119 122 … … 121 124 122 125 123 typedef enum { 126 typedef enum 127 { 124 128 SWEEP_EDIT_MODE_READY, 125 SWEEP_EDIT_MODE_META, /* modifying metadata: sels etc. */129 SWEEP_EDIT_MODE_META, /* modifying metadata: sels etc. */ 126 130 SWEEP_EDIT_MODE_FILTER, 127 131 SWEEP_EDIT_MODE_ALLOC, 128 132 } sw_edit_mode; 129 133 130 typedef enum { 134 typedef enum 135 { 131 136 SWEEP_EDIT_STATE_IDLE, 132 137 SWEEP_EDIT_STATE_PENDING, … … 136 141 } sw_edit_state; 137 142 138 typedef enum { 143 typedef enum 144 { 139 145 SWEEP_TRANSPORT_STOP, 140 146 SWEEP_TRANSPORT_PLAY, … … 143 149 144 150 /* File formats */ 145 typedef enum { 146 SWEEP_FILE_FORMAT_NONE=0, 147 SWEEP_FILE_FORMAT_BY_EXTENSION=0, 151 typedef enum 152 { 153 SWEEP_FILE_FORMAT_NONE = 0, 154 SWEEP_FILE_FORMAT_BY_EXTENSION = 0, 148 155 SWEEP_FILE_FORMAT_RAW, 149 156 SWEEP_FILE_FORMAT_WAV, … … 165 172 * The length of data available *data is (end - start) 166 173 */ 167 struct _sw_edit_region { 174 struct _sw_edit_region 175 { 168 176 sw_framecount_t start; 169 177 sw_framecount_t end; … … 172 180 }; 173 181 174 struct _sw_edit_buffer { 175 sw_format * format; 176 GList * regions; 182 struct _sw_edit_buffer 183 { 184 sw_format *format; 185 GList *regions; 177 186 gint refcount; 178 187 }; … … 186 195 typedef struct _sw_op_instance sw_op_instance; 187 196 188 struct _sw_operation { 197 struct _sw_operation 198 { 189 199 sw_edit_mode edit_mode; 190 200 SweepCallback _do_; … … 196 206 }; 197 207 198 struct _sw_op_instance { 199 sw_sample * sample; 200 char * description; 201 sw_operation * op; 208 struct _sw_op_instance 209 { 210 sw_sample *sample; 211 char *description; 212 sw_operation *op; 202 213 gpointer do_data; 203 214 gpointer undo_data; … … 208 219 * Basic types for parameters 209 220 */ 210 typedef enum { 221 typedef enum 222 { 211 223 SWEEP_TYPE_BOOL = 0, 212 224 SWEEP_TYPE_INT, … … 218 230 typedef gint sw_int; 219 231 typedef gdouble sw_float; 220 typedef gchar * sw_string;232 typedef gchar *sw_string; 221 233 222 234 … … 225 237 */ 226 238 typedef union _sw_param sw_param; 227 typedef sw_param * sw_param_set; 228 229 union _sw_param { 239 typedef sw_param *sw_param_set; 240 241 union _sw_param 242 { 230 243 sw_bool b; 231 sw_int i;244 sw_int i; 232 245 sw_float f; 233 246 sw_string s; … … 243 256 * the usage of the sw_constraint. 244 257 */ 245 typedef enum { 258 typedef enum 259 { 246 260 /* 247 261 * SW_PARAM_CONSTRAINED_NOT indicates that the parameter is completely … … 253 267 * How free is its life, how wretched its lot! 254 268 */ 255 SW_PARAM_CONSTRAINED_NOT =0,269 SW_PARAM_CONSTRAINED_NOT = 0, 256 270 257 271 /* … … 303 317 #define SW_RANGE_STEP_VALID (1<<2) 304 318 305 #define SW_RANGE_ALL_VALID (SW_RANGE_LOWER_BOUND_VALID|SW_RANGE_UPPER_BOUND_VALID|SW_RANGE_STEP_VALID) 319 #define SW_RANGE_ALL_VALID (SW_RANGE_LOWER_BOUND_VALID|SW_RANGE_UPPER_BOUND_VALID|SW_RANGE_STEP_VALID) 306 320 307 321 /* … … 335 349 */ 336 350 #define SW_PARAM_HINT_FILENAME (1<<3) 337 351 338 352 339 353 typedef struct _sw_param_spec sw_param_spec; … … 355 369 * string parameters. 356 370 */ 357 struct _sw_param_range { 371 struct _sw_param_range 372 { 358 373 int valid_mask; 359 374 sw_param lower; … … 369 384 * All constraints are disregarded for boolean parameters. 370 385 */ 371 union _sw_constraint { 386 union _sw_constraint 387 { 372 388 /* 373 389 * param_list: Values are constrained to those within a list of … … 376 392 * ie. this length = constraint->param_list[0].i 377 393 */ 378 sw_param * list;394 sw_param *list; 379 395 380 396 /* 381 397 * param_range, as described above. 382 398 */ 383 sw_param_range * range;/* param range */399 sw_param_range *range; /* param range */ 384 400 }; 385 401 … … 388 404 * sw_param_spec: specification for a parameter. 389 405 */ 390 struct _sw_param_spec { 406 struct _sw_param_spec 407 { 391 408 /* A short name for this parameter */ 392 gchar * name;409 gchar *name; 393 410 394 411 /* A longer description of the parameter's purpose and usage */ 395 gchar * desc;412 gchar *desc; 396 413 397 414 /* The type of the parameter */ … … 414 431 typedef struct _sw_plugin sw_plugin; 415 432 416 struct _sw_procedure { 417 gchar * name; 418 gchar * description; 419 gchar * author; 420 gchar * copyright; 421 gchar * url; 422 423 gchar * identifier; 433 struct _sw_procedure 434 { 435 gchar *name; 436 gchar *description; 437 gchar *author; 438 gchar *copyright; 439 gchar *url; 440 441 gchar *identifier; 424 442 425 443 /* Key bindings */ … … 428 446 429 447 gint nr_params; 430 sw_param_spec * param_specs;448 sw_param_spec *param_specs; 431 449 432 450 /* suggest sets suggested values for the members of pset, … … 446 464 * If nr_params is 0 then this function will be passed a NULL pset. 447 465 */ 448 sw_op_instance * (*apply) (sw_sample * sample,449 sw_param_set pset, gpointer custom_data);466 sw_op_instance *(*apply) (sw_sample * sample, 467 sw_param_set pset, gpointer custom_data); 450 468 451 469 /* custom data to pass to the suggest and apply functions */ … … 453 471 }; 454 472 455 struct _sw_plugin { 473 struct _sw_plugin 474 { 456 475 /* plugin_init () returns a list of procedures */ 457 GList * (*plugin_init) (void);476 GList *(*plugin_init) (void); 458 477 459 478 /* plugin_cleanup() frees the plugin's private data structures */ … … 461 480 }; 462 481 463 typedef sw_sample * (*SweepFilter) (sw_sample * sample, 464 sw_param_set pset, 465 gpointer custom_data); 466 467 468 #endif /* __SWEEP_TYPES_H__ */ 469 470 471 472 473 474 482 typedef sw_sample *(*SweepFilter) (sw_sample * sample, 483 sw_param_set pset, gpointer custom_data); 484 485 486 #endif /* __SWEEP_TYPES_H__ */ sweep/branches/display-cache/include/sweep/sweep_undo.h
r124 r471 24 24 #include "sweep_types.h" 25 25 26 gint 27 update_edit_progress (gpointer data); 26 gint update_edit_progress (gpointer data); 28 27 29 sw_op_instance * 30 sw_op_instance_new (sw_sample * sample, char * description, 31 sw_operation * operation); 28 sw_op_instance *sw_op_instance_new (sw_sample * sample, char *description, 29 sw_operation * operation); 32 30 33 31 void 34 schedule_operation (sw_sample * sample, char * description,35 sw_operation * operation, void * do_data);32 schedule_operation (sw_sample * sample, char *description, 33 sw_operation * operation, void *do_data); 36 34 37 void 38 register_operation (sw_sample * s, sw_op_instance * inst); 35 void register_operation (sw_sample * s, sw_op_instance * inst); 39 36 40 void 41 trim_registered_ops (sw_sample * s, int length); 37 void trim_registered_ops (sw_sample * s, int length); 42 38 43 void 44 undo_current (sw_sample * s); 39 void undo_current (sw_sample * s); 45 40 46 void 47 redo_current (sw_sample * s); 41 void redo_current (sw_sample * s); 48 42 49 void 50 revert_op (sw_sample * sample, GList * op_gl); 43 void revert_op (sw_sample * sample, GList * op_gl); 51 44 52 void 53 set_active_op (sw_sample * s, sw_op_instance * inst); 45 void set_active_op (sw_sample * s, sw_op_instance * inst); 54 46 55 void 56 cancel_active_op (sw_sample * s); 47 void cancel_active_op (sw_sample * s); 57 48 58 49 /* Stock undo functions */ … … 61 52 typedef struct _replace_data replace_data; 62 53 63 struct _replace_data { 64 sw_sample * old_sample; 65 sw_sample * new_sample; 54 struct _replace_data 55 { 56 sw_sample *old_sample; 57 sw_sample *new_sample; 66 58 }; 67 59 68 replace_data * 69 replace_data_new (sw_sample * old_sample,sw_sample * new_sample);60 replace_data *replace_data_new (sw_sample * old_sample, 61 sw_sample * new_sample); 70 62 71 void 72 undo_by_replace (replace_data * r); 63 void undo_by_replace (replace_data * r); 73 64 74 void 75 redo_by_replace (replace_data * r); 65 void redo_by_replace (replace_data * r); 76 66 #endif 77 67 78 68 typedef struct _sounddata_replace_data sounddata_replace_data; 79 69 80 struct _sounddata_replace_data { 81 sw_sample * sample; 82 sw_sounddata * old_sounddata; 83 sw_sounddata * new_sounddata; 70 struct _sounddata_replace_data 71 { 72 sw_sample *sample; 73 sw_sounddata *old_sounddata; 74 sw_sounddata *new_sounddata; 84 75 }; 85 76 86 sounddata_replace_data * 87 sounddata_replace_data_new (sw_sample * sample, 88 sw_sounddata * old_sounddata, 89 sw_sounddata * new_sounddata); 77 sounddata_replace_data *sounddata_replace_data_new (sw_sample * sample, 78 sw_sounddata * 79 old_sounddata, 80 sw_sounddata * 81 new_sounddata); 90 82 91 void 92 sounddata_replace_data_destroy (sounddata_replace_data * sr); 83 void sounddata_replace_data_destroy (sounddata_replace_data * sr); 93 84 94 void 95 undo_by_sounddata_replace (sw_sample * s, sounddata_replace_data * sr); 85 void undo_by_sounddata_replace (sw_sample * s, sounddata_replace_data * sr); 96 86 97 void 98 redo_by_sounddata_replace (sw_sample * s, sounddata_replace_data * sr); 87 void redo_by_sounddata_replace (sw_sample * s, sounddata_replace_data * sr); 99 88 100 89 101 90 typedef struct _paste_over_data paste_over_data; 102 91 103 struct _paste_over_data { 104 sw_sample * sample; 105 sw_edit_buffer * old_eb; 106 sw_edit_buffer * new_eb; 92 struct _paste_over_data 93 { 94 sw_sample *sample; 95 sw_edit_buffer *old_eb; 96 sw_edit_buffer *new_eb; 107 97 }; 108 98 109 paste_over_data * 110 paste_over_data_new (sw_edit_buffer * old_eb,sw_edit_buffer * new_eb);99 paste_over_data *paste_over_data_new (sw_edit_buffer * old_eb, 100 sw_edit_buffer * new_eb); 111 101 112 void 113 paste_over_data_destroy (paste_over_data * p); 102 void paste_over_data_destroy (paste_over_data * p); 114 103 115 void 116 undo_by_paste_over (sw_sample * s, paste_over_data * p); 104 void undo_by_paste_over (sw_sample * s, paste_over_data * p); 117 105 118 void 119 redo_by_paste_over (sw_sample * s, paste_over_data * p); 106 void redo_by_paste_over (sw_sample * s, paste_over_data * p); 120 107 121 108 122 109 typedef struct _splice_data splice_data; 123 110 124 struct _splice_data { 125 sw_sample * sample; 126 sw_edit_buffer * eb; 127 GList * sels; /* Previous sels of sounddata */ 111 struct _splice_data 112 { 113 sw_sample *sample; 114 sw_edit_buffer *eb; 115 GList *sels; /* Previous sels of sounddata */ 128 116 }; 129 117 130 splice_data * 131 splice_data_new (sw_edit_buffer * eb, GList * sels); 118 splice_data *splice_data_new (sw_edit_buffer * eb, GList * sels); 132 119 133 void 134 splice_data_destroy (splice_data * s); 120 void splice_data_destroy (splice_data * s); 135 121 136 void 137 undo_by_splice_in (sw_sample * s, splice_data * sp); 122 void undo_by_splice_in (sw_sample * s, splice_data * sp); 138 123 139 void 140 redo_by_splice_out (sw_sample * s, splice_data * sp); 124 void redo_by_splice_out (sw_sample * s, splice_data * sp); 141 125 142 void 143 undo_by_splice_out (sw_sample * s, splice_data * sp); 126 void undo_by_splice_out (sw_sample * s, splice_data * sp); 144 127 145 void 146 redo_by_splice_in (sw_sample * s, splice_data * sp); 128 void redo_by_splice_in (sw_sample * s, splice_data * sp); 147 129 148 void 149 undo_by_splice_over (sw_sample * s, splice_data * sp); 130 void undo_by_splice_over (sw_sample * s, splice_data * sp); 150 131 151 void 152 redo_by_splice_over (sw_sample * s, splice_data * sp); 132 void redo_by_splice_over (sw_sample * s, splice_data * sp); 153 133 154 void 155 undo_by_crop_in (sw_sample * s, splice_data * sp); 134 void undo_by_crop_in (sw_sample * s, splice_data * sp); 156 135 157 void 158 redo_by_crop_out (sw_sample * s, splice_data * sp); 136 void redo_by_crop_out (sw_sample * s, splice_data * sp); 159 137 160 138 #endif /* __SWEEP_UNDO_H__ */ sweep/branches/display-cache/intl/bindtextdom.c
r183 r471 70 70 /* Lock variable to protect the global data in the gettext implementation. */ 71 71 __libc_rwlock_define (extern, _nl_state_lock attribute_hidden) 72 73 74 72 /* Names for the libintl functions are a problem. They must not clash 75 73 with existing names and they should follow ANSI C. But this source … … 86 84 # define BIND_TEXTDOMAIN_CODESET libintl_bind_textdomain_codeset 87 85 #endif 88 89 86 /* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP 90 87 to be used for the DOMAINNAME message catalog. … … 93 90 If DIRNAMEP or CODESETP is NULL, the corresponding attribute is neither 94 91 modified nor returned. */ 95 static void96 set_binding_values (const char *domainname,97 const char **dirnamep, const char **codesetp)92 static void 93 set_binding_values (const char *domainname, 94 const char **dirnamep, const char **codesetp) 98 95 { 99 96 struct binding *binding; … … 114 111 modified = 0; 115 112 116 for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) 113 for (binding = _nl_domain_bindings; binding != NULL; 114 binding = binding->next) 117 115 { 118 116 int compare = strcmp (domainname, binding->domainname); … … 140 138 { 141 139 /* The domain is already bound. If the new value and the old 142 one are equal we simply do nothing. Otherwise replace the143 old binding. */140 one are equal we simply do nothing. Otherwise replace the 141 old binding. */ 144 142 char *result = binding->dirname; 145 143 if (strcmp (dirname, result) != 0) 146 144 { 147 if (strcmp (dirname, INTUSE (_nl_default_dirname)) == 0)148 result = (char *) INTUSE (_nl_default_dirname);145 if (strcmp (dirname, INTUSE (_nl_default_dirname)) == 0) 146 result = (char *) INTUSE (_nl_default_dirname); 149 147 else 150 148 { … … 161 159 if (__builtin_expect (result != NULL, 1)) 162 160 { 163 if (binding->dirname != INTUSE (_nl_default_dirname))161 if (binding->dirname != INTUSE (_nl_default_dirname)) 164 162 free (binding->dirname); 165 163 … … 182 180 { 183 181 /* The domain is already bound. If the new value and the old 184 one are equal we simply do nothing. Otherwise replace the185 old binding. */182 one are equal we simply do nothing. Otherwise replace the 183 old binding. */ 186 184 char *result = binding->codeset; 187 185 if (result == NULL || strcmp (codeset, result) != 0) … … 215 213 /* Simply return the default values. */ 216 214 if (dirnamep) 217 *dirnamep = INTUSE (_nl_default_dirname);215 *dirnamep = INTUSE (_nl_default_dirname); 218 216 if (codesetp) 219 217 *codesetp = NULL; … … 224 222 size_t len = strlen (domainname) + 1; 225 223 struct binding *new_binding = 226 (struct binding *) malloc (offsetof (struct binding, domainname) + len); 224 (struct binding *) malloc (offsetof (struct binding, domainname) + 225 len); 227 226 228 227 if (__builtin_expect (new_binding == NULL, 0)) … … 237 236 if (dirname == NULL) 238 237 /* The default value. */ 239 dirname = INTUSE (_nl_default_dirname);238 dirname = INTUSE (_nl_default_dirname); 240 239 else 241 240 { 242 if (strcmp (dirname, INTUSE (_nl_default_dirname)) == 0)243 dirname = INTUSE (_nl_default_dirname);241 if (strcmp (dirname, INTUSE (_nl_default_dirname)) == 0) 242 dirname = INTUSE (_nl_default_dirname); 244 243 else 245 244 { … … 264 263 else 265 264 /* The default value. */ 266 new_binding->dirname = (char *) INTUSE (_nl_default_dirname);265 new_binding->dirname = (char *) INTUSE (_nl_default_dirname); 267 266 268 267 new_binding->codeset_cntr = 0; … … 320 319 { 321 320 failed_codeset: 322 if (new_binding->dirname != INTUSE (_nl_default_dirname))321 if (new_binding->dirname != INTUSE (_nl_default_dirname)) 323 322 free (new_binding->dirname); 324 323 failed_dirname: sweep/branches/display-cache/intl/dcgettext.c
r183 r471 52 52 #ifdef _LIBC 53 53 /* Alias for function name in GNU C Library. */ 54 INTDEF(__dcgettext) 55 weak_alias (__dcgettext, dcgettext); 54 INTDEF (__dcgettext) weak_alias (__dcgettext, dcgettext); 56 55 #endif sweep/branches/display-cache/intl/dcigettext.c
r183 r471 42 42 # else 43 43 # ifdef _AIX 44 #pragma alloca44 #pragma alloca 45 45 # else 46 46 # ifndef alloca … … 291 291 /* Value used as the default domain for gettext(3). */ 292 292 const char *_nl_current_default_domain attribute_hidden 293 = _nl_default_default_domain;293 = _nl_default_default_domain; 294 294 295 295 /* Contains the default location of the message catalogs. */ … … 300 300 INTVARDEF (_nl_default_dirname) 301 301 #endif 302 303 302 /* List with bindings of specific domains created by bindtextdomain() 304 303 calls. */ 305 struct binding *_nl_domain_bindings;304 struct binding *_nl_domain_bindings; 306 305 307 306 /* Prototypes for local functions. */ 308 static char *plural_lookup (struct loaded_l10nfile *domain,309 unsigned long int n,310 const char *translation, size_t translation_len)311 internal_function;312 static const char *guess_category_value (int category,313 const char *categoryname)314 internal_function;307 static char *plural_lookup (struct loaded_l10nfile *domain, 308 unsigned long int n, 309 const char *translation, 310 size_t translation_len) internal_function; 311 static const char *guess_category_value (int category, 312 const char *categoryname) 313 internal_function; 315 314 #ifdef _LIBC 316 315 # include "../locale/localeinfo.h" 317 316 # define category_to_name(category) _nl_category_names[category] 318 317 #else 319 static const char *category_to_name (int category) internal_function;318 static const char *category_to_name (int category) internal_function; 320 319 #endif 321 320 … … 325 324 #ifdef HAVE_ALLOCA 326 325 /* Nothing has to be done. */ 327 # define freea(p) /* nothing */328 # define ADD_BLOCK(list, address) /* nothing */329 # define FREE_BLOCKS(list) /* nothing */330 #else 331 struct block_list332 {333 void *address;334 struct block_list *next;335 };326 # define freea(p) /* nothing */ 327 # define ADD_BLOCK(list, address) /* nothing */ 328 # define FREE_BLOCKS(list) /* nothing */ 329 #else 330 struct block_list 331 { 332 void *address; 333 struct block_list *next; 334 }; 336 335 # define ADD_BLOCK(list, addr) \ 337 336 do { \ … … 357 356 # define alloca(size) (malloc (size)) 358 357 # define freea(p) free (p) 359 #endif /* have alloca */358 #endif /* have alloca */ 360 359 361 360 362 361 #ifdef _LIBC 363 362 /* List of blocks allocated for translations. */ 364 typedef struct transmem_list365 {366 struct transmem_list *next;367 char data[ZERO];368 } transmem_block_t;369 static struct transmem_list *transmem_list;370 #else 371 typedef unsigned char transmem_block_t;363 typedef struct transmem_list 364 { 365 struct transmem_list *next; 366 char data[ZERO]; 367 } transmem_block_t; 368 static struct transmem_list *transmem_list; 369 #else 370 typedef unsigned char transmem_block_t; 372 371 #endif 373 372 … … 387 386 __libc_rwlock_define_initialized (, _nl_state_lock attribute_hidden) 388 387 #endif 389 390 388 /* Checking whether the binaries runs SUID must be done and glibc provides 391 389 easier methods therefore we make a difference here. */ … … 406 404 # define getegid() getgid() 407 405 # endif 408 static int enable_secure;406 static int enable_secure; 409 407 # define ENABLE_SECURE (enable_secure == 1) 410 408 # define DETERMINE_SECURE \ … … 424 422 CATEGORY locale and, if PLURAL is nonzero, search over string 425 423 depending on the plural form determined by N. */ 426 char * 427 DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,428 int plural, unsigned long int n,int category)424 char *DCIGETTEXT (const char *domainname, const char *msgid1, 425 const char *msgid2, int plural, unsigned long int n, 426 int category) 429 427 { 430 428 #ifndef HAVE_ALLOCA … … 454 452 if (category < 0 || category >= __LC_LAST || category == LC_ALL) 455 453 /* Bogus. */ 456 return (plural == 0 457 ? (char *) msgid1 454 return (plural == 0 ? (char *) msgid1 458 455 /* Use the Germanic plural rule. */ 459 456 : n == 1 ? (char *) msgid1 : (char *) msgid2); … … 480 477 some time. */ 481 478 search = (struct known_translation_t *) 482 alloca (offsetof (struct known_translation_t, msgid) + msgid_len);479 alloca (offsetof (struct known_translation_t, msgid) + msgid_len); 483 480 memcpy (search->msgid, msgid1, msgid_len); 484 481 search->domainname = (char *) domainname; … … 508 505 509 506 /* First find matching binding. */ 510 for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) 507 for (binding = _nl_domain_bindings; binding != NULL; 508 binding = binding->next) 511 509 { 512 510 int compare = strcmp (domainname, binding->domainname); … … 523 521 524 522 if (binding == NULL) 525 dirname = (char *) INTUSE (_nl_default_dirname);523 dirname = (char *) INTUSE (_nl_default_dirname); 526 524 else if (IS_ABSOLUTE_PATH (binding->dirname)) 527 525 dirname = binding->dirname; … … 563 561 564 562 domainname_len = strlen (domainname); 565 xdomainname = (char *) alloca (strlen (categoryname) 566 + domainname_len + 5); 563 xdomainname = (char *) alloca (strlen (categoryname) + domainname_len + 5); 567 564 ADD_BLOCK (block_list, xdomainname); 568 565 569 566 stpcpy (mempcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"), 570 domainname, domainname_len), 571 ".mo"); 567 domainname, domainname_len), ".mo"); 572 568 573 569 /* Creating working area. */ … … 607 603 608 604 /* If the current locale value is C (or POSIX) we don't load a 609 domain. Return the MSGID. */605 domain. Return the MSGID. */ 610 606 if (strcmp (single_locale, "C") == 0 611 607 || strcmp (single_locale, "POSIX") == 0) … … 613 609 614 610 /* Find structure describing the message catalog matching the 615 DOMAINNAME and CATEGORY. */611 DOMAINNAME and CATEGORY. */ 616 612 domain = _nl_find_domain (dirname, single_locale, xdomainname, binding); 617 613 … … 640 636 { 641 637 /* Found the translation of MSGID1 in domain DOMAIN: 642 starting at RETVAL, RETLEN bytes. */638 starting at RETVAL, RETLEN bytes. */ 643 639 FREE_BLOCKS (block_list); 644 640 #if defined HAVE_TSEARCH || defined _LIBC … … 655 651 newp->domainname = 656 652 mempcpy (newp->msgid, msgid1, msgid_len); 657 memcpy (newp->domainname, domainname, domainname_len + 1); 653 memcpy (newp->domainname, domainname, 654 domainname_len + 1); 658 655 newp->category = category; 659 656 newp->counter = _nl_msg_cat_cntr; … … 692 689 } 693 690 694 return_untranslated:691 return_untranslated: 695 692 /* Return the untranslated MSGID. */ 696 693 FREE_BLOCKS (block_list); … … 701 698 extern void _nl_log_untranslated (const char *logfilename, 702 699 const char *domainname, 703 const char *msgid1, const char *msgid2,704 int plural);700 const char *msgid1, 701 const char *msgid2, int plural); 705 702 const char *logfilename = getenv ("GETTEXT_LOG_UNTRANSLATED"); 706 703 707 704 if (logfilename != NULL && logfilename[0] != '\0') 708 _nl_log_untranslated (logfilename, domainname, msgid1, msgid2, plural); 705 _nl_log_untranslated (logfilename, domainname, msgid1, msgid2, 706 plural); 709 707 } 710 708 #endif 711 709 __set_errno (saved_errno); 712 return (plural == 0 713 ? (char *) msgid1 710 return (plural == 0 ? (char *) msgid1 714 711 /* Use the Germanic plural rule. */ 715 712 : n == 1 ? (char *) msgid1 : (char *) msgid2); … … 717 714 718 715 719 char * 720 internal_function 716 char *internal_function 721 717 _nl_find_msg (struct loaded_l10nfile *domain_file, 722 718 struct binding *domainbinding, const char *msgid, 723 size_t * lengthp)719 size_t * lengthp) 724 720 { 725 721 struct loaded_domain *domain; … … 764 760 if (nstr < nstrings 765 761 ? W (domain->must_swap, domain->orig_tab[nstr].length) >= len 766 && (strcmp (msgid,767 domain->data + W (domain->must_swap,768 domain->orig_tab[nstr].offset))769 == 0)762 && (strcmp (msgid, 763 domain->data + W (domain->must_swap, 764 domain->orig_tab[nstr].offset)) 765 == 0) 770 766 : domain->orig_sysdep_tab[nstr - nstrings].length > len 771 && (strcmp (msgid,772 domain->orig_sysdep_tab[nstr - nstrings].pointer)773 == 0))767 && (strcmp (msgid, 768 domain->orig_sysdep_tab[nstr - nstrings].pointer) 769 == 0)) 774 770 { 775 771 act = nstr; … … 787 783 { 788 784 /* Try the default method: binary search in the sorted array of 789 messages. */785 messages. */ 790 786 size_t top, bottom; 791 787 … … 811 807 } 812 808 813 found:809 found: 814 810 /* The translation was found at index ACT. If we have to convert the 815 811 string to use a different character set, this is the time. */ … … 831 827 { 832 828 /* The domain's codeset has changed through bind_textdomain_codeset() 833 since the message catalog was initialized or last accessed. We834 have to reinitialize the converter. */829 since the message catalog was initialized or last accessed. We 830 have to reinitialize the converter. */ 835 831 _nl_free_domain_conv (domain); 836 832 _nl_init_domain_conv (domain_file, domain, domainbinding); … … 839 835 if ( 840 836 # ifdef _LIBC 841 domain->conv != (__gconv_t) -1837 domain->conv != (__gconv_t) - 1 842 838 # else 843 839 # if HAVE_ICONV 844 domain->conv != (iconv_t) -1840 domain->conv != (iconv_t) - 1 845 841 # endif 846 842 # endif 847 )843 ) 848 844 { 849 845 /* We are supposed to do a conversion. First allocate an 850 appropriate table with the same structure as the table851 of translations in the file, where we can put the pointers852 to the converted strings in.853 There is a slight complication with plural entries. They854 are represented by consecutive NUL terminated strings. We855 handle this case by converting RESULTLEN bytes, including856 NULs. */846 appropriate table with the same structure as the table 847 of translations in the file, where we can put the pointers 848 to the converted strings in. 849 There is a slight complication with plural entries. They 850 are represented by consecutive NUL terminated strings. We 851 handle this case by converting RESULTLEN bytes, including 852 NULs. */ 857 853 858 854 if (domain->conv_tab == NULL 859 855 && ((domain->conv_tab = 860 (char **) calloc (nstrings + domain->n_sysdep_strings, 861 sizeof (char *))) 862 == NULL)) 856 (char **) calloc (nstrings + domain->n_sysdep_strings, 857 sizeof (char *))) == NULL)) 863 858 /* Mark that we didn't succeed allocating a table. */ 864 859 domain->conv_tab = (char **) -1; … … 932 927 if (iconv (domain->conv, 933 928 (ICONV_CONST char **) &inptr, &inleft, 934 &outptr, &outleft) 935 != (size_t) (-1)) 929 &outptr, &outleft) != (size_t) (-1)) 936 930 { 937 931 outbuf = (unsigned char *) outptr; … … 982 976 # ifdef _LIBC 983 977 /* Add the block to the list of blocks we have to free 984 at some point. */978 at some point. */ 985 979 newmem->next = transmem_list; 986 980 transmem_list = newmem; … … 1004 998 freemem = outbuf; 1005 999 freemem += freemem_size & (alignof (size_t) - 1); 1006 freemem_size = freemem_size & ~ (alignof (size_t) - 1);1000 freemem_size = freemem_size & ~(alignof (size_t) - 1); 1007 1001 1008 1002 __libc_lock_unlock (lock); … … 1010 1004 1011 1005 /* Now domain->conv_tab[act] contains the translation of all 1012 the plural variants. */1006 the plural variants. */ 1013 1007 result = domain->conv_tab[act] + sizeof (size_t); 1014 1008 resultlen = *(size_t *) domain->conv_tab[act]; 1015 1009 } 1016 1010 1017 converted:1011 converted: 1018 1012 /* The result string is converted. */ 1019 1013 … … 1026 1020 1027 1021 /* Look up a plural variant. */ 1028 static char * 1029 internal_function 1022 static char *internal_function 1030 1023 plural_lookup (struct loaded_l10nfile *domain, unsigned long int n, 1031 1024 const char *translation, size_t translation_len) … … 1064 1057 #ifndef _LIBC 1065 1058 /* Return string representation of locale CATEGORY. */ 1066 static const char * 1067 internal_function 1059 static const char *internal_function 1068 1060 category_to_name (int category) 1069 1061 { … … 1071 1063 1072 1064 switch (category) 1073 {1065 { 1074 1066 #ifdef LC_COLLATE 1075 case LC_COLLATE:1076 retval = "LC_COLLATE";1077 break;1067 case LC_COLLATE: 1068 retval = "LC_COLLATE"; 1069 break; 1078 1070 #endif 1079 1071 #ifdef LC_CTYPE 1080 case LC_CTYPE:1081 retval = "LC_CTYPE";1082 break;1072 case LC_CTYPE: 1073 retval = "LC_CTYPE"; 1074 break; 1083 1075 #endif 1084 1076 #ifdef LC_MONETARY 1085 case LC_MONETARY:1086 retval = "LC_MONETARY";1087 break;1077 case LC_MONETARY: 1078 retval = "LC_MONETARY"; 1079 break; 1088 1080 #endif 1089 1081 #ifdef LC_NUMERIC 1090 case LC_NUMERIC:1091 retval = "LC_NUMERIC";1092 break;1082 case LC_NUMERIC: 1083 retval = "LC_NUMERIC"; 1084 break; 1093 1085 #endif 1094 1086 #ifdef LC_TIME 1095 case LC_TIME:1096 retval = "LC_TIME";1097 break;1087 case LC_TIME: 1088 retval = "LC_TIME"; 1089 break; 1098 1090 #endif 1099 1091 #ifdef LC_MESSAGES 1100 case LC_MESSAGES:1101 retval = "LC_MESSAGES";1102 break;1092 case LC_MESSAGES: 1093 retval = "LC_MESSAGES"; 1094 break; 1103 1095 #endif 1104 1096 #ifdef LC_RESPONSE 1105 case LC_RESPONSE:1106 retval = "LC_RESPONSE";1107 break;1097 case LC_RESPONSE: 1098 retval = "LC_RESPONSE"; 1099 break; 1108 1100 #endif 1109 1101 #ifdef LC_ALL 1110 case LC_ALL:1111 /* This might not make sense but is perhaps better than any other1112 value. */1113 retval = "LC_ALL";1114 break;1115 #endif 1116 default:1117 /* If you have a better idea for a default value let me know. */1118 retval = "LC_XXX";1119 }1102 case LC_ALL: 1103 /* This might not make sense but is perhaps better than any other 1104 value. */ 1105 retval = "LC_ALL"; 1106 break; 1107 #endif 1108 default: 1109 /* If you have a better idea for a default value let me know. */ 1110 retval = "LC_XXX"; 1111 } 1120 1112 1121 1113 return retval; … … 1125 1117 /* Guess value of current locale from value of the environment variables 1126 1118 or system-dependent defaults. */ 1127 static const char * 1128 internal_function 1119 static const char *internal_function 1129 1120 guess_category_value (int category, const char *categoryname) 1130 1121 { … … 1138 1129 /* We use the settings in the following order: 1139 1130 1. The value of the environment variable 'LANGUAGE'. This is a GNU 1140 extension. Its value can be a colon-separated list of locale names.1131 extension. Its value can be a colon-separated list of locale names. 1141 1132 2. The value of the environment variable 'LC_ALL', 'LC_xxx', or 'LANG'. 1142 More precisely, the first among these that is set to a non-empty value.1143 This is how POSIX specifies it. The value is a single locale name.1133 More precisely, the first among these that is set to a non-empty value. 1134 This is how POSIX specifies it. The value is a single locale name. 1144 1135 3. A system-dependent preference list of languages. Its value can be a 1145 colon-separated list of locale names.1136 colon-separated list of locale names. 1146 1137 4. A system-dependent default locale name. 1147 1138 This way: 1148 - System-dependent settings can be overridden by environment variables.1149 - If the system provides both a list of languages and a default locale,1150 the former is used. */1139 - System-dependent settings can be overridden by environment variables. 1140 - If the system provides both a list of languages and a default locale, 1141 the former is used. */ 1151 1142 1152 1143 /* Fetch the locale name, through the POSIX method of looking to `LC_ALL', … … 1168 1159 to "C" because 1169 1160 1. "C" locale usually uses the ASCII encoding, and most international 1170 messages use non-ASCII characters. These characters get displayed1171 as question marks (if using glibc's iconv()) or as invalid 8-bit1172 characters (because other iconv()s refuse to convert most non-ASCII1173 characters to ASCII). In any case, the output is ugly.1161 messages use non-ASCII characters. These characters get displayed 1162 as question marks (if using glibc's iconv()) or as invalid 8-bit 1163 characters (because other iconv()s refuse to convert most non-ASCII 1164 characters to ASCII). In any case, the output is ugly. 1174 1165 2. The precise output of some programs in the "C" locale is specified 1175 by POSIX and should not depend on environment variables like1176 "LANGUAGE" or system-dependent information. We allow such programs1177 to use gettext(). */1166 by POSIX and should not depend on environment variables like 1167 "LANGUAGE" or system-dependent information. We allow such programs 1168 to use gettext(). */ 1178 1169 if (strcmp (locale, "C") == 0) 1179 1170 return locale; … … 1191 1182 language_default = _nl_language_preferences_default (); 1192 1183 if (language_default != NULL) 1193 return language_default;1184 return language_default; 1194 1185 } 1195 1186 /* The least priority value is the locale name, if defaulted. */ … … 1234 1225 struct binding *oldp = _nl_domain_bindings; 1235 1226 _nl_domain_bindings = _nl_domain_bindings->next; 1236 if (oldp->dirname != INTUSE (_nl_default_dirname))1227 if (oldp->dirname != INTUSE (_nl_default_dirname)) 1237 1228 /* Yes, this is a pointer comparison. */ 1238 1229 free (oldp->dirname); sweep/branches/display-cache/intl/eval-plural.h
r183 r471 22 22 23 23 /* Evaluate the plural expression and return an index value. */ 24 STATIC 25 unsigned long int 26 internal_function 24 STATIC unsigned long int internal_function 27 25 plural_eval (struct expression *pexp, unsigned long int n) 28 26 { … … 45 43 /* pexp->operation must be lnot. */ 46 44 unsigned long int arg = plural_eval (pexp->val.args[0], n); 47 return ! arg;45 return !arg; 48 46 } 49 47 case 2: sweep/branches/display-cache/intl/explodename.c
r183 r471 56 56 const char **sponsor, const char **revision) 57 57 { 58 enum { undecided, xpg, cen } syntax; 58 enum 59 { undecided, xpg, cen } syntax; 59 60 char *cp; 60 61 int mask; … … 136 137 if (cp[0] == '+') 137 138 { 138 /* Next is special application (CEN syntax). */139 /* Next is special application (CEN syntax). */ 139 140 cp[0] = '\0'; 140 141 *special = ++cp; … … 148 149 if (cp[0] == ',') 149 150 { 150 /* Next is sponsor (CEN syntax). */151 /* Next is sponsor (CEN syntax). */ 151 152 cp[0] = '\0'; 152 153 *sponsor = ++cp; … … 160 161 if (cp[0] == '_') 161 162 { 162 /* Next is revision (CEN syntax). */163 /* Next is revision (CEN syntax). */ 163 164 cp[0] = '\0'; 164 165 *revision = ++cp; sweep/branches/display-cache/intl/finddomain.c
r183 r471 46 46 the DOMAINNAME and CATEGORY parameters with respect to the currently 47 47 established bindings. */ 48 struct loaded_l10nfile * 49 internal_function 48 struct loaded_l10nfile *internal_function 50 49 _nl_find_domain (const char *dirname, char *locale, 51 50 const char *domainname, struct binding *domainbinding) … … 65 64 /* LOCALE can consist of up to four recognized parts for the XPG syntax: 66 65 67 language[_territory[.codeset]][@modifier]66 language[_territory[.codeset]][@modifier] 68 67 69 68 and six parts for the CEN syntax: 70 69 71 language[_territory][+audience][+special][,[sponsor][_revision]]70 language[_territory][+audience][+special][,[sponsor][_revision]] 72 71 73 72 Beside the first part all of them are allowed to be missing. If … … 75 74 looked for. The various parts will be stripped off according to 76 75 the following order: 77 (1) revision78 (2) sponsor79 (3) special80 (4) codeset81 (5) normalized codeset82 (6) territory83 (7) audience/modifier76 (1) revision 77 (2) sponsor 78 (3) special 79 (4) codeset 80 (5) normalized codeset 81 (6) territory 82 (7) audience/modifier 84 83 */ 85 84 … … 113 112 114 113 /* See whether the locale value is an alias. If yes its value 115 *overwrites* the alias name. No test for the original value is116 done. */114 *overwrites* the alias name. No test for the original value is 115 done. */ 117 116 alias_value = _nl_expand_alias (locale); 118 117 if (alias_value != NULL) … … 142 141 generalization. */ 143 142 retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname, 144 strlen (dirname) + 1, mask, language, territory, 145 codeset, normalized_codeset, modifier, special, 146 sponsor, revision, domainname, 1); 143 strlen (dirname) + 1, mask, language, 144 territory, codeset, normalized_codeset, 145 modifier, special, sponsor, revision, 146 domainname, 1); 147 147 if (retval == NULL) 148 148 /* This means we are out of core. */ sweep/branches/display-cache/intl/gettextP.h
r183 r471 141 141 struct binding *next; 142 142 char *dirname; 143 int codeset_cntr; /* Incremented each time codeset changes. */143 int codeset_cntr; /* Incremented each time codeset changes. */ 144 144 char *codeset; 145 145 char domainname[ZERO]; … … 158 158 #endif 159 159 160 struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale, 161 const char *__domainname, 162 struct binding *__domainbinding) 163 internal_function; 164 void _nl_load_domain (struct loaded_l10nfile *__domain, 165 struct binding *__domainbinding) 166 internal_function; 167 void _nl_unload_domain (struct loaded_domain *__domain) 168 internal_function; 169 const char *_nl_init_domain_conv (struct loaded_l10nfile *__domain_file, 170 struct loaded_domain *__domain, 171 struct binding *__domainbinding) 172 internal_function; 173 void _nl_free_domain_conv (struct loaded_domain *__domain) 174 internal_function; 175 176 char *_nl_find_msg (struct loaded_l10nfile *domain_file, 177 struct binding *domainbinding, const char *msgid, 178 size_t *lengthp) 179 internal_function; 180 181 #ifdef _LIBC 182 extern char *__gettext (const char *__msgid); 183 extern char *__dgettext (const char *__domainname, const char *__msgid); 184 extern char *__dcgettext (const char *__domainname, const char *__msgid, 185 int __category); 186 extern char *__ngettext (const char *__msgid1, const char *__msgid2, 187 unsigned long int __n); 188 extern char *__dngettext (const char *__domainname, 189 const char *__msgid1, const char *__msgid2, 190 unsigned long int n); 191 extern char *__dcngettext (const char *__domainname, 192 const char *__msgid1, const char *__msgid2, 193 unsigned long int __n, int __category); 194 extern char *__dcigettext (const char *__domainname, 195 const char *__msgid1, const char *__msgid2, 196 int __plural, unsigned long int __n, 197 int __category); 198 extern char *__textdomain (const char *__domainname); 199 extern char *__bindtextdomain (const char *__domainname, 200 const char *__dirname); 201 extern char *__bind_textdomain_codeset (const char *__domainname, 202 const char *__codeset); 160 struct loaded_l10nfile * 161 _nl_find_domain (const char *__dirname, char *__locale, 162 const char *__domainname, struct binding *__domainbinding) 163 internal_function; 164 void _nl_load_domain (struct loaded_l10nfile *__domain, 165 struct binding *__domainbinding) internal_function; 166 void _nl_unload_domain (struct loaded_domain *__domain) 167 internal_function; 168 const char *_nl_init_domain_conv (struct loaded_l10nfile *__domain_file, 169 struct loaded_domain *__domain, 170 struct binding *__domainbinding) 171 internal_function; 172 void _nl_free_domain_conv (struct loaded_domain *__domain) 173 internal_function; 174 175 char *_nl_find_msg (struct loaded_l10nfile *domain_file, 176 struct binding *domainbinding, const char *msgid, 177 size_t * lengthp) internal_function; 178 179 #ifdef _LIBC 180 extern char *__gettext (const char *__msgid); 181 extern char *__dgettext (const char *__domainname, const char *__msgid); 182 extern char *__dcgettext (const char *__domainname, const char *__msgid, 183 int __category); 184 extern char *__ngettext (const char *__msgid1, const char *__msgid2, 185 unsigned long int __n); 186 extern char *__dngettext (const char *__domainname, 187 const char *__msgid1, const char *__msgid2, 188 unsigned long int n); 189 extern char *__dcngettext (const char *__domainname, 190 const char *__msgid1, const char *__msgid2, 191 unsigned long int __n, int __category); 192 extern char *__dcigettext (const char *__domainname, 193 const char *__msgid1, const char *__msgid2, 194 int __plural, unsigned long int __n, 195 int __category); 196 extern char *__textdomain (const char *__domainname); 197 extern char *__bindtextdomain (const char *__domainname, 198 const char *__dirname); 199 extern char *__bind_textdomain_codeset (const char *__domainname, 200 const char *__codeset); 203 201 #else 204 202 /* Declare the exported libintl_* functions, in a way that allows us to … … 208 206 # define _INTL_REDIRECT_MACROS 209 207 # include "libgnuintl.h" 210 extern char *libintl_dcigettext (const char *__domainname,211 const char *__msgid1, const char *__msgid2,212 int __plural, unsigned long int __n,213 int __category);208 extern char *libintl_dcigettext (const char *__domainname, 209 const char *__msgid1, 210 const char *__msgid2, int __plural, 211 unsigned long int __n, int __category); 214 212 #endif 215 213 sweep/branches/display-cache/intl/gmo.h
r183 r471 64 64 /* The following line is intended to throw an error. Using #error is 65 65 not portable enough. */ 66 "Cannot determine unsigned 32-bit data type."66 "Cannot determine unsigned 32-bit data type." 67 67 # endif 68 68 # endif 69 69 #endif 70 71 72 70 /* Header for binary .mo file format. */ 73 struct mo_file_header71 struct mo_file_header 74 72 { 75 73 /* The magic number. */ … … 147 145 /* @@ begin of epilog @@ */ 148 146 149 #endif /* gettext.h */147 #endif /* gettext.h */ sweep/branches/display-cache/intl/intl-compat.c
r183 r471 57 57 58 58 59 DLL_EXPORTED 60 char * 59 DLL_EXPORTED char * 61 60 gettext (const char *msgid) 62 61 { … … 65 64 66 65 67 DLL_EXPORTED 68 char * 66 DLL_EXPORTED char * 69 67 dgettext (const char *domainname, const char *msgid) 70 68 { … … 73 71 74 72 75 DLL_EXPORTED 76 char * 73 DLL_EXPORTED char * 77 74 dcgettext (const char *domainname, const char *msgid, int category) 78 75 { … … 81 78 82 79 83 DLL_EXPORTED 84 char * 80 DLL_EXPORTED char * 85 81 ngettext (const char *msgid1, const char *msgid2, unsigned long int n) 86 82 { … … 89 85 90 86 91 DLL_EXPORTED 92 char * 87 DLL_EXPORTED char * 93 88 dngettext (const char *domainname, 94 89 const char *msgid1, const char *msgid2, unsigned long int n) … … 98 93 99 94 100 DLL_EXPORTED 101 char * 95 DLL_EXPORTED char * 102 96 dcngettext (const char *domainname, 103 97 const char *msgid1, const char *msgid2, unsigned long int n, … … 108 102 109 103 110 DLL_EXPORTED 111 char * 104 DLL_EXPORTED char * 112 105 textdomain (const char *domainname) 113 106 { … … 116 109 117 110 118 DLL_EXPORTED 119 char * 111 DLL_EXPORTED char * 120 112 bindtextdomain (const char *domainname, const char *dirname) 121 113 { … … 124 116 125 117 126 DLL_EXPORTED 127 char * 118 DLL_EXPORTED char * 128 119 bind_textdomain_codeset (const char *domainname, const char *codeset) 129 120 { sweep/branches/display-cache/intl/l10nflist.c
r183 r471 98 98 return count; 99 99 } 100 100 101 # undef __argz_count 101 102 # define __argz_count(argz, len) argz_count__ (argz, len) … … 104 105 # define __argz_count(argz, len) INTUSE(__argz_count) (argz, len) 105 106 # endif 106 #endif /* !_LIBC && !HAVE___ARGZ_COUNT */107 #endif /* !_LIBC && !HAVE___ARGZ_COUNT */ 107 108 108 109 #if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY … … 121 122 } 122 123 } 124 123 125 # undef __argz_stringify 124 126 # define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep) … … 128 130 INTUSE(__argz_stringify) (argz, len, sep) 129 131 # endif 130 #endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */132 #endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */ 131 133 132 134 #if !defined _LIBC && !defined HAVE___ARGZ_NEXT … … 137 139 { 138 140 if (entry < argz + argz_len) 139 entry = strchr (entry, '\0') + 1;141 entry = strchr (entry, '\0') + 1; 140 142 141 143 return entry >= argz + argz_len ? NULL : (char *) entry; 142 144 } 145 else if (argz_len > 0) 146 return argz; 143 147 else 144 if (argz_len > 0) 145 return argz; 146 else 147 return 0; 148 } 148 return 0; 149 } 150 149 151 # undef __argz_next 150 152 # define __argz_next(argz, len, entry) argz_next__ (argz, len, entry) 151 #endif /* !_LIBC && !HAVE___ARGZ_NEXT */153 #endif /* !_LIBC && !HAVE___ARGZ_NEXT */ 152 154 153 155 … … 164 166 return x; 165 167 } 166 167 168 169 168 170 struct loaded_l10nfile * 169 171 _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, … … 243 245 { 244 246 /* This component can be part of both syntaces but has different 245 leading characters. For CEN we use `+', else `@'. */247 leading characters. For CEN we use `+', else `@'. */ 246 248 *cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@'; 247 249 cp = stpcpy (cp, modifier); sweep/branches/display-cache/intl/langprefs.c
r183 r471 44 44 _nl_language_preferences_default (void) 45 45 { 46 #if HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.2 or newer */46 #if HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.2 or newer */ 47 47 { 48 48 /* Cache the preferences list, since CoreFoundation calls are expensive. */ … … 58 58 && CFGetTypeID (preferences) == CFArrayGetTypeID ()) 59 59 { 60 CFArrayRef prefArray = (CFArrayRef) preferences;60 CFArrayRef prefArray = (CFArrayRef) preferences; 61 61 int n = CFArrayGetCount (prefArray); 62 62 char buf[256]; … … 69 69 if (element != NULL 70 70 && CFGetTypeID (element) == CFStringGetTypeID () 71 && CFStringGetCString ((CFStringRef) element,71 && CFStringGetCString ((CFStringRef) element, 72 72 buf, sizeof (buf), 73 73 kCFStringEncodingASCII)) … … 99 99 CFArrayGetValueAtIndex (prefArray, i); 100 100 if (element != NULL 101 && CFGetTypeID (element) == CFStringGetTypeID ()102 && CFStringGetCString ((CFStringRef) element,101 && CFGetTypeID (element) == CFStringGetTypeID () 102 && CFStringGetCString ((CFStringRef) element, 103 103 buf, sizeof (buf), 104 104 kCFStringEncodingASCII)) sweep/branches/display-cache/intl/loadinfo.h
r183 r471 99 99 furthermore its ->successor[] field contains a list of other lookup 100 100 results from which this lookup result inherits. */ 101 extern struct loaded_l10nfile * 102 _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, 103 const char *dirlist, size_t dirlist_len, int mask, 104 const char *language, const char *territory, 105 const char *codeset, const char *normalized_codeset, 106 const char *modifier, const char *special, 107 const char *sponsor, const char *revision, 108 const char *filename, int do_allocate); 101 extern struct loaded_l10nfile *_nl_make_l10nflist (struct loaded_l10nfile 102 **l10nfile_list, 103 const char *dirlist, 104 size_t dirlist_len, 105 int mask, 106 const char *language, 107 const char *territory, 108 const char *codeset, 109 const char 110 *normalized_codeset, 111 const char *modifier, 112 const char *special, 113 const char *sponsor, 114 const char *revision, 115 const char *filename, 116 int do_allocate); 109 117 110 118 /* Lookup the real locale name for a locale alias NAME, or NULL if … … 143 151 extern char *_nl_find_language (const char *name); 144 152 145 #endif /* loadinfo.h */153 #endif /* loadinfo.h */ sweep/branches/display-cache/intl/loadmsgcat.c
r183 r471 47 47 # else 48 48 # ifdef _AIX 49 #pragma alloca49 #pragma alloca 50 50 # else 51 51 # ifndef alloca … … 468 468 some additional code emulating it. */ 469 469 #ifdef HAVE_ALLOCA 470 # define freea(p) /* nothing */470 # define freea(p) /* nothing */ 471 471 #else 472 472 # define alloca(n) malloc (n) … … 754 754 #if defined _LIBC || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 755 755 /* The 'I' flag, in numeric format directives, replaces ASCII digits 756 with the 'outdigits' defined in the LC_CTYPE locale facet. This is757 used for Farsi (Persian) and maybe Arabic. */756 with the 'outdigits' defined in the LC_CTYPE locale facet. This is 757 used for Farsi (Persian) and maybe Arabic. */ 758 758 return "I"; 759 759 #else … … 767 767 /* Initialize the codeset dependent parts of an opened message catalog. 768 768 Return the header entry. */ 769 const char * 770 internal_function 769 const char *internal_function 771 770 _nl_init_domain_conv (struct loaded_l10nfile *domain_file, 772 771 struct loaded_domain *domain, … … 785 784 (domainbinding != NULL ? domainbinding->codeset_cntr : 0); 786 785 #ifdef _LIBC 787 domain->conv = (__gconv_t) - 1;786 domain->conv = (__gconv_t) - 1; 788 787 #else 789 788 # if HAVE_ICONV 790 domain->conv = (iconv_t) - 1;789 domain->conv = (iconv_t) - 1; 791 790 # endif 792 791 #endif … … 847 846 charset = norm_add_slashes (charset, NULL); 848 847 if (__gconv_open (outcharset, charset, &domain->conv, 849 GCONV_AVOID_NOCONV) 850 != __GCONV_OK) 851 domain->conv = (__gconv_t) -1; 848 GCONV_AVOID_NOCONV) != __GCONV_OK) 849 domain->conv = (__gconv_t) - 1; 852 850 # else 853 851 # if HAVE_ICONV … … 885 883 886 884 /* Frees the codeset dependent parts of an opened message catalog. */ 887 void 888 internal_function 885 void internal_function 889 886 _nl_free_domain_conv (struct loaded_domain *domain) 890 887 { … … 893 890 894 891 #ifdef _LIBC 895 if (domain->conv != (__gconv_t) - 1)892 if (domain->conv != (__gconv_t) - 1) 896 893 __gconv_close (domain->conv); 897 894 #else 898 895 # if HAVE_ICONV 899 if (domain->conv != (iconv_t) - 1)896 if (domain->conv != (iconv_t) - 1) 900 897 iconv_close (domain->conv); 901 898 # endif … … 905 902 /* Load the message catalogs specified by FILENAME. If it is no valid 906 903 message catalog do nothing. */ 907 void 908 internal_function 904 void internal_function 909 905 _nl_load_domain (struct loaded_l10nfile *domain_file, 910 906 struct binding *domainbinding) … … 945 941 if ( 946 942 #ifdef _LIBC 947 __builtin_expect (fstat64 (fd, &st) != 0, 0)943 __builtin_expect (fstat64 (fd, &st) != 0, 0) 948 944 #else 949 __builtin_expect (fstat (fd, &st) != 0, 0)950 #endif 951 || __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0)952 || __builtin_expect (size < sizeof (struct mo_file_header), 0))945 __builtin_expect (fstat (fd, &st) != 0, 0) 946 #endif 947 || __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0) 948 || __builtin_expect (size < sizeof (struct mo_file_header), 0)) 953 949 { 954 950 /* Something went wrong. */ … … 1006 1002 /* Using the magic number we can test whether it really is a message 1007 1003 catalog file. */ 1008 if (__builtin_expect (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED,1009 0))1004 if (__builtin_expect 1005 (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED, 0)) 1010 1006 { 1011 1007 /* The magic number is wrong: not a message catalog file. */ … … 1046 1042 (domain->hash_size > 2 1047 1043 ? (const nls_uint32 *) 1048 ((char *) data + W (domain->must_swap, data->hash_tab_offset))1044 ((char *) data + W (domain->must_swap, data->hash_tab_offset)) 1049 1045 : NULL); 1050 1046 domain->must_swap_hash_tab = domain->must_swap; … … 1067 1063 goto invalid; 1068 1064 1069 n_sysdep_strings = 1070 W (domain->must_swap, data->n_sysdep_strings); 1065 n_sysdep_strings = W (domain->must_swap, data->n_sysdep_strings); 1071 1066 if (n_sysdep_strings > 0) 1072 1067 { … … 1106 1101 } 1107 1102 1108 sysdep_segment_values[i] = get_sysdep_segment_value (name); 1103 sysdep_segment_values[i] = 1104 get_sysdep_segment_value (name); 1109 1105 } 1110 1106 … … 1131 1127 const struct sysdep_string *sysdep_string = 1132 1128 (const struct sysdep_string *) 1133 ((char *) data 1134 + W (domain->must_swap, 1135 j == 0 1136 ? orig_sysdep_tab[i] 1137 : trans_sysdep_tab[i])); 1129 ((char *) data + W (domain->must_swap, 1130 j == 0 1131 ? orig_sysdep_tab[i] 1132 : trans_sysdep_tab[i])); 1138 1133 size_t need = 0; 1139 const struct segment_pair *p = sysdep_string->segments; 1140 1141 if (W (domain->must_swap, p->sysdepref) != SEGMENTS_END) 1134 const struct segment_pair *p = 1135 sysdep_string->segments; 1136 1137 if (W (domain->must_swap, p->sysdepref) != 1138 SEGMENTS_END) 1142 1139 for (p = sysdep_string->segments;; p++) 1143 1140 { … … 1164 1161 } 1165 1162 1166 need += strlen (sysdep_segment_values[sysdepref]); 1163 need += 1164 strlen (sysdep_segment_values[sysdepref]); 1167 1165 } 1168 1166 … … 1179 1177 } 1180 1178 memneed += 2 * n_inmem_sysdep_strings 1181 * sizeof (struct sysdep_string_desc);1179 * sizeof (struct sysdep_string_desc); 1182 1180 1183 1181 if (n_inmem_sysdep_strings > 0) … … 1193 1191 inmem_orig_sysdep_tab = (struct sysdep_string_desc *) mem; 1194 1192 mem += n_inmem_sysdep_strings 1195 * sizeof (struct sysdep_string_desc); 1196 inmem_trans_sysdep_tab = (struct sysdep_string_desc *) mem; 1197 mem += n_inmem_sysdep_strings 1198 * sizeof (struct sysdep_string_desc); 1193 * sizeof (struct sysdep_string_desc); 1194 inmem_trans_sysdep_tab = 1195 (struct sysdep_string_desc *) mem; 1196 mem += 1197 n_inmem_sysdep_strings * 1198 sizeof (struct sysdep_string_desc); 1199 1199 inmem_hash_tab = (nls_uint32 *) mem; 1200 1200 mem += domain->hash_size * sizeof (nls_uint32); … … 1210 1210 const struct sysdep_string *sysdep_string = 1211 1211 (const struct sysdep_string *) 1212 ((char *) data 1213 + W (domain->must_swap, 1214 j == 0 1215 ? orig_sysdep_tab[i] 1216 : trans_sysdep_tab[i])); 1212 ((char *) data + W (domain->must_swap, 1213 j == 0 1214 ? orig_sysdep_tab[i] 1215 : trans_sysdep_tab[i])); 1217 1216 const struct segment_pair *p = 1218 1217 sysdep_string->segments; … … 1229 1228 break; 1230 1229 1231 if (sysdep_segment_values[sysdepref] == NULL) 1230 if (sysdep_segment_values[sysdepref] == 1231 NULL) 1232 1232 { 1233 1233 /* This particular string pair is 1234 invalid. */1234 invalid. */ 1235 1235 valid = 0; 1236 1236 break; … … 1248 1248 const struct sysdep_string *sysdep_string = 1249 1249 (const struct sysdep_string *) 1250 ((char *) data 1251 + W (domain->must_swap, 1252 j == 0 1253 ? orig_sysdep_tab[i] 1254 : trans_sysdep_tab[i])); 1250 ((char *) data + W (domain->must_swap, 1251 j == 0 1252 ? orig_sysdep_tab[i] 1253 : trans_sysdep_tab[i])); 1255 1254 const char *static_segments = 1256 1255 (char *) data 1257 + W (domain->must_swap, sysdep_string->offset); 1256 + W (domain->must_swap, 1257 sysdep_string->offset); 1258 1258 const struct segment_pair *p = 1259 1259 sysdep_string->segments; … … 1266 1266 (j == 0 1267 1267 ? inmem_orig_sysdep_tab 1268 : inmem_trans_sysdep_tab) 1269 + k; 1268 : inmem_trans_sysdep_tab) + k; 1270 1269 1271 1270 if (W (domain->must_swap, p->sysdepref) … … 1275 1274 inmem_tab_entry->length = 1276 1275 W (domain->must_swap, p->segsize); 1277 inmem_tab_entry->pointer = static_segments; 1276 inmem_tab_entry->pointer = 1277 static_segments; 1278 1278 } 1279 1279 else … … 1291 1291 if (segsize > 0) 1292 1292 { 1293 memcpy (mem, static_segments, segsize); 1293 memcpy (mem, static_segments, 1294 segsize); 1294 1295 mem += segsize; 1295 1296 static_segments += segsize; … … 1299 1300 break; 1300 1301 1301 n = strlen (sysdep_segment_values[sysdepref]); 1302 memcpy (mem, sysdep_segment_values[sysdepref], n); 1302 n = 1303 strlen (sysdep_segment_values 1304 [sysdepref]); 1305 memcpy (mem, 1306 sysdep_segment_values 1307 [sysdepref], n); 1303 1308 mem += n; 1304 1309 } … … 1332 1337 { 1333 1338 /* Hash table entry is empty. Use it. */ 1334 inmem_hash_tab[idx] = 1 + domain->nstrings + i; 1339 inmem_hash_tab[idx] = 1340 1 + domain->nstrings + i; 1335 1341 break; 1336 1342 } … … 1397 1403 1398 1404 #ifdef _LIBC 1399 void 1400 internal_function 1405 void internal_function 1401 1406 _nl_unload_domain (struct loaded_domain *domain) 1402 1407 { sweep/branches/display-cache/intl/localcharset.c
r409 r471 42 42 43 43 #if defined _WIN32 || defined __WIN32__ 44 # undef WIN32 /* avoid warning on mingw32 */44 # undef WIN32 /* avoid warning on mingw32 */ 45 45 # define WIN32 46 46 #endif … … 99 99 are atomic. But I don't know what will happen if the two assignments mix. */ 100 100 #if __STDC__ != 1 101 # define volatile /* empty */101 # define volatile /* empty */ 102 102 #endif 103 103 /* Pointer to the contents of the charset.alias file, if it has already been 104 104 read, else NULL. Its format is: 105 105 ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */ 106 static const char * volatile charset_aliases;106 static const char *volatile charset_aliases; 107 107 108 108 /* Return a pointer to the contents of the charset.alias file. */ … … 122 122 123 123 /* Make it possible to override the charset.alias location. This is 124 necessary for running the testsuite before "make install". */124 necessary for running the testsuite before "make install". */ 125 125 dir = getenv ("CHARSETALIASDIR"); 126 126 if (dir == NULL || dir[0] == '\0') … … 154 154 { 155 155 int c; 156 char buf1[50 +1];157 char buf2[50 +1];156 char buf1[50 + 1]; 157 char buf2[50 + 1]; 158 158 size_t l1, l2; 159 159 char *old_res_ptr; … … 218 218 # if defined VMS 219 219 /* To avoid the troubles of an extra file charset.alias_vms in the 220 sources of many GNU packages, simply inline the aliases here. */220 sources of many GNU packages, simply inline the aliases here. */ 221 221 /* The list of encodings is taken from the OpenVMS 7.3-1 documentation 222 "Compaq C Run-Time Library Reference Manual for OpenVMS systems"223 section 10.7 "Handling Different Character Sets". */222 "Compaq C Run-Time Library Reference Manual for OpenVMS systems" 223 section 10.7 "Handling Different Character Sets". */ 224 224 cp = "ISO8859-1" "\0" "ISO-8859-1" "\0" 225 "ISO8859-2" "\0" "ISO-8859-2" "\0" 226 "ISO8859-5" "\0" "ISO-8859-5" "\0" 227 "ISO8859-7" "\0" "ISO-8859-7" "\0" 228 "ISO8859-8" "\0" "ISO-8859-8" "\0" 229 "ISO8859-9" "\0" "ISO-8859-9" "\0" 230 /* Japanese */ 231 "eucJP" "\0" "EUC-JP" "\0" 232 "SJIS" "\0" "SHIFT_JIS" "\0" 233 "DECKANJI" "\0" "DEC-KANJI" "\0" 234 "SDECKANJI" "\0" "EUC-JP" "\0" 235 /* Chinese */ 236 "eucTW" "\0" "EUC-TW" "\0" 237 "DECHANYU" "\0" "DEC-HANYU" "\0" 238 "DECHANZI" "\0" "GB2312" "\0" 239 /* Korean */ 240 "DECKOREAN" "\0" "EUC-KR" "\0"; 225 "ISO8859-2" "\0" "ISO-8859-2" "\0" 226 "ISO8859-5" "\0" "ISO-8859-5" "\0" 227 "ISO8859-7" "\0" "ISO-8859-7" "\0" 228 "ISO8859-8" "\0" "ISO-8859-8" "\0" "ISO8859-9" "\0" "ISO-8859-9" "\0" 229 /* Japanese */ 230 "eucJP" "\0" "EUC-JP" "\0" 231 "SJIS" "\0" "SHIFT_JIS" "\0" 232 "DECKANJI" "\0" "DEC-KANJI" "\0" "SDECKANJI" "\0" "EUC-JP" "\0" 233 /* Chinese */ 234 "eucTW" "\0" "EUC-TW" "\0" 235 "DECHANYU" "\0" "DEC-HANYU" "\0" "DECHANZI" "\0" "GB2312" "\0" 236 /* Korean */ 237 "DECKOREAN" "\0" "EUC-KR" "\0"; 241 238 # endif 242 239 243 240 # if defined WIN32 244 241 /* To avoid the troubles of installing a separate file in the same 245 directory as the DLL and of retrieving the DLL's directory at246 runtime, simply inline the aliases here. */242 directory as the DLL and of retrieving the DLL's directory at 243 runtime, simply inline the aliases here. */ 247 244 248 245 cp = "CP936" "\0" "GBK" "\0" 249 "CP1361" "\0" "JOHAB" "\0" 250 "CP20127" "\0" "ASCII" "\0" 251 "CP20866" "\0" "KOI8-R" "\0" 252 "CP21866" "\0" "KOI8-RU" "\0" 253 "CP28591" "\0" "ISO-8859-1" "\0" 254 "CP28592" "\0" "ISO-8859-2" "\0" 255 "CP28593" "\0" "ISO-8859-3" "\0" 256 "CP28594" "\0" "ISO-8859-4" "\0" 257 "CP28595" "\0" "ISO-8859-5" "\0" 258 "CP28596" "\0" "ISO-8859-6" "\0" 259 "CP28597" "\0" "ISO-8859-7" "\0" 260 "CP28598" "\0" "ISO-8859-8" "\0" 261 "CP28599" "\0" "ISO-8859-9" "\0" 262 "CP28605" "\0" "ISO-8859-15" "\0"; 246 "CP1361" "\0" "JOHAB" "\0" 247 "CP20127" "\0" "ASCII" "\0" 248 "CP20866" "\0" "KOI8-R" "\0" 249 "CP21866" "\0" "KOI8-RU" "\0" 250 "CP28591" "\0" "ISO-8859-1" "\0" 251 "CP28592" "\0" "ISO-8859-2" "\0" 252 "CP28593" "\0" "ISO-8859-3" "\0" 253 "CP28594" "\0" "ISO-8859-4" "\0" 254 "CP28595" "\0" "ISO-8859-5" "\0" 255 "CP28596" "\0" "ISO-8859-6" "\0" 256 "CP28597" "\0" "ISO-8859-7" "\0" 257 "CP28598" "\0" "ISO-8859-8" "\0" 258 "CP28599" "\0" "ISO-8859-9" "\0" "CP28605" "\0" "ISO-8859-15" "\0"; 263 259 # endif 264 260 #endif … … 363 359 { 364 360 memcpy (buf, dot, modifier - dot); 365 buf [modifier - dot] = '\0';361 buf[modifier - dot] = '\0'; 366 362 return buf; 367 363 } sweep/branches/display-cache/intl/localcharset.h
r183 r471 23 23 24 24 #ifdef __cplusplus 25 extern "C" { 25 extern "C" 26 { 26 27 #endif 27 28 … … 32 33 If the canonical name cannot be determined, the result is a non-canonical 33 34 name. */ 34 extern const char *locale_charset (void);35 extern const char *locale_charset (void); 35 36 36 37 … … 40 41 41 42 42 #endif /* _LOCALCHARSET_H */43 #endif /* _LOCALCHARSET_H */ sweep/branches/display-cache/intl/localealias.c
r183 r471 48 48 # else 49 49 # ifdef _AIX 50 #pragma alloca50 #pragma alloca 51 51 # else 52 52 # ifndef alloca … … 105 105 some additional code emulating it. */ 106 106 #ifdef HAVE_ALLOCA 107 # define freea(p) /* nothing */107 # define freea(p) /* nothing */ 108 108 #else 109 109 # define alloca(n) malloc (n) … … 141 141 142 142 /* Prototypes for local functions. */ 143 static size_t read_alias_file (const char *fname, int fname_len)144 internal_function; 145 static int extend_alias_table (void);146 static int alias_compare (const struct alias_map *map1, 147 const struct alias_map *map2); 148 149 150 const char * 151 _nl_expand_alias (const char *name)143 static size_t 144 read_alias_file (const char *fname, int fname_len) 145 internal_function; 146 static int extend_alias_table (void); 147 static int alias_compare (const struct alias_map *map1, 148 const struct alias_map *map2); 149 150 151 const char *_nl_expand_alias (const char *name) 152 152 { 153 153 static const char *locale_alias_path; … … 172 172 retval = (struct alias_map *) bsearch (&item, map, nmap, 173 173 sizeof (struct alias_map), 174 (int (*) (const void *,175 const void *)176 )alias_compare);174 (int (*)(const void *, 175 const void *)) 176 alias_compare); 177 177 else 178 178 retval = NULL; … … 213 213 214 214 215 static size_t 216 internal_function 215 static size_t internal_function 217 216 read_alias_file (const char *fname, int fname_len) 218 217 { … … 245 244 { 246 245 /* It is a reasonable approach to use a fix buffer here because 247 a) we are only interested in the first two fields248 b) these fields must be usable as file names and so must not249 be that long250 We avoid a multi-kilobyte buffer here since this would use up251 stack space which we might not have if the program ran out of252 memory. */246 a) we are only interested in the first two fields 247 b) these fields must be usable as file names and so must not 248 be that long 249 We avoid a multi-kilobyte buffer here since this would use up 250 stack space which we might not have if the program ran out of 251 memory. */ 253 252 char buf[400]; 254 253 char *alias; … … 345 344 346 345 /* Possibly not the whole line fits into the buffer. Ignore 347 the rest of the line. */346 the rest of the line. */ 348 347 while (strchr (buf, '\n') == NULL) 349 348 if (FGETS (buf, sizeof buf, fp) == NULL) … … 359 358 if (added > 0) 360 359 qsort (map, nmap, sizeof (struct alias_map), 361 (int (*) (const void *, const void *)) alias_compare);360 (int (*)(const void *, const void *)) alias_compare); 362 361 363 362 return added; … … 400 399 { 401 400 /* I know this seems to be odd but the tolower() function in 402 some systems libc cannot handle nonalpha characters. */401 some systems libc cannot handle nonalpha characters. */ 403 402 c1 = isupper (*p1) ? tolower (*p1) : *p1; 404 403 c2 = isupper (*p2) ? tolower (*p2) : *p2; sweep/branches/display-cache/intl/localename.c
r183 r471 39 39 40 40 #if defined _WIN32 || defined __WIN32__ 41 # undef WIN32 /* avoid warning on mingw32 */41 # undef WIN32 /* avoid warning on mingw32 */ 42 42 # define WIN32 43 43 #endif … … 714 714 MacOS X 10.3.8 function 715 715 CFLocaleCreateCanonicalLocaleIdentifierFromString(). */ 716 typedef struct { const char legacy[21+1]; const char unixy[5+1]; } 717 legacy_entry; 716 typedef struct 717 { 718 const char legacy[21 + 1]; 719 const char unixy[5 + 1]; 720 } 721 legacy_entry; 718 722 static const legacy_entry legacy_table[] = { 719 { "Afrikaans", "af"},720 { "Albanian", "sq"},721 { "Amharic", "am"},722 { "Arabic", "ar"},723 { "Armenian", "hy"},724 { "Assamese", "as"},725 { "Aymara", "ay"},726 { "Azerbaijani", "az"},727 { "Basque", "eu"},728 { "Belarusian", "be"},729 { "Belorussian", "be"},730 { "Bengali", "bn"},731 { "Brazilian Portugese", "pt_BR"},732 { "Brazilian Portuguese", "pt_BR"},733 { "Breton", "br"},734 { "Bulgarian", "bg"},735 { "Burmese", "my"},736 { "Byelorussian", "be"},737 { "Catalan", "ca"},738 { "Chewa", "ny"},739 { "Chichewa", "ny"},740 { "Chinese", "zh"},741 { "Chinese, Simplified", "zh_CN"},742 { "Chinese, Traditional", "zh_TW"},743 { "Chinese, Tradtional", "zh_TW"},744 { "Croatian", "hr"},745 { "Czech", "cs"},746 { "Danish", "da"},747 { "Dutch", "nl"},748 { "Dzongkha", "dz"},749 { "English", "en"},750 { "Esperanto", "eo"},751 { "Estonian", "et"},752 { "Faroese", "fo"},753 { "Farsi", "fa"},754 { "Finnish", "fi"},755 { "Flemish", "nl_BE"},756 { "French", "fr"},757 { "Galician", "gl"},758 { "Gallegan", "gl"},759 { "Georgian", "ka"},760 { "German", "de"},761 { "Greek", "el"},762 { "Greenlandic", "kl"},763 { "Guarani", "gn"},764 { "Gujarati", "gu"},765 { "Hawaiian", "haw" },/* Yes, "haw", not "cpe". */766 { "Hebrew", "he"},767 { "Hindi", "hi"},768 { "Hungarian", "hu"},769 { "Icelandic", "is"},770 { "Indonesian", "id"},771 { "Inuktitut", "iu"},772 { "Irish", "ga"},773 { "Italian", "it"},774 { "Japanese", "ja"},775 { "Javanese", "jv"},776 { "Kalaallisut", "kl"},777 { "Kannada", "kn"},778 { "Kashmiri", "ks"},779 { "Kazakh", "kk"},780 { "Khmer", "km"},781 { "Kinyarwanda", "rw"},782 { "Kirghiz", "ky"},783 { "Korean", "ko"},784 { "Kurdish", "ku"},785 { "Latin", "la"},786 { "Latvian", "lv"},787 { "Lithuanian", "lt"},788 { "Macedonian", "mk"},789 { "Malagasy", "mg"},790 { "Malay", "ms"},791 { "Malayalam", "ml"},792 { "Maltese", "mt"},793 { "Manx", "gv"},794 { "Marathi", "mr"},795 { "Moldavian", "mo"},796 { "Mongolian", "mn"},797 { "Nepali", "ne"},798 { "Norwegian", "nb" },/* Yes, "nb", not the obsolete "no". */799 { "Nyanja", "ny"},800 { "Nynorsk", "nn"},801 { "Oriya", "or"},802 { "Oromo", "om"},803 { "Panjabi", "pa"},804 { "Pashto", "ps"},805 { "Persian", "fa"},806 { "Polish", "pl"},807 { "Portuguese", "pt"},808 { "Portuguese, Brazilian", "pt_BR"},809 { "Punjabi", "pa"},810 { "Pushto", "ps"},811 { "Quechua", "qu"},812 { "Romanian", "ro"},813 { "Ruanda", "rw"},814 { "Rundi", "rn"},815 { "Russian", "ru"},816 { "Sami", "se_NO" },/* Not just "se". */817 { "Sanskrit", "sa"},818 { "Scottish", "gd"},819 { "Serbian", "sr"},820 { "Simplified Chinese", "zh_CN"},821 { "Sindhi", "sd"},822 { "Sinhalese", "si"},823 { "Slovak", "sk"},824 { "Slovenian", "sl"},825 { "Somali", "so"},826 { "Spanish", "es"},827 { "Sundanese", "su"},828 { "Swahili", "sw"},829 { "Swedish", "sv"},830 { "Tagalog", "tl"},831 { "Tajik", "tg"},832 { "Tajiki", "tg"},833 { "Tamil", "ta"},834 { "Tatar", "tt"},835 { "Telugu", "te"},836 { "Thai", "th"},837 { "Tibetan", "bo"},838 { "Tigrinya", "ti"},839 { "Tongan", "to"},840 { "Traditional Chinese", "zh_TW"},841 { "Turkish", "tr"},842 { "Turkmen", "tk"},843 { "Uighur", "ug"},844 { "Ukrainian", "uk"},845 { "Urdu", "ur"},846 { "Uzbek", "uz"},847 { "Vietnamese", "vi"},848 { "Welsh", "cy"},849 { "Yiddish", "yi"}723 {"Afrikaans", "af"}, 724 {"Albanian", "sq"}, 725 {"Amharic", "am"}, 726 {"Arabic", "ar"}, 727 {"Armenian", "hy"}, 728 {"Assamese", "as"}, 729 {"Aymara", "ay"}, 730 {"Azerbaijani", "az"}, 731 {"Basque", "eu"}, 732 {"Belarusian", "be"}, 733 {"Belorussian", "be"}, 734 {"Bengali", "bn"}, 735 {"Brazilian Portugese", "pt_BR"}, 736 {"Brazilian Portuguese", "pt_BR"}, 737 {"Breton", "br"}, 738 {"Bulgarian", "bg"}, 739 {"Burmese", "my"}, 740 {"Byelorussian", "be"}, 741 {"Catalan", "ca"}, 742 {"Chewa", "ny"}, 743 {"Chichewa", "ny"}, 744 {"Chinese", "zh"}, 745 {"Chinese, Simplified", "zh_CN"}, 746 {"Chinese, Traditional", "zh_TW"}, 747 {"Chinese, Tradtional", "zh_TW"}, 748 {"Croatian", "hr"}, 749 {"Czech", "cs"}, 750 {"Danish", "da"}, 751 {"Dutch", "nl"}, 752 {"Dzongkha", "dz"}, 753 {"English", "en"}, 754 {"Esperanto", "eo"}, 755 {"Estonian", "et"}, 756 {"Faroese", "fo"}, 757 {"Farsi", "fa"}, 758 {"Finnish", "fi"}, 759 {"Flemish", "nl_BE"}, 760 {"French", "fr"}, 761 {"Galician", "gl"}, 762 {"Gallegan", "gl"}, 763 {"Georgian", "ka"}, 764 {"German", "de"}, 765 {"Greek", "el"}, 766 {"Greenlandic", "kl"}, 767 {"Guarani", "gn"}, 768 {"Gujarati", "gu"}, 769 {"Hawaiian", "haw"}, /* Yes, "haw", not "cpe". */ 770 {"Hebrew", "he"}, 771 {"Hindi", "hi"}, 772 {"Hungarian", "hu"}, 773 {"Icelandic", "is"}, 774 {"Indonesian", "id"}, 775 {"Inuktitut", "iu"}, 776 {"Irish", "ga"}, 777 {"Italian", "it"}, 778 {"Japanese", "ja"}, 779 {"Javanese", "jv"}, 780 {"Kalaallisut", "kl"}, 781 {"Kannada", "kn"}, 782 {"Kashmiri", "ks"}, 783 {"Kazakh", "kk"}, 784 {"Khmer", "km"}, 785 {"Kinyarwanda", "rw"}, 786 {"Kirghiz", "ky"}, 787 {"Korean", "ko"}, 788 {"Kurdish", "ku"}, 789 {"Latin", "la"}, 790 {"Latvian", "lv"}, 791 {"Lithuanian", "lt"}, 792 {"Macedonian", "mk"}, 793 {"Malagasy", "mg"}, 794 {"Malay", "ms"}, 795 {"Malayalam", "ml"}, 796 {"Maltese", "mt"}, 797 {"Manx", "gv"}, 798 {"Marathi", "mr"}, 799 {"Moldavian", "mo"}, 800 {"Mongolian", "mn"}, 801 {"Nepali", "ne"}, 802 {"Norwegian", "nb"}, /* Yes, "nb", not the obsolete "no". */ 803 {"Nyanja", "ny"}, 804 {"Nynorsk", "nn"}, 805 {"Oriya", "or"}, 806 {"Oromo", "om"}, 807 {"Panjabi", "pa"}, 808 {"Pashto", "ps"}, 809 {"Persian", "fa"}, 810 {"Polish", "pl"}, 811 {"Portuguese", "pt"}, 812 {"Portuguese, Brazilian", "pt_BR"}, 813 {"Punjabi", "pa"}, 814 {"Pushto", "ps"}, 815 {"Quechua", "qu"}, 816 {"Romanian", "ro"}, 817 {"Ruanda", "rw"}, 818 {"Rundi", "rn"}, 819 {"Russian", "ru"}, 820 {"Sami", "se_NO"}, /* Not just "se". */ 821 {"Sanskrit", "sa"}, 822 {"Scottish", "gd"}, 823 {"Serbian", "sr"}, 824 {"Simplified Chinese", "zh_CN"}, 825 {"Sindhi", "sd"}, 826 {"Sinhalese", "si"}, 827 {"Slovak", "sk"}, 828 {"Slovenian", "sl"}, 829 {"Somali", "so"}, 830 {"Spanish", "es"}, 831 {"Sundanese", "su"}, 832 {"Swahili", "sw"}, 833 {"Swedish", "sv"}, 834 {"Tagalog", "tl"}, 835 {"Tajik", "tg"}, 836 {"Tajiki", "tg"}, 837 {"Tamil", "ta"}, 838 {"Tatar", "tt"}, 839 {"Telugu", "te"}, 840 {"Thai", "th"}, 841 {"Tibetan", "bo"}, 842 {"Tigrinya", "ti"}, 843 {"Tongan", "to"}, 844 {"Traditional Chinese", "zh_TW"}, 845 {"Turkish", "tr"}, 846 {"Turkmen", "tk"}, 847 {"Uighur", "ug"}, 848 {"Ukrainian", "uk"}, 849 {"Urdu", "ur"}, 850 {"Uzbek", "uz"}, 851 {"Vietnamese", "vi"}, 852 {"Welsh", "cy"}, 853 {"Yiddish", "yi"} 850 854 }; 851 855 852 856 /* Convert new-style locale names with language tags (ISO 639 and ISO 15924) 853 857 to Unix (ISO 639 and ISO 3166) names. */ 854 typedef struct { const char langtag[7+1]; const char unixy[12+1]; } 855 langtag_entry; 858 typedef struct 859 { 860 const char langtag[7 + 1]; 861 const char unixy[12 + 1]; 862 } 863 langtag_entry; 856 864 static const langtag_entry langtag_table[] = { 857 865 /* MacOS X has "az-Arab", "az-Cyrl", "az-Latn". 858 866 The default script for az on Unix is Latin. */ 859 { "az-Latn", "az"},867 {"az-Latn", "az"}, 860 868 /* MacOS X has "ga-dots". Does not yet exist on Unix. */ 861 { "ga-dots", "ga"},869 {"ga-dots", "ga"}, 862 870 /* MacOS X has "kk-Cyrl". Does not yet exist on Unix. */ 863 871 /* MacOS X has "mn-Cyrl", "mn-Mong". 864 872 The default script for mn on Unix is Cyrillic. */ 865 { "mn-Cyrl", "mn"},873 {"mn-Cyrl", "mn"}, 866 874 /* MacOS X has "ms-Arab", "ms-Latn". 867 875 The default script for ms on Unix is Latin. */ 868 { "ms-Latn", "ms"},876 {"ms-Latn", "ms"}, 869 877 /* MacOS X has "tg-Cyrl". 870 878 The default script for tg on Unix is Cyrillic. */ 871 { "tg-Cyrl", "tg"},879 {"tg-Cyrl", "tg"}, 872 880 /* MacOS X has "tk-Cyrl". Does not yet exist on Unix. */ 873 881 /* MacOS X has "tt-Cyrl". 874 882 The default script for tt on Unix is Cyrillic. */ 875 { "tt-Cyrl", "tt"},883 {"tt-Cyrl", "tt"}, 876 884 /* MacOS X has "zh-Hans", "zh-Hant". 877 885 Country codes are used to distinguish these on Unix. */ 878 { "zh-Hans", "zh_CN"},879 { "zh-Hant", "zh_TW"}886 {"zh-Hans", "zh_CN"}, 887 {"zh-Hant", "zh_TW"} 880 888 }; 881 889 882 890 /* Convert script names (ISO 15924) to Unix conventions. 883 891 See http://www.unicode.org/iso15924/iso15924-codes.html */ 884 typedef struct { const char script[4+1]; const char unixy[9+1]; } 885 script_entry; 892 typedef struct 893 { 894 const char script[4 + 1]; 895 const char unixy[9 + 1]; 896 } 897 script_entry; 886 898 static const script_entry script_table[] = { 887 { "Arab", "arabic"},888 { "Cyrl", "cyrillic"},889 { "Mong", "mongolian"}899 {"Arab", "arabic"}, 900 {"Cyrl", "cyrillic"}, 901 {"Mong", "mongolian"} 890 902 }; 891 903 … … 1017 1029 /* POSIX:2001 says: 1018 1030 "All implementations shall define a locale as the default locale, to be 1019 invoked when no environment variables are set, or set to the empty1020 string. This default locale can be the POSIX locale or any other1021 implementation-defined locale. Some implementations may provide1022 facilities for local installation administrators to set the default1023 locale, customizing it for each location. POSIX:2001 does not require1024 such a facility. */1031 invoked when no environment variables are set, or set to the empty 1032 string. This default locale can be the POSIX locale or any other 1033 implementation-defined locale. Some implementations may provide 1034 facilities for local installation administrators to set the default 1035 locale, customizing it for each location. POSIX:2001 does not require 1036 such a facility. */ 1025 1037 1026 1038 #if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined(WIN32)) … … 1046 1058 { 1047 1059 char namebuf[256]; 1048 # if HAVE_CFLOCALECOPYCURRENT /* MacOS X 10.3 or newer */1060 # if HAVE_CFLOCALECOPYCURRENT /* MacOS X 10.3 or newer */ 1049 1061 CFLocaleRef locale = CFLocaleCopyCurrent (); 1050 1062 CFStringRef name = CFLocaleGetIdentifier (locale); 1051 1063 1052 if (CFStringGetCString (name, namebuf, sizeof (namebuf),1064 if (CFStringGetCString (name, namebuf, sizeof (namebuf), 1053 1065 kCFStringEncodingASCII)) 1054 1066 { … … 1057 1069 } 1058 1070 CFRelease (locale); 1059 # elif HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.2 or newer */ 1060 CFTypeRef value = 1061 CFPreferencesCopyAppValue (CFSTR ("AppleLocale"), 1062 kCFPreferencesCurrentApplication); 1071 # elif HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.2 or newer */ 1072 CFTypeRef value = CFPreferencesCopyAppValue (CFSTR ("AppleLocale"), 1073 kCFPreferencesCurrentApplication); 1063 1074 if (value != NULL 1064 1075 && CFGetTypeID (value) == CFStringGetTypeID () 1065 && CFStringGetCString ((CFStringRef) value, namebuf, sizeof(namebuf),1066 kCFStringEncodingASCII))1076 && CFStringGetCString ((CFStringRef) value, namebuf, 1077 sizeof (namebuf), kCFStringEncodingASCII)) 1067 1078 { 1068 1079 _nl_locale_name_canonicalize (namebuf); … … 1078 1089 # endif 1079 1090 1080 # if defined(WIN32) /* WIN32 */1091 # if defined(WIN32) /* WIN32 */ 1081 1092 { 1082 1093 LCID lcid; … … 1099 1110 switch (primary) 1100 1111 { 1101 case LANG_AFRIKAANS: return "af_ZA"; 1102 case LANG_ALBANIAN: return "sq_AL"; 1103 case LANG_AMHARIC: return "am_ET"; 1112 case LANG_AFRIKAANS: 1113 return "af_ZA"; 1114 case LANG_ALBANIAN: 1115 return "sq_AL"; 1116 case LANG_AMHARIC: 1117 return "am_ET"; 1104 1118 case LANG_ARABIC: 1105 1119 switch (sub) 1106 1120 { 1107 case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA"; 1108 case SUBLANG_ARABIC_IRAQ: return "ar_IQ"; 1109 case SUBLANG_ARABIC_EGYPT: return "ar_EG"; 1110 case SUBLANG_ARABIC_LIBYA: return "ar_LY"; 1111 case SUBLANG_ARABIC_ALGERIA: return "ar_DZ"; 1112 case SUBLANG_ARABIC_MOROCCO: return "ar_MA"; 1113 case SUBLANG_ARABIC_TUNISIA: return "ar_TN"; 1114 case SUBLANG_ARABIC_OMAN: return "ar_OM"; 1115 case SUBLANG_ARABIC_YEMEN: return "ar_YE"; 1116 case SUBLANG_ARABIC_SYRIA: return "ar_SY"; 1117 case SUBLANG_ARABIC_JORDAN: return "ar_JO"; 1118 case SUBLANG_ARABIC_LEBANON: return "ar_LB"; 1119 case SUBLANG_ARABIC_KUWAIT: return "ar_KW"; 1120 case SUBLANG_ARABIC_UAE: return "ar_AE"; 1121 case SUBLANG_ARABIC_BAHRAIN: return "ar_BH"; 1122 case SUBLANG_ARABIC_QATAR: return "ar_QA"; 1121 case SUBLANG_ARABIC_SAUDI_ARABIA: 1122 return "ar_SA"; 1123 case SUBLANG_ARABIC_IRAQ: 1124 return "ar_IQ"; 1125 case SUBLANG_ARABIC_EGYPT: 1126 return "ar_EG"; 1127 case SUBLANG_ARABIC_LIBYA: 1128 return "ar_LY"; 1129 case SUBLANG_ARABIC_ALGERIA: 1130 return "ar_DZ"; 1131 case SUBLANG_ARABIC_MOROCCO: 1132 return "ar_MA"; 1133 case SUBLANG_ARABIC_TUNISIA: 1134 return "ar_TN"; 1135 case SUBLANG_ARABIC_OMAN: 1136 return "ar_OM"; 1137 case SUBLANG_ARABIC_YEMEN: 1138 return "ar_YE"; 1139 case SUBLANG_ARABIC_SYRIA: 1140 return "ar_SY"; 1141 case SUBLANG_ARABIC_JORDAN: 1142 return "ar_JO"; 1143 case SUBLANG_ARABIC_LEBANON: 1144 return "ar_LB"; 1145 case SUBLANG_ARABIC_KUWAIT: 1146 return "ar_KW"; 1147 case SUBLANG_ARABIC_UAE: 1148 return "ar_AE"; 1149 case SUBLANG_ARABIC_BAHRAIN: 1150 return "ar_BH"; 1151 case SUBLANG_ARABIC_QATAR: 1152 return "ar_QA"; 1123 1153 } 1124 1154 return "ar"; 1125 case LANG_ARMENIAN: return "hy_AM"; 1126 case LANG_ASSAMESE: return "as_IN"; 1155 case LANG_ARMENIAN: 1156 return "hy_AM"; 1157 case LANG_ASSAMESE: 1158 return "as_IN"; 1127 1159 case LANG_AZERI: 1128 1160 switch (sub) 1129 1161 { 1130 /* FIXME: Adjust this when Azerbaijani locales appear on Unix. */ 1131 case SUBLANG_AZERI_LATIN: return "az_AZ@latin"; 1132 case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic"; 1162 /* FIXME: Adjust this when Azerbaijani locales appear on Unix. */ 1163 case SUBLANG_AZERI_LATIN: 1164 return "az_AZ@latin"; 1165 case SUBLANG_AZERI_CYRILLIC: 1166 return "az_AZ@cyrillic"; 1133 1167 } 1134 1168 return "az"; … … 1136 1170 switch (sub) 1137 1171 { 1138 case SUBLANG_DEFAULT: return "eu_ES"; 1139 } 1140 return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */ 1141 case LANG_BELARUSIAN: return "be_BY"; 1172 case SUBLANG_DEFAULT: 1173 return "eu_ES"; 1174 } 1175 return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */ 1176 case LANG_BELARUSIAN: 1177 return "be_BY"; 1142 1178 case LANG_BENGALI: 1143 1179 switch (sub) 1144 1180 { 1145 case SUBLANG_BENGALI_INDIA: return "bn_IN"; 1146 case SUBLANG_BENGALI_BANGLADESH: return "bn_BD"; 1181 case SUBLANG_BENGALI_INDIA: 1182 return "bn_IN"; 1183 case SUBLANG_BENGALI_BANGLADESH: 1184 return "bn_BD"; 1147 1185 } 1148 1186 return "bn"; 1149 case LANG_BULGARIAN: return "bg_BG"; 1150 case LANG_BURMESE: return "my_MM"; 1151 case LANG_CAMBODIAN: return "km_KH"; 1152 case LANG_CATALAN: return "ca_ES"; 1153 case LANG_CHEROKEE: return "chr_US"; 1187 case LANG_BULGARIAN: 1188 return "bg_BG"; 1189 case LANG_BURMESE: 1190 return "my_MM"; 1191 case LANG_CAMBODIAN: 1192 return "km_KH"; 1193 case LANG_CATALAN: 1194 return "ca_ES"; 1195 case LANG_CHEROKEE: 1196 return "chr_US"; 1154 1197 case LANG_CHINESE: 1155 1198 switch (sub) 1156 1199 { 1157 case SUBLANG_CHINESE_TRADITIONAL: return "zh_TW"; 1158 case SUBLANG_CHINESE_SIMPLIFIED: return "zh_CN"; 1159 case SUBLANG_CHINESE_HONGKONG: return "zh_HK"; 1160 case SUBLANG_CHINESE_SINGAPORE: return "zh_SG"; 1161 case SUBLANG_CHINESE_MACAU: return "zh_MO"; 1200 case SUBLANG_CHINESE_TRADITIONAL: 1201 return "zh_TW"; 1202 case SUBLANG_CHINESE_SIMPLIFIED: 1203 return "zh_CN"; 1204 case SUBLANG_CHINESE_HONGKONG: 1205 return "zh_HK"; 1206 case SUBLANG_CHINESE_SINGAPORE: 1207 return "zh_SG"; 1208 case SUBLANG_CHINESE_MACAU: 1209 return "zh_MO"; 1162 1210 } 1163 1211 return "zh"; 1164 case LANG_CROATIAN: /* LANG_CROATIAN == LANG_SERBIAN1212 case LANG_CROATIAN: /* LANG_CROATIAN == LANG_SERBIAN 1165 1213 * What used to be called Serbo-Croatian 1166 1214 * should really now be two separate … … 1172 1220 switch (sub) 1173 1221 { 1174 case SUBLANG_DEFAULT: return "hr_HR"; 1175 case SUBLANG_SERBIAN_LATIN: return "sr_CS"; 1176 case SUBLANG_SERBIAN_CYRILLIC: return "sr_CS@cyrillic"; 1222 case SUBLANG_DEFAULT: 1223 return "hr_HR"; 1224 case SUBLANG_SERBIAN_LATIN: 1225 return "sr_CS"; 1226 case SUBLANG_SERBIAN_CYRILLIC: 1227 return "sr_CS@cyrillic"; 1177 1228 } 1178 1229 return "hr"; 1179 case LANG_CZECH: return "cs_CZ"; 1180 case LANG_DANISH: return "da_DK"; 1181 case LANG_DIVEHI: return "dv_MV"; 1230 case LANG_CZECH: 1231 return "cs_CZ"; 1232 case LANG_DANISH: 1233 return "da_DK"; 1234 case LANG_DIVEHI: 1235 return "dv_MV"; 1182 1236 case LANG_DUTCH: 1183 1237 switch (sub) 1184 1238 { 1185 case SUBLANG_DUTCH: return "nl_NL"; 1186 case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE"; 1239 case SUBLANG_DUTCH: 1240 return "nl_NL"; 1241 case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ 1242 return "nl_BE"; 1187 1243 } 1188 1244 return "nl"; 1189 case LANG_EDO: return "bin_NG"; 1245 case LANG_EDO: 1246 return "bin_NG"; 1190 1247 case LANG_ENGLISH: 1191 1248 switch (sub) 1192 1249 { 1193 /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought 1194 * English was the language spoken in England. 1195 * Oh well. 1196 */ 1197 case SUBLANG_ENGLISH_US: return "en_US"; 1198 case SUBLANG_ENGLISH_UK: return "en_GB"; 1199 case SUBLANG_ENGLISH_AUS: return "en_AU"; 1200 case SUBLANG_ENGLISH_CAN: return "en_CA"; 1201 case SUBLANG_ENGLISH_NZ: return "en_NZ"; 1202 case SUBLANG_ENGLISH_EIRE: return "en_IE"; 1203 case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA"; 1204 case SUBLANG_ENGLISH_JAMAICA: return "en_JM"; 1205 case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */ 1206 case SUBLANG_ENGLISH_BELIZE: return "en_BZ"; 1207 case SUBLANG_ENGLISH_TRINIDAD: return "en_TT"; 1208 case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW"; 1209 case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH"; 1210 case SUBLANG_ENGLISH_INDONESIA: return "en_ID"; 1211 case SUBLANG_ENGLISH_HONGKONG: return "en_HK"; 1212 case SUBLANG_ENGLISH_INDIA: return "en_IN"; 1213 case SUBLANG_ENGLISH_MALAYSIA: return "en_MY"; 1214 case SUBLANG_ENGLISH_SINGAPORE: return "en_SG"; 1250 /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought 1251 * English was the language spoken in England. 1252 * Oh well. 1253 */ 1254 case SUBLANG_ENGLISH_US: 1255 return "en_US"; 1256 case SUBLANG_ENGLISH_UK: 1257 return "en_GB"; 1258 case SUBLANG_ENGLISH_AUS: 1259 return "en_AU"; 1260 case SUBLANG_ENGLISH_CAN: 1261 return "en_CA"; 1262 case SUBLANG_ENGLISH_NZ: 1263 return "en_NZ"; 1264 case SUBLANG_ENGLISH_EIRE: 1265 return "en_IE"; 1266 case SUBLANG_ENGLISH_SOUTH_AFRICA: 1267 return "en_ZA"; 1268 case SUBLANG_ENGLISH_JAMAICA: 1269 return "en_JM"; 1270 case SUBLANG_ENGLISH_CARIBBEAN: 1271 return "en_GD"; /* Grenada? */ 1272 case SUBLANG_ENGLISH_BELIZE: 1273 return "en_BZ"; 1274 case SUBLANG_ENGLISH_TRINIDAD: 1275 return "en_TT"; 1276 case SUBLANG_ENGLISH_ZIMBABWE: 1277 return "en_ZW"; 1278 case SUBLANG_ENGLISH_PHILIPPINES: 1279 return "en_PH"; 1280 case SUBLANG_ENGLISH_INDONESIA: 1281 return "en_ID"; 1282 case SUBLANG_ENGLISH_HONGKONG: 1283 return "en_HK"; 1284 case SUBLANG_ENGLISH_INDIA: 1285 return "en_IN"; 1286 case SUBLANG_ENGLISH_MALAYSIA: 1287 return "en_MY"; 1288 case SUBLANG_ENGLISH_SINGAPORE: 1289 return "en_SG"; 1215 1290 } 1216 1291 return "en"; 1217 case LANG_ESTONIAN: return "et_EE"; 1218 case LANG_FAEROESE: return "fo_FO"; 1219 case LANG_FARSI: return "fa_IR"; 1220 case LANG_FINNISH: return "fi_FI"; 1292 case LANG_ESTONIAN: 1293 return "et_EE"; 1294 case LANG_FAEROESE: 1295 return "fo_FO"; 1296 case LANG_FARSI: 1297 return "fa_IR"; 1298 case LANG_FINNISH: 1299 return "fi_FI"; 1221 1300 case LANG_FRENCH: 1222 1301 switch (sub) 1223 1302 { 1224 case SUBLANG_FRENCH: return "fr_FR"; 1225 case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE"; 1226 case SUBLANG_FRENCH_CANADIAN: return "fr_CA"; 1227 case SUBLANG_FRENCH_SWISS: return "fr_CH"; 1228 case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU"; 1229 case SUBLANG_FRENCH_MONACO: return "fr_MC"; 1230 case SUBLANG_FRENCH_WESTINDIES: return "fr"; /* Caribbean? */ 1231 case SUBLANG_FRENCH_REUNION: return "fr_RE"; 1232 case SUBLANG_FRENCH_CONGO: return "fr_CG"; 1233 case SUBLANG_FRENCH_SENEGAL: return "fr_SN"; 1234 case SUBLANG_FRENCH_CAMEROON: return "fr_CM"; 1235 case SUBLANG_FRENCH_COTEDIVOIRE: return "fr_CI"; 1236 case SUBLANG_FRENCH_MALI: return "fr_ML"; 1237 case SUBLANG_FRENCH_MOROCCO: return "fr_MA"; 1238 case SUBLANG_FRENCH_HAITI: return "fr_HT"; 1303 case SUBLANG_FRENCH: 1304 return "fr_FR"; 1305 case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ 1306 return "fr_BE"; 1307 case SUBLANG_FRENCH_CANADIAN: 1308 return "fr_CA"; 1309 case SUBLANG_FRENCH_SWISS: 1310 return "fr_CH"; 1311 case SUBLANG_FRENCH_LUXEMBOURG: 1312 return "fr_LU"; 1313 case SUBLANG_FRENCH_MONACO: 1314 return "fr_MC"; 1315 case SUBLANG_FRENCH_WESTINDIES: 1316 return "fr"; /* Caribbean? */ 1317 case SUBLANG_FRENCH_REUNION: 1318 return "fr_RE"; 1319 case SUBLANG_FRENCH_CONGO: 1320 return "fr_CG"; 1321 case SUBLANG_FRENCH_SENEGAL: 1322 return "fr_SN"; 1323 case SUBLANG_FRENCH_CAMEROON: 1324 return "fr_CM"; 1325 case SUBLANG_FRENCH_COTEDIVOIRE: 1326 return "fr_CI"; 1327 case SUBLANG_FRENCH_MALI: 1328 return "fr_ML"; 1329 case SUBLANG_FRENCH_MOROCCO: 1330 return "fr_MA"; 1331 case SUBLANG_FRENCH_HAITI: 1332 return "fr_HT"; 1239 1333 } 1240 1334 return "fr"; 1241 case LANG_FRISIAN: return "fy_NL"; 1335 case LANG_FRISIAN: 1336 return "fy_NL"; 1242 1337 case LANG_FULFULDE: 1243 1338 /* Spoken in Nigeria, Guinea, Senegal, Mali, Niger, Cameroon, Benin. */ … … 1246 1341 switch (sub) 1247 1342 { 1248 case 0x01: /* SCOTTISH */ return "gd_GB"; 1249 case 0x02: /* IRISH */ return "ga_IE"; 1343 case 0x01: /* SCOTTISH */ 1344 return "gd_GB"; 1345 case 0x02: /* IRISH */ 1346 return "ga_IE"; 1250 1347 } 1251 1348 return "C"; 1252 case LANG_GALICIAN: return "gl_ES"; 1253 case LANG_GEORGIAN: return "ka_GE"; 1349 case LANG_GALICIAN: 1350 return "gl_ES"; 1351 case LANG_GEORGIAN: 1352 return "ka_GE"; 1254 1353 case LANG_GERMAN: 1255 1354 switch (sub) 1256 1355 { 1257 case SUBLANG_GERMAN: return "de_DE"; 1258 case SUBLANG_GERMAN_SWISS: return "de_CH"; 1259 case SUBLANG_GERMAN_AUSTRIAN: return "de_AT"; 1260 case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU"; 1261 case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI"; 1356 case SUBLANG_GERMAN: 1357 return "de_DE"; 1358 case SUBLANG_GERMAN_SWISS: 1359 return "de_CH"; 1360 case SUBLANG_GERMAN_AUSTRIAN: 1361 return "de_AT"; 1362 case SUBLANG_GERMAN_LUXEMBOURG: 1363 return "de_LU"; 1364 case SUBLANG_GERMAN_LIECHTENSTEIN: 1365 return "de_LI"; 1262 1366 } 1263 1367 return "de"; 1264 case LANG_GREEK: return "el_GR"; 1265 case LANG_GUARANI: return "gn_PY"; 1266 case LANG_GUJARATI: return "gu_IN"; 1267 case LANG_HAUSA: return "ha_NG"; 1368 case LANG_GREEK: 1369 return "el_GR"; 1370 case LANG_GUARANI: 1371 return "gn_PY"; 1372 case LANG_GUJARATI: 1373 return "gu_IN"; 1374 case LANG_HAUSA: 1375 return "ha_NG"; 1268 1376 case LANG_HAWAIIAN: 1269 1377 /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers) 1270 1378 or Hawaii Creole English ("cpe_US", 600000 speakers)? */ 1271 1379 return "cpe_US"; 1272 case LANG_HEBREW: return "he_IL"; 1273 case LANG_HINDI: return "hi_IN"; 1274 case LANG_HUNGARIAN: return "hu_HU"; 1275 case LANG_IBIBIO: return "nic_NG"; 1276 case LANG_ICELANDIC: return "is_IS"; 1277 case LANG_IGBO: return "ig_NG"; 1278 case LANG_INDONESIAN: return "id_ID"; 1279 case LANG_INUKTITUT: return "iu_CA"; 1380 case LANG_HEBREW: 1381 return "he_IL"; 1382 case LANG_HINDI: 1383 return "hi_IN"; 1384 case LANG_HUNGARIAN: 1385 return "hu_HU"; 1386 case LANG_IBIBIO: 1387 return "nic_NG"; 1388 case LANG_ICELANDIC: 1389 return "is_IS"; 1390 case LANG_IGBO: 1391 return "ig_NG"; 1392 case LANG_INDONESIAN: 1393 return "id_ID"; 1394 case LANG_INUKTITUT: 1395 return "iu_CA"; 1280 1396 case LANG_ITALIAN: 1281 1397 switch (sub) 1282 1398 { 1283 case SUBLANG_ITALIAN: return "it_IT"; 1284 case SUBLANG_ITALIAN_SWISS: return "it_CH"; 1399 case SUBLANG_ITALIAN: 1400 return "it_IT"; 1401 case SUBLANG_ITALIAN_SWISS: 1402 return "it_CH"; 1285 1403 } 1286 1404 return "it"; 1287 case LANG_JAPANESE: return "ja_JP"; 1288 case LANG_KANNADA: return "kn_IN"; 1289 case LANG_KANURI: return "kr_NG"; 1405 case LANG_JAPANESE: 1406 return "ja_JP"; 1407 case LANG_KANNADA: 1408 return "kn_IN"; 1409 case LANG_KANURI: 1410 return "kr_NG"; 1290 1411 case LANG_KASHMIRI: 1291 1412 switch (sub) 1292 1413 { 1293 case SUBLANG_DEFAULT: return "ks_PK"; 1294 case SUBLANG_KASHMIRI_INDIA: return "ks_IN"; 1414 case SUBLANG_DEFAULT: 1415 return "ks_PK"; 1416 case SUBLANG_KASHMIRI_INDIA: 1417 return "ks_IN"; 1295 1418 } 1296 1419 return "ks"; 1297 case LANG_KAZAK: return "kk_KZ"; 1420 case LANG_KAZAK: 1421 return "kk_KZ"; 1298 1422 case LANG_KONKANI: 1299 1423 /* FIXME: Adjust this when such locales appear on Unix. */ 1300 1424 return "kok_IN"; 1301 case LANG_KOREAN: return "ko_KR"; 1302 case LANG_KYRGYZ: return "ky_KG"; 1303 case LANG_LAO: return "lo_LA"; 1304 case LANG_LATIN: return "la_VA"; 1305 case LANG_LATVIAN: return "lv_LV"; 1306 case LANG_LITHUANIAN: return "lt_LT"; 1307 case LANG_MACEDONIAN: return "mk_MK"; 1425 case LANG_KOREAN: 1426 return "ko_KR"; 1427 case LANG_KYRGYZ: 1428 return "ky_KG"; 1429 case LANG_LAO: 1430 return "lo_LA"; 1431 case LANG_LATIN: 1432 return "la_VA"; 1433 case LANG_LATVIAN: 1434 return "lv_LV"; 1435 case LANG_LITHUANIAN: 1436 return "lt_LT"; 1437 case LANG_MACEDONIAN: 1438 return "mk_MK"; 1308 1439 case LANG_MALAY: 1309 1440 switch (sub) 1310 1441 { 1311 case SUBLANG_MALAY_MALAYSIA: return "ms_MY"; 1312 case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN"; 1442 case SUBLANG_MALAY_MALAYSIA: 1443 return "ms_MY"; 1444 case SUBLANG_MALAY_BRUNEI_DARUSSALAM: 1445 return "ms_BN"; 1313 1446 } 1314 1447 return "ms"; 1315 case LANG_MALAYALAM: return "ml_IN"; 1316 case LANG_MALTESE: return "mt_MT"; 1448 case LANG_MALAYALAM: 1449 return "ml_IN"; 1450 case LANG_MALTESE: 1451 return "mt_MT"; 1317 1452 case LANG_MANIPURI: 1318 1453 /* FIXME: Adjust this when such locales appear on Unix. */ 1319 1454 return "mni_IN"; 1320 case LANG_MARATHI: return "mr_IN"; 1455 case LANG_MARATHI: 1456 return "mr_IN"; 1321 1457 case LANG_MONGOLIAN: 1322 1458 switch (sub) 1323 1459 { 1324 case SUBLANG_DEFAULT: return "mn_MN"; 1325 } 1326 return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN". */ 1460 case SUBLANG_DEFAULT: 1461 return "mn_MN"; 1462 } 1463 return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN". */ 1327 1464 case LANG_NEPALI: 1328 1465 switch (sub) 1329 1466 { 1330 case SUBLANG_DEFAULT: return "ne_NP"; 1331 case SUBLANG_NEPALI_INDIA: return "ne_IN"; 1467 case SUBLANG_DEFAULT: 1468 return "ne_NP"; 1469 case SUBLANG_NEPALI_INDIA: 1470 return "ne_IN"; 1332 1471 } 1333 1472 return "ne"; … … 1335 1474 switch (sub) 1336 1475 { 1337 case SUBLANG_NORWEGIAN_BOKMAL: return "nb_NO"; 1338 case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO"; 1476 case SUBLANG_NORWEGIAN_BOKMAL: 1477 return "nb_NO"; 1478 case SUBLANG_NORWEGIAN_NYNORSK: 1479 return "nn_NO"; 1339 1480 } 1340 1481 return "no"; 1341 case LANG_ORIYA: return "or_IN"; 1342 case LANG_OROMO: return "om_ET"; 1343 case LANG_PAPIAMENTU: return "pap_AN"; 1482 case LANG_ORIYA: 1483 return "or_IN"; 1484 case LANG_OROMO: 1485 return "om_ET"; 1486 case LANG_PAPIAMENTU: 1487 return "pap_AN"; 1344 1488 case LANG_PASHTO: 1345 return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF". */ 1346 case LANG_POLISH: return "pl_PL"; 1489 return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF". */ 1490 case LANG_POLISH: 1491 return "pl_PL"; 1347 1492 case LANG_PORTUGUESE: 1348 1493 switch (sub) 1349 1494 { 1350 case SUBLANG_PORTUGUESE: return "pt_PT"; 1351 /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT. 1352 Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */ 1353 case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR"; 1495 case SUBLANG_PORTUGUESE: 1496 return "pt_PT"; 1497 /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT. 1498 Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */ 1499 case SUBLANG_PORTUGUESE_BRAZILIAN: 1500 return "pt_BR"; 1354 1501 } 1355 1502 return "pt"; … … 1357 1504 switch (sub) 1358 1505 { 1359 case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */ 1360 case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */ 1506 case SUBLANG_PUNJABI_INDIA: 1507 return "pa_IN"; /* Gurmukhi script */ 1508 case SUBLANG_PUNJABI_PAKISTAN: 1509 return "pa_PK"; /* Arabic script */ 1361 1510 } 1362 1511 return "pa"; 1363 case LANG_RHAETO_ROMANCE: return "rm_CH"; 1512 case LANG_RHAETO_ROMANCE: 1513 return "rm_CH"; 1364 1514 case LANG_ROMANIAN: 1365 1515 switch (sub) 1366 1516 { 1367 case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO"; 1368 case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD"; 1517 case SUBLANG_ROMANIAN_ROMANIA: 1518 return "ro_RO"; 1519 case SUBLANG_ROMANIAN_MOLDOVA: 1520 return "ro_MD"; 1369 1521 } 1370 1522 return "ro"; … … 1372 1524 switch (sub) 1373 1525 { 1374 case SUBLANG_DEFAULT: return "ru_RU"; 1375 } 1376 return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD". */ 1377 case LANG_SAAMI: /* actually Northern Sami */ return "se_NO"; 1378 case LANG_SANSKRIT: return "sa_IN"; 1526 case SUBLANG_DEFAULT: 1527 return "ru_RU"; 1528 } 1529 return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD". */ 1530 case LANG_SAAMI: /* actually Northern Sami */ 1531 return "se_NO"; 1532 case LANG_SANSKRIT: 1533 return "sa_IN"; 1379 1534 case LANG_SINDHI: 1380 1535 switch (sub) 1381 1536 { 1382 case SUBLANG_SINDHI_INDIA: return "sd_IN"; 1383 case SUBLANG_SINDHI_PAKISTAN: return "sd_PK"; 1537 case SUBLANG_SINDHI_INDIA: 1538 return "sd_IN"; 1539 case SUBLANG_SINDHI_PAKISTAN: 1540 return "sd_PK"; 1384 1541 } 1385 1542 return "sd"; 1386 case LANG_SINHALESE: return "si_LK"; 1387 case LANG_SLOVAK: return "sk_SK"; 1388 case LANG_SLOVENIAN: return "sl_SI"; 1389 case LANG_SOMALI: return "so_SO"; 1543 case LANG_SINHALESE: 1544 return "si_LK"; 1545 case LANG_SLOVAK: 1546 return "sk_SK"; 1547 case LANG_SLOVENIAN: 1548 return "sl_SI"; 1549 case LANG_SOMALI: 1550 return "so_SO"; 1390 1551 case LANG_SORBIAN: 1391 1552 /* FIXME: Adjust this when such locales appear on Unix. */ … … 1394 1555 switch (sub) 1395 1556 { 1396 case SUBLANG_SPANISH: return "es_ES"; 1397 case SUBLANG_SPANISH_MEXICAN: return "es_MX"; 1557 case SUBLANG_SPANISH: 1558 return "es_ES"; 1559 case SUBLANG_SPANISH_MEXICAN: 1560 return "es_MX"; 1398 1561 case SUBLANG_SPANISH_MODERN: 1399 1562 return "es_ES@modern"; /* not seen on Unix */ 1400 case SUBLANG_SPANISH_GUATEMALA: return "es_GT"; 1401 case SUBLANG_SPANISH_COSTA_RICA: return "es_CR"; 1402 case SUBLANG_SPANISH_PANAMA: return "es_PA"; 1403 case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO"; 1404 case SUBLANG_SPANISH_VENEZUELA: return "es_VE"; 1405 case SUBLANG_SPANISH_COLOMBIA: return "es_CO"; 1406 case SUBLANG_SPANISH_PERU: return "es_PE"; 1407 case SUBLANG_SPANISH_ARGENTINA: return "es_AR"; 1408 case SUBLANG_SPANISH_ECUADOR: return "es_EC"; 1409 case SUBLANG_SPANISH_CHILE: return "es_CL"; 1410 case SUBLANG_SPANISH_URUGUAY: return "es_UY"; 1411 case SUBLANG_SPANISH_PARAGUAY: return "es_PY"; 1412 case SUBLANG_SPANISH_BOLIVIA: return "es_BO"; 1413 case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV"; 1414 case SUBLANG_SPANISH_HONDURAS: return "es_HN"; 1415 case SUBLANG_SPANISH_NICARAGUA: return "es_NI"; 1416 case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR"; 1563 case SUBLANG_SPANISH_GUATEMALA: 1564 return "es_GT"; 1565 case SUBLANG_SPANISH_COSTA_RICA: 1566 return "es_CR"; 1567 case SUBLANG_SPANISH_PANAMA: 1568 return "es_PA"; 1569 case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: 1570 return "es_DO"; 1571 case SUBLANG_SPANISH_VENEZUELA: 1572 return "es_VE"; 1573 case SUBLANG_SPANISH_COLOMBIA: 1574 return "es_CO"; 1575 case SUBLANG_SPANISH_PERU: 1576 return "es_PE"; 1577 case SUBLANG_SPANISH_ARGENTINA: 1578 return "es_AR"; 1579 case SUBLANG_SPANISH_ECUADOR: 1580 return "es_EC"; 1581 case SUBLANG_SPANISH_CHILE: 1582 return "es_CL"; 1583 case SUBLANG_SPANISH_URUGUAY: 1584 return "es_UY"; 1585 case SUBLANG_SPANISH_PARAGUAY: 1586 return "es_PY"; 1587 case SUBLANG_SPANISH_BOLIVIA: 1588 return "es_BO"; 1589 case SUBLANG_SPANISH_EL_SALVADOR: 1590 return "es_SV"; 1591 case SUBLANG_SPANISH_HONDURAS: 1592 return "es_HN"; 1593 case SUBLANG_SPANISH_NICARAGUA: 1594 return "es_NI"; 1595 case SUBLANG_SPANISH_PUERTO_RICO: 1596 return "es_PR"; 1417 1597 } 1418 1598 return "es"; 1419 case LANG_SUTU: return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */ 1420 case LANG_SWAHILI: return "sw_KE"; 1599 case LANG_SUTU: 1600 return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */ 1601 case LANG_SWAHILI: 1602 return "sw_KE"; 1421 1603 case LANG_SWEDISH: 1422 1604 switch (sub) 1423 1605 { 1424 case SUBLANG_DEFAULT: return "sv_SE"; 1425 case SUBLANG_SWEDISH_FINLAND: return "sv_FI"; 1606 case SUBLANG_DEFAULT: 1607 return "sv_SE"; 1608 case SUBLANG_SWEDISH_FINLAND: 1609 return "sv_FI"; 1426 1610 } 1427 1611 return "sv"; 1428 case LANG_SYRIAC: return "syr_TR"; /* An extinct language. */ 1429 case LANG_TAGALOG: return "tl_PH"; 1430 case LANG_TAJIK: return "tg_TJ"; 1612 case LANG_SYRIAC: 1613 return "syr_TR"; /* An extinct language. */ 1614 case LANG_TAGALOG: 1615 return "tl_PH"; 1616 case LANG_TAJIK: 1617 return "tg_TJ"; 1431 1618 case LANG_TAMAZIGHT: 1432 1619 switch (sub) 1433 1620 { 1434 /* FIXME: Adjust this when Tamazight locales appear on Unix. */ 1435 case SUBLANG_TAMAZIGHT_ARABIC: return "ber_MA@arabic"; 1436 case SUBLANG_TAMAZIGHT_LATIN: return "ber_MA@latin"; 1621 /* FIXME: Adjust this when Tamazight locales appear on Unix. */ 1622 case SUBLANG_TAMAZIGHT_ARABIC: 1623 return "ber_MA@arabic"; 1624 case SUBLANG_TAMAZIGHT_LATIN: 1625 return "ber_MA@latin"; 1437 1626 } 1438 1627 return "ber_MA"; … … 1440 1629 switch (sub) 1441 1630 { 1442 case SUBLANG_DEFAULT: return "ta_IN"; 1443 } 1444 return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */ 1445 case LANG_TATAR: return "tt_RU"; 1446 case LANG_TELUGU: return "te_IN"; 1447 case LANG_THAI: return "th_TH"; 1448 case LANG_TIBETAN: return "bo_CN"; 1631 case SUBLANG_DEFAULT: 1632 return "ta_IN"; 1633 } 1634 return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */ 1635 case LANG_TATAR: 1636 return "tt_RU"; 1637 case LANG_TELUGU: 1638 return "te_IN"; 1639 case LANG_THAI: 1640 return "th_TH"; 1641 case LANG_TIBETAN: 1642 return "bo_CN"; 1449 1643 case LANG_TIGRINYA: 1450 1644 switch (sub) 1451 1645 { 1452 case SUBLANG_TIGRINYA_ETHIOPIA: return "ti_ET"; 1453 case SUBLANG_TIGRINYA_ERITREA: return "ti_ER"; 1646 case SUBLANG_TIGRINYA_ETHIOPIA: 1647 return "ti_ET"; 1648 case SUBLANG_TIGRINYA_ERITREA: 1649 return "ti_ER"; 1454 1650 } 1455 1651 return "ti"; 1456 case LANG_TSONGA: return "ts_ZA"; 1457 case LANG_TSWANA: return "tn_BW"; 1458 case LANG_TURKISH: return "tr_TR"; 1459 case LANG_TURKMEN: return "tk_TM"; 1460 case LANG_UKRAINIAN: return "uk_UA"; 1652 case LANG_TSONGA: 1653 return "ts_ZA"; 1654 case LANG_TSWANA: 1655 return "tn_BW"; 1656 case LANG_TURKISH: 1657 return "tr_TR"; 1658 case LANG_TURKMEN: 1659 return "tk_TM"; 1660 case LANG_UKRAINIAN: 1661 return "uk_UA"; 1461 1662 case LANG_URDU: 1462 1663 switch (sub) 1463 1664 { 1464 case SUBLANG_URDU_PAKISTAN: return "ur_PK"; 1465 case SUBLANG_URDU_INDIA: return "ur_IN"; 1665 case SUBLANG_URDU_PAKISTAN: 1666 return "ur_PK"; 1667 case SUBLANG_URDU_INDIA: 1668 return "ur_IN"; 1466 1669 } 1467 1670 return "ur"; … … 1469 1672 switch (sub) 1470 1673 { 1471 case SUBLANG_UZBEK_LATIN: return "uz_UZ"; 1472 case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic"; 1674 case SUBLANG_UZBEK_LATIN: 1675 return "uz_UZ"; 1676 case SUBLANG_UZBEK_CYRILLIC: 1677 return "uz_UZ@cyrillic"; 1473 1678 } 1474 1679 return "uz"; 1475 case LANG_VENDA: return "ve_ZA"; 1476 case LANG_VIETNAMESE: return "vi_VN"; 1477 case LANG_WELSH: return "cy_GB"; 1478 case LANG_XHOSA: return "xh_ZA"; 1479 case LANG_YI: return "sit_CN"; 1480 case LANG_YIDDISH: return "yi_IL"; 1481 case LANG_YORUBA: return "yo_NG"; 1482 case LANG_ZULU: return "zu_ZA"; 1483 default: return "C"; 1680 case LANG_VENDA: 1681 return "ve_ZA"; 1682 case LANG_VIETNAMESE: 1683 return "vi_VN"; 1684 case LANG_WELSH: 1685 return "cy_GB"; 1686 case LANG_XHOSA: 1687 return "xh_ZA"; 1688 case LANG_YI: 1689 return "sit_CN"; 1690 case LANG_YIDDISH: 1691 return "yi_IL"; 1692 case LANG_YORUBA: 1693 return "yo_NG"; 1694 case LANG_ZULU: 1695 return "zu_ZA"; 1696 default: 1697 return "C"; 1484 1698 } 1485 1699 } sweep/branches/display-cache/intl/log.c
r183 r471 29 29 /* Print an ASCII string with quotes and escape sequences where needed. */ 30 30 static void 31 print_escaped (FILE * stream, const char *str)31 print_escaped (FILE * stream, const char *str) 32 32 { 33 33 putc ('"', stream); sweep/branches/display-cache/intl/os2compat.c
r183 r471 27 27 28 28 /* A version of getenv() that works from DLLs */ 29 extern unsigned long DosScanEnv (const unsigned char *pszName, unsigned char **ppszValue); 29 extern unsigned long DosScanEnv (const unsigned char *pszName, 30 unsigned char **ppszValue); 30 31 31 32 char * … … 40 41 41 42 /* A fixed size buffer. */ 42 char libintl_nl_default_dirname[MAXPATHLEN +1];43 char libintl_nl_default_dirname[MAXPATHLEN + 1]; 43 44 44 45 char *_nlos2_libdir = NULL; … … 46 47 char *_nlos2_localedir = NULL; 47 48 48 static __attribute__ ((constructor)) void49 nlos2_initialize ()49 static __attribute__ ((constructor)) 50 void nlos2_initialize () 50 51 { 51 52 char *root = getenv ("UNIXROOT"); … … 56 57 { 57 58 if (root) 58 {59 size_t sl = strlen (root);60 _nlos2_libdir = (char *) malloc (sl + strlen (LIBDIR) + 1);61 memcpy (_nlos2_libdir, root, sl);62 memcpy (_nlos2_libdir + sl, LIBDIR, strlen (LIBDIR) + 1);63 }59 { 60 size_t sl = strlen (root); 61 _nlos2_libdir = (char *) malloc (sl + strlen (LIBDIR) + 1); 62 memcpy (_nlos2_libdir, root, sl); 63 memcpy (_nlos2_libdir + sl, LIBDIR, strlen (LIBDIR) + 1); 64 } 64 65 else 65 _nlos2_libdir = LIBDIR;66 _nlos2_libdir = LIBDIR; 66 67 } 67 68 … … 70 71 { 71 72 if (root) 72 { 73 size_t sl = strlen (root); 74 _nlos2_localealiaspath = (char *) malloc (sl + strlen (LOCALE_ALIAS_PATH) + 1); 75 memcpy (_nlos2_localealiaspath, root, sl); 76 memcpy (_nlos2_localealiaspath + sl, LOCALE_ALIAS_PATH, strlen (LOCALE_ALIAS_PATH) + 1); 77 } 78 else 79 _nlos2_localealiaspath = LOCALE_ALIAS_PATH; 73 { 74 size_t sl = strlen (root); 75 _nlos2_localealiaspath = 76 (char *) malloc (sl + strlen (LOCALE_ALIAS_PATH) + 1); 77 memcpy (_nlos2_localealiaspath, root, sl); 78 memcpy (_nlos2_localealiaspath + sl, LOCALE_ALIAS_PATH, 79 strlen (LOCALE_ALIAS_PATH) + 1); 80 } 81 else 82 _nlos2_localealiaspath = LOCALE_ALIAS_PATH; 80 83 } 81 84 … … 84 87 { 85 88 if (root) 86 {87 size_t sl = strlen (root);88 _nlos2_localedir = (char *) malloc (sl + strlen (LOCALEDIR) + 1);89 memcpy (_nlos2_localedir, root, sl);90 memcpy (_nlos2_localedir + sl, LOCALEDIR, strlen (LOCALEDIR) + 1);91 }89 { 90 size_t sl = strlen (root); 91 _nlos2_localedir = (char *) malloc (sl + strlen (LOCALEDIR) + 1); 92 memcpy (_nlos2_localedir, root, sl); 93 memcpy (_nlos2_localedir + sl, LOCALEDIR, strlen (LOCALEDIR) + 1); 94 } 92 95 else 93 _nlos2_localedir = LOCALEDIR;96 _nlos2_localedir = LOCALEDIR; 94 97 } 95 98 sweep/branches/display-cache/intl/plural-exp.c
r183 r471 33 33 /* These structs are the constant expression for the germanic plural 34 34 form determination. It represents the expression "n != 1". */ 35 static const struct expression plvar = 36 { 35 static const struct expression plvar = { 37 36 .nargs = 0, 38 37 .operation = var, 39 38 }; 40 static const struct expression plone = 41 { 39 static const struct expression plone = { 42 40 .nargs = 0, 43 41 .operation = num, 44 .val = 45 { 46 .num = 1 47 } 42 .val = { 43 .num = 1} 48 44 }; 49 struct expression GERMANIC_PLURAL = 50 { 45 struct expression GERMANIC_PLURAL = { 51 46 .nargs = 2, 52 47 .operation = not_equal, 53 .val = 54 { 55 .args = 56 { 57 [0] = (struct expression *) &plvar, 58 [1] = (struct expression *) &plone 59 } 60 } 48 .val = { 49 .args = { 50 [0] = (struct expression *) &plvar, 51 [1] = (struct expression *) &plone} 52 } 61 53 }; 62 54 … … 95 87 #endif 96 88 97 void 98 internal_function 89 void internal_function 99 90 EXTRACT_PLURAL_EXPRESSION (const char *nullentry, struct expression **pluralp, 100 91 unsigned long int *npluralsp) sweep/branches/display-cache/intl/plural-exp.h
r183 r471 102 102 #endif 103 103 104 extern void FREE_EXPRESSION (struct expression *exp) 105 internal_function; 106 extern int PLURAL_PARSE (void *arg); 107 extern struct expression GERMANIC_PLURAL attribute_hidden; 108 extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry, 109 struct expression **pluralp, 110 unsigned long int *npluralsp) 111 internal_function; 104 extern void 105 FREE_EXPRESSION (struct expression *exp) 106 internal_function; 107 extern int PLURAL_PARSE (void *arg); 108 extern struct expression GERMANIC_PLURAL attribute_hidden; 109 extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry, 110 struct expression **pluralp, 111 unsigned long int *npluralsp) 112 internal_function; 112 113 113 114 #if !defined (_LIBC) && !defined (IN_LIBINTL) 114 extern unsigned long int plural_eval (struct expression *pexp,115 unsigned long int n);115 extern unsigned long int plural_eval (struct expression *pexp, 116 unsigned long int n); 116 117 #endif 117 118 sweep/branches/display-cache/intl/plural.c
r183 r471 2 2 by GNU bison 1.35. */ 3 3 4 #define YYBISON 1 /* Identify Bison output. */4 #define YYBISON 1 /* Identify Bison output. */ 5 5 6 6 #define yyparse __gettextparse … … 43 43 because <config.h> may include arbitrary system headers. */ 44 44 #if defined _AIX && !defined __GNUC__ 45 #pragma alloca45 #pragma alloca 46 46 #endif 47 47 … … 65 65 #line 49 "plural.y" 66 66 #ifndef YYSTYPE 67 typedef union { 67 typedef union 68 { 68 69 unsigned long int num; 69 enum operator op;70 enum operator op; 70 71 struct expression *exp; 71 72 } yystype; … … 76 77 77 78 /* Prototypes for local functions. */ 78 static int yylex (YYSTYPE * lval, const char **pexp);79 static int yylex (YYSTYPE * lval, const char **pexp); 79 80 static void yyerror (const char *str); 80 81 … … 82 83 83 84 static struct expression * 84 new_exp (int nargs, enum operator op, struct expression *const *args)85 new_exp (int nargs, enum operator op, struct expression *const *args) 85 86 { 86 87 int i; … … 103 104 } 104 105 105 fail:106 fail: 106 107 for (i = nargs - 1; i >= 0; i--) 107 108 FREE_EXPRESSION (args[i]); … … 111 112 112 113 static inline struct expression * 113 new_exp_0 (enum operator op)114 new_exp_0 (enum operator op) 114 115 { 115 116 return new_exp (0, op, NULL); … … 117 118 118 119 static inline struct expression * 119 new_exp_1 (enum operator op, struct expression *right)120 new_exp_1 (enum operator op, struct expression *right) 120 121 { 121 122 struct expression *args[1]; … … 126 127 127 128 static struct expression * 128 new_exp_2 (enum operator op, struct expression *left, struct expression *right) 129 new_exp_2 (enum operator op, struct expression *left, 130 struct expression *right) 129 131 { 130 132 struct expression *args[2]; … … 136 138 137 139 static inline struct expression * 138 new_exp_3 (enum operator op, struct expression *bexp,140 new_exp_3 (enum operator op, struct expression *bexp, 139 141 struct expression *tbranch, struct expression *fbranch) 140 142 { … … 161 163 162 164 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ 163 static const char yytranslate[] = 164 { 165 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 166 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 167 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 168 2, 2, 2, 10, 2, 2, 2, 2, 5, 2, 169 14, 15, 2, 2, 2, 2, 2, 2, 2, 2, 170 2, 2, 2, 2, 2, 2, 2, 2, 12, 2, 171 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 172 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 173 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 174 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 175 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 176 13, 2, 2, 2, 2, 2, 2, 2, 2, 2, 177 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 178 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 179 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 180 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 181 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 183 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 184 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 190 2, 2, 2, 2, 2, 2, 1, 6, 7, 8, 191 9, 11 165 static const char yytranslate[] = { 166 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 167 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 168 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 169 2, 2, 2, 10, 2, 2, 2, 2, 5, 2, 170 14, 15, 2, 2, 2, 2, 2, 2, 2, 2, 171 2, 2, 2, 2, 2, 2, 2, 2, 12, 2, 172 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 173 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 174 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 175 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 176 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 177 13, 2, 2, 2, 2, 2, 2, 2, 2, 2, 178 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 179 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 180 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 181 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 183 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 184 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 190 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 191 2, 2, 2, 2, 2, 2, 1, 6, 7, 8, 192 9, 11 192 193 }; 193 194 194 195 #if YYDEBUG 195 static const short yyprhs[] = 196 { 197 0, 0, 2, 8, 12, 16, 20, 24, 28, 32, 198 35, 37, 39 196 static const short yyprhs[] = { 197 0, 0, 2, 8, 12, 16, 20, 24, 28, 32, 198 35, 37, 39 199 199 }; 200 static const short yyrhs[] = 201 { 202 17, 0, 17, 3, 17, 12, 17, 0, 17, 4, 203 17, 0, 17, 5, 17, 0, 17, 6, 17, 0, 204 17, 7, 17, 0, 17, 8, 17, 0, 17, 9, 205 17, 0, 10, 17, 0, 13, 0, 11, 0, 14, 206 17, 15, 0 200 static const short yyrhs[] = { 201 17, 0, 17, 3, 17, 12, 17, 0, 17, 4, 202 17, 0, 17, 5, 17, 0, 17, 6, 17, 0, 203 17, 7, 17, 0, 17, 8, 17, 0, 17, 9, 204 17, 0, 10, 17, 0, 13, 0, 11, 0, 14, 205 17, 15, 0 207 206 }; 208 207 … … 211 210 #if YYDEBUG 212 211 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 213 static const short yyrline[] = 214 { 215 0, 150, 158, 162, 166, 170, 174, 178, 182, 186, 216 190, 194, 199 212 static const short yyrline[] = { 213 0, 150, 158, 162, 166, 170, 174, 178, 182, 186, 214 190, 194, 199 217 215 }; 218 216 #endif … … 222 220 223 221 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ 224 static const char *const yytname[] = 225 { 226 "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2", 227 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'", 222 static const char *const yytname[] = { 223 "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2", 224 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'", 228 225 "start", "exp", 0 229 226 }; … … 231 228 232 229 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 233 static const short yyr1[] = 234 { 235 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 236 17, 17, 17 230 static const short yyr1[] = { 231 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 232 17, 17, 17 237 233 }; 238 234 239 235 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 240 static const short yyr2[] = 241 { 242 0, 1, 5, 3, 3, 3, 3, 3, 3, 2, 243 1, 1, 3 236 static const short yyr2[] = { 237 0, 1, 5, 3, 3, 3, 3, 3, 3, 2, 238 1, 1, 3 244 239 }; 245 240 … … 247 242 doesn't specify something else to do. Zero means the default is an 248 243 error. */ 249 static const short yydefact[] = 250 { 251 0, 0, 11, 10, 0, 1, 9, 0, 0, 0, 252 0, 0, 0, 0, 0, 12, 0, 3, 4, 5, 253 6, 7, 8, 0, 2, 0, 0, 0 244 static const short yydefact[] = { 245 0, 0, 11, 10, 0, 1, 9, 0, 0, 0, 246 0, 0, 0, 0, 0, 12, 0, 3, 4, 5, 247 6, 7, 8, 0, 2, 0, 0, 0 254 248 }; 255 249 256 static const short yydefgoto[] = 257 { 258 25, 5 250 static const short yydefgoto[] = { 251 25, 5 259 252 }; 260 253 261 static const short yypact[] = 262 { 263 -9, -9,-32768,-32768, -9, 34,-32768, 11, -9, -9, 264 -9, -9, -9, -9, -9,-32768, 24, 39, 43, 16, 265 26, -3,-32768, -9, 34, 21, 53,-32768 254 static const short yypact[] = { 255 -9, -9, -32768, -32768, -9, 34, -32768, 11, -9, -9, 256 -9, -9, -9, -9, -9, -32768, 24, 39, 43, 16, 257 26, -3, -32768, -9, 34, 21, 53, -32768 266 258 }; 267 259 268 static const short yypgoto[] = 269 { 270 -32768, -1 260 static const short yypgoto[] = { 261 -32768, -1 271 262 }; 272 263 … … 275 266 276 267 277 static const short yytable[] = 278 { 279 6, 1, 2, 7, 3, 4, 14, 16, 17, 18, 280 19, 20, 21, 22, 8, 9, 10, 11, 12, 13, 281 14, 26, 24, 12, 13, 14, 15, 8, 9, 10, 282 11, 12, 13, 14, 13, 14, 23, 8, 9, 10, 283 11, 12, 13, 14, 10, 11, 12, 13, 14, 11, 284 12, 13, 14, 27 268 static const short yytable[] = { 269 6, 1, 2, 7, 3, 4, 14, 16, 17, 18, 270 19, 20, 21, 22, 8, 9, 10, 11, 12, 13, 271 14, 26, 24, 12, 13, 14, 15, 8, 9, 10, 272 11, 12, 13, 14, 13, 14, 23, 8, 9, 10, 273 11, 12, 13, 14, 10, 11, 12, 13, 14, 11, 274 12, 13, 14, 27 285 275 }; 286 276 287 static const short yycheck[] = 288 { 289 1, 10, 11, 4, 13, 14, 9, 8, 9, 10, 290 11, 12, 13, 14, 3, 4, 5, 6, 7, 8, 291 9, 0, 23, 7, 8, 9, 15, 3, 4, 5, 292 6, 7, 8, 9, 8, 9, 12, 3, 4, 5, 293 6, 7, 8, 9, 5, 6, 7, 8, 9, 6, 294 7, 8, 9, 0 277 static const short yycheck[] = { 278 1, 10, 11, 4, 13, 14, 9, 8, 9, 10, 279 11, 12, 13, 14, 3, 4, 5, 6, 7, 8, 280 9, 0, 23, 7, 8, 9, 15, 3, 4, 5, 281 6, 7, 8, 9, 8, 9, 12, 3, 4, 5, 282 6, 7, 8, 9, 5, 6, 7, 8, 9, 6, 283 7, 8, 9, 0 295 284 }; 285 296 286 #define YYPURE 1 297 287 … … 359 349 # else 360 350 # if defined (__STDC__) || defined (__cplusplus) 361 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */351 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 362 352 # define YYSIZE_T size_t 363 353 # endif … … 442 432 #if ! defined (YYSIZE_T) 443 433 # if defined (__STDC__) || defined (__cplusplus) 444 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */434 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 445 435 # define YYSIZE_T size_t 446 436 # endif … … 512 502 # define YYLEX yylex (&yylval) 513 503 # endif 514 # endif /* !YYLSP_NEEDED */504 # endif /* !YYLSP_NEEDED */ 515 505 #else /* !YYPURE */ 516 506 # define YYLEX yylex () … … 522 512 523 513 # ifndef YYFPRINTF 524 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */514 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 525 515 # define YYFPRINTF fprintf 526 516 # endif … … 670 660 #if !YYPURE 671 661 YY_DECL_VARIABLES 672 #endif /* !YYPURE */ 673 674 int 662 #endif /* !YYPURE */ 663 int 675 664 yyparse (YYPARSE_PARAM_ARG) 676 YYPARSE_PARAM_DECL665 YYPARSE_PARAM_DECL 677 666 { 678 667 /* If reentrant, generate the variables here. */ 679 668 #if YYPURE 680 669 YY_DECL_VARIABLES 681 #endif /* !YYPURE */ 682 670 #endif /* !YYPURE */ 683 671 register int yystate; 684 672 register int yyn; … … 698 686 699 687 /* The state stack. */ 700 short yyssa[YYINITDEPTH];688 short yyssa[YYINITDEPTH]; 701 689 short *yyss = yyssa; 702 690 register short *yyssp; … … 756 744 | yynewstate -- Push a new state, which is found in yystate. | 757 745 `------------------------------------------------------------*/ 758 yynewstate:746 yynewstate: 759 747 /* In all cases, when you get here, the value and location stacks 760 748 have just been pushed. so pushing a state here evens the stacks. 761 */749 */ 762 750 yyssp++; 763 751 764 yysetstate:752 yysetstate: 765 753 *yyssp = yystate; 766 754 … … 787 775 &yyss1, yysize * sizeof (*yyssp), 788 776 &yyvs1, yysize * sizeof (*yyvsp), 789 &yyls1, yysize * sizeof (*yylsp), 790 &yystacksize); 777 &yyls1, yysize * sizeof (*yylsp), &yystacksize); 791 778 yyls = yyls1; 792 779 # else 793 780 yyoverflow ("parser stack overflow", 794 781 &yyss1, yysize * sizeof (*yyssp), 795 &yyvs1, yysize * sizeof (*yyvsp), 796 &yystacksize); 782 &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); 797 783 # endif 798 784 yyss = yyss1; … … 814 800 union yyalloc *yyptr = 815 801 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 816 if (! yyptr)802 if (!yyptr) 817 803 goto yyoverflowlab; 818 804 YYSTACK_RELOCATE (yyss); … … 886 872 887 873 #if YYDEBUG 888 /* We have to keep this `#if YYDEBUG', since we use variables889 which are defined only if `YYDEBUG' is set. */874 /* We have to keep this `#if YYDEBUG', since we use variables 875 which are defined only if `YYDEBUG' is set. */ 890 876 if (yydebug) 891 877 { … … 911 897 Negative => reduce, -yyn is rule number. 912 898 Positive => shift, yyn is new state. 913 New state is final state => don't bother to shift,914 just return success.899 New state is final state => don't bother to shift, 900 just return success. 915 901 0, or most negative number => error. */ 916 902 … … 929 915 930 916 /* Shift the lookahead token. */ 931 YYDPRINTF ((stderr, "Shifting token %d (%s), ", 932 yychar, yytname[yychar1])); 917 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1])); 933 918 934 919 /* Discard the token being shifted unless it is eof. */ … … 975 960 unconditionally makes the parser a bit smaller, and it avoids a 976 961 GCC warning that YYVAL may be used uninitialized. */ 977 yyval = yyvsp[1 -yylen];962 yyval = yyvsp[1 - yylen]; 978 963 979 964 #if YYLSP_NEEDED 980 965 /* Similarly for the default location. Let the user run additional 981 966 commands if for instance locations are ranges. */ 982 yyloc = yylsp[1 -yylen];967 yyloc = yylsp[1 - yylen]; 983 968 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); 984 969 #endif … … 1001 986 #endif 1002 987 1003 switch (yyn) { 1004 1005 case 1: 988 switch (yyn) 989 { 990 991 case 1: 1006 992 #line 151 "plural.y" 1007 {1008 if (yyvsp[0].exp == NULL)1009 YYABORT;1010 ((struct parse_args *) arg)->res = yyvsp[0].exp;1011 }1012 break;1013 case 2:993 { 994 if (yyvsp[0].exp == NULL) 995 YYABORT; 996 ((struct parse_args *) arg)->res = yyvsp[0].exp; 997 } 998 break; 999 case 2: 1014 1000 #line 159 "plural.y" 1015 { 1016 yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp); 1017 } 1018 break; 1019 case 3: 1001 { 1002 yyval.exp = 1003 new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp); 1004 } 1005 break; 1006 case 3: 1020 1007 #line 163 "plural.y" 1021 {1022 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);1023 }1024 break;1025 case 4:1008 { 1009 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp); 1010 } 1011 break; 1012 case 4: 1026 1013 #line 167 "plural.y" 1027 {1028 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);1029 }1030 break;1031 case 5:1014 { 1015 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp); 1016 } 1017 break; 1018 case 5: 1032 1019 #line 171 "plural.y" 1033 {1034 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);1035 }1036 break;1037 case 6:1020 { 1021 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); 1022 } 1023 break; 1024 case 6: 1038 1025 #line 175 "plural.y" 1039 {1040 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);1041 }1042 break;1043 case 7:1026 { 1027 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); 1028 } 1029 break; 1030 case 7: 1044 1031 #line 179 "plural.y" 1045 {1046 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);1047 }1048 break;1049 case 8:1032 { 1033 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); 1034 } 1035 break; 1036 case 8: 1050 1037 #line 183 "plural.y" 1051 {1052 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);1053 }1054 break;1055 case 9:1038 { 1039 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); 1040 } 1041 break; 1042 case 9: 1056 1043 #line 187 "plural.y" 1057 {1058 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);1059 }1060 break;1061 case 10:1044 { 1045 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp); 1046 } 1047 break; 1048 case 10: 1062 1049 #line 191 "plural.y" 1063 {1064 yyval.exp = new_exp_0 (var);1065 }1066 break;1067 case 11:1050 { 1051 yyval.exp = new_exp_0 (var); 1052 } 1053 break; 1054 case 11: 1068 1055 #line 195 "plural.y" 1069 {1070 if ((yyval.exp = new_exp_0 (num)) != NULL)1071 yyval.exp->val.num = yyvsp[0].num;1072 }1073 break;1074 case 12:1056 { 1057 if ((yyval.exp = new_exp_0 (num)) != NULL) 1058 yyval.exp->val.num = yyvsp[0].num; 1059 } 1060 break; 1061 case 12: 1075 1062 #line 200 "plural.y" 1076 {1077 yyval.exp = yyvsp[-1].exp;1078 }1079 break;1080 }1063 { 1064 yyval.exp = yyvsp[-1].exp; 1065 } 1066 break; 1067 } 1081 1068 1082 1069 #line 705 "/home/haible/gnu/arch/linuxlibc6/share/bison/bison.simple" 1083 1084 1070 1071 1085 1072 yyvsp -= yylen; 1086 1073 yyssp -= yylen; … … 1161 1148 if (yycheck[yyx + yyn] == yyx) 1162 1149 { 1163 const char *yyq = ! yycount ? ", expecting " : " or ";1150 const char *yyq = !yycount ? ", expecting " : " or "; 1164 1151 yyp = yystpcpy (yyp, yyq); 1165 1152 yyp = yystpcpy (yyp, yytname[yyx]); … … 1187 1174 { 1188 1175 /* If just tried and failed to reuse lookahead token after an 1189 error, discard it. */1176 error, discard it. */ 1190 1177 1191 1178 /* return failure if at end of input */ … … 1311 1298 return yyresult; 1312 1299 } 1300 1313 1301 #line 205 "plural.y" 1314 1302 1315 1303 1316 void 1317 internal_function 1304 void internal_function 1318 1305 FREE_EXPRESSION (struct expression *exp) 1319 1306 { … … 1342 1329 1343 1330 static int 1344 yylex (YYSTYPE * lval, const char **pexp)1331 yylex (YYSTYPE * lval, const char **pexp) 1345 1332 { 1346 1333 const char *exp = *pexp; … … 1364 1351 switch (result) 1365 1352 { 1366 case '0': case '1': case '2': case '3': case '4': 1367 case '5': case '6': case '7': case '8': case '9': 1353 case '0': 1354 case '1': 1355 case '2': 1356 case '3': 1357 case '4': 1358 case '5': 1359 case '6': 1360 case '7': 1361 case '8': 1362 case '9': 1368 1363 { 1369 1364 unsigned long int n = result - '0'; sweep/branches/display-cache/intl/printf-args.c
r183 r471 27 27 STATIC 28 28 #endif 29 int30 printf_fetchargs (va_list args, arguments * a)29 int 30 printf_fetchargs (va_list args, arguments * a) 31 31 { 32 32 size_t i; … … 37 37 { 38 38 case TYPE_SCHAR: 39 ap->a.a_schar = va_arg (args, /*signed char */ int);39 ap->a.a_schar = va_arg (args, /*signed char */ int); 40 40 break; 41 41 case TYPE_UCHAR: 42 ap->a.a_uchar = va_arg (args, /*unsigned char */ int);42 ap->a.a_uchar = va_arg (args, /*unsigned char */ int); 43 43 break; 44 44 case TYPE_SHORT: 45 ap->a.a_short = va_arg (args, /*short */ int);45 ap->a.a_short = va_arg (args, /*short */ int); 46 46 break; 47 47 case TYPE_USHORT: 48 ap->a.a_ushort = va_arg (args, /*unsigned short */ int);48 ap->a.a_ushort = va_arg (args, /*unsigned short */ int); 49 49 break; 50 50 case TYPE_INT: sweep/branches/display-cache/intl/printf-args.h
r183 r471 71 71 TYPE_COUNT_LONGINT_POINTER 72 72 #ifdef HAVE_LONG_LONG 73 , TYPE_COUNT_LONGLONGINT_POINTER73 , TYPE_COUNT_LONGLONGINT_POINTER 74 74 #endif 75 75 } arg_type; … … 81 81 union 82 82 { 83 signed char a_schar;84 unsigned char a_uchar;85 short a_short;86 unsigned short a_ushort;87 int a_int;88 unsigned int a_uint;89 long int a_longint;90 unsigned long int a_ulongint;83 signed char a_schar; 84 unsigned char a_uchar; 85 short a_short; 86 unsigned short a_ushort; 87 int a_int; 88 unsigned int a_uint; 89 long int a_longint; 90 unsigned long int a_ulongint; 91 91 #ifdef HAVE_LONG_LONG 92 long long int a_longlongint;93 unsigned long long int a_ulonglongint;92 long long int a_longlongint; 93 unsigned long long int a_ulonglongint; 94 94 #endif 95 float a_float;96 double a_double;95 float a_float; 96 double a_double; 97 97 #ifdef HAVE_LONG_DOUBLE 98 long double a_longdouble;98 long double a_longdouble; 99 99 #endif 100 int a_char;100 int a_char; 101 101 #ifdef HAVE_WINT_T 102 wint_t a_wide_char;102 wint_t a_wide_char; 103 103 #endif 104 const char *a_string;104 const char *a_string; 105 105 #ifdef HAVE_WCHAR_T 106 const wchar_t *a_wide_string;106 const wchar_t *a_wide_string; 107 107 #endif 108 void *a_pointer;109 signed char * a_count_schar_pointer;110 short * a_count_short_pointer;111 int * a_count_int_pointer;112 long int * a_count_longint_pointer;108 void *a_pointer; 109 signed char *a_count_schar_pointer; 110 short *a_count_short_pointer; 111 int *a_count_int_pointer; 112 long int *a_count_longint_pointer; 113 113 #ifdef HAVE_LONG_LONG 114 long long int * a_count_longlongint_pointer;114 long long int *a_count_longlongint_pointer; 115 115 #endif 116 116 } … … 133 133 extern 134 134 #endif 135 int printf_fetchargs (va_list args, arguments * a);135 int printf_fetchargs (va_list args, arguments * a); 136 136 137 137 #endif /* _PRINTF_ARGS_H */ sweep/branches/display-cache/intl/printf-parse.c
r183 r471 60 60 STATIC 61 61 #endif 62 int63 PRINTF_PARSE (const CHAR_T * format, DIRECTIVES *d, arguments *a)62 int 63 PRINTF_PARSE (const CHAR_T * format, DIRECTIVES * d, arguments * a) 64 64 { 65 const CHAR_T *cp = format; /* pointer into format */65 const CHAR_T *cp = format; /* pointer into format */ 66 66 size_t arg_posn = 0; /* number of regular arguments consumed */ 67 size_t d_allocated; /* allocated elements of d->dir */68 size_t a_allocated; /* allocated elements of a->arg */67 size_t d_allocated; /* allocated elements of d->dir */ 68 size_t a_allocated; /* allocated elements of a->arg */ 69 69 size_t max_width_length = 0; 70 70 size_t max_precision_length = 0; … … 119 119 { 120 120 size_t arg_index = ARG_NONE; 121 DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */121 DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */ 122 122 123 123 /* Initialize the next directive. */ … … 349 349 { 350 350 /* 'z' is standardized in ISO C 99, but glibc uses 'Z' 351 because the warning facility in gcc-2.95.2 understands352 only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */351 because the warning facility in gcc-2.95.2 understands 352 only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */ 353 353 if (sizeof (size_t) > sizeof (long)) 354 354 { … … 385 385 switch (c) 386 386 { 387 case 'd': case 'i': 387 case 'd': 388 case 'i': 388 389 #ifdef HAVE_LONG_LONG 389 390 if (flags >= 16 || (flags & 4)) … … 400 401 type = TYPE_INT; 401 402 break; 402 case 'o': case 'u': case 'x': case 'X': 403 case 'o': 404 case 'u': 405 case 'x': 406 case 'X': 403 407 #ifdef HAVE_LONG_LONG 404 408 if (flags >= 16 || (flags & 4)) … … 415 419 type = TYPE_UINT; 416 420 break; 417 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': 418 case 'a': case 'A': 421 case 'f': 422 case 'F': 423 case 'e': 424 case 'E': 425 case 'g': 426 case 'G': 427 case 'a': 428 case 'A': 419 429 #ifdef HAVE_LONG_DOUBLE 420 430 if (flags >= 16 || (flags & 4)) … … 422 432 else 423 433 #endif 424 type = TYPE_DOUBLE;434 type = TYPE_DOUBLE; 425 435 break; 426 436 case 'c': sweep/branches/display-cache/intl/printf-parse.h
r183 r471 37 37 typedef struct 38 38 { 39 const char *dir_start;40 const char *dir_end;39 const char *dir_start; 40 const char *dir_end; 41 41 int flags; 42 const char *width_start;43 const char *width_end;42 const char *width_start; 43 const char *width_end; 44 44 size_t width_arg_index; 45 const char *precision_start;46 const char *precision_end;45 const char *precision_start; 46 const char *precision_end; 47 47 size_t precision_arg_index; 48 char conversion; /* d i o u x X f e E g G c s p n U % but not C S */48 char conversion; /* d i o u x X f e E g G c s p n U % but not C S */ 49 49 size_t arg_index; 50 50 } … … 71 71 extern 72 72 #endif 73 int printf_parse (const char *format, char_directives * d, arguments *a);73 int printf_parse (const char *format, char_directives * d, arguments * a); 74 74 75 75 #endif /* _PRINTF_PARSE_H */ sweep/branches/display-cache/intl/printf.c
r409 r471 34 34 # else 35 35 # ifdef _AIX 36 #pragma alloca36 #pragma alloca 37 37 # else 38 38 # ifndef alloca … … 71 71 #define vasnprintf libintl_vasnprintf 72 72 #include "vasnprintf.c" 73 #if 0 /* not needed */73 #if 0 /* not needed */ 74 74 #define asnprintf libintl_asnprintf 75 75 #include "asnprintf.c" 76 76 #endif 77 77 78 DLL_EXPORTED 79 int 80 libintl_vfprintf (FILE *stream, const char *format, va_list args) 78 DLL_EXPORTED int 79 libintl_vfprintf (FILE * stream, const char *format, va_list args) 81 80 { 82 81 if (strchr (format, '$') == NULL) … … 97 96 } 98 97 99 DLL_EXPORTED 100 int 101 libintl_fprintf (FILE *stream, const char *format, ...) 98 DLL_EXPORTED int 99 libintl_fprintf (FILE * stream, const char *format, ...) 102 100 { 103 101 va_list args; … … 110 108 } 111 109 112 DLL_EXPORTED 113 int 110 DLL_EXPORTED int 114 111 libintl_vprintf (const char *format, va_list args) 115 112 { … … 117 114 } 118 115 119 DLL_EXPORTED 120 int 116 DLL_EXPORTED int 121 117 libintl_printf (const char *format, ...) 122 118 { … … 140 136 # endif 141 137 142 DLL_EXPORTED 143 int 144 libintl_vsnprintf (char *resultbuf, size_t length, const char *format,va_list args)138 DLL_EXPORTED int 139 libintl_vsnprintf (char *resultbuf, size_t length, const char *format, 140 va_list args) 145 141 { 146 142 if (strchr (format, '$') == NULL) … … 167 163 } 168 164 169 DLL_EXPORTED 170 int 165 DLL_EXPORTED int 171 166 libintl_snprintf (char *resultbuf, size_t length, const char *format, ...) 172 167 { … … 184 179 #if HAVE_ASPRINTF 185 180 186 DLL_EXPORTED 187 int 181 DLL_EXPORTED int 188 182 libintl_vasprintf (char **resultp, const char *format, va_list args) 189 183 { … … 196 190 } 197 191 198 DLL_EXPORTED 199 int 192 DLL_EXPORTED int 200 193 libintl_asprintf (char **resultp, const char *format, ...) 201 194 { … … 223 216 #define vasnwprintf libintl_vasnwprintf 224 217 #include "vasnprintf.c" 225 #if 0 /* not needed */218 #if 0 /* not needed */ 226 219 #define asnwprintf libintl_asnwprintf 227 220 #include "asnprintf.c" … … 236 229 # endif 237 230 238 DLL_EXPORTED 239 int 240 libintl_vfwprintf (FILE *stream, const wchar_t *format, va_list args) 231 DLL_EXPORTED int 232 libintl_vfwprintf (FILE * stream, const wchar_t * format, va_list args) 241 233 { 242 234 if (wcschr (format, '$') == NULL) … … 261 253 } 262 254 263 DLL_EXPORTED 264 int 265 libintl_fwprintf (FILE *stream, const wchar_t *format, ...) 255 DLL_EXPORTED int 256 libintl_fwprintf (FILE * stream, const wchar_t * format, ...) 266 257 { 267 258 va_list args; … … 274 265 } 275 266 276 DLL_EXPORTED 277 int 278 libintl_vwprintf (const wchar_t *format, va_list args) 267 DLL_EXPORTED int 268 libintl_vwprintf (const wchar_t * format, va_list args) 279 269 { 280 270 return libintl_vfwprintf (stdout, format, args); 281 271 } 282 272 283 DLL_EXPORTED 284 int 285 libintl_wprintf (const wchar_t *format, ...) 273 DLL_EXPORTED int 274 libintl_wprintf (const wchar_t * format, ...) 286 275 { 287 276 va_list args; … … 294 283 } 295 284 296 DLL_EXPORTED 297 int 298 libintl_vswprintf (wchar_t *resultbuf, size_t length, const wchar_t *format,va_list args)285 DLL_EXPORTED int 286 libintl_vswprintf (wchar_t * resultbuf, size_t length, const wchar_t * format, 287 va_list args) 299 288 { 300 289 if (wcschr (format, '$') == NULL) … … 303 292 { 304 293 size_t maxlength = length; 305 wchar_t *result = libintl_vasnwprintf (resultbuf, &length, format, args); 294 wchar_t *result = 295 libintl_vasnwprintf (resultbuf, &length, format, args); 306 296 if (result != resultbuf) 307 297 { … … 321 311 } 322 312 323 DLL_EXPORTED 324 int 325 libintl_swprintf (wchar_t *resultbuf, size_t length, const wchar_t *format,...)313 DLL_EXPORTED int 314 libintl_swprintf (wchar_t * resultbuf, size_t length, const wchar_t * format, 315 ...) 326 316 { 327 317 va_list args; sweep/branches/display-cache/intl/relocatable.c
r183 r471 109 109 if (orig_prefix_arg != NULL && curr_prefix_arg != NULL 110 110 /* Optimization: if orig_prefix and curr_prefix are equal, the 111 relocation is a nop. */111 relocation is a nop. */ 112 112 && strcmp (orig_prefix_arg, curr_prefix_arg) != 0) 113 113 { … … 142 142 instead of "/"). */ 143 143 void 144 set_relocation_prefix (const char *orig_prefix_arg, const char *curr_prefix_arg) 144 set_relocation_prefix (const char *orig_prefix_arg, 145 const char *curr_prefix_arg) 145 146 { 146 147 set_this_relocation_prefix (orig_prefix_arg, curr_prefix_arg); … … 170 171 const char * 171 172 compute_curr_prefix (const char *orig_installprefix, 172 const char *orig_installdir, 173 const char *curr_pathname) 173 const char *orig_installdir, const char *curr_pathname) 174 174 { 175 175 const char *curr_installdir; … … 182 182 This is simply the difference between orig_installprefix and 183 183 orig_installdir. */ 184 if (strncmp (orig_installprefix, orig_installdir, strlen (orig_installprefix))185 != 0)184 if (strncmp 185 (orig_installprefix, orig_installdir, strlen (orig_installprefix)) != 0) 186 186 /* Shouldn't happen - nothing should be installed outside $(prefix). */ 187 187 return NULL; … … 190 190 /* Determine the current installation directory. */ 191 191 { 192 const char *p_base = curr_pathname + FILE_SYSTEM_PREFIX_LEN (curr_pathname); 192 const char *p_base = 193 curr_pathname + FILE_SYSTEM_PREFIX_LEN (curr_pathname); 193 194 const char *p = curr_pathname + strlen (curr_pathname); 194 195 char *q; … … 341 342 342 343 ungetc (c, fp); 343 shared_library_fullname = NULL; size = 0; 344 shared_library_fullname = NULL; 345 size = 0; 344 346 len = getline (&shared_library_fullname, &size, fp); 345 347 if (len >= 0) … … 393 395 { 394 396 /* At this point, orig_prefix and curr_prefix likely have already been 395 set through the main program's set_program_name_and_installdir396 function. This is sufficient in the case that the library has397 initially been installed in the same orig_prefix. But we can do398 better, to also cover the cases that 1. it has been installed399 in a different prefix before being moved to orig_prefix and (later)400 to curr_prefix, 2. unlike the program, it has not moved away from401 orig_prefix. */397 set through the main program's set_program_name_and_installdir 398 function. This is sufficient in the case that the library has 399 initially been installed in the same orig_prefix. But we can do 400 better, to also cover the cases that 1. it has been installed 401 in a different prefix before being moved to orig_prefix and (later) 402 to curr_prefix, 2. unlike the program, it has not moved away from 403 orig_prefix. */ 402 404 const char *orig_installprefix = INSTALLPREFIX; 403 405 const char *orig_installdir = INSTALLDIR; sweep/branches/display-cache/intl/relocatable.h
r183 r471 22 22 23 23 #ifdef __cplusplus 24 extern "C" { 24 extern "C" 25 { 25 26 #endif 26 27 … … 43 44 prefixes should be directory names without trailing slash (i.e. use "" 44 45 instead of "/"). */ 45 extern RELOCATABLE_DLL_EXPORTED void 46 set_relocation_prefix (const char *orig_prefix, 47 const char *curr_prefix); 46 extern RELOCATABLE_DLL_EXPORTED void 47 set_relocation_prefix (const char *orig_prefix, const char *curr_prefix); 48 48 49 49 /* Returns the pathname, relocated according to the current installation 50 50 directory. */ 51 extern const char *relocate (const char *pathname);51 extern const char *relocate (const char *pathname); 52 52 53 53 /* Memory management: relocate() leaks memory, because it has to construct … … 59 59 installation prefix, the original installation directory of a particular 60 60 file, and the current pathname of this file. Returns NULL upon failure. */ 61 extern const char *compute_curr_prefix (const char *orig_installprefix,62 const char *orig_installdir,63 const char *curr_pathname);61 extern const char *compute_curr_prefix (const char *orig_installprefix, 62 const char *orig_installdir, 63 const char *curr_pathname); 64 64 65 65 #else … … 75 75 #endif 76 76 77 #endif /* _RELOCATABLE_H */77 #endif /* _RELOCATABLE_H */ sweep/branches/display-cache/intl/textdomain.c
r183 r471 73 73 /* Lock variable to protect the global data in the gettext implementation. */ 74 74 __libc_rwlock_define (extern, _nl_state_lock attribute_hidden) 75 76 75 /* Set the current default message catalog to DOMAINNAME. 77 76 If DOMAINNAME is null, return the current default. 78 77 If DOMAINNAME is "", reset to the default of "messages". */ 79 char * 80 TEXTDOMAIN (const char *domainname) 78 char *TEXTDOMAIN (const char *domainname) 81 79 { 82 80 char *new_domain; … … 105 103 { 106 104 /* If the following malloc fails `_nl_current_default_domain' 107 will be NULL. This value will be returned and so signals we108 are out of core. */105 will be NULL. This value will be returned and so signals we 106 are out of core. */ 109 107 #if defined _LIBC || defined HAVE_STRDUP 110 108 new_domain = strdup (domainname); … … 127 125 ++_nl_msg_cat_cntr; 128 126 129 if (old_domain != new_domain && old_domain != _nl_default_default_domain) 127 if (old_domain != new_domain 128 && old_domain != _nl_default_default_domain) 130 129 free (old_domain); 131 130 } sweep/branches/display-cache/intl/vasnprintf.c
r409 r471 38 38 #endif 39 39 40 #include <stdio.h> /* snprintf() */41 #include <stdlib.h> /* abort(), malloc(), realloc(), free() */42 #include <string.h> /* memcpy(), strlen() */43 #include <errno.h> /* errno */44 #include <limits.h> /* CHAR_BIT, INT_MAX */45 #include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */40 #include <stdio.h> /* snprintf() */ 41 #include <stdlib.h> /* abort(), malloc(), realloc(), free() */ 42 #include <string.h> /* memcpy(), strlen() */ 43 #include <errno.h> /* errno */ 44 #include <limits.h> /* CHAR_BIT, INT_MAX */ 45 #include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */ 46 46 #if WIDE_CHAR_VERSION 47 47 # include "wprintf-parse.h" … … 69 69 # define local_wcslen_defined 1 70 70 static size_t 71 local_wcslen (const wchar_t * s)71 local_wcslen (const wchar_t * s) 72 72 { 73 73 const wchar_t *ptr; … … 113 113 114 114 CHAR_T * 115 VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list args) 115 VASNPRINTF (CHAR_T * resultbuf, size_t * lengthp, const CHAR_T * format, 116 va_list args) 116 117 { 117 118 DIRECTIVES d; … … 210 211 } 211 212 212 for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++)213 for (cp = format, i = 0, dp = &d.dir[0];; cp = dp->dir_end, i++, dp++) 213 214 { 214 215 if (cp != dp->dir_start) … … 259 260 #ifdef HAVE_LONG_LONG 260 261 case TYPE_COUNT_LONGLONGINT_POINTER: 261 *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length; 262 *a.arg[dp->arg_index].a.a_count_longlongint_pointer = 263 length; 262 264 break; 263 265 #endif … … 307 309 case TYPE_ULONGLONGINT: 308 310 *p++ = 'l'; 309 /*FALLTHROUGH*/311 /*FALLTHROUGH*/ 310 312 #endif 311 313 case TYPE_LONGINT: … … 342 344 if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 343 345 abort (); 344 prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int; 346 prefixes[prefix_count++] = 347 a.arg[dp->width_arg_index].a.a_int; 345 348 } 346 349 if (dp->precision_arg_index != ARG_NONE) … … 348 351 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) 349 352 abort (); 350 prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int; 353 prefixes[prefix_count++] = 354 a.arg[dp->precision_arg_index].a.a_int; 351 355 } 352 356 … … 436 440 case TYPE_ULONGINT: 437 441 { 438 unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint; 442 unsigned long int arg = 443 a.arg[dp->arg_index].a.a_ulongint; 439 444 SNPRINTF_BUF (arg); 440 445 } … … 443 448 case TYPE_LONGLONGINT: 444 449 { 445 long long int arg = a.arg[dp->arg_index].a.a_longlongint; 450 long long int arg = 451 a.arg[dp->arg_index].a.a_longlongint; 446 452 SNPRINTF_BUF (arg); 447 453 } … … 449 455 case TYPE_ULONGLONGINT: 450 456 { 451 unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint; 457 unsigned long long int arg = 458 a.arg[dp->arg_index].a.a_ulonglongint; 452 459 SNPRINTF_BUF (arg); 453 460 } … … 463 470 case TYPE_LONGDOUBLE: 464 471 { 465 long double arg = a.arg[dp->arg_index].a.a_longdouble; 472 long double arg = 473 a.arg[dp->arg_index].a.a_longdouble; 466 474 SNPRINTF_BUF (arg); 467 475 } … … 491 499 case TYPE_WIDE_STRING: 492 500 { 493 const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string; 501 const wchar_t *arg = 502 a.arg[dp->arg_index].a.a_wide_string; 494 503 SNPRINTF_BUF (arg); 495 504 } … … 568 577 if (count >= tmp_length) 569 578 /* tmp_length was incorrectly calculated - fix the 570 code above! */579 code above! */ 571 580 abort (); 572 581 #endif sweep/branches/display-cache/intl/vasnprintf.h
r183 r471 29 29 /* This feature is available in gcc versions 2.5 and later. */ 30 30 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ 31 # define __attribute__(Spec) /* empty */31 # define __attribute__(Spec) /* empty */ 32 32 # endif 33 33 /* The __-protected variants of `format' and `printf' attributes … … 40 40 41 41 #ifdef __cplusplus 42 extern "C" { 42 extern "C" 43 { 43 44 #endif 44 45 … … 67 68 } 68 69 */ 69 extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) 70 __attribute__ ((__format__ (__printf__, 3, 4))); 71 extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) 72 __attribute__ ((__format__ (__printf__, 3, 0))); 70 extern char *asnprintf (char *resultbuf, size_t * lengthp, 71 const char *format, ...) 72 __attribute__ ((__format__ (__printf__, 3, 4))); 73 extern char *vasnprintf (char *resultbuf, size_t * lengthp, 74 const char *format, va_list args) 75 __attribute__ ((__format__ (__printf__, 3, 0))); 73 76 74 77 #ifdef __cplusplus … … 76 79 #endif 77 80 78 #endif /* _VASNPRINTF_H */81 #endif /* _VASNPRINTF_H */ sweep/branches/display-cache/intl/vasnwprintf.h
r183 r471 27 27 28 28 #ifdef __cplusplus 29 extern "C" { 29 extern "C" 30 { 30 31 #endif 31 32 … … 37 38 number of resulting bytes, excluding the trailing NUL. Upon error, set 38 39 errno and return NULL. */ 39 extern wchar_t * asnwprintf (wchar_t *resultbuf, size_t *lengthp, const wchar_t *format, ...); 40 extern wchar_t * vasnwprintf (wchar_t *resultbuf, size_t *lengthp, const wchar_t *format, va_list args); 40 extern wchar_t *asnwprintf (wchar_t * resultbuf, size_t * lengthp, 41 const wchar_t * format, ...); 42 extern wchar_t *vasnwprintf (wchar_t * resultbuf, size_t * lengthp, 43 const wchar_t * format, va_list args); 41 44 42 45 #ifdef __cplusplus … … 44 47 #endif 45 48 46 #endif /* _VASNWPRINTF_H */49 #endif /* _VASNWPRINTF_H */ sweep/branches/display-cache/intl/wprintf-parse.h
r183 r471 37 37 typedef struct 38 38 { 39 const wchar_t *dir_start;40 const wchar_t *dir_end;39 const wchar_t *dir_start; 40 const wchar_t *dir_end; 41 41 int flags; 42 const wchar_t *width_start;43 const wchar_t *width_end;42 const wchar_t *width_start; 43 const wchar_t *width_end; 44 44 size_t width_arg_index; 45 const wchar_t *precision_start;46 const wchar_t *precision_end;45 const wchar_t *precision_start; 46 const wchar_t *precision_end; 47 47 size_t precision_arg_index; 48 wchar_t conversion; /* d i o u x X f e E g G c s p n U % but not C S */48 wchar_t conversion; /* d i o u x X f e E g G c s p n U % but not C S */ 49 49 size_t arg_index; 50 50 } … … 71 71 extern 72 72 #endif 73 int wprintf_parse (const wchar_t *format, wchar_t_directives *d, arguments *a); 73 int wprintf_parse (const wchar_t * format, wchar_t_directives * d, 74 arguments * a); 74 75 75 76 #endif /* _WPRINTF_PARSE_H */ sweep/branches/display-cache/intl/xsize.h
r183 r471 53 53 static inline size_t 54 54 #if __GNUC__ >= 3 55 __attribute__ ((__pure__))55 __attribute__ ((__pure__)) 56 56 #endif 57 xsum (size_t size1, size_t size2)57 xsum (size_t size1, size_t size2) 58 58 { 59 59 size_t sum = size1 + size2; … … 64 64 static inline size_t 65 65 #if __GNUC__ >= 3 66 __attribute__ ((__pure__))66 __attribute__ ((__pure__)) 67 67 #endif 68 xsum3 (size_t size1, size_t size2, size_t size3)68 xsum3 (size_t size1, size_t size2, size_t size3) 69 69 { 70 70 return xsum (xsum (size1, size2), size3); … … 74 74 static inline size_t 75 75 #if __GNUC__ >= 3 76 __attribute__ ((__pure__))76 __attribute__ ((__pure__)) 77 77 #endif 78 xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)78 xsum4 (size_t size1, size_t size2, size_t size3, size_t size4) 79 79 { 80 80 return xsum (xsum (xsum (size1, size2), size3), size4); … … 84 84 static inline size_t 85 85 #if __GNUC__ >= 3 86 __attribute__ ((__pure__))86 __attribute__ ((__pure__)) 87 87 #endif 88 xmax (size_t size1, size_t size2)88 xmax (size_t size1, size_t size2) 89 89 { 90 90 /* No explicit check is needed here, because for any n: sweep/branches/display-cache/plugins/byenergy/byenergy.c
r124 r471 30 30 31 31 static sw_param_range resolution_range = { 32 SW_RANGE_LOWER_BOUND_VALID |SW_RANGE_STEP_VALID,33 lower: {f:0.001},34 step: {f:0.001}32 SW_RANGE_LOWER_BOUND_VALID | SW_RANGE_STEP_VALID, 33 lower: {f:0.001}, 34 step: {f:0.001} 35 35 }; 36 36 37 37 static sw_param_range threshold_range = { 38 38 SW_RANGE_ALL_VALID, 39 lower: {f:0.0},40 upper: {f:1.0},41 step: {f:0.01}39 lower: {f:0.0}, 40 upper: {f:1.0}, 41 step: {f:0.01} 42 42 }; 43 43 44 44 static sw_param_range min_duration_range = { 45 SW_RANGE_LOWER_BOUND_VALID |SW_RANGE_STEP_VALID,46 lower: {f:0.0},47 step: {f:0.01}45 SW_RANGE_LOWER_BOUND_VALID | SW_RANGE_STEP_VALID, 46 lower: {f:0.0}, 47 step: {f:0.01} 48 48 }; 49 49 50 50 static sw_param_range max_interruption_range = { 51 SW_RANGE_LOWER_BOUND_VALID |SW_RANGE_STEP_VALID,52 lower: {f:0.0},53 step: {f:0.01}51 SW_RANGE_LOWER_BOUND_VALID | SW_RANGE_STEP_VALID, 52 lower: {f:0.0}, 53 step: {f:0.01} 54 54 }; 55 55 56 56 static sw_param_spec param_specs[] = { 57 57 { 58 N_("Select regions above threshold"),59 N_("Whether to select those regions lying above a given threshold "60 "or below it."),61 SWEEP_TYPE_BOOL,62 SW_PARAM_CONSTRAINED_NOT,63 {NULL},64 },65 { 66 N_("Resolution"),67 N_("Width of energy detection window (s)"),68 SWEEP_TYPE_FLOAT,69 SW_PARAM_CONSTRAINED_RANGE,70 {range:&resolution_range}71 },72 { 73 N_("Threshold"),74 N_("Energy level to detect [0.0 - 1.0]"),75 SWEEP_TYPE_FLOAT,76 SW_PARAM_CONSTRAINED_RANGE,77 {range:&threshold_range},78 },79 { 80 N_("Minimum duration"),81 N_("Shortest region of selection to detect (s)"),82 SWEEP_TYPE_FLOAT,83 SW_PARAM_CONSTRAINED_RANGE,84 {range:&min_duration_range}85 },86 { 87 N_("Maximum interruption"),88 N_("Longest length of sound above threshold to allow (s)"),89 SWEEP_TYPE_FLOAT,90 SW_PARAM_CONSTRAINED_RANGE,91 {range:&max_interruption_range}92 }58 N_("Select regions above threshold"), 59 N_("Whether to select those regions lying above a given threshold " 60 "or below it."), 61 SWEEP_TYPE_BOOL, 62 SW_PARAM_CONSTRAINED_NOT, 63 {NULL}, 64 }, 65 { 66 N_("Resolution"), 67 N_("Width of energy detection window (s)"), 68 SWEEP_TYPE_FLOAT, 69 SW_PARAM_CONSTRAINED_RANGE, 70 {range:&resolution_range} 71 }, 72 { 73 N_("Threshold"), 74 N_("Energy level to detect [0.0 - 1.0]"), 75 SWEEP_TYPE_FLOAT, 76 SW_PARAM_CONSTRAINED_RANGE, 77 {range:&threshold_range}, 78 }, 79 { 80 N_("Minimum duration"), 81 N_("Shortest region of selection to detect (s)"), 82 SWEEP_TYPE_FLOAT, 83 SW_PARAM_CONSTRAINED_RANGE, 84 {range:&min_duration_range} 85 }, 86 { 87 N_("Maximum interruption"), 88 N_("Longest length of sound above threshold to allow (s)"), 89 SWEEP_TYPE_FLOAT, 90 SW_PARAM_CONSTRAINED_RANGE, 91 {range:&max_interruption_range} 92 } 93 93 }; 94 94 95 95 static void 96 by_energy_suggest (sw_sample * sample, sw_param_set pset, gpointer custom_data) 96 by_energy_suggest (sw_sample * sample, sw_param_set pset, 97 gpointer custom_data) 97 98 { 98 99 pset[0].b = FALSE; … … 112 113 gfloat max_interruption_f = pset[4].f; 113 114 114 sw_sounddata * sounddata;115 sw_audio_t * d;115 sw_sounddata *sounddata; 116 sw_audio_t *d; 116 117 glong window, win_s; 117 118 gint i, doff; 118 119 glong min_duration, max_interruption; 119 glong length, loc =0;120 glong start =-1, end=-1;121 sw_audio_intermediate_t di, energy, max_energy =0, factor=1.0;120 glong length, loc = 0; 121 glong start = -1, end = -1; 122 sw_audio_intermediate_t di, energy, max_energy = 0, factor = 1.0; 122 123 123 124 sounddata = sample_get_sounddata (s); 124 125 125 window = (glong) (resolution * (gfloat)sounddata->format->rate);126 window = (glong) (resolution * (gfloat) sounddata->format->rate); 126 127 length = sounddata->nr_frames; 127 min_duration = (glong) (min_duration_f * (gfloat)sounddata->format->rate);128 min_duration = (glong) (min_duration_f * (gfloat) sounddata->format->rate); 128 129 129 130 /* check (end-1 - (start+1)) > 0 */ 130 min_duration = MAX(2*window, min_duration); 131 max_interruption = (glong)(max_interruption_f * (gfloat)sounddata->format->rate); 132 133 d = (sw_audio_t *)sounddata->data; 131 min_duration = MAX (2 * window, min_duration); 132 max_interruption = 133 (glong) (max_interruption_f * (gfloat) sounddata->format->rate); 134 135 d = (sw_audio_t *) sounddata->data; 134 136 135 137 sounddata_lock_selection (sounddata); … … 141 143 length = sounddata->nr_frames; 142 144 doff = 0; 143 while (length > 0) { 144 energy = 0; 145 146 win_s = frames_to_samples (sounddata->format, MIN(length, window)); 147 148 /* calculate avg. for this window */ 149 for (i=0; i<win_s; i++) { 150 di = (sw_audio_intermediate_t)(d[doff+i] * factor); 151 energy += fabs(di); 145 while (length > 0) 146 { 147 energy = 0; 148 149 win_s = frames_to_samples (sounddata->format, MIN (length, window)); 150 151 /* calculate avg. for this window */ 152 for (i = 0; i < win_s; i++) 153 { 154 di = (sw_audio_intermediate_t) (d[doff + i] * factor); 155 energy += fabs (di); 156 } 157 doff += win_s; 158 159 energy /= (sw_audio_intermediate_t) win_s; 160 energy = sqrt (energy); 161 162 max_energy = MAX (energy, max_energy); 163 164 length -= window; 152 165 } 153 doff += win_s;154 155 energy /= (sw_audio_intermediate_t)win_s;156 energy = sqrt(energy);157 158 max_energy = MAX(energy, max_energy);159 160 length -= window;161 }162 166 163 167 factor = SW_AUDIO_T_MAX / max_energy; … … 167 171 #endif 168 172 169 threshold *= (gfloat) max_energy;173 threshold *= (gfloat) max_energy; 170 174 171 175 length = sounddata->nr_frames; 172 176 doff = 0; 173 while (length > 0) { 174 energy = 0; 175 176 win_s = frames_to_samples (sounddata->format, MIN(length, window)); 177 178 /* calculate RMS energy for this window */ 179 for (i=0; i<win_s; i++) { 180 di = (sw_audio_intermediate_t)(d[doff+i]); 181 energy += fabs(di); 177 while (length > 0) 178 { 179 energy = 0; 180 181 win_s = frames_to_samples (sounddata->format, MIN (length, window)); 182 183 /* calculate RMS energy for this window */ 184 for (i = 0; i < win_s; i++) 185 { 186 di = (sw_audio_intermediate_t) (d[doff + i]); 187 energy += fabs (di); 188 } 189 doff += win_s; 190 191 energy /= (sw_audio_intermediate_t) win_s; 192 energy = sqrt (energy); 193 194 #ifdef DEBUG 195 g_print ("%ld\tenergy: %f\tthreshold: %f\n", loc, energy, threshold); 196 #endif 197 198 /* Check if threshold condition is met */ 199 if (select_above ? (energy >= threshold) : (energy <= threshold)) 200 { 201 if (start == -1) 202 { 203 /* Not in possible selection; initialise start,end */ 204 end = start = loc; 205 } 206 else 207 { 208 end = loc; 209 } 210 } 211 else if (end != -1) 212 { 213 if (loc - end > max_interruption) 214 { 215 if (end - start > min_duration) 216 { 217 sounddata_add_selection_1 (sounddata, start + 1, end - 1); 218 } 219 end = start = -1; 220 } 221 /* else do nothing: keep start, end where they are */ 222 } 223 224 loc += window; 225 length -= window; 182 226 } 183 doff += win_s; 184 185 energy /= (sw_audio_intermediate_t)win_s; 186 energy = sqrt(energy); 187 188 #ifdef DEBUG 189 g_print ("%ld\tenergy: %f\tthreshold: %f\n", loc, energy, threshold); 190 #endif 191 192 /* Check if threshold condition is met */ 193 if (select_above ? (energy >= threshold) : (energy <= threshold)) { 194 if (start == -1) { 195 /* Not in possible selection; initialise start,end */ 196 end = start = loc; 197 } else { 198 end = loc; 199 } 200 } else if (end != -1) { 201 if (loc - end > max_interruption) { 202 if (end - start > min_duration) { 203 sounddata_add_selection_1 (sounddata, start+1, end-1); 204 } 205 end = start = -1; 206 } 207 /* else do nothing: keep start, end where they are */ 227 228 if (start != -1) 229 { 230 if (end - start > min_duration) 231 { 232 sounddata_add_selection_1 (sounddata, start, end); 233 } 208 234 } 209 235 210 loc += window;211 length -= window;212 }213 214 if (start != -1) {215 if (end - start > min_duration) {216 sounddata_add_selection_1 (sounddata, start, end);217 }218 }219 220 236 sounddata_unlock_selection (sounddata); 221 237 } 222 238 223 239 static sw_op_instance * 224 apply_by_energy (sw_sample * sample, sw_param_set pset, gpointer custom_data)240 apply_by_energy (sw_sample * sample, sw_param_set pset, gpointer custom_data) 225 241 { 226 242 return 227 243 perform_selection_op (sample, _("Select by energy"), 228 (SweepFilter) select_by_energy, pset, NULL);244 (SweepFilter) select_by_energy, pset, NULL); 229 245 } 230 246 … … 235 251 "Copyright (C) 2000 CSIRO Australia", 236 252 "http://sweep.sourceforge.net/plugins/byenergy", 237 "Filters/Select by energy", /* identifier */238 0, /* accel_key */239 0, /* accel_mods */240 NR_PARAMS, /* nr_params */241 param_specs, /* param_specs */242 by_energy_suggest, /* suggests() */253 "Filters/Select by energy", /* identifier */ 254 0, /* accel_key */ 255 0, /* accel_mods */ 256 NR_PARAMS, /* nr_params */ 257 param_specs, /* param_specs */ 258 by_energy_suggest, /* suggests() */ 243 259 apply_by_energy, 244 NULL, /* custom data */260 NULL, /* custom data */ 245 261 }; 246 262 … … 248 264 by_energy_init (void) 249 265 { 250 return g_list_append ((GList *) NULL, &proc_by_energy);266 return g_list_append ((GList *) NULL, &proc_by_energy); 251 267 } 252 268 253 269 254 270 sw_plugin plugin = { 255 by_energy_init, /* plugin_init */256 NULL, /* plugin_cleanup */257 }; 271 by_energy_init, /* plugin_init */ 272 NULL, /* plugin_cleanup */ 273 }; sweep/branches/display-cache/plugins/echo/echo.c
r80 r471 36 36 37 37 static sw_param_range delay_range = { 38 SW_RANGE_LOWER_BOUND_VALID |SW_RANGE_STEP_VALID,39 lower: {f:0.0},40 step: {f:0.001}38 SW_RANGE_LOWER_BOUND_VALID | SW_RANGE_STEP_VALID, 39 lower: {f:0.0}, 40 step: {f:0.001} 41 41 }; 42 42 43 43 static sw_param_range gain_range = { 44 44 SW_RANGE_ALL_VALID, 45 lower: {f:0.0},46 upper: {f:1.0},47 step: {f:0.01}45 lower: {f:0.0}, 46 upper: {f:1.0}, 47 step: {f:0.01} 48 48 }; 49 49 … … 51 51 static sw_param_spec param_specs[] = { 52 52 { 53 N_("Delay"), 54 N_("Time to delay by"), 55 SWEEP_TYPE_FLOAT, 56 SW_PARAM_CONSTRAINED_RANGE, 57 {range: &delay_range}, 58 SW_PARAM_HINT_TIME 59 }, 53 N_("Delay"), 54 N_("Time to delay by"), 55 SWEEP_TYPE_FLOAT, 56 SW_PARAM_CONSTRAINED_RANGE, 57 {range:&delay_range}, 58 SW_PARAM_HINT_TIME}, 60 59 { 61 N_("Gain"), 62 N_("Gain with which to mix in delayed signal"), 63 SWEEP_TYPE_FLOAT, 64 SW_PARAM_CONSTRAINED_RANGE, 65 {range: &gain_range}, 66 SW_PARAM_HINT_DEFAULT 67 }, 60 N_("Gain"), 61 N_("Gain with which to mix in delayed signal"), 62 SWEEP_TYPE_FLOAT, 63 SW_PARAM_CONSTRAINED_RANGE, 64 {range:&gain_range}, 65 SW_PARAM_HINT_DEFAULT}, 68 66 }; 69 67 … … 83 81 84 82 sw_framecount_t i, delay_f, dlen_s; 85 sw_audio_t * d, *e;83 sw_audio_t *d, *e; 86 84 gpointer ep; 87 85 88 86 delay_f = time_to_frames (format, delay); 89 87 90 d = (sw_audio_t *) data;88 d = (sw_audio_t *) data; 91 89 ep = data + frames_to_bytes (format, delay_f); 92 e = (sw_audio_t *) ep;90 e = (sw_audio_t *) ep; 93 91 94 if (delay > nr_frames) return; 92 if (delay > nr_frames) 93 return; 95 94 96 95 dlen_s = frames_to_samples (format, nr_frames - delay_f); 97 96 98 for (i = 0; i < dlen_s; i++) { 99 e[i] += (sw_audio_t)((gfloat)(d[i]) * gain); 100 } 97 for (i = 0; i < dlen_s; i++) 98 { 99 e[i] += (sw_audio_t) ((gfloat) (d[i]) * gain); 100 } 101 101 } 102 102 … … 106 106 return 107 107 perform_filter_region_op (sample, _("Echo"), 108 (SweepFilterRegion) region_echo, pset, NULL);108 (SweepFilterRegion) region_echo, pset, NULL); 109 109 } 110 110 … … 116 116 "Copyright (C) 2000", 117 117 "http://sweep.sourceforge.net/plugins/echo", 118 "Filters/Echo", /* identifier */119 GDK_e, /* accel_key */120 GDK_SHIFT_MASK, /* accel_mods */121 NR_PARAMS, /* nr_params */122 param_specs, /* param_specs */123 echo_suggest, /* suggests() */118 "Filters/Echo", /* identifier */ 119 GDK_e, /* accel_key */ 120 GDK_SHIFT_MASK, /* accel_mods */ 121 NR_PARAMS, /* nr_params */ 122 param_specs, /* param_specs */ 123 echo_suggest, /* suggests() */ 124 124 echo_apply, 125 NULL, /* custom_data */125 NULL, /* custom_data */ 126 126 }; 127 127 … … 129 129 echo_init (void) 130 130 { 131 return g_list_append ((GList *) NULL, &proc_echo);131 return g_list_append ((GList *) NULL, &proc_echo); 132 132 } 133 133 134 134 135 135 sw_plugin plugin = { 136 echo_init, /* plugin_init */137 NULL, /* plugin_cleanup */136 echo_init, /* plugin_init */ 137 NULL, /* plugin_cleanup */ 138 138 }; sweep/branches/display-cache/plugins/example/example.c
r75 r471 34 34 35 35 static sw_param stix_list[] = { 36 {i:4},37 {s:N_("With a fork")},38 {s:N_("With a spoon")},39 {s:N_("With false teeth")},40 {s:N_("With Nigel's bum")}36 {i:4}, 37 {s:N_("With a fork")}, 38 {s:N_("With a spoon")}, 39 {s:N_("With false teeth")}, 40 {s:N_("With Nigel's bum")} 41 41 }; 42 42 43 43 static sw_param pants_list[] = { 44 {i:7},45 {i:0},46 {i:1},47 {i:2},48 {i:7},49 {i:42},50 {i:44100},51 {i:1000000}44 {i:7}, 45 {i:0}, 46 {i:1}, 47 {i:2}, 48 {i:7}, 49 {i:42}, 50 {i:44100}, 51 {i:1000000} 52 52 }; 53 53 54 54 static sw_param_spec example_filter_region_param_specs[] = { 55 55 { 56 N_("Flim"), 57 N_("Should you manage your flim?"), 58 SWEEP_TYPE_BOOL, 59 SW_PARAM_CONSTRAINED_NOT, 60 {NULL}, 61 SW_PARAM_HINT_DEFAULT 62 }, 56 N_("Flim"), 57 N_("Should you manage your flim?"), 58 SWEEP_TYPE_BOOL, 59 SW_PARAM_CONSTRAINED_NOT, 60 {NULL}, 61 SW_PARAM_HINT_DEFAULT}, 63 62 { 64 N_("Beans"), 65 N_("Method of eating beans"), 66 SWEEP_TYPE_STRING, 67 SW_PARAM_CONSTRAINED_LIST, 68 {list: (sw_param *)&stix_list}, 69 SW_PARAM_HINT_DEFAULT 70 }, 63 N_("Beans"), 64 N_("Method of eating beans"), 65 SWEEP_TYPE_STRING, 66 SW_PARAM_CONSTRAINED_LIST, 67 {list:(sw_param *) & stix_list}, 68 SW_PARAM_HINT_DEFAULT}, 71 69 { 72 N_("Pants methodology"), 73 N_("How many pants should you wear per day?"), 74 SWEEP_TYPE_INT, 75 SW_PARAM_CONSTRAINED_LIST, 76 {list: (sw_param *)&pants_list}, 77 SW_PARAM_HINT_DEFAULT 78 } 70 N_("Pants methodology"), 71 N_("How many pants should you wear per day?"), 72 SWEEP_TYPE_INT, 73 SW_PARAM_CONSTRAINED_LIST, 74 {list:(sw_param *) & pants_list}, 75 SW_PARAM_HINT_DEFAULT} 79 76 }; 80 77 … … 93 90 { 94 91 gboolean flim = pset[0].b; 95 gchar * beans = pset[1].s;92 gchar *beans = pset[1].s; 96 93 gint nr_pants = pset[2].i; 97 94 98 if (flim) { 99 /* manage flim */ 100 } 95 if (flim) 96 { 97 /* manage flim */ 98 } 101 99 102 if (!strcmp(beans, "With a spoon")) { 103 /* eat beans with a spoon */ 104 } else { 105 /* spill beans everywhere */ 106 } 100 if (!strcmp (beans, "With a spoon")) 101 { 102 /* eat beans with a spoon */ 103 } 104 else 105 { 106 /* spill beans everywhere */ 107 } 107 108 108 if (nr_pants > 1000) { 109 /* We're wearing too many pants! */ 110 return; 111 } 109 if (nr_pants > 1000) 110 { 111 /* We're wearing too many pants! */ 112 return; 113 } 112 114 113 115 /* Do filtering stuff */ … … 121 123 return 122 124 perform_filter_region_op (sample, _("Example Filter Region"), 123 (SweepFilterRegion) example_filter_region_func,125 (SweepFilterRegion) example_filter_region_func, 124 126 pset, NULL); 125 127 } … … 132 134 "Copyright (C) 2000", 133 135 "http://sweep.sourceforge.net/plugins/example", 134 "Example", /* identifier */135 0, /* accel_key */136 0, /* accel_mods */137 3, /* nr_params */138 example_filter_region_param_specs, /* param_specs */139 example_filter_region_suggest, /* suggests() */136 "Example", /* identifier */ 137 0, /* accel_key */ 138 0, /* accel_mods */ 139 3, /* nr_params */ 140 example_filter_region_param_specs, /* param_specs */ 141 example_filter_region_suggest, /* suggests() */ 140 142 example_filter_region_apply, 141 NULL, /* custom_data */143 NULL, /* custom_data */ 142 144 }; 143 145 … … 145 147 example_init (void) 146 148 { 147 return g_list_append ((GList *) NULL, &proc_example_filter_region);149 return g_list_append ((GList *) NULL, &proc_example_filter_region); 148 150 } 149 151 150 152 151 153 sw_plugin plugin = { 152 example_init, /* plugin_init */153 NULL, /* plugin_cleanup */154 example_init, /* plugin_init */ 155 NULL, /* plugin_cleanup */ 154 156 }; sweep/branches/display-cache/plugins/fade/fade.c
r124 r471 26 26 #include <sweep/sweep.h> 27 27 28 #include <../src/sweep_app.h> /* XXX */28 #include <../src/sweep_app.h> /* XXX */ 29 29 30 30 static sw_sample * 31 31 fade (sw_sample * sample, gfloat start, gfloat end) 32 32 { 33 sw_sounddata * sounddata;34 sw_format * f;35 GList * gl;36 sw_sel * sel;37 sw_audio_t * d;33 sw_sounddata *sounddata; 34 sw_format *f; 35 GList *gl; 36 sw_sel *sel; 37 sw_audio_t *d; 38 38 gfloat factor = start; 39 39 sw_framecount_t op_total, run_total; … … 47 47 48 48 op_total = sounddata_selection_nr_frames (sounddata) / 100; 49 if (op_total == 0) op_total = 1; 49 if (op_total == 0) 50 op_total = 1; 50 51 run_total = 0; 51 52 52 53 #if 0 53 54 /* Find max */ 54 for (gl = sounddata->sels; active && gl; gl = gl->next) { 55 sel = (sw_sel *)gl->data; 56 57 offset = 0; 58 remaining = sel->sel_end - sel->sel_start; 59 60 while (active && remaining > 0) { 61 g_mutex_lock (sample->ops_mutex); 62 63 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 64 active = FALSE; 65 } else { 66 67 d = sounddata->data + frames_to_bytes (f, sel->sel_start + offset); 68 69 n = MIN(remaining, 1024); 70 71 for (i=0; i < n * f->channels; i++) { 72 if(d[i]>=0) max = MAX(max, d[i]); 73 else max = MAX(max, -d[i]); 55 for (gl = sounddata->sels; active && gl; gl = gl->next) 56 { 57 sel = (sw_sel *) gl->data; 58 59 offset = 0; 60 remaining = sel->sel_end - sel->sel_start; 61 62 while (active && remaining > 0) 63 { 64 g_mutex_lock (sample->ops_mutex); 65 66 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 67 { 68 active = FALSE; 69 } 70 else 71 { 72 73 d = 74 sounddata->data + frames_to_bytes (f, 75 sel->sel_start + offset); 76 77 n = MIN (remaining, 1024); 78 79 for (i = 0; i < n * f->channels; i++) 80 { 81 if (d[i] >= 0) 82 max = MAX (max, d[i]); 83 else 84 max = MAX (max, -d[i]); 85 } 86 87 remaining -= n; 88 offset += n; 89 90 run_total += n; 91 sample_set_progress_percent (sample, run_total / op_total); 92 } 93 94 g_mutex_unlock (sample->ops_mutex); 74 95 } 75 76 remaining -= n;77 offset += n;78 79 run_total += n;80 sample_set_progress_percent (sample, run_total / op_total);81 }82 83 g_mutex_unlock (sample->ops_mutex);84 96 } 85 } 86 87 if (max != 0) factor = SW_AUDIO_T_MAX / (gfloat)max;97 98 if (max != 0) 99 factor = SW_AUDIO_T_MAX / (gfloat) max; 88 100 #endif 89 101 90 102 /* Fade */ 91 for (gl = sounddata->sels; active && gl; gl = gl->next) { 92 sel = (sw_sel *)gl->data; 93 94 offset = 0; 95 remaining = sel->sel_end - sel->sel_start; 96 97 while (active && remaining > 0) { 98 g_mutex_lock (sample->ops_mutex); 99 100 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 101 active = FALSE; 102 } else { 103 d = sounddata->data + frames_to_bytes (f, sel->sel_start + offset); 104 105 n = MIN(remaining, 1024); 106 107 factor = start + (end - start) * 0.01 * 108 (gfloat)run_total / (gfloat)op_total; 109 110 for (i=0; i < n * f->channels; i++) { 111 d[i] = (sw_audio_t)((gfloat)d[i] * factor); 103 for (gl = sounddata->sels; active && gl; gl = gl->next) 104 { 105 sel = (sw_sel *) gl->data; 106 107 offset = 0; 108 remaining = sel->sel_end - sel->sel_start; 109 110 while (active && remaining > 0) 111 { 112 g_mutex_lock (sample->ops_mutex); 113 114 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 115 { 116 active = FALSE; 117 } 118 else 119 { 120 d = 121 sounddata->data + frames_to_bytes (f, 122 sel->sel_start + offset); 123 124 n = MIN (remaining, 1024); 125 126 factor = start + (end - start) * 0.01 * 127 (gfloat) run_total / (gfloat) op_total; 128 129 for (i = 0; i < n * f->channels; i++) 130 { 131 d[i] = (sw_audio_t) ((gfloat) d[i] * factor); 132 } 133 134 remaining -= n; 135 offset += n; 136 137 run_total += n; 138 sample_set_progress_percent (sample, 139 run_total * 100 / op_total); 140 } 141 142 g_mutex_unlock (sample->ops_mutex); 112 143 } 113 114 remaining -= n;115 offset += n;116 117 run_total += n;118 sample_set_progress_percent (sample, run_total * 100 / op_total);119 }120 121 g_mutex_unlock (sample->ops_mutex);122 144 } 123 }124 145 125 146 return sample; … … 142 163 { 143 164 return 144 perform_filter_op (sample, _("Fade in"), (SweepFilter) fade_in,165 perform_filter_op (sample, _("Fade in"), (SweepFilter) fade_in, 145 166 pset, NULL); 146 167 } … … 150 171 { 151 172 return 152 perform_filter_op (sample, _("Fade out"), (SweepFilter) fade_out,173 perform_filter_op (sample, _("Fade out"), (SweepFilter) fade_out, 153 174 pset, NULL); 154 175 } … … 160 181 "Copyright (C) 2002", 161 182 "http://sweep.sourceforge.net/plugins/fade", 162 "Filters/Fade_In", /* identifier */163 0, /* accel_key */164 0, /* accel_mods */165 0, /* nr_params */166 NULL, /* param_specs */167 NULL, /* suggests() */183 "Filters/Fade_In", /* identifier */ 184 0, /* accel_key */ 185 0, /* accel_mods */ 186 0, /* nr_params */ 187 NULL, /* param_specs */ 188 NULL, /* suggests() */ 168 189 apply_fade_in, 169 NULL, /* custom_data */190 NULL, /* custom_data */ 170 191 }; 171 192 … … 176 197 "Copyright (C) 2002", 177 198 "http://sweep.sourceforge.net/plugins/fade", 178 "Filters/Fade_In", /* identifier */179 0, /* accel_key */180 0, /* accel_mods */181 0, /* nr_params */182 NULL, /* param_specs */183 NULL, /* suggests() */199 "Filters/Fade_In", /* identifier */ 200 0, /* accel_key */ 201 0, /* accel_mods */ 202 0, /* nr_params */ 203 NULL, /* param_specs */ 204 NULL, /* suggests() */ 184 205 apply_fade_out, 185 NULL, /* custom_data */206 NULL, /* custom_data */ 186 207 }; 187 208 188 209 static GList * 189 210 fade_init (void) 190 211 { 191 GList * gl = NULL;212 GList *gl = NULL; 192 213 193 214 gl = g_list_append (gl, &proc_fade_in); … … 199 220 200 221 sw_plugin plugin = { 201 fade_init, /* plugin_init */202 NULL, /* plugin_cleanup */222 fade_init, /* plugin_init */ 223 NULL, /* plugin_cleanup */ 203 224 }; sweep/branches/display-cache/plugins/ladspa/ladspa.h
r124 r471 24 24 25 25 #ifdef __cplusplus 26 extern "C" { 26 extern "C" 27 { 27 28 #endif 28 29 … … 78 79 amplitude and is a `normal' signal level. */ 79 80 80 typedef float LADSPA_Data;81 typedef float LADSPA_Data; 81 82 82 83 /*****************************************************************************/ … … 88 89 properties together. */ 89 90 90 typedef int LADSPA_Properties;91 typedef int LADSPA_Properties; 91 92 92 93 /* Property LADSPA_PROPERTY_REALTIME indicates that the plugin has a … … 146 147 and that a port must be a control or audio port but not both. */ 147 148 148 typedef int LADSPA_PortDescriptor;149 typedef int LADSPA_PortDescriptor; 149 150 150 151 /* Property LADSPA_PORT_INPUT indicates that the port is an input. */ … … 194 195 LADSPA_PortRangeHint structure. */ 195 196 196 typedef int LADSPA_PortRangeHintDescriptor;197 typedef int LADSPA_PortRangeHintDescriptor; 197 198 198 199 /* Hint LADSPA_HINT_BOUNDED_BELOW indicates that the LowerBound field … … 331 332 == LADSPA_HINT_DEFAULT_440) 332 333 333 typedef struct _LADSPA_PortRangeHint { 334 335 /* Hints about the port. */ 336 LADSPA_PortRangeHintDescriptor HintDescriptor; 337 338 /* Meaningful when hint LADSPA_HINT_BOUNDED_BELOW is active. When 339 LADSPA_HINT_SAMPLE_RATE is also active then this value should be 340 multiplied by the relevant sample rate. */ 341 LADSPA_Data LowerBound; 342 343 /* Meaningful when hint LADSPA_HINT_BOUNDED_ABOVE is active. When 344 LADSPA_HINT_SAMPLE_RATE is also active then this value should be 345 multiplied by the relevant sample rate. */ 346 LADSPA_Data UpperBound; 347 348 } LADSPA_PortRangeHint; 334 typedef struct _LADSPA_PortRangeHint 335 { 336 337 /* Hints about the port. */ 338 LADSPA_PortRangeHintDescriptor HintDescriptor; 339 340 /* Meaningful when hint LADSPA_HINT_BOUNDED_BELOW is active. When 341 LADSPA_HINT_SAMPLE_RATE is also active then this value should be 342 multiplied by the relevant sample rate. */ 343 LADSPA_Data LowerBound; 344 345 /* Meaningful when hint LADSPA_HINT_BOUNDED_ABOVE is active. When 346 LADSPA_HINT_SAMPLE_RATE is also active then this value should be 347 multiplied by the relevant sample rate. */ 348 LADSPA_Data UpperBound; 349 350 } LADSPA_PortRangeHint; 349 351 350 352 /*****************************************************************************/ … … 357 359 may use it to reference internal instance data. */ 358 360 359 typedef void *LADSPA_Handle;361 typedef void *LADSPA_Handle; 360 362 361 363 /*****************************************************************************/ … … 367 369 buffers and workspaces and to run it. */ 368 370 369 typedef struct _LADSPA_Descriptor { 370 371 /* This numeric identifier indicates the plugin type 372 uniquely. Plugin programmers may reserve ranges of IDs from a 373 central body to avoid clashes. Hosts may assume that IDs are 374 below 0x1000000. */ 375 unsigned long UniqueID; 376 377 /* This identifier can be used as a unique, case-sensitive 378 identifier for the plugin type within the plugin file. Plugin 379 types should be identified by file and label rather than by index 380 or plugin name, which may be changed in new plugin 381 versions. Labels must not contain white-space characters. */ 382 const char * Label; 383 384 /* This indicates a number of properties of the plugin. */ 385 LADSPA_Properties Properties; 386 387 /* This member points to the null-terminated name of the plugin 388 (e.g. "Sine Oscillator"). */ 389 const char * Name; 390 391 /* This member points to the null-terminated string indicating the 392 maker of the plugin. This can be an empty string but not NULL. */ 393 const char * Maker; 394 395 /* This member points to the null-terminated string indicating any 396 copyright applying to the plugin. If no Copyright applies the 397 string "None" should be used. */ 398 const char * Copyright; 399 400 /* This indicates the number of ports (input AND output) present on 401 the plugin. */ 402 unsigned long PortCount; 403 404 /* This member indicates an array of port descriptors. Valid indices 405 vary from 0 to PortCount-1. */ 406 const LADSPA_PortDescriptor * PortDescriptors; 407 408 /* This member indicates an array of null-terminated strings 409 describing ports (e.g. "Frequency (Hz)"). Valid indices vary from 410 0 to PortCount-1. */ 411 const char * const * PortNames; 412 413 /* This member indicates an array of range hints for each port (see 414 above). Valid indices vary from 0 to PortCount-1. */ 415 const LADSPA_PortRangeHint * PortRangeHints; 416 417 /* This may be used by the plugin developer to pass any custom 418 implementation data into an instantiate call. It must not be used 419 or interpreted by the host. It is expected that most plugin 420 writers will not use this facility as LADSPA_Handle should be 421 used to hold instance data. */ 422 void * ImplementationData; 423 424 /* This member is a function pointer that instantiates a plugin. A 425 handle is returned indicating the new plugin instance. The 426 instantiation function accepts a sample rate as a parameter. The 427 plugin descriptor from which this instantiate function was found 428 must also be passed. This function must return NULL if 429 instantiation fails. 430 431 Note that instance initialisation should generally occur in 432 activate() rather than here. */ 433 LADSPA_Handle (*instantiate)(const struct _LADSPA_Descriptor * Descriptor, 434 unsigned long SampleRate); 435 436 /* This member is a function pointer that connects a port on an 437 instantiated plugin to a memory location at which a block of data 438 for the port will be read/written. The data location is expected 439 to be an array of LADSPA_Data for audio ports or a single 440 LADSPA_Data value for control ports. Memory issues will be 441 managed by the host. The plugin must read/write the data at these 442 locations every time run() or run_adding() is called and the data 443 present at the time of this connection call should not be 444 considered meaningful. 445 446 connect_port() may be called more than once for a plugin instance 447 to allow the host to change the buffers that the plugin is 448 reading or writing. These calls may be made before or after 449 activate() or deactivate() calls. 450 451 connect_port() must be called at least once for each port before 452 run() or run_adding() is called. When working with blocks of 453 LADSPA_Data the plugin should pay careful attention to the block 454 size passed to the run function as the block allocated may only 455 just be large enough to contain the block of samples. 456 457 Plugin writers should be aware that the host may elect to use the 458 same buffer for more than one port and even use the same buffer 459 for both input and output (see LADSPA_PROPERTY_INPLACE_BROKEN). 460 However, overlapped buffers or use of a single buffer for both 461 audio and control data may result in unexpected behaviour. */ 462 void (*connect_port)(LADSPA_Handle Instance, 463 unsigned long Port, 464 LADSPA_Data * DataLocation); 465 466 /* This member is a function pointer that initialises a plugin 467 instance and activates it for use. This is separated from 468 instantiate() to aid real-time support and so that hosts can 469 reinitialise a plugin instance by calling deactivate() and then 470 activate(). In this case the plugin instance must reset all state 471 information dependent on the history of the plugin instance 472 except for any data locations provided by connect_port() and any 473 gain set by set_run_adding_gain(). If there is nothing for 474 activate() to do then the plugin writer may provide a NULL rather 475 than an empty function. 476 477 When present, hosts must call this function once before run() (or 478 run_adding()) is called for the first time. This call should be 479 made as close to the run() call as possible and indicates to 480 real-time plugins that they are now live. Plugins should not rely 481 on a prompt call to run() after activate(). activate() may not be 482 called again unless deactivate() is called first. Note that 483 connect_port() may be called before or after a call to 484 activate(). */ 485 void (*activate)(LADSPA_Handle Instance); 486 487 /* This method is a function pointer that runs an instance of a 488 plugin for a block. Two parameters are required: the first is a 489 handle to the particular instance to be run and the second 490 indicates the block size (in samples) for which the plugin 491 instance may run. 492 493 Note that if an activate() function exists then it must be called 494 before run() or run_adding(). If deactivate() is called for a 495 plugin instance then the plugin instance may not be reused until 496 activate() has been called again. 497 498 If the plugin has the property LADSPA_PROPERTY_HARD_RT_CAPABLE 499 then there are various things that the plugin should not do 500 within the run() or run_adding() functions (see above). */ 501 void (*run)(LADSPA_Handle Instance, 502 unsigned long SampleCount); 503 504 /* This method is a function pointer that runs an instance of a 505 plugin for a block. This has identical behaviour to run() except 506 in the way data is output from the plugin. When run() is used, 507 values are written directly to the memory areas associated with 508 the output ports. However when run_adding() is called, values 509 must be added to the values already present in the memory 510 areas. Furthermore, output values written must be scaled by the 511 current gain set by set_run_adding_gain() (see below) before 512 addition. 513 514 run_adding() is optional. When it is not provided by a plugin, 515 this function pointer must be set to NULL. When it is provided, 516 the function set_run_adding_gain() must be provided also. */ 517 void (*run_adding)(LADSPA_Handle Instance, 518 unsigned long SampleCount); 519 520 /* This method is a function pointer that sets the output gain for 521 use when run_adding() is called (see above). If this function is 522 never called the gain is assumed to default to 1. Gain 523 information should be retained when activate() or deactivate() 524 are called. 525 526 This function should be provided by the plugin if and only if the 527 run_adding() function is provided. When it is absent this 528 function pointer must be set to NULL. */ 529 void (*set_run_adding_gain)(LADSPA_Handle Instance, 530 LADSPA_Data Gain); 531 532 /* This is the counterpart to activate() (see above). If there is 533 nothing for deactivate() to do then the plugin writer may provide 534 a NULL rather than an empty function. 535 536 Hosts must deactivate all activated units after they have been 537 run() (or run_adding()) for the last time. This call should be 538 made as close to the last run() call as possible and indicates to 539 real-time plugins that they are no longer live. Plugins should 540 not rely on prompt deactivation. Note that connect_port() may be 541 called before or after a call to deactivate(). 542 543 Deactivation is not similar to pausing as the plugin instance 544 will be reinitialised when activate() is called to reuse it. */ 545 void (*deactivate)(LADSPA_Handle Instance); 546 547 /* Once an instance of a plugin has been finished with it can be 548 deleted using the following function. The instance handle passed 549 ceases to be valid after this call. 550 551 If activate() was called for a plugin instance then a 552 corresponding call to deactivate() must be made before cleanup() 553 is called. */ 554 void (*cleanup)(LADSPA_Handle Instance); 555 556 } LADSPA_Descriptor; 371 typedef struct _LADSPA_Descriptor 372 { 373 374 /* This numeric identifier indicates the plugin type 375 uniquely. Plugin programmers may reserve ranges of IDs from a 376 central body to avoid clashes. Hosts may assume that IDs are 377 below 0x1000000. */ 378 unsigned long UniqueID; 379 380 /* This identifier can be used as a unique, case-sensitive 381 identifier for the plugin type within the plugin file. Plugin 382 types should be identified by file and label rather than by index 383 or plugin name, which may be changed in new plugin 384 versions. Labels must not contain white-space characters. */ 385 const char *Label; 386 387 /* This indicates a number of properties of the plugin. */ 388 LADSPA_Properties Properties; 389 390 /* This member points to the null-terminated name of the plugin 391 (e.g. "Sine Oscillator"). */ 392 const char *Name; 393 394 /* This member points to the null-terminated string indicating the 395 maker of the plugin. This can be an empty string but not NULL. */ 396 const char *Maker; 397 398 /* This member points to the null-terminated string indicating any 399 copyright applying to the plugin. If no Copyright applies the 400 string "None" should be used. */ 401 const char *Copyright; 402 403 /* This indicates the number of ports (input AND output) present on 404 the plugin. */ 405 unsigned long PortCount; 406 407 /* This member indicates an array of port descriptors. Valid indices 408 vary from 0 to PortCount-1. */ 409 const LADSPA_PortDescriptor *PortDescriptors; 410 411 /* This member indicates an array of null-terminated strings 412 describing ports (e.g. "Frequency (Hz)"). Valid indices vary from 413 0 to PortCount-1. */ 414 const char *const *PortNames; 415 416 /* This member indicates an array of range hints for each port (see 417 above). Valid indices vary from 0 to PortCount-1. */ 418 const LADSPA_PortRangeHint *PortRangeHints; 419 420 /* This may be used by the plugin developer to pass any custom 421 implementation data into an instantiate call. It must not be used 422 or interpreted by the host. It is expected that most plugin 423 writers will not use this facility as LADSPA_Handle should be 424 used to hold instance data. */ 425 void *ImplementationData; 426 427 /* This member is a function pointer that instantiates a plugin. A 428 handle is returned indicating the new plugin instance. The 429 instantiation function accepts a sample rate as a parameter. The 430 plugin descriptor from which this instantiate function was found 431 must also be passed. This function must return NULL if 432 instantiation fails. 433 434 Note that instance initialisation should generally occur in 435 activate() rather than here. */ 436 LADSPA_Handle (*instantiate) (const struct _LADSPA_Descriptor * 437 Descriptor, unsigned long SampleRate); 438 439 /* This member is a function pointer that connects a port on an 440 instantiated plugin to a memory location at which a block of data 441 for the port will be read/written. The data location is expected 442 to be an array of LADSPA_Data for audio ports or a single 443 LADSPA_Data value for control ports. Memory issues will be 444 managed by the host. The plugin must read/write the data at these 445 locations every time run() or run_adding() is called and the data 446 present at the time of this connection call should not be 447 considered meaningful. 448 449 connect_port() may be called more than once for a plugin instance 450 to allow the host to change the buffers that the plugin is 451 reading or writing. These calls may be made before or after 452 activate() or deactivate() calls. 453 454 connect_port() must be called at least once for each port before 455 run() or run_adding() is called. When working with blocks of 456 LADSPA_Data the plugin should pay careful attention to the block 457 size passed to the run function as the block allocated may only 458 just be large enough to contain the block of samples. 459 460 Plugin writers should be aware that the host may elect to use the 461 same buffer for more than one port and even use the same buffer 462 for both input and output (see LADSPA_PROPERTY_INPLACE_BROKEN). 463 However, overlapped buffers or use of a single buffer for both 464 audio and control data may result in unexpected behaviour. */ 465 void (*connect_port) (LADSPA_Handle Instance, 466 unsigned long Port, LADSPA_Data * DataLocation); 467 468 /* This member is a function pointer that initialises a plugin 469 instance and activates it for use. This is separated from 470 instantiate() to aid real-time support and so that hosts can 471 reinitialise a plugin instance by calling deactivate() and then 472 activate(). In this case the plugin instance must reset all state 473 information dependent on the history of the plugin instance 474 except for any data locations provided by connect_port() and any 475 gain set by set_run_adding_gain(). If there is nothing for 476 activate() to do then the plugin writer may provide a NULL rather 477 than an empty function. 478 479 When present, hosts must call this function once before run() (or 480 run_adding()) is called for the first time. This call should be 481 made as close to the run() call as possible and indicates to 482 real-time plugins that they are now live. Plugins should not rely 483 on a prompt call to run() after activate(). activate() may not be 484 called again unless deactivate() is called first. Note that 485 connect_port() may be called before or after a call to 486 activate(). */ 487 void (*activate) (LADSPA_Handle Instance); 488 489 /* This method is a function pointer that runs an instance of a 490 plugin for a block. Two parameters are required: the first is a 491 handle to the particular instance to be run and the second 492 indicates the block size (in samples) for which the plugin 493 instance may run. 494 495 Note that if an activate() function exists then it must be called 496 before run() or run_adding(). If deactivate() is called for a 497 plugin instance then the plugin instance may not be reused until 498 activate() has been called again. 499 500 If the plugin has the property LADSPA_PROPERTY_HARD_RT_CAPABLE 501 then there are various things that the plugin should not do 502 within the run() or run_adding() functions (see above). */ 503 void (*run) (LADSPA_Handle Instance, unsigned long SampleCount); 504 505 /* This method is a function pointer that runs an instance of a 506 plugin for a block. This has identical behaviour to run() except 507 in the way data is output from the plugin. When run() is used, 508 values are written directly to the memory areas associated with 509 the output ports. However when run_adding() is called, values 510 must be added to the values already present in the memory 511 areas. Furthermore, output values written must be scaled by the 512 current gain set by set_run_adding_gain() (see below) before 513 addition. 514 515 run_adding() is optional. When it is not provided by a plugin, 516 this function pointer must be set to NULL. When it is provided, 517 the function set_run_adding_gain() must be provided also. */ 518 void (*run_adding) (LADSPA_Handle Instance, unsigned long SampleCount); 519 520 /* This method is a function pointer that sets the output gain for 521 use when run_adding() is called (see above). If this function is 522 never called the gain is assumed to default to 1. Gain 523 information should be retained when activate() or deactivate() 524 are called. 525 526 This function should be provided by the plugin if and only if the 527 run_adding() function is provided. When it is absent this 528 function pointer must be set to NULL. */ 529 void (*set_run_adding_gain) (LADSPA_Handle Instance, LADSPA_Data Gain); 530 531 /* This is the counterpart to activate() (see above). If there is 532 nothing for deactivate() to do then the plugin writer may provide 533 a NULL rather than an empty function. 534 535 Hosts must deactivate all activated units after they have been 536 run() (or run_adding()) for the last time. This call should be 537 made as close to the last run() call as possible and indicates to 538 real-time plugins that they are no longer live. Plugins should 539 not rely on prompt deactivation. Note that connect_port() may be 540 called before or after a call to deactivate(). 541 542 Deactivation is not similar to pausing as the plugin instance 543 will be reinitialised when activate() is called to reuse it. */ 544 void (*deactivate) (LADSPA_Handle Instance); 545 546 /* Once an instance of a plugin has been finished with it can be 547 deleted using the following function. The instance handle passed 548 ceases to be valid after this call. 549 550 If activate() was called for a plugin instance then a 551 corresponding call to deactivate() must be made before cleanup() 552 is called. */ 553 void (*cleanup) (LADSPA_Handle Instance); 554 555 } LADSPA_Descriptor; 557 556 558 557 /**********************************************************************/ … … 583 582 for the least index that results in NULL being returned. */ 584 583 585 const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index);584 const LADSPA_Descriptor *ladspa_descriptor (unsigned long Index); 586 585 587 586 /* Datatype corresponding to the ladspa_descriptor() function. */ 588 typedef const LADSPA_Descriptor * 589 (*LADSPA_Descriptor_Function)(unsigned long Index);587 typedef const LADSPA_Descriptor * 588 (*LADSPA_Descriptor_Function) (unsigned long Index); 590 589 591 590 /**********************************************************************/ … … 595 594 #endif 596 595 597 #endif /* LADSPA_INCLUDED */596 #endif /* LADSPA_INCLUDED */ 598 597 599 598 /* EOF */ sweep/branches/display-cache/plugins/ladspa/ladspameta.c
r130 r471 30 30 #include <dirent.h> 31 31 #include <string.h> 32 #include <math.h> /* for ceil() */32 #include <math.h> /* for ceil() */ 33 33 34 34 #include <glib.h> … … 59 59 #define LADSPA_frames_to_bytes(f) (f * sizeof(LADSPA_Data)) 60 60 61 static char * default_ladspa_path = "/usr/lib/ladspa:/usr/local/lib/ladspa:/opt/ladspa/lib"; 62 63 static GList * modules_list = NULL; 61 static char *default_ladspa_path = 62 "/usr/lib/ladspa:/usr/local/lib/ladspa:/opt/ladspa/lib"; 63 64 static GList *modules_list = NULL; 64 65 static gboolean ladspa_meta_initialised = FALSE; 65 66 … … 73 74 */ 74 75 static gboolean 75 is_usable (const LADSPA_Descriptor * d)76 is_usable (const LADSPA_Descriptor * d) 76 77 { 77 78 LADSPA_PortDescriptor pd; 78 79 gint i; 79 gint 80 nr_ai=0, /* audio inputs */ 81 nr_ao=0; /* audio outputs */ 82 83 for (i=0; i < d->PortCount; i++) { 84 pd = d->PortDescriptors[i]; 85 if (LADSPA_IS_AUDIO_INPUT(pd)) 86 nr_ai++; 87 if (LADSPA_IS_AUDIO_OUTPUT(pd)) 88 nr_ao++; 89 } 90 91 if (nr_ao == 0) return FALSE; 80 gint nr_ai = 0, /* audio inputs */ 81 nr_ao = 0; /* audio outputs */ 82 83 for (i = 0; i < d->PortCount; i++) 84 { 85 pd = d->PortDescriptors[i]; 86 if (LADSPA_IS_AUDIO_INPUT (pd)) 87 nr_ai++; 88 if (LADSPA_IS_AUDIO_OUTPUT (pd)) 89 nr_ao++; 90 } 91 92 if (nr_ao == 0) 93 return FALSE; 92 94 93 95 /* Sanity checks */ 94 if (! d->run) return FALSE; /* plugin does nothing! */ 95 if (! d->instantiate) return FALSE; /* plugin cannot be instantiated */ 96 if (! d->connect_port) return FALSE; /* plugin cannot be wired up */ 96 if (!d->run) 97 return FALSE; /* plugin does nothing! */ 98 if (!d->instantiate) 99 return FALSE; /* plugin cannot be instantiated */ 100 if (!d->connect_port) 101 return FALSE; /* plugin cannot be wired up */ 97 102 98 103 return (nr_ai == nr_ao); … … 102 107 convert_type (const LADSPA_PortRangeHintDescriptor prhd) 103 108 { 104 if (LADSPA_IS_HINT_TOGGLED (prhd))109 if (LADSPA_IS_HINT_TOGGLED (prhd)) 105 110 return SWEEP_TYPE_BOOL; 106 else if (LADSPA_IS_HINT_INTEGER (prhd))111 else if (LADSPA_IS_HINT_INTEGER (prhd)) 107 112 return SWEEP_TYPE_INT; 108 113 else … … 113 118 get_valid_mask (const LADSPA_PortRangeHintDescriptor prhd) 114 119 { 115 int ret =0;116 117 if (LADSPA_IS_HINT_BOUNDED_BELOW (prhd))120 int ret = 0; 121 122 if (LADSPA_IS_HINT_BOUNDED_BELOW (prhd)) 118 123 ret |= SW_RANGE_LOWER_BOUND_VALID; 119 if (LADSPA_IS_HINT_BOUNDED_ABOVE (prhd))124 if (LADSPA_IS_HINT_BOUNDED_ABOVE (prhd)) 120 125 ret |= SW_RANGE_UPPER_BOUND_VALID; 121 126 … … 124 129 125 130 static sw_param_range * 126 convert_constraint ( /* sw_format * format, */127 const LADSPA_PortRangeHint * prh)128 { 129 sw_param_range * pr;131 convert_constraint ( /* sw_format * format, */ 132 const LADSPA_PortRangeHint * prh) 133 { 134 sw_param_range *pr; 130 135 LADSPA_PortRangeHintDescriptor prhd = prh->HintDescriptor; 131 136 LADSPA_Data lower, upper; 132 137 133 if (LADSPA_IS_HINT_TOGGLED (prhd))138 if (LADSPA_IS_HINT_TOGGLED (prhd)) 134 139 return NULL; 135 140 … … 141 146 upper = prh->UpperBound; 142 147 143 if LADSPA_IS_HINT_SAMPLE_RATE (prhd) { 148 if LADSPA_IS_HINT_SAMPLE_RATE 149 (prhd) 150 { 144 151 #if 0 145 lower *= format->rate;146 upper *= format->rate;152 lower *= format->rate; 153 upper *= format->rate; 147 154 #else 148 lower *= 44100;149 upper *= 44100;155 lower *= 44100; 156 upper *= 44100; 150 157 #endif 151 } 152 153 if (LADSPA_IS_HINT_INTEGER(prhd)) { 154 if (LADSPA_IS_HINT_BOUNDED_BELOW(prhd)) 155 pr->lower.i = (sw_int)lower; 156 if (LADSPA_IS_HINT_BOUNDED_ABOVE(prhd)) 157 pr->upper.i = (sw_int)upper; 158 } else { 159 if (LADSPA_IS_HINT_BOUNDED_BELOW(prhd)) 160 pr->lower.f = (sw_float)lower; 161 if (LADSPA_IS_HINT_BOUNDED_ABOVE(prhd)) 162 pr->upper.f = (sw_float)upper; 163 } 158 } 159 160 if (LADSPA_IS_HINT_INTEGER (prhd)) 161 { 162 if (LADSPA_IS_HINT_BOUNDED_BELOW (prhd)) 163 pr->lower.i = (sw_int) lower; 164 if (LADSPA_IS_HINT_BOUNDED_ABOVE (prhd)) 165 pr->upper.i = (sw_int) upper; 166 } 167 else 168 { 169 if (LADSPA_IS_HINT_BOUNDED_BELOW (prhd)) 170 pr->lower.f = (sw_float) lower; 171 if (LADSPA_IS_HINT_BOUNDED_ABOVE (prhd)) 172 pr->upper.f = (sw_float) upper; 173 } 164 174 165 175 return pr; … … 168 178 typedef struct _lm_custom lm_custom; 169 179 170 struct _lm_custom { 171 const LADSPA_Descriptor * d; 172 sw_param_spec * param_specs; 180 struct _lm_custom 181 { 182 const LADSPA_Descriptor *d; 183 sw_param_spec *param_specs; 173 184 }; 174 185 … … 176 187 lm_custom_new (const LADSPA_Descriptor * d, sw_param_spec * param_specs) 177 188 { 178 lm_custom * lmc;189 lm_custom *lmc; 179 190 180 191 lmc = g_malloc (sizeof (*lmc)); 181 if (lmc) { 182 lmc->d = d; 183 lmc->param_specs = param_specs; 184 } 192 if (lmc) 193 { 194 lmc->d = d; 195 lmc->param_specs = param_specs; 196 } 185 197 186 198 return lmc; … … 203 215 upper = prh->UpperBound; 204 216 205 if LADSPA_IS_HINT_SAMPLE_RATE (prhd) { 206 lower *= format->rate; 207 upper *= format->rate; 208 } 217 if LADSPA_IS_HINT_SAMPLE_RATE 218 (prhd) 219 { 220 lower *= format->rate; 221 upper *= format->rate; 222 } 209 223 210 224 /* Determine default value, as sw_float */ 211 225 212 if (!LADSPA_IS_HINT_HAS_DEFAULT (prhd)) { 213 def = 0.0; 214 } else if (LADSPA_IS_HINT_DEFAULT_MINIMUM (prhd)) { 215 def = prh->LowerBound; 216 } else if (bounded && LADSPA_IS_HINT_DEFAULT_LOW (prhd)) { 217 if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) { 218 def = exp(log(lower) * 0.75 + log(upper) * 0.25); 219 } else { 220 def = lower * 0.75 + upper * 0.25; 221 } 222 } else if (bounded && LADSPA_IS_HINT_DEFAULT_MIDDLE (prhd)) { 223 if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) { 224 exp(log(lower) * 0.5 + log(upper) * 0.5); 225 } else { 226 def = lower * 0.5 + upper * 0.5; 227 } 228 } else if (bounded && LADSPA_IS_HINT_DEFAULT_HIGH (prhd)) { 229 if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) { 230 exp(log(lower) * 0.25 + log(upper) * 0.75); 231 } else { 232 def = lower * 0.25 + upper * 0.75; 233 } 234 } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM (prhd)) { 235 def = prh->UpperBound; 236 } else if (LADSPA_IS_HINT_DEFAULT_0 (prhd)) { 237 def = 0.0; 238 } else if (LADSPA_IS_HINT_DEFAULT_1 (prhd)) { 239 def = 1.0; 240 } else if (LADSPA_IS_HINT_DEFAULT_100 (prhd)) { 241 def = 100.0; 242 } else if (LADSPA_IS_HINT_DEFAULT_440 (prhd)) { 243 def = 440.0; 244 } else { 245 def = 0.0; 246 } 226 if (!LADSPA_IS_HINT_HAS_DEFAULT (prhd)) 227 { 228 def = 0.0; 229 } 230 else if (LADSPA_IS_HINT_DEFAULT_MINIMUM (prhd)) 231 { 232 def = prh->LowerBound; 233 } 234 else if (bounded && LADSPA_IS_HINT_DEFAULT_LOW (prhd)) 235 { 236 if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) 237 { 238 def = exp (log (lower) * 0.75 + log (upper) * 0.25); 239 } 240 else 241 { 242 def = lower * 0.75 + upper * 0.25; 243 } 244 } 245 else if (bounded && LADSPA_IS_HINT_DEFAULT_MIDDLE (prhd)) 246 { 247 if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) 248 { 249 exp (log (lower) * 0.5 + log (upper) * 0.5); 250 } 251 else 252 { 253 def = lower * 0.5 + upper * 0.5; 254 } 255 } 256 else if (bounded && LADSPA_IS_HINT_DEFAULT_HIGH (prhd)) 257 { 258 if (LADSPA_IS_HINT_LOGARITHMIC (prhd)) 259 { 260 exp (log (lower) * 0.25 + log (upper) * 0.75); 261 } 262 else 263 { 264 def = lower * 0.25 + upper * 0.75; 265 } 266 } 267 else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM (prhd)) 268 { 269 def = prh->UpperBound; 270 } 271 else if (LADSPA_IS_HINT_DEFAULT_0 (prhd)) 272 { 273 def = 0.0; 274 } 275 else if (LADSPA_IS_HINT_DEFAULT_1 (prhd)) 276 { 277 def = 1.0; 278 } 279 else if (LADSPA_IS_HINT_DEFAULT_100 (prhd)) 280 { 281 def = 100.0; 282 } 283 else if (LADSPA_IS_HINT_DEFAULT_440 (prhd)) 284 { 285 def = 440.0; 286 } 287 else 288 { 289 def = 0.0; 290 } 247 291 248 292 /* Convert to sw_param type */ 249 293 250 if (LADSPA_IS_HINT_TOGGLED (prhd)) { 251 param.b = (sw_bool)def; 252 } else if (LADSPA_IS_HINT_INTEGER (prhd)) { 253 param.i = (sw_int)def; 254 } else { 255 param.f = (sw_float)def; 256 } 294 if (LADSPA_IS_HINT_TOGGLED (prhd)) 295 { 296 param.b = (sw_bool) def; 297 } 298 else if (LADSPA_IS_HINT_INTEGER (prhd)) 299 { 300 param.i = (sw_int) def; 301 } 302 else 303 { 304 param.f = (sw_float) def; 305 } 257 306 258 307 return param; … … 263 312 gpointer custom_data) 264 313 { 265 sw_sounddata * sounddata;266 lm_custom * lm = (lm_custom *)custom_data;267 const LADSPA_Descriptor * d = lm->d;314 sw_sounddata *sounddata; 315 lm_custom *lm = (lm_custom *) custom_data; 316 const LADSPA_Descriptor *d = lm->d; 268 317 269 318 LADSPA_PortDescriptor pd; … … 272 321 sounddata = sample_get_sounddata (sample); 273 322 274 for (i=0; i < d->PortCount; i++) { 275 pd = d->PortDescriptors[i]; 276 if (LADSPA_IS_CONTROL_INPUT(pd)) { 277 pset[pset_i] = convert_default (sounddata->format, 278 &d->PortRangeHints[i]); 279 pset_i++; 280 } 281 } 323 for (i = 0; i < d->PortCount; i++) 324 { 325 pd = d->PortDescriptors[i]; 326 if (LADSPA_IS_CONTROL_INPUT (pd)) 327 { 328 pset[pset_i] = convert_default (sounddata->format, 329 &d->PortRangeHints[i]); 330 pset_i++; 331 } 332 } 282 333 283 334 } … … 289 340 gpointer custom_data) 290 341 { 291 lm_custom * lm = (lm_custom *)custom_data;292 const LADSPA_Descriptor * d = lm->d;293 sw_param_spec * param_specs = lm->param_specs;294 295 sw_sounddata * sounddata;296 sw_format * format;342 lm_custom *lm = (lm_custom *) custom_data; 343 const LADSPA_Descriptor *d = lm->d; 344 sw_param_spec *param_specs = lm->param_specs; 345 346 sw_sounddata *sounddata; 347 sw_format *format; 297 348 sw_framecount_t op_total, run_total; 298 349 sw_framecount_t offset, remaining, n; 299 350 300 GList * gl;301 sw_sel * sel;351 GList *gl; 352 sw_sel *sel; 302 353 303 354 gpointer pcmdata; … … 310 361 gint nr_handles; 311 362 312 LADSPA_Handle ** handles;313 LADSPA_Data ** input_buffers, **output_buffers;314 LADSPA_Data * mono_input_buffers[1], *mono_output_buffers[1];315 LADSPA_Data * p;316 LADSPA_Data * control_inputs;363 LADSPA_Handle **handles; 364 LADSPA_Data **input_buffers, **output_buffers; 365 LADSPA_Data *mono_input_buffers[1], *mono_output_buffers[1]; 366 LADSPA_Data *p; 367 LADSPA_Data *control_inputs; 317 368 LADSPA_Data dummy_control_output; 318 369 LADSPA_PortDescriptor pd; 319 370 glong length_b; 320 gulong port_i; /* counter for iterating over ports */371 gulong port_i; /* counter for iterating over ports */ 321 372 gint h, i, j, c; 322 373 323 374 /* Enumerate the numbers of each type of port on the ladspa plugin */ 324 gint 325 nr_ci=0, /* control inputs */ 326 nr_ai=0, /* audio inputs */ 327 nr_co=0, /* control outputs */ 328 nr_ao=0; /* audio outputs */ 375 gint nr_ci = 0, /* control inputs */ 376 nr_ai = 0, /* audio inputs */ 377 nr_co = 0, /* control outputs */ 378 nr_ao = 0; /* audio outputs */ 329 379 330 380 /* The number of audio channels to be processed */ … … 332 382 333 383 /* The number of input and output buffers to use */ 334 gint nr_i =0, nr_o=0;384 gint nr_i = 0, nr_o = 0; 335 385 336 386 /* Counters for allocating input and output buffers */ 337 gint ibi =0, obi=0;387 gint ibi = 0, obi = 0; 338 388 339 389 gboolean active = TRUE; … … 346 396 347 397 op_total = sounddata_selection_nr_frames (sounddata) / 100; 348 if (op_total == 0) op_total = 1; 398 if (op_total == 0) 399 op_total = 1; 349 400 run_total = 0; 350 401 351 402 /* Cache how many of each type of port this ladspa plugin has */ 352 for (port_i=0; port_i < d->PortCount; port_i++) { 353 pd = d->PortDescriptors[(int)port_i]; 354 if (LADSPA_IS_CONTROL_INPUT(pd)) 355 nr_ci++; 356 if (LADSPA_IS_AUDIO_INPUT(pd)) 357 nr_ai++; 358 if (LADSPA_IS_CONTROL_OUTPUT(pd)) 359 nr_co++; 360 if (LADSPA_IS_AUDIO_OUTPUT(pd)) 361 nr_ao++; 362 } 403 for (port_i = 0; port_i < d->PortCount; port_i++) 404 { 405 pd = d->PortDescriptors[(int) port_i]; 406 if (LADSPA_IS_CONTROL_INPUT (pd)) 407 nr_ci++; 408 if (LADSPA_IS_AUDIO_INPUT (pd)) 409 nr_ai++; 410 if (LADSPA_IS_CONTROL_OUTPUT (pd)) 411 nr_co++; 412 if (LADSPA_IS_AUDIO_OUTPUT (pd)) 413 nr_ao++; 414 } 363 415 364 416 /* Basic assumption of this meta plugin, which was … … 374 426 g_assert (nr_ao > 0); 375 427 376 nr_handles = (gint) ceil (((double)nr_channels) / ((double)nr_ao));428 nr_handles = (gint) ceil (((double) nr_channels) / ((double) nr_ao)); 377 429 378 430 /* Numbers of input and output buffers: ensure … … 384 436 /* Create all input and output buffers */ 385 437 386 if ((nr_channels == 1) && (nr_ai == 1) && (nr_ao >= 1)) { 387 /* 388 * Processing a mono sample with a mono filter. 389 * Attempt to do this in place. 390 */ 391 392 /* Create an input buffer if this ladspa plugin cannot work inplace */ 393 if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 394 length_b = frames_to_bytes (format, BLOCK_SIZE); 395 mono_input_buffers[0] = g_malloc (length_b); 396 } else { 397 /* Input directly from sample data; mark as NULL */ 398 mono_input_buffers[0] = NULL; 399 } 400 input_buffers = mono_input_buffers; 401 402 /* Always output directly into the sample data; mark as NULL */ 403 mono_output_buffers[0] = NULL; 404 output_buffers = mono_output_buffers; 405 406 } else { 407 length_b = LADSPA_frames_to_bytes (BLOCK_SIZE); 408 409 /* Allocate zeroed input buffers; these will remain zeroed 410 * if there aren't enough channels in the input pcmdata 411 * to use them. 412 */ 413 input_buffers = g_malloc (sizeof(LADSPA_Data *) * nr_i); 414 for (i=0; i < nr_i; i++) { 415 input_buffers[i] = g_malloc0 (length_b); 416 } 417 418 output_buffers = g_malloc(sizeof(LADSPA_Data *) * nr_o); 419 420 /* Create separate output buffers if this ladspa plugin cannot 421 * work inplace */ 422 if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 423 for (i=0; i < nr_o; i++) { 424 output_buffers[i] = g_malloc (length_b); 425 } 426 } else { 427 /* Re-use the input buffers, directly mapping them to 428 * corresponding output buffers 438 if ((nr_channels == 1) && (nr_ai == 1) && (nr_ao >= 1)) 439 { 440 /* 441 * Processing a mono sample with a mono filter. 442 * Attempt to do this in place. 429 443 */ 430 for (i=0; i < MIN(nr_i, nr_o); i++) { 431 output_buffers[i] = input_buffers[i]; 432 } 433 /* Create some extra output buffers if nr_o > nr_i */ 434 for (; i < nr_o; i++) { 435 output_buffers[i] = g_malloc (length_b); 436 } 437 } 438 } 444 445 /* Create an input buffer if this ladspa plugin cannot work inplace */ 446 if (LADSPA_META_IS_INPLACE_BROKEN (d->Properties)) 447 { 448 length_b = frames_to_bytes (format, BLOCK_SIZE); 449 mono_input_buffers[0] = g_malloc (length_b); 450 } 451 else 452 { 453 /* Input directly from sample data; mark as NULL */ 454 mono_input_buffers[0] = NULL; 455 } 456 input_buffers = mono_input_buffers; 457 458 /* Always output directly into the sample data; mark as NULL */ 459 mono_output_buffers[0] = NULL; 460 output_buffers = mono_output_buffers; 461 462 } 463 else 464 { 465 length_b = LADSPA_frames_to_bytes (BLOCK_SIZE); 466 467 /* Allocate zeroed input buffers; these will remain zeroed 468 * if there aren't enough channels in the input pcmdata 469 * to use them. 470 */ 471 input_buffers = g_malloc (sizeof (LADSPA_Data *) * nr_i); 472 for (i = 0; i < nr_i; i++) 473 { 474 input_buffers[i] = g_malloc0 (length_b); 475 } 476 477 output_buffers = g_malloc (sizeof (LADSPA_Data *) * nr_o); 478 479 /* Create separate output buffers if this ladspa plugin cannot 480 * work inplace */ 481 if (LADSPA_META_IS_INPLACE_BROKEN (d->Properties)) 482 { 483 for (i = 0; i < nr_o; i++) 484 { 485 output_buffers[i] = g_malloc (length_b); 486 } 487 } 488 else 489 { 490 /* Re-use the input buffers, directly mapping them to 491 * corresponding output buffers 492 */ 493 for (i = 0; i < MIN (nr_i, nr_o); i++) 494 { 495 output_buffers[i] = input_buffers[i]; 496 } 497 /* Create some extra output buffers if nr_o > nr_i */ 498 for (; i < nr_o; i++) 499 { 500 output_buffers[i] = g_malloc (length_b); 501 } 502 } 503 } 439 504 440 505 /* instantiate the ladspa plugin */ 441 506 handles = g_malloc (sizeof (LADSPA_Handle *) * nr_handles); 442 for (h = 0; h < nr_handles; h++) { 443 handles[h] = d->instantiate (d, (long)format->rate); 444 } 507 for (h = 0; h < nr_handles; h++) 508 { 509 handles[h] = d->instantiate (d, (long) format->rate); 510 } 445 511 446 512 /* connect control ports */ 447 control_inputs = g_malloc (nr_ci * sizeof(LADSPA_Data)); 448 j=0; 449 for (port_i=0; port_i < d->PortCount; port_i++) { 450 pd = d->PortDescriptors[(int)port_i]; 451 if (LADSPA_IS_CONTROL_INPUT(pd)) { 452 /* do something with pset! */ 453 switch (param_specs[j].type) { 454 case SWEEP_TYPE_BOOL: 455 /* from ladspa.h: 456 * Data less than or equal to zero should be considered 457 * `off' or `false,' 458 * and data above zero should be considered `on' or `true.' 459 */ 460 control_inputs[j] = pset[j].b ? 1.0 : 0.0; 461 break; 462 case SWEEP_TYPE_INT: 463 control_inputs[j] = (LADSPA_Data)pset[j].i; 464 break; 465 case SWEEP_TYPE_FLOAT: 466 control_inputs[j] = pset[j].f; 467 break; 468 default: 469 /* This plugin should produce no other types */ 470 g_assert_not_reached (); 471 break; 472 } 473 474 for (h = 0; h < nr_handles; h++) { 475 d->connect_port (handles[h], port_i, &control_inputs[j]); 476 } 477 478 j++; 479 } 480 if (LADSPA_IS_CONTROL_OUTPUT(pd)) { 481 for (h = 0; h < nr_handles; h++) { 482 d->connect_port (handles[h], port_i, &dummy_control_output); 483 } 484 } 485 } 513 control_inputs = g_malloc (nr_ci * sizeof (LADSPA_Data)); 514 j = 0; 515 for (port_i = 0; port_i < d->PortCount; port_i++) 516 { 517 pd = d->PortDescriptors[(int) port_i]; 518 if (LADSPA_IS_CONTROL_INPUT (pd)) 519 { 520 /* do something with pset! */ 521 switch (param_specs[j].type) 522 { 523 case SWEEP_TYPE_BOOL: 524 /* from ladspa.h: 525 * Data less than or equal to zero should be considered 526 * `off' or `false,' 527 * and data above zero should be considered `on' or `true.' 528 */ 529 control_inputs[j] = pset[j].b ? 1.0 : 0.0; 530 break; 531 case SWEEP_TYPE_INT: 532 control_inputs[j] = (LADSPA_Data) pset[j].i; 533 break; 534 case SWEEP_TYPE_FLOAT: 535 control_inputs[j] = pset[j].f; 536 break; 537 default: 538 /* This plugin should produce no other types */ 539 g_assert_not_reached (); 540 break; 541 } 542 543 for (h = 0; h < nr_handles; h++) 544 { 545 d->connect_port (handles[h], port_i, &control_inputs[j]); 546 } 547 548 j++; 549 } 550 if (LADSPA_IS_CONTROL_OUTPUT (pd)) 551 { 552 for (h = 0; h < nr_handles; h++) 553 { 554 d->connect_port (handles[h], port_i, &dummy_control_output); 555 } 556 } 557 } 486 558 487 559 /* activate the ladspa plugin */ 488 if (d->activate) { 489 for (h = 0; h < nr_handles; h++) { 490 d->activate (handles[h]); 491 } 492 } 560 if (d->activate) 561 { 562 for (h = 0; h < nr_handles; h++) 563 { 564 d->activate (handles[h]); 565 } 566 } 493 567 494 568 /* run the plugin on selection regions */ 495 for (gl = sounddata->sels; active && gl; gl = gl->next) { 496 sel = (sw_sel *)gl->data; 497 498 offset = 0; 499 remaining = sel->sel_end - sel->sel_start; 500 501 while (active && remaining > 0) { 502 g_mutex_lock (sample->ops_mutex); 503 504 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 505 active = FALSE; 506 } else { /* cancel */ 507 pcmdata = sounddata->data + 508 frames_to_bytes (format, sel->sel_start + offset); 509 510 n = MIN(remaining, BLOCK_SIZE); 511 512 /* Copy data into input buffers */ 513 if (nr_channels == 1) { 514 if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 515 length_b = frames_to_bytes (format, n); 516 memcpy (input_buffers[0], pcmdata, length_b); 517 } else { 518 /* we're processing in-place, so we haven't needed to set 519 * up a separate input buffer; input_buffers[0] actually 520 * points to pcmdata hence we don't do any copying here. 521 */ 522 input_buffers[0] = (LADSPA_Data *)pcmdata; 523 } 524 525 output_buffers[0] = (LADSPA_Data *)pcmdata; 526 527 } else { 528 /* de-interleave multichannel data */ 529 530 p = (LADSPA_Data *)pcmdata; 531 532 for (i=0; i < n; i++) { 533 for (c=0; c < nr_channels; c++) { 534 input_buffers[c][i] = *p++; 535 } 536 } 537 } 538 539 g_assert (input_buffers[0] != NULL); 540 g_assert (output_buffers[0] != NULL); 541 542 /* connect input and output audio buffers to the 543 * audio ports of the ladspa plugin */ 544 ibi = 0; obi = 0; 545 for (h = 0; h < nr_handles; h++) { 546 for (port_i=0; port_i < d->PortCount; port_i++) { 547 pd = d->PortDescriptors[(int)port_i]; 548 if (LADSPA_IS_AUDIO_INPUT(pd)) { 549 d->connect_port (handles[h], port_i, input_buffers[ibi++]); 550 } 551 if (LADSPA_IS_AUDIO_OUTPUT(pd)) { 552 d->connect_port (handles[h], port_i, output_buffers[obi++]); 553 } 554 } 555 } 556 557 /* run the ladspa plugin */ 558 for (h = 0; h < nr_handles; h++) { 559 d->run (handles[h], n); 560 } 561 562 /* re-interleave data */ 563 if (nr_channels > 1) { 564 p = (LADSPA_Data *)pcmdata; 565 566 for (i=0; i < n; i++) { 567 for (c=0; c < nr_channels; c++) { 568 *p++ = output_buffers[c][i]; 569 } 570 } 571 } 572 573 remaining -= n; 574 offset += n; 575 576 run_total += n; 577 sample_set_progress_percent (sample, run_total / op_total); 578 } 579 580 g_mutex_unlock (sample->ops_mutex); 581 } 582 } 569 for (gl = sounddata->sels; active && gl; gl = gl->next) 570 { 571 sel = (sw_sel *) gl->data; 572 573 offset = 0; 574 remaining = sel->sel_end - sel->sel_start; 575 576 while (active && remaining > 0) 577 { 578 g_mutex_lock (sample->ops_mutex); 579 580 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 581 { 582 active = FALSE; 583 } 584 else 585 { /* cancel */ 586 pcmdata = sounddata->data + 587 frames_to_bytes (format, sel->sel_start + offset); 588 589 n = MIN (remaining, BLOCK_SIZE); 590 591 /* Copy data into input buffers */ 592 if (nr_channels == 1) 593 { 594 if (LADSPA_META_IS_INPLACE_BROKEN (d->Properties)) 595 { 596 length_b = frames_to_bytes (format, n); 597 memcpy (input_buffers[0], pcmdata, length_b); 598 } 599 else 600 { 601 /* we're processing in-place, so we haven't needed to set 602 * up a separate input buffer; input_buffers[0] actually 603 * points to pcmdata hence we don't do any copying here. 604 */ 605 input_buffers[0] = (LADSPA_Data *) pcmdata; 606 } 607 608 output_buffers[0] = (LADSPA_Data *) pcmdata; 609 610 } 611 else 612 { 613 /* de-interleave multichannel data */ 614 615 p = (LADSPA_Data *) pcmdata; 616 617 for (i = 0; i < n; i++) 618 { 619 for (c = 0; c < nr_channels; c++) 620 { 621 input_buffers[c][i] = *p++; 622 } 623 } 624 } 625 626 g_assert (input_buffers[0] != NULL); 627 g_assert (output_buffers[0] != NULL); 628 629 /* connect input and output audio buffers to the 630 * audio ports of the ladspa plugin */ 631 ibi = 0; 632 obi = 0; 633 for (h = 0; h < nr_handles; h++) 634 { 635 for (port_i = 0; port_i < d->PortCount; port_i++) 636 { 637 pd = d->PortDescriptors[(int) port_i]; 638 if (LADSPA_IS_AUDIO_INPUT (pd)) 639 { 640 d->connect_port (handles[h], port_i, 641 input_buffers[ibi++]); 642 } 643 if (LADSPA_IS_AUDIO_OUTPUT (pd)) 644 { 645 d->connect_port (handles[h], port_i, 646 output_buffers[obi++]); 647 } 648 } 649 } 650 651 /* run the ladspa plugin */ 652 for (h = 0; h < nr_handles; h++) 653 { 654 d->run (handles[h], n); 655 } 656 657 /* re-interleave data */ 658 if (nr_channels > 1) 659 { 660 p = (LADSPA_Data *) pcmdata; 661 662 for (i = 0; i < n; i++) 663 { 664 for (c = 0; c < nr_channels; c++) 665 { 666 *p++ = output_buffers[c][i]; 667 } 668 } 669 } 670 671 remaining -= n; 672 offset += n; 673 674 run_total += n; 675 sample_set_progress_percent (sample, run_total / op_total); 676 } 677 678 g_mutex_unlock (sample->ops_mutex); 679 } 680 } 583 681 584 682 /* deactivate the ladspa plugin */ 585 if (d->deactivate) { 586 for (h = 0; h < nr_handles; h++) { 587 d->deactivate (handles[h]); 588 } 589 } 683 if (d->deactivate) 684 { 685 for (h = 0; h < nr_handles; h++) 686 { 687 d->deactivate (handles[h]); 688 } 689 } 590 690 591 691 /* let the ladspa plugin clean up after itself */ 592 if (d->cleanup) { 593 for (h = 0; h < nr_handles; h++) { 594 d->cleanup (handles[h]); 595 } 596 } 692 if (d->cleanup) 693 { 694 for (h = 0; h < nr_handles; h++) 695 { 696 d->cleanup (handles[h]); 697 } 698 } 597 699 598 700 /* free the array of handles */ 599 701 g_free (handles); 600 702 601 703 /* free the input and output buffers */ 602 if (control_inputs) g_free (control_inputs); 603 604 if ((nr_channels == 1) && (nr_ai == 1) && (nr_ao >= 1)) { 605 if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 606 g_free (mono_input_buffers[0]); 607 } 608 } else { 609 610 /* free the output buffers */ 611 for (i=0; i < nr_o; i++) { 612 g_free (output_buffers[i]); 613 } 614 g_free (output_buffers); 615 616 /* free the input buffers, if we created some */ 617 if (LADSPA_META_IS_INPLACE_BROKEN(d->Properties)) { 618 for (i=0; i < nr_i; i++) { 619 g_free (input_buffers[i]); 620 } 621 } else { 622 /* inplace worked, but if (nr_i > nr_o), then 623 * we still need to free the last input buffers 624 **/ 625 for (i=nr_o; i < nr_i; i++) { 626 g_free (input_buffers[i]); 627 } 628 } 629 g_free (input_buffers); 630 } 704 if (control_inputs) 705 g_free (control_inputs); 706 707 if ((nr_channels == 1) && (nr_ai == 1) && (nr_ao >= 1)) 708 { 709 if (LADSPA_META_IS_INPLACE_BROKEN (d->Properties)) 710 { 711 g_free (mono_input_buffers[0]); 712 } 713 } 714 else 715 { 716 717 /* free the output buffers */ 718 for (i = 0; i < nr_o; i++) 719 { 720 g_free (output_buffers[i]); 721 } 722 g_free (output_buffers); 723 724 /* free the input buffers, if we created some */ 725 if (LADSPA_META_IS_INPLACE_BROKEN (d->Properties)) 726 { 727 for (i = 0; i < nr_i; i++) 728 { 729 g_free (input_buffers[i]); 730 } 731 } 732 else 733 { 734 /* inplace worked, but if (nr_i > nr_o), then 735 * we still need to free the last input buffers 736 **/ 737 for (i = nr_o; i < nr_i; i++) 738 { 739 g_free (input_buffers[i]); 740 } 741 } 742 g_free (input_buffers); 743 } 631 744 632 745 return sample; … … 637 750 sw_param_set pset, gpointer custom_data) 638 751 { 639 lm_custom * lm = (lm_custom *)custom_data;640 const LADSPA_Descriptor * d = lm->d;752 lm_custom *lm = (lm_custom *) custom_data; 753 const LADSPA_Descriptor *d = lm->d; 641 754 642 755 return 643 perform_filter_op (sample, (char *) d->Name,644 (SweepFilter) ladspa_meta_apply_filter,756 perform_filter_op (sample, (char *) d->Name, 757 (SweepFilter) ladspa_meta_apply_filter, 645 758 pset, custom_data); 646 759 } … … 658 771 #define PATH_LEN 256 659 772 gchar path[PATH_LEN]; 660 void * module;773 void *module; 661 774 LADSPA_Descriptor_Function desc_func; 662 const LADSPA_Descriptor * d;775 const LADSPA_Descriptor *d; 663 776 LADSPA_PortDescriptor pd; 664 777 gint i, j, k, nr_params; 665 778 int valid_mask; 666 sw_procedure * proc;779 sw_procedure *proc; 667 780 668 781 snprintf (path, PATH_LEN, "%s/%s", dir, name); 669 782 670 783 module = dlopen (path, RTLD_NOW); 671 if (!module) return; 784 if (!module) 785 return; 672 786 673 787 modules_list = g_list_append (modules_list, module); 674 788 675 if ((desc_func = dlsym (module, "ladspa_descriptor"))) { 676 for (i=0; (d = desc_func (i)) != NULL; i++) { 677 678 if (!is_usable(d)) 679 continue; 680 681 proc = g_malloc0 (sizeof (*proc)); 682 proc->name = (gchar *)d->Name; 683 proc->author = (gchar *)d->Maker; 684 proc->copyright = (gchar *)d->Copyright; 685 686 nr_params=0; 687 for (j=0; j < d->PortCount; j++) { 688 pd = d->PortDescriptors[j]; 689 if (LADSPA_IS_CONTROL_INPUT(pd)) { 690 nr_params++; 691 } 692 } 693 694 proc->nr_params = nr_params; 695 proc->param_specs = 696 (sw_param_spec *)g_malloc0 (nr_params * sizeof (sw_param_spec)); 697 698 k=0; 699 for (j=0; j < d->PortCount; j++) { 700 pd = d->PortDescriptors[j]; 701 if (LADSPA_IS_CONTROL_INPUT(pd)) { 702 proc->param_specs[k].name = (gchar *)d->PortNames[j]; 703 proc->param_specs[k].desc = (gchar *)d->PortNames[j]; 704 proc->param_specs[k].type = 705 convert_type (d->PortRangeHints[j].HintDescriptor); 706 valid_mask = get_valid_mask (d->PortRangeHints[j].HintDescriptor); 707 if (valid_mask == 0) { 708 proc->param_specs[k].constraint_type = SW_PARAM_CONSTRAINED_NOT; 709 } else { 710 proc->param_specs[k].constraint_type = SW_PARAM_CONSTRAINED_RANGE; 711 proc->param_specs[k].constraint.range = 712 convert_constraint (&d->PortRangeHints[j]); 713 } 714 k++; 715 } 716 } 717 718 proc->suggest = ladspa_meta_suggest; 719 720 proc->apply = ladspa_meta_apply; 721 722 proc->custom_data = lm_custom_new (d, proc->param_specs); 723 724 *gl = g_list_append (*gl, proc); 725 } 726 } 789 if ((desc_func = dlsym (module, "ladspa_descriptor"))) 790 { 791 for (i = 0; (d = desc_func (i)) != NULL; i++) 792 { 793 794 if (!is_usable (d)) 795 continue; 796 797 proc = g_malloc0 (sizeof (*proc)); 798 proc->name = (gchar *) d->Name; 799 proc->author = (gchar *) d->Maker; 800 proc->copyright = (gchar *) d->Copyright; 801 802 nr_params = 0; 803 for (j = 0; j < d->PortCount; j++) 804 { 805 pd = d->PortDescriptors[j]; 806 if (LADSPA_IS_CONTROL_INPUT (pd)) 807 { 808 nr_params++; 809 } 810 } 811 812 proc->nr_params = nr_params; 813 proc->param_specs = 814 (sw_param_spec *) g_malloc0 (nr_params * sizeof (sw_param_spec)); 815 816 k = 0; 817 for (j = 0; j < d->PortCount; j++) 818 { 819 pd = d->PortDescriptors[j]; 820 if (LADSPA_IS_CONTROL_INPUT (pd)) 821 { 822 proc->param_specs[k].name = (gchar *) d->PortNames[j]; 823 proc->param_specs[k].desc = (gchar *) d->PortNames[j]; 824 proc->param_specs[k].type = 825 convert_type (d->PortRangeHints[j].HintDescriptor); 826 valid_mask = 827 get_valid_mask (d->PortRangeHints[j].HintDescriptor); 828 if (valid_mask == 0) 829 { 830 proc->param_specs[k].constraint_type = 831 SW_PARAM_CONSTRAINED_NOT; 832 } 833 else 834 { 835 proc->param_specs[k].constraint_type = 836 SW_PARAM_CONSTRAINED_RANGE; 837 proc->param_specs[k].constraint.range = 838 convert_constraint (&d->PortRangeHints[j]); 839 } 840 k++; 841 } 842 } 843 844 proc->suggest = ladspa_meta_suggest; 845 846 proc->apply = ladspa_meta_apply; 847 848 proc->custom_data = lm_custom_new (d, proc->param_specs); 849 850 *gl = g_list_append (*gl, proc); 851 } 852 } 727 853 } 728 854 … … 736 862 ladspa_meta_init_dir (gchar * dirname, GList ** gl) 737 863 { 738 DIR * dir; 739 struct dirent * dirent; 740 char * name; 741 742 if (!dirname) return; 864 DIR *dir; 865 struct dirent *dirent; 866 char *name; 867 868 if (!dirname) 869 return; 743 870 744 871 dir = opendir (dirname); 745 if (!dir) { 746 return; 747 } 748 749 while ((dirent = readdir (dir)) != NULL) { 750 name = dirent->d_name; 751 if (strcmp (name, ".") && strcmp (name, "..")) 752 ladspa_meta_add_procs (dirname, dirent->d_name, gl); 753 } 872 if (!dir) 873 { 874 return; 875 } 876 877 while ((dirent = readdir (dir)) != NULL) 878 { 879 name = dirent->d_name; 880 if (strcmp (name, ".") && strcmp (name, "..")) 881 ladspa_meta_add_procs (dirname, dirent->d_name, gl); 882 } 754 883 } 755 884 … … 757 886 ladspa_meta_init (void) 758 887 { 759 GList * gl = NULL;760 char * ladspa_path=NULL;761 char * next_sep=NULL;762 char * saved_lp=NULL;888 GList *gl = NULL; 889 char *ladspa_path = NULL; 890 char *next_sep = NULL; 891 char *saved_lp = NULL; 763 892 764 893 /* If this ladspa_meta module has already been initialised, don't … … 770 899 ladspa_path = getenv ("LADSPA_PATH"); 771 900 if (!ladspa_path) 772 ladspa_path = saved_lp = strdup(default_ladspa_path); 773 774 do { 775 next_sep = strchr (ladspa_path, ':'); 776 if (next_sep != NULL) *next_sep = '\0'; 777 778 ladspa_meta_init_dir (ladspa_path, &gl); 779 780 if (next_sep != NULL) ladspa_path = ++next_sep; 781 782 } while ((next_sep != NULL) && (*next_sep != '\0')); 901 ladspa_path = saved_lp = strdup (default_ladspa_path); 902 903 do 904 { 905 next_sep = strchr (ladspa_path, ':'); 906 if (next_sep != NULL) 907 *next_sep = '\0'; 908 909 ladspa_meta_init_dir (ladspa_path, &gl); 910 911 if (next_sep != NULL) 912 ladspa_path = ++next_sep; 913 914 } 915 while ((next_sep != NULL) && (*next_sep != '\0')); 783 916 784 917 ladspa_meta_initialised = TRUE; 785 918 786 919 /* free string if dup'd for ladspa_path */ 787 if (saved_lp != NULL) free(saved_lp); 920 if (saved_lp != NULL) 921 free (saved_lp); 788 922 789 923 return gl; … … 793 927 ladspa_meta_cleanup (void) 794 928 { 795 GList * gl; 796 797 if (!ladspa_meta_initialised) return; 798 799 for (gl = modules_list; gl; gl = gl->next) { 800 dlclose(gl->data); 801 } 929 GList *gl; 930 931 if (!ladspa_meta_initialised) 932 return; 933 934 for (gl = modules_list; gl; gl = gl->next) 935 { 936 dlclose (gl->data); 937 } 802 938 } 803 939 804 940 sw_plugin plugin = { 805 ladspa_meta_init, /* plugin_init */806 ladspa_meta_cleanup, /* plugin_cleanup */941 ladspa_meta_init, /* plugin_init */ 942 ladspa_meta_cleanup, /* plugin_cleanup */ 807 943 }; sweep/branches/display-cache/plugins/normalise/normalise.c
r125 r471 26 26 #include <sweep/sweep.h> 27 27 28 #include <../src/sweep_app.h> /* XXX */28 #include <../src/sweep_app.h> /* XXX */ 29 29 30 30 static sw_sample * 31 31 normalise (sw_sample * sample, sw_param_set pset, gpointer custom_data) 32 32 { 33 sw_sounddata * sounddata;34 sw_format * f;35 GList * gl;36 sw_sel * sel;37 sw_audio_t * d;33 sw_sounddata *sounddata; 34 sw_format *f; 35 GList *gl; 36 sw_sel *sel; 37 sw_audio_t *d; 38 38 sw_audio_t max = 0; 39 39 gfloat factor = 1.0; … … 47 47 f = sounddata->format; 48 48 49 op_total = sounddata_selection_nr_frames (sounddata) * 2 / 100;/* 2 passes */ 50 if (op_total == 0) op_total = 1; 49 op_total = sounddata_selection_nr_frames (sounddata) * 2 / 100; /* 2 passes */ 50 if (op_total == 0) 51 op_total = 1; 51 52 run_total = 0; 52 53 53 54 /* Find max */ 54 for (gl = sounddata->sels; active && gl; gl = gl->next) { 55 sel = (sw_sel *)gl->data; 55 for (gl = sounddata->sels; active && gl; gl = gl->next) 56 { 57 sel = (sw_sel *) gl->data; 56 58 57 offset = 0;58 remaining = sel->sel_end - sel->sel_start;59 offset = 0; 60 remaining = sel->sel_end - sel->sel_start; 59 61 60 while (active && remaining > 0) { 61 g_mutex_lock (sample->ops_mutex); 62 while (active && remaining > 0) 63 { 64 g_mutex_lock (sample->ops_mutex); 62 65 63 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 64 active = FALSE; 65 } else { 66 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 67 { 68 active = FALSE; 69 } 70 else 71 { 66 72 67 d = sounddata->data + frames_to_bytes (f, sel->sel_start + offset); 73 d = 74 sounddata->data + frames_to_bytes (f, 75 sel->sel_start + offset); 68 76 69 n = MIN(remaining, 1024);77 n = MIN (remaining, 1024); 70 78 71 for (i=0; i < n * f->channels; i++) { 72 if(d[i]>=0) max = MAX(max, d[i]); 73 else max = MAX(max, -d[i]); 79 for (i = 0; i < n * f->channels; i++) 80 { 81 if (d[i] >= 0) 82 max = MAX (max, d[i]); 83 else 84 max = MAX (max, -d[i]); 85 } 86 87 remaining -= n; 88 offset += n; 89 90 run_total += n; 91 sample_set_progress_percent (sample, run_total / op_total); 92 } 93 94 g_mutex_unlock (sample->ops_mutex); 74 95 } 96 } 75 97 76 remaining -= n; 77 offset += n; 78 79 run_total += n; 80 sample_set_progress_percent (sample, run_total / op_total); 81 } 82 83 g_mutex_unlock (sample->ops_mutex); 84 } 85 } 86 87 if (max != 0) factor = SW_AUDIO_T_MAX / (gfloat)max; 98 if (max != 0) 99 factor = SW_AUDIO_T_MAX / (gfloat) max; 88 100 89 101 /* Scale */ 90 for (gl = sounddata->sels; active && gl; gl = gl->next) { 91 sel = (sw_sel *)gl->data; 102 for (gl = sounddata->sels; active && gl; gl = gl->next) 103 { 104 sel = (sw_sel *) gl->data; 92 105 93 offset = 0;94 remaining = sel->sel_end - sel->sel_start;106 offset = 0; 107 remaining = sel->sel_end - sel->sel_start; 95 108 96 while (active && remaining > 0) { 97 g_mutex_lock (sample->ops_mutex); 109 while (active && remaining > 0) 110 { 111 g_mutex_lock (sample->ops_mutex); 98 112 99 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 100 active = FALSE; 101 } else { 102 d = sounddata->data + frames_to_bytes (f, sel->sel_start + offset); 113 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 114 { 115 active = FALSE; 116 } 117 else 118 { 119 d = 120 sounddata->data + frames_to_bytes (f, 121 sel->sel_start + offset); 103 122 104 n = MIN(remaining, 1024);123 n = MIN (remaining, 1024); 105 124 106 for (i=0; i < n * f->channels; i++) { 107 d[i] = (sw_audio_t)((gfloat)d[i] * factor); 125 for (i = 0; i < n * f->channels; i++) 126 { 127 d[i] = (sw_audio_t) ((gfloat) d[i] * factor); 128 } 129 130 remaining -= n; 131 offset += n; 132 133 run_total += n; 134 sample_set_progress_percent (sample, 135 run_total * 100 / op_total); 136 } 137 138 g_mutex_unlock (sample->ops_mutex); 108 139 } 109 110 remaining -= n;111 offset += n;112 113 run_total += n;114 sample_set_progress_percent (sample, run_total * 100 / op_total);115 }116 117 g_mutex_unlock (sample->ops_mutex);118 140 } 119 }120 141 121 142 return sample; … … 123 144 124 145 static sw_op_instance * 125 apply_normalise (sw_sample * sample, sw_param_set pset, gpointer custom_data)146 apply_normalise (sw_sample * sample, sw_param_set pset, gpointer custom_data) 126 147 { 127 148 return 128 perform_filter_op (sample, _("Normalise"), (SweepFilter) normalise,149 perform_filter_op (sample, _("Normalise"), (SweepFilter) normalise, 129 150 pset, NULL); 130 151 } … … 136 157 "Copyright (C) 2000", 137 158 "http://sweep.sourceforge.net/plugins/normalise", 138 "Filters/Normalise", /* identifier */139 GDK_n, /* accel_key */140 GDK_SHIFT_MASK, /* accel_mods */141 0, /* nr_params */142 NULL, /* param_specs */143 NULL, /* suggests() */159 "Filters/Normalise", /* identifier */ 160 GDK_n, /* accel_key */ 161 GDK_SHIFT_MASK, /* accel_mods */ 162 0, /* nr_params */ 163 NULL, /* param_specs */ 164 NULL, /* suggests() */ 144 165 apply_normalise, 145 NULL, /* custom_data */166 NULL, /* custom_data */ 146 167 }; 147 168 148 169 static GList * 149 170 normalise_init (void) 150 171 { 151 return g_list_append ((GList *) NULL, &proc_normalise);172 return g_list_append ((GList *) NULL, &proc_normalise); 152 173 } 153 174 154 175 155 176 sw_plugin plugin = { 156 normalise_init, /* plugin_init */157 NULL, /* plugin_cleanup */177 normalise_init, /* plugin_init */ 178 NULL, /* plugin_cleanup */ 158 179 }; sweep/branches/display-cache/plugins/reverse/reverse.c
r125 r471 26 26 #include <sweep/sweep.h> 27 27 28 #include "../src/sweep_app.h" /* XXX */28 #include "../src/sweep_app.h" /* XXX */ 29 29 30 30 #if 0 … … 42 42 e = d + frames_to_bytes (format, nr_frames); 43 43 44 for (i = 0; i <= nr_frames/2; i++) { 45 memcpy (t, d, sw); 46 memcpy (d, e, sw); 47 memcpy (e, t, sw); 48 49 d += sw; 50 e -= sw; 51 } 44 for (i = 0; i <= nr_frames / 2; i++) 45 { 46 memcpy (t, d, sw); 47 memcpy (d, e, sw); 48 memcpy (e, t, sw); 49 50 d += sw; 51 e -= sw; 52 } 52 53 53 54 g_free (t); … … 59 60 gpointer custom_data) 60 61 { 61 GList * gl;62 sw_sel * sel;62 GList *gl; 63 sw_sel *sel; 63 64 glong i, sw; 64 sw_sounddata * sounddata;65 sw_format * format;65 sw_sounddata *sounddata; 66 sw_format *format; 66 67 sw_framecount_t nr_frames; 67 68 gpointer d, e, t; … … 76 77 77 78 op_total = sounddata_selection_nr_frames (sounddata) / 200; 78 if (op_total == 0) op_total = 1; 79 if (op_total == 0) 80 op_total = 1; 79 81 run_total = 0; 80 82 … … 82 84 t = alloca (sw); 83 85 84 for (gl = sounddata->sels; active && gl; gl = gl->next) { 85 sel = (sw_sel *)gl->data; 86 for (gl = sounddata->sels; active && gl; gl = gl->next) 87 { 88 sel = (sw_sel *) gl->data; 86 89 87 d = sounddata->data + frames_to_bytes (format, sel->sel_start);88 nr_frames = sel->sel_end - sel->sel_start;90 d = sounddata->data + frames_to_bytes (format, sel->sel_start); 91 nr_frames = sel->sel_end - sel->sel_start; 89 92 90 e = d + frames_to_bytes (format, nr_frames); 91 92 remaining = nr_frames/2; 93 e = d + frames_to_bytes (format, nr_frames); 93 94 94 while (active && remaining > 0) { 95 g_mutex_lock (sample->ops_mutex); 95 remaining = nr_frames / 2; 96 96 97 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 98 active = FALSE; 99 } else { 100 n = MIN (remaining, 1024); 97 while (active && remaining > 0) 98 { 99 g_mutex_lock (sample->ops_mutex); 101 100 102 for (i = 0; i <= n; i++) { 103 memcpy (t, d, sw); 104 memcpy (d, e, sw); 105 memcpy (e, t, sw); 106 107 d += sw; 108 e -= sw; 101 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 102 { 103 active = FALSE; 104 } 105 else 106 { 107 n = MIN (remaining, 1024); 108 109 for (i = 0; i <= n; i++) 110 { 111 memcpy (t, d, sw); 112 memcpy (d, e, sw); 113 memcpy (e, t, sw); 114 115 d += sw; 116 e -= sw; 117 } 118 119 remaining -= n; 120 121 run_total += n; 122 sample_set_progress_percent (sample, run_total / op_total); 123 } 124 125 g_mutex_unlock (sample->ops_mutex); 109 126 } 110 111 remaining -= n;112 113 run_total += n;114 sample_set_progress_percent (sample, run_total / op_total);115 }116 117 g_mutex_unlock (sample->ops_mutex);118 127 } 119 }120 128 121 129 return sample; … … 128 136 return 129 137 perform_filter_region_op (sample, _("Reverse"), 130 (SweepFilterRegion)region_reverse, pset, NULL);138 (SweepFilterRegion) region_reverse, pset, NULL); 131 139 #endif 132 140 133 141 return 134 142 perform_filter_op (sample, _("Reverse"), 135 (SweepFilter) sounddata_reverse, pset, NULL);143 (SweepFilter) sounddata_reverse, pset, NULL); 136 144 } 137 145 … … 143 151 "Copyright (C) 2000", 144 152 "http://sweep.sourceforge.net/plugins/reverse", 145 "Filters/Reverse", /* identifier */146 GDK_f, /* accel_key */147 GDK_SHIFT_MASK, /* accel_mods */148 0, /* nr_params */149 NULL, /* param_specs */150 NULL, /* suggests() */153 "Filters/Reverse", /* identifier */ 154 GDK_f, /* accel_key */ 155 GDK_SHIFT_MASK, /* accel_mods */ 156 0, /* nr_params */ 157 NULL, /* param_specs */ 158 NULL, /* suggests() */ 151 159 apply_reverse, 152 NULL, /* custom_data */160 NULL, /* custom_data */ 153 161 }; 154 162 … … 156 164 reverse_init (void) 157 165 { 158 return g_list_append ((GList *) NULL, &proc_reverse);166 return g_list_append ((GList *) NULL, &proc_reverse); 159 167 } 160 168 161 169 162 170 sw_plugin plugin = { 163 reverse_init, /* plugin_init */164 NULL, /* plugin_cleanup */171 reverse_init, /* plugin_init */ 172 NULL, /* plugin_cleanup */ 165 173 }; sweep/branches/display-cache/po/fr.po
r402 r471 4 4 # 5 5 #: src/sample-display.c:220 6 #, fuzzy7 6 msgid "" 8 7 msgstr "" sweep/branches/display-cache/po/pl.po
r402 r471 2634 2634 c do ciszy" 2635 2635 2636 #~ msgid "About Sweep"2637 #~ msgstr "O programie Sweep"2638 2639 #~ msgid "Channels:"2640 #~ msgstr "Kanały:"2641 2642 #~ msgid "Mono (mixdown)"2643 #~ msgstr "Mono (wymieszane)"2644 2645 #~ msgid "Stereo (duplicate)"2646 #~ msgstr "Stereo (powielone)"2647 2648 #~ msgid "Bitwidth:"2649 #~ msgstr "Szerokość bitowa:"2650 2651 #~ msgid "8 bit"2652 #~ msgstr "8 bit"2653 2654 #~ msgid "16 bit"2655 #~ msgstr "16 bit"2656 2657 #~ msgid "24 bit"2658 #~ msgstr "24 bit"2659 2660 #~ msgid "32 bit"2661 #~ msgstr "32 bit"sweep/branches/display-cache/src/about_dialog.c
r409 r471 36 36 37 37 38 static void about_dialog_destroy(void); 39 static int about_dialog_button(GtkWidget * widget, 40 GdkEventButton * event); 38 static void about_dialog_destroy (void); 39 static int about_dialog_button (GtkWidget * widget, GdkEventButton * event); 41 40 42 41 static GtkWidget *about_dialog = NULL; … … 49 48 50 49 void 51 about_dialog_create ()50 about_dialog_create () 52 51 { 53 /* FIXME: for unused about box font style, reimplement?)54 * GtkStyle *style;55 */52 /* FIXME: for unused about box font style, reimplement?) 53 * GtkStyle *style; 54 */ 56 55 GtkWidget *vbox; 57 56 GtkWidget *label; 58 57 #define BUF_LEN 64 59 58 gchar buf[BUF_LEN]; 60 GtkWidget * button;61 GtkWidget * about_image;62 GtkWidget * about_ebox;59 GtkWidget *button; 60 GtkWidget *about_image; 61 GtkWidget *about_ebox; 63 62 gchar buf2[1024]; 64 63 65 if (!about_dialog) { 66 about_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); 67 gtk_window_set_type_hint (GTK_WINDOW(about_dialog), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); 68 gtk_window_set_decorated ( GTK_WINDOW (about_dialog), FALSE); 69 gtk_window_set_wmclass(GTK_WINDOW(about_dialog), "about_dialog", "Sweep"); 70 gtk_window_set_resizable (GTK_WINDOW(about_dialog), FALSE); 71 gtk_window_set_position (GTK_WINDOW(about_dialog), GTK_WIN_POS_CENTER); 72 g_signal_connect(GTK_OBJECT(about_dialog), "destroy", 73 G_CALLBACK(about_dialog_destroy), NULL); 74 g_signal_connect(GTK_OBJECT(about_dialog), "button_press_event", 75 G_CALLBACK(about_dialog_button), NULL); 76 gtk_widget_set_events(about_dialog, GDK_BUTTON_PRESS_MASK); 64 if (!about_dialog) 65 { 66 about_dialog = gtk_window_new (GTK_WINDOW_TOPLEVEL); 67 gtk_window_set_type_hint (GTK_WINDOW (about_dialog), 68 GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); 69 gtk_window_set_decorated (GTK_WINDOW (about_dialog), FALSE); 70 gtk_window_set_wmclass (GTK_WINDOW (about_dialog), "about_dialog", 71 "Sweep"); 72 gtk_window_set_resizable (GTK_WINDOW (about_dialog), FALSE); 73 gtk_window_set_position (GTK_WINDOW (about_dialog), GTK_WIN_POS_CENTER); 74 g_signal_connect (GTK_OBJECT (about_dialog), "destroy", 75 G_CALLBACK (about_dialog_destroy), NULL); 76 g_signal_connect (GTK_OBJECT (about_dialog), "button_press_event", 77 G_CALLBACK (about_dialog_button), NULL); 78 gtk_widget_set_events (about_dialog, GDK_BUTTON_PRESS_MASK); 77 79 78 80 79 81 80 vbox = gtk_vbox_new(FALSE, 1);81 gtk_container_add(GTK_CONTAINER(about_dialog), vbox);82 gtk_widget_show(vbox);82 vbox = gtk_vbox_new (FALSE, 1); 83 gtk_container_add (GTK_CONTAINER (about_dialog), vbox); 84 gtk_widget_show (vbox); 83 85 84 about_ebox = gtk_event_box_new();85 gtk_box_pack_start(GTK_BOX(vbox), about_ebox, TRUE, TRUE, 0);86 gtk_widget_show(about_ebox);87 snprintf(buf2, sizeof (buf2), "%s/sweep_splash.png", PACKAGE_DATA_DIR);88 about_image = gtk_image_new_from_file (buf2);89 gtk_container_add(GTK_CONTAINER(about_ebox), about_image);90 gtk_widget_show(about_ebox);91 gtk_widget_show(about_image);86 about_ebox = gtk_event_box_new (); 87 gtk_box_pack_start (GTK_BOX (vbox), about_ebox, TRUE, TRUE, 0); 88 gtk_widget_show (about_ebox); 89 snprintf (buf2, sizeof (buf2), "%s/sweep_splash.png", PACKAGE_DATA_DIR); 90 about_image = gtk_image_new_from_file (buf2); 91 gtk_container_add (GTK_CONTAINER (about_ebox), about_image); 92 gtk_widget_show (about_ebox); 93 gtk_widget_show (about_image); 92 94 93 /* FIXME: old gtk font code. reimplement?94 * style = gtk_style_new();95 * gdk_font_unref(style->font);96 * style->font = gdk_font_load("-Adobe-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*");97 * gtk_widget_push_style(style);98 */99 snprintf (buf, BUF_LEN, "%s %s", _("This is Sweep version"), VERSION);100 label = gtk_label_new(buf);101 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);102 gtk_widget_show(label);95 /* FIXME: old gtk font code. reimplement? 96 * style = gtk_style_new(); 97 * gdk_font_unref(style->font); 98 * style->font = gdk_font_load("-Adobe-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*"); 99 * gtk_widget_push_style(style); 100 */ 101 snprintf (buf, BUF_LEN, "%s %s", _("This is Sweep version"), VERSION); 102 label = gtk_label_new (buf); 103 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); 104 gtk_widget_show (label); 103 105 104 106 #if 0 105 label = gtk_label_new("Copyright (c) 2000 Conrad Parker, conrad@vergenet.net"); 106 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0); 107 gtk_widget_show(label); 107 label = 108 gtk_label_new 109 ("Copyright (c) 2000 Conrad Parker, conrad@vergenet.net"); 110 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); 111 gtk_widget_show (label); 108 112 #endif 109 113 110 /* FIXME: old style code111 * gtk_widget_pop_style();112 */114 /* FIXME: old style code 115 * gtk_widget_pop_style(); 116 */ 113 117 114 118 #if 0 115 alignment = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);116 gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, TRUE, 0);117 gtk_widget_show(alignment);119 alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); 120 gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, TRUE, 0); 121 gtk_widget_show (alignment); 118 122 119 label = gtk_label_new(_("http://sweep.sourceforge.net/"));120 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);121 gtk_widget_show(label);123 label = gtk_label_new (_("http://sweep.sourceforge.net/")); 124 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0); 125 gtk_widget_show (label); 122 126 #endif 123 127 124 button = gtk_button_new_with_label ("http://sweep.sourceforge.net/"); 125 gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, TRUE, 0); 126 gtk_widget_show (button); 127 g_signal_connect (GTK_OBJECT(button), "clicked", 128 G_CALLBACK(sweep_homepage), NULL); 129 } 130 if (!GTK_WIDGET_VISIBLE(about_dialog)) { 131 gtk_widget_show(about_dialog); 132 } else { 133 gdk_window_raise(about_dialog->window); 134 } 128 button = gtk_button_new_with_label ("http://sweep.sourceforge.net/"); 129 gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, TRUE, 0); 130 gtk_widget_show (button); 131 g_signal_connect (GTK_OBJECT (button), "clicked", 132 G_CALLBACK (sweep_homepage), NULL); 133 } 134 if (!GTK_WIDGET_VISIBLE (about_dialog)) 135 { 136 gtk_widget_show (about_dialog); 137 } 138 else 139 { 140 gdk_window_raise (about_dialog->window); 141 } 135 142 } 136 143 137 144 static void 138 about_dialog_destroy ()145 about_dialog_destroy () 139 146 { 140 147 about_dialog = NULL; … … 142 149 143 150 static int 144 about_dialog_button(GtkWidget * widget, 145 GdkEventButton * event) 151 about_dialog_button (GtkWidget * widget, GdkEventButton * event) 146 152 { 147 gtk_widget_hide (about_dialog);153 gtk_widget_hide (about_dialog); 148 154 149 155 return FALSE; sweep/branches/display-cache/src/about_dialog.h
r7 r471 22 22 #define __ABOUT_DIALOG_H__ 23 23 24 void about_dialog_create (void);24 void about_dialog_create (void); 25 25 26 26 #endif /* __ABOUT_DIALOG_H__ */ sweep/branches/display-cache/src/callbacks.c
r285 r471 71 71 sample_new_empty_cb (GtkWidget * widget, gpointer data) 72 72 { 73 sw_view * view = (sw_view *)data; 74 75 if (view == NULL) { 76 create_sample_new_dialog_defaults (NULL); 77 } else { 78 create_sample_new_dialog_like (view->sample); 79 } 73 sw_view *view = (sw_view *) data; 74 75 if (view == NULL) 76 { 77 create_sample_new_dialog_defaults (NULL); 78 } 79 else 80 { 81 create_sample_new_dialog_like (view->sample); 82 } 80 83 } 81 84 … … 83 86 sample_new_copy_cb (GtkWidget * widget, gpointer data) 84 87 { 85 sw_sample * ns;86 SampleDisplay * sd = SAMPLE_DISPLAY(data);87 sw_sample * s;88 sw_view * v;88 sw_sample *ns; 89 SampleDisplay *sd = SAMPLE_DISPLAY (data); 90 sw_sample *s; 91 sw_view *v; 89 92 90 93 s = sd->view->sample; 91 94 92 if(!s) return; 93 94 ns = sample_new_copy(s); 95 96 while (ns->color == s->color) { 97 ns->color = (random()) % VIEW_COLOR_MAX; 98 } 95 if (!s) 96 return; 97 98 ns = sample_new_copy (s); 99 100 while (ns->color == s->color) 101 { 102 ns->color = (random ()) % VIEW_COLOR_MAX; 103 } 99 104 100 105 v = view_new_all (ns, 1.0); 101 106 sample_add_view (ns, v); 102 107 103 sample_bank_add (ns);108 sample_bank_add (ns); 104 109 } 105 110 … … 110 115 { 111 116 function (data); 112 if (view->repeater_tag <= 0) { 113 view->repeater_tag = g_timeout_add ((guint32)1000/ZOOM_FRAMERATE, 117 if (view->repeater_tag <= 0) 118 { 119 view->repeater_tag = g_timeout_add ((guint32) 1000 / ZOOM_FRAMERATE, 114 120 (GSourceFunc) function, data); 115 }121 } 116 122 } 117 123 … … 119 125 repeater_released_cb (GtkWidget * widget, gpointer data) 120 126 { 121 sw_view * view = (sw_view *)data; 122 123 if (view->repeater_tag > 0) { 124 g_source_remove(view->repeater_tag); 125 view->repeater_tag = 0; 126 } 127 sw_view *view = (sw_view *) data; 128 129 if (view->repeater_tag > 0) 130 { 131 g_source_remove (view->repeater_tag); 132 view->repeater_tag = 0; 133 } 127 134 } 128 135 … … 132 139 view_new_all_cb (GtkWidget * widget, gpointer data) 133 140 { 134 SampleDisplay * sd = SAMPLE_DISPLAY(data);135 sw_sample * s;136 sw_view * v;141 SampleDisplay *sd = SAMPLE_DISPLAY (data); 142 sw_sample *s; 143 sw_view *v; 137 144 138 145 s = sd->view->sample; 139 v = view_new_all (s, 1.0);146 v = view_new_all (s, 1.0); 140 147 141 148 sample_add_view (s, v); … … 145 152 view_new_cb (GtkWidget * widget, gpointer data) 146 153 { 147 SampleDisplay * sd = SAMPLE_DISPLAY(data);148 sw_sample * s;149 sw_view * view, *v;154 SampleDisplay *sd = SAMPLE_DISPLAY (data); 155 sw_sample *s; 156 sw_view *view, *v; 150 157 151 158 v = sd->view; … … 160 167 view_close_cb (GtkWidget * widget, gpointer data) 161 168 { 162 SampleDisplay * sd = SAMPLE_DISPLAY(data);163 sw_view * v;169 SampleDisplay *sd = SAMPLE_DISPLAY (data); 170 sw_view *v; 164 171 165 172 v = sd->view; 166 173 167 view_close (v);174 view_close (v); 168 175 } 169 176 … … 179 186 { 180 187 #if 0 181 gint tool = (gint) data;182 183 /* current_tool = tool; */188 gint tool = (gint) data; 189 190 /* current_tool = tool; */ 184 191 #endif 185 192 g_print ("NOOOOOOOOOOOOOO global current_tool\n"); … … 189 196 view_set_tool_cb (GtkWidget * widget, gpointer data) 190 197 { 191 sw_view * view = (sw_view *)data;198 sw_view *view = (sw_view *) data; 192 199 sw_tool_t tool; 193 200 194 201 tool = (sw_tool_t) 195 GPOINTER_TO_INT (g_object_get_data (G_OBJECT(widget), "default"));202 GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "default")); 196 203 197 204 view->current_tool = tool; … … 205 212 zoom_in_step (gpointer data) 206 213 { 207 sw_view * view = (sw_view *)data;214 sw_view *view = (sw_view *) data; 208 215 209 216 view_zoom_in (view, DEFAULT_ZOOM); … … 215 222 zoom_in_cb (GtkWidget * widget, gpointer data) 216 223 { 217 sw_view * view = (sw_view *)data;224 sw_view *view = (sw_view *) data; 218 225 view_zoom_in (view, DEFAULT_ZOOM); 219 226 } … … 222 229 zoom_out_step (gpointer data) 223 230 { 224 sw_view * view = (sw_view *)data;231 sw_view *view = (sw_view *) data; 225 232 226 233 view_zoom_out (view, DEFAULT_ZOOM); … … 232 239 zoom_out_cb (GtkWidget * widget, gpointer data) 233 240 { 234 sw_view * view = (sw_view *)data;241 sw_view *view = (sw_view *) data; 235 242 view_zoom_out (view, DEFAULT_ZOOM); 236 243 } … … 240 247 zoom_in_pressed_cb (GtkWidget * widget, gpointer data) 241 248 { 242 sw_view * view = (sw_view *)data;249 sw_view *view = (sw_view *) data; 243 250 244 251 view_zoom_in (view, DEFAULT_ZOOM); 245 view_init_repeater (view, (GtkFunction) zoom_in_step, data);252 view_init_repeater (view, (GtkFunction) zoom_in_step, data); 246 253 } 247 254 … … 249 256 zoom_out_pressed_cb (GtkWidget * widget, gpointer data) 250 257 { 251 sw_view * view = (sw_view *)data;258 sw_view *view = (sw_view *) data; 252 259 253 260 view_zoom_out (view, DEFAULT_ZOOM); 254 view_init_repeater (view, (GtkFunction) zoom_out_step, data);261 view_init_repeater (view, (GtkFunction) zoom_out_step, data); 255 262 } 256 263 … … 258 265 zoom_to_sel_cb (GtkWidget * widget, gpointer data) 259 266 { 260 SampleDisplay * sd = SAMPLE_DISPLAY(data);261 sw_view * v = sd->view;267 SampleDisplay *sd = SAMPLE_DISPLAY (data); 268 sw_view *v = sd->view; 262 269 263 270 view_zoom_to_sel (v); … … 267 274 zoom_left_cb (GtkWidget * widget, gpointer data) 268 275 { 269 SampleDisplay * sd = SAMPLE_DISPLAY(data);270 sw_view * v = sd->view;276 SampleDisplay *sd = SAMPLE_DISPLAY (data); 277 sw_view *v = sd->view; 271 278 272 279 view_zoom_left (v); … … 276 283 zoom_right_cb (GtkWidget * widget, gpointer data) 277 284 { 278 SampleDisplay * sd = SAMPLE_DISPLAY(data);279 sw_view * v = sd->view;285 SampleDisplay *sd = SAMPLE_DISPLAY (data); 286 sw_view *v = sd->view; 280 287 281 288 view_zoom_right (v); … … 285 292 zoom_all_cb (GtkWidget * widget, gpointer data) 286 293 { 287 sw_view * v = (sw_view *)data;294 sw_view *v = (sw_view *) data; 288 295 289 296 view_zoom_all (v); … … 294 301 zoom_2_1_cb (GtkWidget * widget, gpointer data) 295 302 { 296 SampleDisplay * sd = SAMPLE_DISPLAY(data);297 sw_sample * s;303 SampleDisplay *sd = SAMPLE_DISPLAY (data); 304 sw_sample *s; 298 305 299 306 s = sd->view->sample; 300 307 301 view_set_ends (sd->view,302 s->sounddata->nr_frames / 4,303 3 * s->sounddata->nr_frames / 4);308 view_set_ends (sd->view, 309 s->sounddata->nr_frames / 4, 310 3 * s->sounddata->nr_frames / 4); 304 311 } 305 312 … … 307 314 zoom_norm_cb (GtkWidget * widget, gpointer data) 308 315 { 309 SampleDisplay * sd = SAMPLE_DISPLAY(data);310 sw_view * view = sd->view;316 SampleDisplay *sd = SAMPLE_DISPLAY (data); 317 sw_view *view = sd->view; 311 318 312 319 view_zoom_normal (view); … … 316 323 zoom_1to1_cb (GtkWidget * widget, gpointer data) 317 324 { 318 SampleDisplay * sd = SAMPLE_DISPLAY(data);325 SampleDisplay *sd = SAMPLE_DISPLAY (data); 319 326 320 327 view_zoom_length (sd->view, sd->width); … … 325 332 zoom_center_cb (GtkWidget * widget, gpointer data) 326 333 { 327 SampleDisplay * sd = SAMPLE_DISPLAY(data);334 SampleDisplay *sd = SAMPLE_DISPLAY (data); 328 335 329 336 view_center_on (sd->view, sd->view->sample->user_offset); … … 333 340 zoom_combo_changed_cb (GtkWidget * widget, gpointer data) 334 341 { 335 sw_view * view = (sw_view *)data;336 gchar * text;342 sw_view *view = (sw_view *) data; 343 gchar *text; 337 344 sw_time_t zoom_time; 338 345 sw_framecount_t zoom_length; 339 346 340 text = (gchar *) gtk_entry_get_text (GTK_ENTRY(widget)); 341 342 if (!strcmp (text, "All")) { 343 view_zoom_all (view); 344 } else { 345 zoom_time = (sw_time_t)strtime_to_seconds (text); 346 if (zoom_time != -1.0) { 347 zoom_length = 348 time_to_frames (view->sample->sounddata->format, zoom_time); 349 350 view_zoom_length (view, zoom_length); 351 352 /* Work around a bug, probably in gtkcombo, whereby all the other 353 * widgets sometimes lost input after choosing a zoom */ 354 gtk_widget_grab_focus (view->display); 355 } 356 } 347 text = (gchar *) gtk_entry_get_text (GTK_ENTRY (widget)); 348 349 if (!strcmp (text, "All")) 350 { 351 view_zoom_all (view); 352 } 353 else 354 { 355 zoom_time = (sw_time_t) strtime_to_seconds (text); 356 if (zoom_time != -1.0) 357 { 358 zoom_length = 359 time_to_frames (view->sample->sounddata->format, zoom_time); 360 361 view_zoom_length (view, zoom_length); 362 363 /* Work around a bug, probably in gtkcombo, whereby all the other 364 * widgets sometimes lost input after choosing a zoom */ 365 gtk_widget_grab_focus (view->display); 366 } 367 } 357 368 } 358 369 … … 370 381 sample_set_color_cb (GtkWidget * widget, gpointer data) 371 382 { 372 sw_view * view = (sw_view *) data;383 sw_view *view = (sw_view *) data; 373 384 gint color; 374 385 375 color = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(widget), "default"));386 color = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "default")); 376 387 sample_set_color (view->sample, color); 377 388 } … … 382 393 follow_toggled_cb (GtkWidget * widget, gpointer data) 383 394 { 384 sw_view * view = (sw_view *) data;395 sw_view *view = (sw_view *) data; 385 396 gboolean active; 386 397 387 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));398 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 388 399 view_set_following (view, active); 389 400 } … … 392 403 follow_toggle_cb (GtkWidget * widget, gpointer data) 393 404 { 394 sw_view * view = (sw_view *)data;405 sw_view *view = (sw_view *) data; 395 406 view_set_following (view, !view->following); 396 407 } … … 399 410 loop_toggled_cb (GtkWidget * widget, gpointer data) 400 411 { 401 sw_view * view = (sw_view *) data;412 sw_view *view = (sw_view *) data; 402 413 gboolean active; 403 414 404 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));415 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 405 416 sample_set_looping (view->sample, active); 406 417 } … … 409 420 loop_toggle_cb (GtkWidget * widget, gpointer data) 410 421 { 411 sw_view * view = (sw_view *)data;422 sw_view *view = (sw_view *) data; 412 423 sample_set_looping (view->sample, !view->sample->play_head->looping); 413 424 } … … 416 427 playrev_toggled_cb (GtkWidget * widget, gpointer data) 417 428 { 418 sw_view * view = (sw_view *) data;429 sw_view *view = (sw_view *) data; 419 430 gboolean active; 420 431 421 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));432 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 422 433 sample_set_playrev (view->sample, active); 423 434 } … … 426 437 playrev_toggle_cb (GtkWidget * widget, gpointer data) 427 438 { 428 sw_view * view = (sw_view *)data;439 sw_view *view = (sw_view *) data; 429 440 sample_set_playrev (view->sample, !view->sample->play_head->reverse); 430 441 } … … 433 444 mute_toggled_cb (GtkWidget * widget, gpointer data) 434 445 { 435 sw_view * view = (sw_view *) data;446 sw_view *view = (sw_view *) data; 436 447 gboolean active; 437 448 438 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));449 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 439 450 sample_set_mute (view->sample, active); 440 451 } … … 443 454 mute_toggle_cb (GtkWidget * widget, gpointer data) 444 455 { 445 sw_view * view = (sw_view *)data;456 sw_view *view = (sw_view *) data; 446 457 sample_set_mute (view->sample, !view->sample->play_head->mute); 447 458 } … … 450 461 monitor_toggled_cb (GtkWidget * widget, gpointer data) 451 462 { 452 sw_view * view = (sw_view *) data;463 sw_view *view = (sw_view *) data; 453 464 gboolean active; 454 465 455 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));466 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 456 467 sample_set_monitor (view->sample, active); 457 468 } … … 460 471 monitor_toggle_cb (GtkWidget * widget, gpointer data) 461 472 { 462 sw_view * view = (sw_view *)data;473 sw_view *view = (sw_view *) data; 463 474 sample_set_monitor (view->sample, !view->sample->play_head->monitor); 464 475 } … … 467 478 play_view_button_cb (GtkWidget * widget, gpointer data) 468 479 { 469 sw_view * view = (sw_view *) data;470 sw_head * head = view->sample->play_head;480 sw_view *view = (sw_view *) data; 481 sw_head *head = view->sample->play_head; 471 482 gboolean was_restricted = head->restricted; 472 483 473 484 head_set_rate (head, 1.0); 474 /* head_set_restricted (head, FALSE);*/ 475 476 if (head->going && (head->scrubbing || !was_restricted)) { 477 pause_playback_cb (widget, data); 478 } else { 479 play_view_all (view); 480 } 485 /* head_set_restricted (head, FALSE); */ 486 487 if (head->going && (head->scrubbing || !was_restricted)) 488 { 489 pause_playback_cb (widget, data); 490 } 491 else 492 { 493 play_view_all (view); 494 } 481 495 } 482 496 … … 484 498 play_view_cb (GtkWidget * widget, gpointer data) 485 499 { 486 sw_view * view = (sw_view *) data;487 sw_head * head = view->sample->play_head;500 sw_view *view = (sw_view *) data; 501 sw_head *head = view->sample->play_head; 488 502 489 503 head_set_rate (head, 1.0); 490 /* head_set_restricted (head, FALSE);*/ 491 492 if (head->going) { 493 pause_playback_cb (widget, data); 494 } else { 495 play_view_all (view); 496 } 504 /* head_set_restricted (head, FALSE); */ 505 506 if (head->going) 507 { 508 pause_playback_cb (widget, data); 509 } 510 else 511 { 512 play_view_all (view); 513 } 497 514 } 498 515 … … 500 517 play_view_sel_button_cb (GtkWidget * widget, gpointer data) 501 518 { 502 sw_view * view = (sw_view *) data;503 sw_head * head = view->sample->play_head;519 sw_view *view = (sw_view *) data; 520 sw_head *head = view->sample->play_head; 504 521 gboolean was_restricted = head->restricted; 505 522 506 if (view->sample->sounddata->sels == NULL) { 507 play_view_cb (widget, data); 508 return; 509 } 523 if (view->sample->sounddata->sels == NULL) 524 { 525 play_view_cb (widget, data); 526 return; 527 } 510 528 511 529 head_set_rate (head, 1.0); 512 /* head_set_restricted (head, TRUE);*/ 513 514 if (head->going && (head->scrubbing || was_restricted)) { 515 pause_playback_cb (widget, data); 516 } else { 517 play_view_sel (view); 518 } 530 /* head_set_restricted (head, TRUE); */ 531 532 if (head->going && (head->scrubbing || was_restricted)) 533 { 534 pause_playback_cb (widget, data); 535 } 536 else 537 { 538 play_view_sel (view); 539 } 519 540 } 520 541 … … 522 543 play_view_sel_cb (GtkWidget * widget, gpointer data) 523 544 { 524 sw_view * view = (sw_view *) data; 525 sw_head * head = view->sample->play_head; 526 527 if (view->sample->sounddata->sels == NULL) { 528 play_view_cb (widget, data); 529 return; 530 } 545 sw_view *view = (sw_view *) data; 546 sw_head *head = view->sample->play_head; 547 548 if (view->sample->sounddata->sels == NULL) 549 { 550 play_view_cb (widget, data); 551 return; 552 } 531 553 532 554 head_set_rate (head, 1.0); 533 /* head_set_restricted (head, TRUE);*/ 534 535 if (head->going) { 536 pause_playback_cb (widget, data); 537 } else { 538 play_view_sel (view); 539 } 555 /* head_set_restricted (head, TRUE); */ 556 557 if (head->going) 558 { 559 pause_playback_cb (widget, data); 560 } 561 else 562 { 563 play_view_sel (view); 564 } 540 565 } 541 566 … … 543 568 pause_playback_cb (GtkWidget * widget, gpointer data) 544 569 { 545 sw_view * view = (sw_view *)data;570 sw_view *view = (sw_view *) data; 546 571 547 572 pause_playback (view->sample); … … 551 576 stop_playback_cb (GtkWidget * widget, gpointer data) 552 577 { 553 sw_view * view = (sw_view *)data;578 sw_view *view = (sw_view *) data; 554 579 555 580 stop_playback (view->sample); … … 559 584 preview_cut_cb (GtkWidget * widget, gpointer data) 560 585 { 561 sw_view * view = (sw_view *) data;586 sw_view *view = (sw_view *) data; 562 587 563 588 sample_refresh_playmode (view->sample); 564 589 565 if (view->sample->sounddata->sels != NULL) { 566 play_preview_cut (view); 567 } else { 568 play_preroll (view); 569 } 590 if (view->sample->sounddata->sels != NULL) 591 { 592 play_preview_cut (view); 593 } 594 else 595 { 596 play_preroll (view); 597 } 570 598 } 571 599 … … 573 601 preroll_cb (GtkWidget * widget, gpointer data) 574 602 { 575 sw_view * view = (sw_view *) data;603 sw_view *view = (sw_view *) data; 576 604 577 605 sample_refresh_playmode (view->sample); 578 606 579 607 play_preroll (view); 580 608 } … … 585 613 show_rec_dialog_cb (GtkWidget * widget, gpointer data) 586 614 { 587 sw_view * view = (sw_view *)data;615 sw_view *view = (sw_view *) data; 588 616 589 617 rec_dialog_create (view->sample); … … 595 623 rewind_step (gpointer data) 596 624 { 597 sw_sample * sample = (sw_sample *)data;625 sw_sample *sample = (sw_sample *) data; 598 626 gint step; 599 627 600 step = sample->sounddata->format->rate; /* 1 second */628 step = sample->sounddata->format->rate; /* 1 second */ 601 629 sample_set_playmarker (sample, sample->user_offset - step, TRUE); 602 630 … … 607 635 ffwd_step (gpointer data) 608 636 { 609 sw_sample * sample = (sw_sample *)data;637 sw_sample *sample = (sw_sample *) data; 610 638 gint step; 611 639 612 step = sample->sounddata->format->rate; /* 1 second */640 step = sample->sounddata->format->rate; /* 1 second */ 613 641 sample_set_playmarker (sample, sample->user_offset + step, TRUE); 614 642 … … 619 647 page_back_cb (GtkWidget * widget, gpointer data) 620 648 { 621 sw_view * view = (sw_view *)data;622 sw_sample * sample = view->sample;649 sw_view *view = (sw_view *) data; 650 sw_sample *sample = view->sample; 623 651 gint step; 624 652 625 step = MIN (sample->sounddata->format->rate, (view->end - view->start));653 step = MIN (sample->sounddata->format->rate, (view->end - view->start)); 626 654 sample_set_playmarker (sample, sample->user_offset - step, TRUE); 627 655 } … … 630 658 page_fwd_cb (GtkWidget * widget, gpointer data) 631 659 { 632 sw_view * view = (sw_view *)data;633 sw_sample * sample = view->sample;660 sw_view *view = (sw_view *) data; 661 sw_sample *sample = view->sample; 634 662 gint step; 635 663 636 step = MIN (sample->sounddata->format->rate, (view->end - view->start));664 step = MIN (sample->sounddata->format->rate, (view->end - view->start)); 637 665 sample_set_playmarker (sample, sample->user_offset + step, TRUE); 638 666 } … … 641 669 rewind_pressed_cb (GtkWidget * widget, gpointer data) 642 670 { 643 sw_view * view = (sw_view *)data;644 sw_sample * sample = view->sample;645 646 view_init_repeater (view, (GtkFunction) rewind_step, sample);671 sw_view *view = (sw_view *) data; 672 sw_sample *sample = view->sample; 673 674 view_init_repeater (view, (GtkFunction) rewind_step, sample); 647 675 } 648 676 … … 650 678 ffwd_pressed_cb (GtkWidget * widget, gpointer data) 651 679 { 652 sw_view * view = (sw_view *)data;653 sw_sample * sample = view->sample;654 655 view_init_repeater (view, (GtkFunction) ffwd_step, sample);680 sw_view *view = (sw_view *) data; 681 sw_sample *sample = view->sample; 682 683 view_init_repeater (view, (GtkFunction) ffwd_step, sample); 656 684 } 657 685 … … 659 687 goto_start_cb (GtkWidget * widget, gpointer data) 660 688 { 661 sw_view * view = (sw_view *)data;662 sw_sample * sample = view->sample;689 sw_view *view = (sw_view *) data; 690 sw_sample *sample = view->sample; 663 691 664 692 sample_set_scrubbing (sample, FALSE); … … 669 697 goto_start_of_view_cb (GtkWidget * widget, gpointer data) 670 698 { 671 sw_view * view = (sw_view *)data;672 sw_sample * sample = view->sample;699 sw_view *view = (sw_view *) data; 700 sw_sample *sample = view->sample; 673 701 674 702 sample_set_scrubbing (sample, FALSE); … … 679 707 goto_end_of_view_cb (GtkWidget * widget, gpointer data) 680 708 { 681 sw_view * view = (sw_view *)data;682 sw_sample * sample = view->sample;709 sw_view *view = (sw_view *) data; 710 sw_sample *sample = view->sample; 683 711 684 712 sample_set_scrubbing (sample, FALSE); … … 689 717 goto_end_cb (GtkWidget * widget, gpointer data) 690 718 { 691 sw_view * view = (sw_view *)data;692 sw_sample * sample = view->sample;719 sw_view *view = (sw_view *) data; 720 sw_sample *sample = view->sample; 693 721 694 722 sample_set_scrubbing (sample, FALSE); … … 701 729 sd_sel_changed_cb (GtkWidget * widget) 702 730 { 703 SampleDisplay * sd = SAMPLE_DISPLAY(widget);731 SampleDisplay *sd = SAMPLE_DISPLAY (widget); 704 732 705 733 sample_refresh_views (sd->view->sample); … … 709 737 sd_win_changed_cb (GtkWidget * widget) 710 738 { 711 SampleDisplay * sd = SAMPLE_DISPLAY(widget);712 sw_view * v = sd->view;713 714 g_signal_handlers_block_matched (GTK_OBJECT (v->adj), G_SIGNAL_MATCH_DATA, 0,715 0, 0, 0, v);739 SampleDisplay *sd = SAMPLE_DISPLAY (widget); 740 sw_view *v = sd->view; 741 742 g_signal_handlers_block_matched (GTK_OBJECT (v->adj), G_SIGNAL_MATCH_DATA, 743 0, 0, 0, 0, v); 716 744 view_fix_adjustment (sd->view); 717 718 g_signal_handlers_unblock_matched (GTK_OBJECT (v->adj), G_SIGNAL_MATCH_DATA, 0,719 0, 0, 0, v);745 746 g_signal_handlers_unblock_matched (GTK_OBJECT (v->adj), G_SIGNAL_MATCH_DATA, 747 0, 0, 0, 0, v); 720 748 view_refresh_hruler (v); 721 749 } … … 724 752 adj_changed_cb (GtkWidget * widget, gpointer data) 725 753 { 726 sw_view * v = (sw_view *)data; 727 SampleDisplay * sd = SAMPLE_DISPLAY(v->display); 728 GtkAdjustment * adj = GTK_ADJUSTMENT(v->adj); 729 730 g_signal_handlers_block_matched (GTK_OBJECT(GTK_OBJECT(sd)), G_SIGNAL_MATCH_DATA, 0, 731 0, 0, 0, v); 732 sample_display_set_window(sd, 733 (gint)adj->value, 734 (gint)(adj->value + adj->page_size)); 735 736 g_signal_handlers_unblock_matched (GTK_OBJECT(GTK_OBJECT(sd)), G_SIGNAL_MATCH_DATA, 0, 737 0, 0, 0, v); 754 sw_view *v = (sw_view *) data; 755 SampleDisplay *sd = SAMPLE_DISPLAY (v->display); 756 GtkAdjustment *adj = GTK_ADJUSTMENT (v->adj); 757 758 g_signal_handlers_block_matched (GTK_OBJECT (GTK_OBJECT (sd)), 759 G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, v); 760 sample_display_set_window (sd, (gint) adj->value, 761 (gint) (adj->value + adj->page_size)); 762 763 g_signal_handlers_unblock_matched (GTK_OBJECT (GTK_OBJECT (sd)), 764 G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, v); 738 765 view_refresh_hruler (v); 739 766 } … … 742 769 adj_value_changed_cb (GtkWidget * widget, gpointer data) 743 770 { 744 sw_view * v = (sw_view *)data; 745 SampleDisplay * sd = SAMPLE_DISPLAY(v->display); 746 GtkAdjustment * adj = GTK_ADJUSTMENT(v->adj); 747 748 if (!v->sample->play_head->going || !v->following) { 749 750 g_signal_handlers_block_matched (GTK_OBJECT(GTK_OBJECT(sd)), G_SIGNAL_MATCH_DATA, 0, 751 0, 0, 0, v); 752 sample_display_set_window(sd, 753 (gint)adj->value, 754 (gint)(adj->value + adj->page_size)); 755 g_signal_handlers_unblock_matched (GTK_OBJECT(GTK_OBJECT(sd)), G_SIGNAL_MATCH_DATA, 0, 756 0, 0, 0, v); 757 } 758 759 if (v->following) { 760 if (v->sample->user_offset < adj->value || 761 v->sample->user_offset > adj->value + adj->page_size) 762 sample_set_playmarker (v->sample, adj->value + adj->page_size/2, TRUE); 763 } 764 765 view_refresh_hruler (v); 771 sw_view *v = (sw_view *) data; 772 SampleDisplay *sd = SAMPLE_DISPLAY (v->display); 773 GtkAdjustment *adj = GTK_ADJUSTMENT (v->adj); 774 775 if (!v->sample->play_head->going || !v->following) 776 { 777 778 g_signal_handlers_block_matched (GTK_OBJECT (GTK_OBJECT (sd)), 779 G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, v); 780 sample_display_set_window (sd, (gint) adj->value, 781 (gint) (adj->value + adj->page_size)); 782 g_signal_handlers_unblock_matched (GTK_OBJECT (GTK_OBJECT (sd)), 783 G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, v); 784 } 785 786 if (v->following) 787 { 788 if (v->sample->user_offset < adj->value || 789 v->sample->user_offset > adj->value + adj->page_size) 790 sample_set_playmarker (v->sample, adj->value + adj->page_size / 2, 791 TRUE); 792 } 793 794 view_refresh_hruler (v); 766 795 } 767 796 … … 771 800 select_invert_cb (GtkWidget * widget, gpointer data) 772 801 { 773 SampleDisplay * sd = SAMPLE_DISPLAY(data);802 SampleDisplay *sd = SAMPLE_DISPLAY (data); 774 803 775 804 sample_selection_invert (sd->view->sample); … … 779 808 select_all_cb (GtkWidget * widget, gpointer data) 780 809 { 781 SampleDisplay * sd = SAMPLE_DISPLAY(data);810 SampleDisplay *sd = SAMPLE_DISPLAY (data); 782 811 783 812 sample_selection_select_all (sd->view->sample); … … 787 816 select_none_cb (GtkWidget * widget, gpointer data) 788 817 { 789 SampleDisplay * sd = SAMPLE_DISPLAY(data);818 SampleDisplay *sd = SAMPLE_DISPLAY (data); 790 819 791 820 sample_selection_select_none (sd->view->sample); … … 795 824 selection_halve_cb (GtkWidget * widget, gpointer data) 796 825 { 797 SampleDisplay * sd = SAMPLE_DISPLAY(data);826 SampleDisplay *sd = SAMPLE_DISPLAY (data); 798 827 799 828 sample_selection_halve (sd->view->sample); … … 803 832 selection_double_cb (GtkWidget * widget, gpointer data) 804 833 { 805 SampleDisplay * sd = SAMPLE_DISPLAY(data);834 SampleDisplay *sd = SAMPLE_DISPLAY (data); 806 835 807 836 sample_selection_double (sd->view->sample); … … 811 840 select_shift_left_cb (GtkWidget * widget, gpointer data) 812 841 { 813 SampleDisplay * sd = SAMPLE_DISPLAY(data);842 SampleDisplay *sd = SAMPLE_DISPLAY (data); 814 843 815 844 sample_selection_shift_left (sd->view->sample); … … 819 848 select_shift_right_cb (GtkWidget * widget, gpointer data) 820 849 { 821 SampleDisplay * sd = SAMPLE_DISPLAY(data);850 SampleDisplay *sd = SAMPLE_DISPLAY (data); 822 851 823 852 sample_selection_shift_right (sd->view->sample); … … 829 858 show_undo_dialog_cb (GtkWidget * widget, gpointer data) 830 859 { 831 sw_view * view = (sw_view *)data;860 sw_view *view = (sw_view *) data; 832 861 833 862 undo_dialog_create (view->sample); … … 837 866 undo_cb (GtkWidget * widget, gpointer data) 838 867 { 839 sw_view * view = (sw_view *)data;868 sw_view *view = (sw_view *) data; 840 869 841 870 undo_current (view->sample); … … 845 874 redo_cb (GtkWidget * widget, gpointer data) 846 875 { 847 sw_view * view = (sw_view *)data;876 sw_view *view = (sw_view *) data; 848 877 849 878 redo_current (view->sample); … … 853 882 cancel_cb (GtkWidget * widget, gpointer data) 854 883 { 855 sw_view * view = (sw_view *)data;884 sw_view *view = (sw_view *) data; 856 885 857 886 cancel_active_op (view->sample); … … 863 892 copy_cb (GtkWidget * widget, gpointer data) 864 893 { 865 sw_view * view = (sw_view *)data;866 sw_sample * s = view->sample;894 sw_view *view = (sw_view *) data; 895 sw_sample *s = view->sample; 867 896 868 897 do_copy (s); … … 872 901 cut_cb (GtkWidget * widget, gpointer data) 873 902 { 874 sw_view * view = (sw_view *)data;875 sw_sample * s = view->sample;903 sw_view *view = (sw_view *) data; 904 sw_sample *s = view->sample; 876 905 877 906 do_cut (s); … … 881 910 clear_cb (GtkWidget * widget, gpointer data) 882 911 { 883 sw_view * view = (sw_view *)data;884 sw_sample * s = view->sample;912 sw_view *view = (sw_view *) data; 913 sw_sample *s = view->sample; 885 914 886 915 do_clear (s); … … 890 919 delete_cb (GtkWidget * widget, gpointer data) 891 920 { 892 sw_view * view = (sw_view *)data;893 sw_sample * s = view->sample;921 sw_view *view = (sw_view *) data; 922 sw_sample *s = view->sample; 894 923 895 924 do_delete (s); … … 899 928 crop_cb (GtkWidget * widget, gpointer data) 900 929 { 901 sw_view * view = (sw_view *)data;902 sw_sample * s = view->sample;930 sw_view *view = (sw_view *) data; 931 sw_sample *s = view->sample; 903 932 904 933 do_crop (s); … … 908 937 paste_cb (GtkWidget * widget, gpointer data) 909 938 { 910 sw_view * view = (sw_view *)data;911 sw_sample * s = view->sample;939 sw_view *view = (sw_view *) data; 940 sw_sample *s = view->sample; 912 941 913 942 do_paste_insert (s); … … 917 946 paste_mix_cb (GtkWidget * widget, gpointer data) 918 947 { 919 sw_view * view = (sw_view *)data; 920 sw_sample * s = view->sample; 921 922 if (clipboard_width() > 0) { 923 create_paste_mix_dialog (s); 924 } else { 925 sample_set_tmp_message (s, _("Clipboard empty")); 926 } 948 sw_view *view = (sw_view *) data; 949 sw_sample *s = view->sample; 950 951 if (clipboard_width () > 0) 952 { 953 create_paste_mix_dialog (s); 954 } 955 else 956 { 957 sample_set_tmp_message (s, _("Clipboard empty")); 958 } 927 959 } 928 960 … … 930 962 paste_xfade_cb (GtkWidget * widget, gpointer data) 931 963 { 932 sw_view * view = (sw_view *)data; 933 sw_sample * s = view->sample; 934 935 if (clipboard_width() > 0) { 936 create_paste_xfade_dialog (s); 937 } else { 938 sample_set_tmp_message (s, _("Clipboard empty")); 939 } 964 sw_view *view = (sw_view *) data; 965 sw_sample *s = view->sample; 966 967 if (clipboard_width () > 0) 968 { 969 create_paste_xfade_dialog (s); 970 } 971 else 972 { 973 sample_set_tmp_message (s, _("Clipboard empty")); 974 } 940 975 } 941 976 … … 943 978 paste_as_new_cb (GtkWidget * widget, gpointer data) 944 979 { 945 sw_sample * s;946 sw_view * v;980 sw_sample *s; 981 sw_view *v; 947 982 948 983 s = do_paste_as_new (); 949 950 if (s) { 951 v = view_new_all (s, 1.0); 952 sample_add_view (s, v); 953 sample_bank_add (s); 954 } 984 985 if (s) 986 { 987 v = view_new_all (s, 1.0); 988 sample_add_view (s, v); 989 sample_bank_add (s); 990 } 955 991 } 956 992 … … 958 994 show_info_dialog_cb (GtkWidget * widget, gpointer data) 959 995 { 960 sw_view * view = (sw_view *)data;996 sw_view *view = (sw_view *) data; 961 997 962 998 sample_show_info_dialog (view->sample); … … 964 1000 965 1001 void 966 hide_window_cb (GtkAccelGroup *accel_group, 967 GObject *acceleratable, 968 guint keyval, 969 GdkModifierType modifier) 970 { 971 if (GTK_IS_WINDOW(acceleratable)) 972 g_signal_emit_by_name(G_OBJECT(acceleratable), "hide"); 973 } 974 975 void 976 close_window_cb (GtkAccelGroup *accel_group, 977 GObject *acceleratable, 978 guint keyval, 979 GdkModifierType modifier) 980 { 981 if (GTK_IS_WINDOW(acceleratable)) 982 g_signal_emit_by_name(G_OBJECT(acceleratable), "destroy"); 983 } 984 1002 hide_window_cb (GtkAccelGroup * accel_group, 1003 GObject * acceleratable, 1004 guint keyval, GdkModifierType modifier) 1005 { 1006 if (GTK_IS_WINDOW (acceleratable)) 1007 g_signal_emit_by_name (G_OBJECT (acceleratable), "hide"); 1008 } 1009 1010 void 1011 close_window_cb (GtkAccelGroup * accel_group, 1012 GObject * acceleratable, 1013 guint keyval, GdkModifierType modifier) 1014 { 1015 if (GTK_IS_WINDOW (acceleratable)) 1016 g_signal_emit_by_name (G_OBJECT (acceleratable), "destroy"); 1017 } 1018 985 1019 /* 986 1020 * Prime the label with the largest string then fetch the width. … … 990 1024 * don't try this at home kids, karma will get you. (oh well.. it works.) 991 1025 */ 992 void 993 hack_max_label_width_cb (GtkWidget *widget, 994 GtkStyle *previous_style, 995 gpointer user_data) 1026 void 1027 hack_max_label_width_cb (GtkWidget * widget, 1028 GtkStyle * previous_style, gpointer user_data) 996 1029 { 997 1030 PangoRectangle logical_rect, ink_rect; 998 1031 const gchar *saved; 999 1000 if (!GTK_IS_LABEL(widget)) 1001 return; 1002 saved = strdup(gtk_label_get_text(GTK_LABEL(widget))); 1003 gtk_label_set_text(GTK_LABEL(widget), "00:00:00.0000"); 1004 pango_layout_get_extents (gtk_label_get_layout (GTK_LABEL(widget)), &ink_rect, &logical_rect); 1005 gtk_label_set_text(GTK_LABEL(widget), saved); 1006 1007 if(saved != NULL) 1008 g_free((gpointer)saved); 1009 gtk_widget_set_usize(GTK_WIDGET(widget), PANGO_PIXELS (ink_rect.width), -1); 1010 } 1011 1012 void 1013 hack_max_combo_width_cb (GtkWidget *widget, 1014 GtkStyle *previous_style, 1015 gpointer user_data) 1032 1033 if (!GTK_IS_LABEL (widget)) 1034 return; 1035 saved = strdup (gtk_label_get_text (GTK_LABEL (widget))); 1036 gtk_label_set_text (GTK_LABEL (widget), "00:00:00.0000"); 1037 pango_layout_get_extents (gtk_label_get_layout (GTK_LABEL (widget)), 1038 &ink_rect, &logical_rect); 1039 gtk_label_set_text (GTK_LABEL (widget), saved); 1040 1041 if (saved != NULL) 1042 g_free ((gpointer) saved); 1043 gtk_widget_set_usize (GTK_WIDGET (widget), PANGO_PIXELS (ink_rect.width), 1044 -1); 1045 } 1046 1047 void 1048 hack_max_combo_width_cb (GtkWidget * widget, 1049 GtkStyle * previous_style, gpointer user_data) 1016 1050 { 1017 1051 PangoRectangle logical_rect, ink_rect; 1018 1052 GtkWidget *tmp_entry; 1019 1020 if (!GTK_IS_ENTRY(widget)) 1021 return; 1022 tmp_entry = gtk_entry_new(); 1023 gtk_widget_set_style(tmp_entry, gtk_style_copy(widget->style)); 1024 gtk_entry_set_text(GTK_ENTRY(tmp_entry), "00:00:00.0000."); 1025 1026 pango_layout_get_extents (gtk_entry_get_layout (GTK_ENTRY(tmp_entry)), &ink_rect, &logical_rect); 1027 gtk_widget_destroy(tmp_entry); 1028 1029 gtk_widget_set_usize(GTK_WIDGET(GTK_ENTRY(widget)), PANGO_PIXELS (ink_rect.width), -1); 1030 } 1053 1054 if (!GTK_IS_ENTRY (widget)) 1055 return; 1056 tmp_entry = gtk_entry_new (); 1057 gtk_widget_set_style (tmp_entry, gtk_style_copy (widget->style)); 1058 gtk_entry_set_text (GTK_ENTRY (tmp_entry), "00:00:00.0000."); 1059 1060 pango_layout_get_extents (gtk_entry_get_layout (GTK_ENTRY (tmp_entry)), 1061 &ink_rect, &logical_rect); 1062 gtk_widget_destroy (tmp_entry); 1063 1064 gtk_widget_set_usize (GTK_WIDGET (GTK_ENTRY (widget)), 1065 PANGO_PIXELS (ink_rect.width), -1); 1066 } sweep/branches/display-cache/src/callbacks.h
r285 r471 24 24 #include <gtk/gtk.h> 25 25 26 void 27 sample_new_empty_cb (GtkWidget * widget, gpointer data); 28 29 void 30 sample_new_copy_cb (GtkWidget * widget, gpointer data); 31 32 void 33 view_new_all_cb (GtkWidget * widget, gpointer data); 34 35 void 36 view_new_cb (GtkWidget * widget, gpointer data); 37 38 void 39 view_close_cb (GtkWidget * widget, gpointer data); 40 41 void 42 exit_cb (GtkWidget * widget, gpointer data); 43 44 void 45 set_tool_cb (GtkWidget * widget, gpointer data); 46 47 void 48 view_set_tool_cb (GtkWidget * widget, gpointer data); 49 50 void 51 repeater_released_cb (GtkWidget * widget, gpointer data); 52 53 void 54 zoom_in_cb (GtkWidget * widget, gpointer data); 55 56 void 57 zoom_out_cb (GtkWidget * widget, gpointer data); 58 59 void 60 zoom_in_pressed_cb (GtkWidget * widget, gpointer data); 61 62 void 63 zoom_out_pressed_cb (GtkWidget * widget, gpointer data); 64 65 void 66 zoom_to_sel_cb (GtkWidget * widget, gpointer data); 67 68 void 69 zoom_left_cb (GtkWidget * widget, gpointer data); 70 71 void 72 zoom_right_cb (GtkWidget * widget, gpointer data); 73 74 void 75 zoom_all_cb (GtkWidget * widget, gpointer data); 76 77 void 78 zoom_2_1_cb (GtkWidget * widget, gpointer data); 79 80 void 81 zoom_norm_cb (GtkWidget * widget, gpointer data); 82 83 void 84 zoom_1to1_cb (GtkWidget * widget, gpointer data); 85 86 void 87 zoom_center_cb (GtkWidget * widget, gpointer data); 88 89 void 90 zoom_combo_changed_cb (GtkWidget * widget, gpointer data); 91 92 void 93 sample_set_color_cb (GtkWidget * widget, gpointer data); 94 95 void 96 device_config_cb (GtkWidget * widget, gpointer data); 97 98 void 99 follow_toggled_cb (GtkWidget * widget, gpointer data); 100 101 void 102 follow_toggle_cb (GtkWidget * widget, gpointer data); 103 104 void 105 loop_toggled_cb (GtkWidget * widget, gpointer data); 106 107 void 108 loop_toggle_cb (GtkWidget * widget, gpointer data); 109 110 void 111 playrev_toggled_cb (GtkWidget * widget, gpointer data); 112 113 void 114 playrev_toggle_cb (GtkWidget * widget, gpointer data); 115 116 void 117 mute_toggled_cb (GtkWidget * widget, gpointer data); 118 119 void 120 mute_toggle_cb (GtkWidget * widget, gpointer data); 121 122 void 123 monitor_toggled_cb (GtkWidget * widget, gpointer data); 124 125 void 126 monitor_toggle_cb (GtkWidget * widget, gpointer data); 127 128 void 129 play_view_button_cb (GtkWidget * widget, gpointer data); 130 131 void 132 play_view_sel_button_cb (GtkWidget * widget, gpointer data); 133 134 void 135 play_view_cb (GtkWidget * widget, gpointer data); 136 137 void 138 play_view_all_once_cb (GtkWidget * widget, gpointer data); 139 140 void 141 play_view_all_loop_cb (GtkWidget * widget, gpointer data); 142 143 void 144 play_view_sel_cb (GtkWidget * widget, gpointer data); 145 146 void 147 play_view_sel_once_cb (GtkWidget * widget, gpointer data); 148 149 void 150 play_view_sel_loop_cb (GtkWidget * widget, gpointer data); 151 152 void 153 pause_playback_cb (GtkWidget * widget, gpointer data); 154 155 void 156 stop_playback_cb (GtkWidget * widget, gpointer data); 157 158 void 159 preview_cut_cb (GtkWidget * widget, gpointer data); 160 161 void 162 preroll_cb (GtkWidget * widget, gpointer data); 163 164 void 165 show_rec_dialog_cb (GtkWidget * widget, gpointer data); 166 167 void 168 page_back_cb (GtkWidget * widget, gpointer data); 169 170 void 171 page_fwd_cb (GtkWidget * widget, gpointer data); 172 173 void 174 rewind_pressed_cb (GtkWidget * widget, gpointer data); 175 176 void 177 ffwd_pressed_cb (GtkWidget * widget, gpointer data); 178 179 void 180 goto_start_cb (GtkWidget * widget, gpointer data); 181 182 void 183 goto_start_of_view_cb (GtkWidget * widget, gpointer data); 184 185 void 186 goto_end_of_view_cb (GtkWidget * widget, gpointer data); 187 188 void 189 goto_end_cb (GtkWidget * widget, gpointer data); 190 191 void 192 sd_sel_changed_cb (GtkWidget * widget); 193 194 void 195 sd_win_changed_cb (GtkWidget * widget); 196 197 void 198 adj_changed_cb (GtkWidget * widget, gpointer data); 199 200 void 201 adj_value_changed_cb (GtkWidget * widget, gpointer data); 202 203 void 204 select_invert_cb (GtkWidget * widget, gpointer data); 205 206 void 207 select_all_cb (GtkWidget * widget, gpointer data); 208 209 void 210 select_none_cb (GtkWidget * widget, gpointer data); 211 212 void 213 selection_halve_cb (GtkWidget * widget, gpointer data); 214 215 void 216 selection_double_cb (GtkWidget * widget, gpointer data); 217 218 void 219 select_shift_left_cb (GtkWidget * widget, gpointer data); 220 221 void 222 select_shift_right_cb (GtkWidget * widget, gpointer data); 223 224 void 225 show_undo_dialog_cb (GtkWidget * widget, gpointer data); 226 227 void 228 undo_cb (GtkWidget * widget, gpointer data); 229 230 void 231 redo_cb (GtkWidget * widget, gpointer data); 232 233 void 234 cancel_cb (GtkWidget * widget, gpointer data); 235 236 void 237 copy_cb (GtkWidget * widget, gpointer data); 238 239 void 240 cut_cb (GtkWidget * widget, gpointer data); 241 242 void 243 clear_cb (GtkWidget * widget, gpointer data); 244 245 void 246 delete_cb (GtkWidget * widget, gpointer data); 247 248 void 249 crop_cb (GtkWidget * widget, gpointer data); 250 251 void 252 paste_cb (GtkWidget * widget, gpointer data); 253 254 void 255 paste_mix_cb (GtkWidget * widget, gpointer data); 256 257 void 258 paste_xfade_cb (GtkWidget * widget, gpointer data); 259 260 void 261 paste_as_new_cb (GtkWidget * widget, gpointer data); 262 263 void 264 reverse_cb (GtkWidget * widget, gpointer data); 265 266 void 267 normalise_cb (GtkWidget * widget, gpointer data); 268 269 void 270 show_info_dialog_cb (GtkWidget * widget, gpointer data); 271 272 void 273 close_window_cb(GtkAccelGroup *accel_group, 274 GObject *acceleratable, 275 guint keyval, 276 GdkModifierType modifier); 277 278 void 279 hide_window_cb(GtkAccelGroup *accel_group, 280 GObject *acceleratable, 281 guint keyval, 282 GdkModifierType modifier); 283 284 void 285 hack_max_label_width_cb (GtkWidget *widget, 286 GtkStyle *previous_style, 287 gpointer user_data); 288 289 void 290 hack_max_combo_width_cb (GtkWidget *widget, 291 GtkStyle *previous_style, 292 gpointer user_data); 26 void sample_new_empty_cb (GtkWidget * widget, gpointer data); 27 28 void sample_new_copy_cb (GtkWidget * widget, gpointer data); 29 30 void view_new_all_cb (GtkWidget * widget, gpointer data); 31 32 void view_new_cb (GtkWidget * widget, gpointer data); 33 34 void view_close_cb (GtkWidget * widget, gpointer data); 35 36 void exit_cb (GtkWidget * widget, gpointer data); 37 38 void set_tool_cb (GtkWidget * widget, gpointer data); 39 40 void view_set_tool_cb (GtkWidget * widget, gpointer data); 41 42 void repeater_released_cb (GtkWidget * widget, gpointer data); 43 44 void zoom_in_cb (GtkWidget * widget, gpointer data); 45 46 void zoom_out_cb (GtkWidget * widget, gpointer data); 47 48 void zoom_in_pressed_cb (GtkWidget * widget, gpointer data); 49 50 void zoom_out_pressed_cb (GtkWidget * widget, gpointer data); 51 52 void zoom_to_sel_cb (GtkWidget * widget, gpointer data); 53 54 void zoom_left_cb (GtkWidget * widget, gpointer data); 55 56 void zoom_right_cb (GtkWidget * widget, gpointer data); 57 58 void zoom_all_cb (GtkWidget * widget, gpointer data); 59 60 void zoom_2_1_cb (GtkWidget * widget, gpointer data); 61 62 void zoom_norm_cb (GtkWidget * widget, gpointer data); 63 64 void zoom_1to1_cb (GtkWidget * widget, gpointer data); 65 66 void zoom_center_cb (GtkWidget * widget, gpointer data); 67 68 void zoom_combo_changed_cb (GtkWidget * widget, gpointer data); 69 70 void sample_set_color_cb (GtkWidget * widget, gpointer data); 71 72 void device_config_cb (GtkWidget * widget, gpointer data); 73 74 void follow_toggled_cb (GtkWidget * widget, gpointer data); 75 76 void follow_toggle_cb (GtkWidget * widget, gpointer data); 77 78 void loop_toggled_cb (GtkWidget * widget, gpointer data); 79 80 void loop_toggle_cb (GtkWidget * widget, gpointer data); 81 82 void playrev_toggled_cb (GtkWidget * widget, gpointer data); 83 84 void playrev_toggle_cb (GtkWidget * widget, gpointer data); 85 86 void mute_toggled_cb (GtkWidget * widget, gpointer data); 87 88 void mute_toggle_cb (GtkWidget * widget, gpointer data); 89 90 void monitor_toggled_cb (GtkWidget * widget, gpointer data); 91 92 void monitor_toggle_cb (GtkWidget * widget, gpointer data); 93 94 void play_view_button_cb (GtkWidget * widget, gpointer data); 95 96 void play_view_sel_button_cb (GtkWidget * widget, gpointer data); 97 98 void play_view_cb (GtkWidget * widget, gpointer data); 99 100 void play_view_all_once_cb (GtkWidget * widget, gpointer data); 101 102 void play_view_all_loop_cb (GtkWidget * widget, gpointer data); 103 104 void play_view_sel_cb (GtkWidget * widget, gpointer data); 105 106 void play_view_sel_once_cb (GtkWidget * widget, gpointer data); 107 108 void play_view_sel_loop_cb (GtkWidget * widget, gpointer data); 109 110 void pause_playback_cb (GtkWidget * widget, gpointer data); 111 112 void stop_playback_cb (GtkWidget * widget, gpointer data); 113 114 void preview_cut_cb (GtkWidget * widget, gpointer data); 115 116 void preroll_cb (GtkWidget * widget, gpointer data); 117 118 void show_rec_dialog_cb (GtkWidget * widget, gpointer data); 119 120 void page_back_cb (GtkWidget * widget, gpointer data); 121 122 void page_fwd_cb (GtkWidget * widget, gpointer data); 123 124 void rewind_pressed_cb (GtkWidget * widget, gpointer data); 125 126 void ffwd_pressed_cb (GtkWidget * widget, gpointer data); 127 128 void goto_start_cb (GtkWidget * widget, gpointer data); 129 130 void goto_start_of_view_cb (GtkWidget * widget, gpointer data); 131 132 void goto_end_of_view_cb (GtkWidget * widget, gpointer data); 133 134 void goto_end_cb (GtkWidget * widget, gpointer data); 135 136 void sd_sel_changed_cb (GtkWidget * widget); 137 138 void sd_win_changed_cb (GtkWidget * widget); 139 140 void adj_changed_cb (GtkWidget * widget, gpointer data); 141 142 void adj_value_changed_cb (GtkWidget * widget, gpointer data); 143 144 void select_invert_cb (GtkWidget * widget, gpointer data); 145 146 void select_all_cb (GtkWidget * widget, gpointer data); 147 148 void select_none_cb (GtkWidget * widget, gpointer data); 149 150 void selection_halve_cb (GtkWidget * widget, gpointer data); 151 152 void selection_double_cb (GtkWidget * widget, gpointer data); 153 154 void select_shift_left_cb (GtkWidget * widget, gpointer data); 155 156 void select_shift_right_cb (GtkWidget * widget, gpointer data); 157 158 void show_undo_dialog_cb (GtkWidget * widget, gpointer data); 159 160 void undo_cb (GtkWidget * widget, gpointer data); 161 162 void redo_cb (GtkWidget * widget, gpointer data); 163 164 void cancel_cb (GtkWidget * widget, gpointer data); 165 166 void copy_cb (GtkWidget * widget, gpointer data); 167 168 void cut_cb (GtkWidget * widget, gpointer data); 169 170 void clear_cb (GtkWidget * widget, gpointer data); 171 172 void delete_cb (GtkWidget * widget, gpointer data); 173 174 void crop_cb (GtkWidget * widget, gpointer data); 175 176 void paste_cb (GtkWidget * widget, gpointer data); 177 178 void paste_mix_cb (GtkWidget * widget, gpointer data); 179 180 void paste_xfade_cb (GtkWidget * widget, gpointer data); 181 182 void paste_as_new_cb (GtkWidget * widget, gpointer data); 183 184 void reverse_cb (GtkWidget * widget, gpointer data); 185 186 void normalise_cb (GtkWidget * widget, gpointer data); 187 188 void show_info_dialog_cb (GtkWidget * widget, gpointer data); 189 190 void 191 close_window_cb (GtkAccelGroup * accel_group, 192 GObject * acceleratable, 193 guint keyval, GdkModifierType modifier); 194 195 void 196 hide_window_cb (GtkAccelGroup * accel_group, 197 GObject * acceleratable, 198 guint keyval, GdkModifierType modifier); 199 200 void 201 hack_max_label_width_cb (GtkWidget * widget, 202 GtkStyle * previous_style, gpointer user_data); 203 204 void 205 hack_max_combo_width_cb (GtkWidget * widget, 206 GtkStyle * previous_style, gpointer user_data); 293 207 294 208 #endif /* __CALLBACKS_H__ */ sweep/branches/display-cache/src/channelops.c
r211 r471 47 47 do_dup_channels_thread (sw_op_instance * inst) 48 48 { 49 sw_sample * sample = inst->sample;50 int new_channels = GPOINTER_TO_INT (inst->do_data);49 sw_sample *sample = inst->sample; 50 int new_channels = GPOINTER_TO_INT (inst->do_data); 51 51 int min_channels; 52 sw_format * old_format = sample->sounddata->format;53 sw_sounddata * old_sounddata, *new_sounddata;52 sw_format *old_format = sample->sounddata->format; 53 sw_sounddata *old_sounddata, *new_sounddata; 54 54 sw_framecount_t nr_frames; 55 55 56 sw_audio_t * old_d, *new_d;56 sw_audio_t *old_d, *new_d; 57 57 58 58 sw_framecount_t remaining, n, run_total, ctotal; … … 72 72 remaining = nr_frames; 73 73 ctotal = remaining / 100; 74 if (ctotal == 0) ctotal = 1; 74 if (ctotal == 0) 75 ctotal = 1; 75 76 run_total = 0; 76 77 77 old_d = (sw_audio_t *) old_sounddata->data;78 new_d = (sw_audio_t *) new_sounddata->data;78 old_d = (sw_audio_t *) old_sounddata->data; 79 new_d = (sw_audio_t *) new_sounddata->data; 79 80 80 81 /* Create selections */ … … 84 85 85 86 /* Mix down */ 86 while (active && remaining > 0) { 87 g_mutex_lock (sample->ops_mutex); 88 89 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 90 active = FALSE; 91 } else { 92 93 n = MIN (remaining, 4096); 94 95 for (i = 0; i < n; i++) { 96 k = 0; 97 while (k < new_channels) { 98 for (j = 0; j < min_channels; j++) { 99 new_d[k++] = old_d[j]; 100 } 101 } 102 old_d += old_format->channels; 103 new_d += new_channels; 104 } 105 106 remaining -= n; 107 run_total += n; 108 109 percent = run_total / ctotal; 110 sample_set_progress_percent (sample, percent); 111 } 112 113 g_mutex_unlock (sample->ops_mutex); 114 } 115 116 if (remaining > 0) { /* cancelled or failed */ 117 sounddata_destroy (new_sounddata); 118 } else if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) { 119 sample->sounddata = new_sounddata; 120 121 inst->redo_data = inst->undo_data = 122 sounddata_replace_data_new (sample, old_sounddata, new_sounddata); 123 124 register_operation (sample, inst); 125 } 87 while (active && remaining > 0) 88 { 89 g_mutex_lock (sample->ops_mutex); 90 91 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 92 { 93 active = FALSE; 94 } 95 else 96 { 97 98 n = MIN (remaining, 4096); 99 100 for (i = 0; i < n; i++) 101 { 102 k = 0; 103 while (k < new_channels) 104 { 105 for (j = 0; j < min_channels; j++) 106 { 107 new_d[k++] = old_d[j]; 108 } 109 } 110 old_d += old_format->channels; 111 new_d += new_channels; 112 } 113 114 remaining -= n; 115 run_total += n; 116 117 percent = run_total / ctotal; 118 sample_set_progress_percent (sample, percent); 119 } 120 121 g_mutex_unlock (sample->ops_mutex); 122 } 123 124 if (remaining > 0) 125 { /* cancelled or failed */ 126 sounddata_destroy (new_sounddata); 127 } 128 else if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) 129 { 130 sample->sounddata = new_sounddata; 131 132 inst->redo_data = inst->undo_data = 133 sounddata_replace_data_new (sample, old_sounddata, new_sounddata); 134 135 register_operation (sample, inst); 136 } 126 137 } 127 138 128 139 static sw_operation dup_channels_op = { 129 140 SWEEP_EDIT_MODE_ALLOC, 130 (SweepCallback) do_dup_channels_thread,131 (SweepFunction) NULL,132 (SweepCallback) undo_by_sounddata_replace,133 (SweepFunction) sounddata_replace_data_destroy,134 (SweepCallback) redo_by_sounddata_replace,135 (SweepFunction) sounddata_replace_data_destroy141 (SweepCallback) do_dup_channels_thread, 142 (SweepFunction) NULL, 143 (SweepCallback) undo_by_sounddata_replace, 144 (SweepFunction) sounddata_replace_data_destroy, 145 (SweepCallback) redo_by_sounddata_replace, 146 (SweepFunction) sounddata_replace_data_destroy 136 147 }; 137 148 … … 143 154 char buf[BUF_LEN]; 144 155 145 if (sample->sounddata->format->channels == 1) { 146 g_snprintf (buf, BUF_LEN, _("Duplicate to %d channels"), new_channels); 147 } else { 148 g_snprintf (buf, BUF_LEN, _("Duplicate from %d to %d channels"), 149 sample->sounddata->format->channels, new_channels); 150 } 151 156 if (sample->sounddata->format->channels == 1) 157 { 158 g_snprintf (buf, BUF_LEN, _("Duplicate to %d channels"), new_channels); 159 } 160 else 161 { 162 g_snprintf (buf, BUF_LEN, _("Duplicate from %d to %d channels"), 163 sample->sounddata->format->channels, new_channels); 164 } 165 152 166 schedule_operation (sample, buf, &dup_channels_op, 153 GINT_TO_POINTER (new_channels));167 GINT_TO_POINTER (new_channels)); 154 168 } 155 169 … … 157 171 dup_stereo_cb (GtkWidget * widget, gpointer data) 158 172 { 159 sw_view * view = (sw_view *)data;160 sw_sample * sample = view->sample;173 sw_view *view = (sw_view *) data; 174 sw_sample *sample = view->sample; 161 175 162 176 dup_channels (sample, 2); … … 166 180 dup_channels_dialog_ok_cb (GtkWidget * widget, gpointer data) 167 181 { 168 sw_sample * sample = (sw_sample *)data;169 GtkWidget * dialog;170 GtkWidget * chooser;182 sw_sample *sample = (sw_sample *) data; 183 GtkWidget *dialog; 184 GtkWidget *chooser; 171 185 172 186 int new_channels; … … 174 188 dialog = gtk_widget_get_toplevel (widget); 175 189 176 chooser = g_object_get_data (G_OBJECT (dialog), "default");190 chooser = g_object_get_data (G_OBJECT (dialog), "default"); 177 191 new_channels = channelcount_chooser_get_count (chooser); 178 192 … … 185 199 dup_channels_dialog_cancel_cb (GtkWidget * widget, gpointer data) 186 200 { 187 GtkWidget * dialog;201 GtkWidget *dialog; 188 202 189 203 dialog = gtk_widget_get_toplevel (widget); … … 194 208 dup_channels_dialog_new_cb (GtkWidget * widget, gpointer data) 195 209 { 196 sw_view * view = (sw_view *)data;197 sw_sample * sample = view->sample;198 GtkWidget * dialog;199 GtkWidget * main_vbox;200 /*GtkWidget * label; */201 GtkWidget * chooser;202 GtkWidget * button, *ok_button;203 204 /*gchar * current; */210 sw_view *view = (sw_view *) data; 211 sw_sample *sample = view->sample; 212 GtkWidget *dialog; 213 GtkWidget *main_vbox; 214 /*GtkWidget * label; */ 215 GtkWidget *chooser; 216 GtkWidget *button, *ok_button; 217 218 /*gchar * current; */ 205 219 206 220 dialog = gtk_dialog_new (); 207 gtk_window_set_title (GTK_WINDOW (dialog), _("Sweep: Duplicate channel"));221 gtk_window_set_title (GTK_WINDOW (dialog), _("Sweep: Duplicate channel")); 208 222 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); 209 gtk_container_set_border_width (GTK_CONTAINER (dialog), 8);210 211 main_vbox = GTK_DIALOG (dialog)->vbox;223 gtk_container_set_border_width (GTK_CONTAINER (dialog), 8); 224 225 main_vbox = GTK_DIALOG (dialog)->vbox; 212 226 213 227 #if 0 … … 215 229 sample->sounddata->format->channels); 216 230 label = gtk_label_new (current); 217 gtk_box_pack_start (GTK_BOX (main_vbox), label, TRUE, TRUE, 8);231 gtk_box_pack_start (GTK_BOX (main_vbox), label, TRUE, TRUE, 8); 218 232 gtk_widget_show (label); 219 233 #endif 220 234 221 235 chooser = channelcount_chooser_new (_("Output channels")); 222 gtk_box_pack_start (GTK_BOX (main_vbox), chooser, TRUE, TRUE, 0);236 gtk_box_pack_start (GTK_BOX (main_vbox), chooser, TRUE, TRUE, 0); 223 237 channelcount_chooser_set_count (chooser, 224 238 sample->sounddata->format->channels); 225 239 gtk_widget_show (chooser); 226 240 227 g_object_set_data (G_OBJECT (dialog), "default", chooser);241 g_object_set_data (G_OBJECT (dialog), "default", chooser); 228 242 229 243 /* OK */ … … 231 245 ok_button = gtk_button_new_with_label (_("OK")); 232 246 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (ok_button), GTK_CAN_DEFAULT); 233 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), ok_button,247 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), ok_button, 234 248 TRUE, TRUE, 0); 235 249 gtk_widget_show (ok_button); 236 g_signal_connect (G_OBJECT(ok_button), "clicked", 237 G_CALLBACK (dup_channels_dialog_ok_cb), 238 sample); 250 g_signal_connect (G_OBJECT (ok_button), "clicked", 251 G_CALLBACK (dup_channels_dialog_ok_cb), sample); 239 252 240 253 /* Cancel */ … … 242 255 button = gtk_button_new_with_label (_("Cancel")); 243 256 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (button), GTK_CAN_DEFAULT); 244 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button,257 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button, 245 258 TRUE, TRUE, 0); 246 259 gtk_widget_show (button); 247 g_signal_connect (G_OBJECT(button), "clicked", 248 G_CALLBACK (dup_channels_dialog_cancel_cb), 249 NULL); 260 g_signal_connect (G_OBJECT (button), "clicked", 261 G_CALLBACK (dup_channels_dialog_cancel_cb), NULL); 250 262 251 263 gtk_widget_grab_default (ok_button); … … 257 269 do_mono_mixdown_thread (sw_op_instance * inst) 258 270 { 259 sw_sample * sample = inst->sample;260 261 sw_format * old_format = sample->sounddata->format;262 sw_sounddata * old_sounddata, *new_sounddata;271 sw_sample *sample = inst->sample; 272 273 sw_format *old_format = sample->sounddata->format; 274 sw_sounddata *old_sounddata, *new_sounddata; 263 275 sw_framecount_t nr_frames; 264 276 265 sw_audio_t * old_d, *new_d;277 sw_audio_t *old_d, *new_d; 266 278 267 279 sw_framecount_t remaining, n, run_total, ctotal; … … 278 290 remaining = nr_frames; 279 291 ctotal = remaining / 100; 280 if (ctotal == 0) ctotal = 1; 292 if (ctotal == 0) 293 ctotal = 1; 281 294 run_total = 0; 282 295 283 old_d = (sw_audio_t *) old_sounddata->data;284 new_d = (sw_audio_t *) new_sounddata->data;296 old_d = (sw_audio_t *) old_sounddata->data; 297 new_d = (sw_audio_t *) new_sounddata->data; 285 298 286 299 /* Create selections */ … … 290 303 291 304 /* Mix down */ 292 while (active && remaining > 0) { 293 g_mutex_lock (sample->ops_mutex); 294 295 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 296 active = FALSE; 297 } else { 298 299 n = MIN (remaining, 4096); 300 301 for (i = 0; i < n; i++) { 302 for (j = 0; j < old_format->channels; j++) { 303 *new_d += *old_d; 304 old_d++; 305 } 306 new_d++; 307 } 308 309 remaining -= n; 310 run_total += n; 311 312 percent = run_total / ctotal; 313 sample_set_progress_percent (sample, percent); 314 } 315 316 g_mutex_unlock (sample->ops_mutex); 317 } 318 319 if (remaining > 0) { /* cancelled or failed */ 320 sounddata_destroy (new_sounddata); 321 } else if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) { 322 sample->sounddata = new_sounddata; 323 324 inst->redo_data = inst->undo_data = 325 sounddata_replace_data_new (sample, old_sounddata, new_sounddata); 326 327 register_operation (sample, inst); 328 } 305 while (active && remaining > 0) 306 { 307 g_mutex_lock (sample->ops_mutex); 308 309 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 310 { 311 active = FALSE; 312 } 313 else 314 { 315 316 n = MIN (remaining, 4096); 317 318 for (i = 0; i < n; i++) 319 { 320 for (j = 0; j < old_format->channels; j++) 321 { 322 *new_d += *old_d; 323 old_d++; 324 } 325 new_d++; 326 } 327 328 remaining -= n; 329 run_total += n; 330 331 percent = run_total / ctotal; 332 sample_set_progress_percent (sample, percent); 333 } 334 335 g_mutex_unlock (sample->ops_mutex); 336 } 337 338 if (remaining > 0) 339 { /* cancelled or failed */ 340 sounddata_destroy (new_sounddata); 341 } 342 else if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) 343 { 344 sample->sounddata = new_sounddata; 345 346 inst->redo_data = inst->undo_data = 347 sounddata_replace_data_new (sample, old_sounddata, new_sounddata); 348 349 register_operation (sample, inst); 350 } 329 351 } 330 352 331 353 static sw_operation mono_mixdown_op = { 332 354 SWEEP_EDIT_MODE_ALLOC, 333 (SweepCallback) do_mono_mixdown_thread,334 (SweepFunction) NULL,335 (SweepCallback) undo_by_sounddata_replace,336 (SweepFunction) sounddata_replace_data_destroy,337 (SweepCallback) redo_by_sounddata_replace,338 (SweepFunction) sounddata_replace_data_destroy355 (SweepCallback) do_mono_mixdown_thread, 356 (SweepFunction) NULL, 357 (SweepCallback) undo_by_sounddata_replace, 358 (SweepFunction) sounddata_replace_data_destroy, 359 (SweepCallback) redo_by_sounddata_replace, 360 (SweepFunction) sounddata_replace_data_destroy 339 361 }; 340 362 … … 342 364 mono_mixdown_cb (GtkWidget * widget, gpointer data) 343 365 { 344 sw_view * view = (sw_view *)data;345 sw_sample * sample = view->sample;366 sw_view *view = (sw_view *) data; 367 sw_sample *sample = view->sample; 346 368 347 369 schedule_operation (sample, _("Mix down to mono"), &mono_mixdown_op, NULL); … … 351 373 do_remove_channel_thread (sw_op_instance * inst) 352 374 { 353 sw_sample * sample = inst->sample;354 int channel = GPOINTER_TO_INT (inst->do_data);355 356 sw_format * old_format = sample->sounddata->format;357 sw_sounddata * old_sounddata, *new_sounddata;375 sw_sample *sample = inst->sample; 376 int channel = GPOINTER_TO_INT (inst->do_data); 377 378 sw_format *old_format = sample->sounddata->format; 379 sw_sounddata *old_sounddata, *new_sounddata; 358 380 sw_framecount_t nr_frames; 359 381 360 sw_audio_t * old_d, *new_d;382 sw_audio_t *old_d, *new_d; 361 383 362 384 sw_framecount_t remaining, n, run_total, ctotal; … … 374 396 remaining = nr_frames; 375 397 ctotal = remaining / 100; 376 if (ctotal == 0) ctotal = 1; 398 if (ctotal == 0) 399 ctotal = 1; 377 400 run_total = 0; 378 401 379 old_d = (sw_audio_t *) old_sounddata->data;380 new_d = (sw_audio_t *) new_sounddata->data;402 old_d = (sw_audio_t *) old_sounddata->data; 403 new_d = (sw_audio_t *) new_sounddata->data; 381 404 382 405 /* Create selections */ … … 386 409 387 410 /* Mix down */ 388 while (active && remaining > 0) { 389 g_mutex_lock (sample->ops_mutex); 390 391 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 392 active = FALSE; 393 } else { 394 395 n = MIN (remaining, 4096); 396 397 for (i = 0; i < n; i++) { 398 for (j = 0; j < old_format->channels; j++) { 399 if (j != channel) { 400 *new_d = *old_d; 401 new_d++; 402 } 403 old_d++; 404 } 405 } 406 407 remaining -= n; 408 run_total += n; 409 410 percent = run_total / ctotal; 411 sample_set_progress_percent (sample, percent); 412 } 413 414 g_mutex_unlock (sample->ops_mutex); 415 } 416 417 if (remaining > 0) { /* cancelled or failed */ 418 sounddata_destroy (new_sounddata); 419 } else if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) { 420 sample->sounddata = new_sounddata; 421 422 inst->redo_data = inst->undo_data = 423 sounddata_replace_data_new (sample, old_sounddata, new_sounddata); 424 425 register_operation (sample, inst); 426 } 411 while (active && remaining > 0) 412 { 413 g_mutex_lock (sample->ops_mutex); 414 415 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 416 { 417 active = FALSE; 418 } 419 else 420 { 421 422 n = MIN (remaining, 4096); 423 424 for (i = 0; i < n; i++) 425 { 426 for (j = 0; j < old_format->channels; j++) 427 { 428 if (j != channel) 429 { 430 *new_d = *old_d; 431 new_d++; 432 } 433 old_d++; 434 } 435 } 436 437 remaining -= n; 438 run_total += n; 439 440 percent = run_total / ctotal; 441 sample_set_progress_percent (sample, percent); 442 } 443 444 g_mutex_unlock (sample->ops_mutex); 445 } 446 447 if (remaining > 0) 448 { /* cancelled or failed */ 449 sounddata_destroy (new_sounddata); 450 } 451 else if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) 452 { 453 sample->sounddata = new_sounddata; 454 455 inst->redo_data = inst->undo_data = 456 sounddata_replace_data_new (sample, old_sounddata, new_sounddata); 457 458 register_operation (sample, inst); 459 } 427 460 } 428 461 429 462 static sw_operation remove_channel_op = { 430 463 SWEEP_EDIT_MODE_ALLOC, 431 (SweepCallback) do_remove_channel_thread,432 (SweepFunction) NULL,433 (SweepCallback) undo_by_sounddata_replace,434 (SweepFunction) sounddata_replace_data_destroy,435 (SweepCallback) redo_by_sounddata_replace,436 (SweepFunction) sounddata_replace_data_destroy464 (SweepCallback) do_remove_channel_thread, 465 (SweepFunction) NULL, 466 (SweepCallback) undo_by_sounddata_replace, 467 (SweepFunction) sounddata_replace_data_destroy, 468 (SweepCallback) redo_by_sounddata_replace, 469 (SweepFunction) sounddata_replace_data_destroy 437 470 }; 438 471 … … 440 473 remove_left_cb (GtkWidget * widget, gpointer data) 441 474 { 442 sw_view * view = (sw_view *)data;443 sw_sample * sample = view->sample;475 sw_view *view = (sw_view *) data; 476 sw_sample *sample = view->sample; 444 477 445 478 schedule_operation (sample, _("Remove left channel"), &remove_channel_op, 446 GINT_TO_POINTER (0));479 GINT_TO_POINTER (0)); 447 480 } 448 481 … … 450 483 remove_right_cb (GtkWidget * widget, gpointer data) 451 484 { 452 sw_view * view = (sw_view *)data;453 sw_sample * sample = view->sample;485 sw_view *view = (sw_view *) data; 486 sw_sample *sample = view->sample; 454 487 455 488 schedule_operation (sample, _("Remove right channel"), &remove_channel_op, 456 GINT_TO_POINTER (1));489 GINT_TO_POINTER (1)); 457 490 } 458 491 … … 461 494 { 462 495 sw_framecount_t nr_frames; 463 sw_audio_t * dl, *dr, t;496 sw_audio_t *dl, *dr, t; 464 497 465 498 sw_framecount_t remaining, n, run_total, ctotal; … … 473 506 remaining = nr_frames; 474 507 ctotal = remaining / 100; 475 if (ctotal == 0) ctotal = 1; 508 if (ctotal == 0) 509 ctotal = 1; 476 510 run_total = 0; 477 511 478 dl = (sw_audio_t *)sample->sounddata->data; 479 dr = dl; dr++; 512 dl = (sw_audio_t *) sample->sounddata->data; 513 dr = dl; 514 dr++; 480 515 481 516 /* Swap channels */ 482 while (active && remaining > 0) { 483 g_mutex_lock (sample->ops_mutex); 484 485 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 486 active = FALSE; 487 } else { 488 489 n = MIN (remaining, 4096); 490 491 for (i = 0; i < n; i++) { 492 t = *dl; 493 *dl = *dr; 494 *dr = t; 495 dl = ++dr; 496 dr++; 497 } 498 499 remaining -= n; 500 run_total += n; 501 502 percent = run_total / ctotal; 503 sample_set_progress_percent (sample, percent); 504 } 505 506 g_mutex_unlock (sample->ops_mutex); 507 } 517 while (active && remaining > 0) 518 { 519 g_mutex_lock (sample->ops_mutex); 520 521 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 522 { 523 active = FALSE; 524 } 525 else 526 { 527 528 n = MIN (remaining, 4096); 529 530 for (i = 0; i < n; i++) 531 { 532 t = *dl; 533 *dl = *dr; 534 *dr = t; 535 dl = ++dr; 536 dr++; 537 } 538 539 remaining -= n; 540 run_total += n; 541 542 percent = run_total / ctotal; 543 sample_set_progress_percent (sample, percent); 544 } 545 546 g_mutex_unlock (sample->ops_mutex); 547 } 508 548 } 509 549 … … 511 551 do_stereo_swap_thread (sw_op_instance * inst) 512 552 { 513 sw_sample * sample = inst->sample;553 sw_sample *sample = inst->sample; 514 554 515 555 do_stereo_swap (sample, NULL); 516 556 517 if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) { 518 register_operation (sample, inst); 519 } 557 if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) 558 { 559 register_operation (sample, inst); 560 } 520 561 } 521 562 522 563 static sw_operation stereo_swap_op = { 523 564 SWEEP_EDIT_MODE_ALLOC, 524 (SweepCallback) do_stereo_swap_thread,525 (SweepFunction) NULL,526 (SweepCallback) do_stereo_swap,527 (SweepFunction) NULL,528 (SweepCallback) do_stereo_swap,529 (SweepFunction) NULL565 (SweepCallback) do_stereo_swap_thread, 566 (SweepFunction) NULL, 567 (SweepCallback) do_stereo_swap, 568 (SweepFunction) NULL, 569 (SweepCallback) do_stereo_swap, 570 (SweepFunction) NULL 530 571 }; 531 572 … … 533 574 stereo_swap_cb (GtkWidget * widget, gpointer data) 534 575 { 535 sw_view * view = (sw_view *)data;536 sw_sample * sample = view->sample;576 sw_view *view = (sw_view *) data; 577 sw_sample *sample = view->sample; 537 578 538 579 if (sample->sounddata->format->channels == 2) … … 548 589 do_change_channels_thread (sw_op_instance * inst) 549 590 { 550 sw_sample * sample = inst->sample;551 int new_channels = GPOINTER_TO_INT (inst->do_data);591 sw_sample *sample = inst->sample; 592 int new_channels = GPOINTER_TO_INT (inst->do_data); 552 593 int min_channels; 553 sw_format * old_format = sample->sounddata->format;554 sw_sounddata * old_sounddata, *new_sounddata;594 sw_format *old_format = sample->sounddata->format; 595 sw_sounddata *old_sounddata, *new_sounddata; 555 596 sw_framecount_t nr_frames; 556 597 557 sw_audio_t * old_d, *new_d;598 sw_audio_t *old_d, *new_d; 558 599 559 600 sw_framecount_t remaining, n, run_total, ctotal; … … 573 614 remaining = nr_frames; 574 615 ctotal = remaining / 100; 575 if (ctotal == 0) ctotal = 1; 616 if (ctotal == 0) 617 ctotal = 1; 576 618 run_total = 0; 577 619 578 old_d = (sw_audio_t *) old_sounddata->data;579 new_d = (sw_audio_t *) new_sounddata->data;620 old_d = (sw_audio_t *) old_sounddata->data; 621 new_d = (sw_audio_t *) new_sounddata->data; 580 622 581 623 /* Create selections */ … … 585 627 586 628 /* Mix down */ 587 while (active && remaining > 0) { 588 g_mutex_lock (sample->ops_mutex); 589 590 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 591 active = FALSE; 592 } else { 593 594 n = MIN (remaining, 4096); 595 596 for (i = 0; i < n; i++) { 597 for (j = 0; j < min_channels; j++) { 598 new_d[j] = old_d[j]; 599 } 600 old_d += old_format->channels; 601 new_d += new_channels; 602 } 603 604 remaining -= n; 605 run_total += n; 606 607 percent = run_total / ctotal; 608 sample_set_progress_percent (sample, percent); 609 } 610 611 g_mutex_unlock (sample->ops_mutex); 612 } 613 614 if (remaining > 0) { /* cancelled or failed */ 615 sounddata_destroy (new_sounddata); 616 } else if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) { 617 sample->sounddata = new_sounddata; 618 619 inst->redo_data = inst->undo_data = 620 sounddata_replace_data_new (sample, old_sounddata, new_sounddata); 621 622 register_operation (sample, inst); 623 } 629 while (active && remaining > 0) 630 { 631 g_mutex_lock (sample->ops_mutex); 632 633 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 634 { 635 active = FALSE; 636 } 637 else 638 { 639 640 n = MIN (remaining, 4096); 641 642 for (i = 0; i < n; i++) 643 { 644 for (j = 0; j < min_channels; j++) 645 { 646 new_d[j] = old_d[j]; 647 } 648 old_d += old_format->channels; 649 new_d += new_channels; 650 } 651 652 remaining -= n; 653 run_total += n; 654 655 percent = run_total / ctotal; 656 sample_set_progress_percent (sample, percent); 657 } 658 659 g_mutex_unlock (sample->ops_mutex); 660 } 661 662 if (remaining > 0) 663 { /* cancelled or failed */ 664 sounddata_destroy (new_sounddata); 665 } 666 else if (sample->edit_state == SWEEP_EDIT_STATE_BUSY) 667 { 668 sample->sounddata = new_sounddata; 669 670 inst->redo_data = inst->undo_data = 671 sounddata_replace_data_new (sample, old_sounddata, new_sounddata); 672 673 register_operation (sample, inst); 674 } 624 675 } 625 676 626 677 static sw_operation change_channels_op = { 627 678 SWEEP_EDIT_MODE_ALLOC, 628 (SweepCallback) do_change_channels_thread,629 (SweepFunction) NULL,630 (SweepCallback) undo_by_sounddata_replace,631 (SweepFunction) sounddata_replace_data_destroy,632 (SweepCallback) redo_by_sounddata_replace,633 (SweepFunction) sounddata_replace_data_destroy679 (SweepCallback) do_change_channels_thread, 680 (SweepFunction) NULL, 681 (SweepCallback) undo_by_sounddata_replace, 682 (SweepFunction) sounddata_replace_data_destroy, 683 (SweepCallback) redo_by_sounddata_replace, 684 (SweepFunction) sounddata_replace_data_destroy 634 685 }; 635 686 … … 643 694 g_snprintf (buf, BUF_LEN, _("Convert from %d to %d channels"), 644 695 sample->sounddata->format->channels, new_channels); 645 696 646 697 schedule_operation (sample, buf, &change_channels_op, 647 GINT_TO_POINTER (new_channels));698 GINT_TO_POINTER (new_channels)); 648 699 } 649 700 … … 651 702 channels_dialog_ok_cb (GtkWidget * widget, gpointer data) 652 703 { 653 sw_sample * sample = (sw_sample *)data;654 GtkWidget * dialog;655 GtkWidget * chooser;704 sw_sample *sample = (sw_sample *) data; 705 GtkWidget *dialog; 706 GtkWidget *chooser; 656 707 657 708 int new_channels; … … 659 710 dialog = gtk_widget_get_toplevel (widget); 660 711 661 chooser = g_object_get_data (G_OBJECT (dialog), "default");712 chooser = g_object_get_data (G_OBJECT (dialog), "default"); 662 713 new_channels = channelcount_chooser_get_count (chooser); 663 714 … … 670 721 channels_dialog_cancel_cb (GtkWidget * widget, gpointer data) 671 722 { 672 GtkWidget * dialog;723 GtkWidget *dialog; 673 724 674 725 dialog = gtk_widget_get_toplevel (widget); … … 679 730 channels_dialog_new_cb (GtkWidget * widget, gpointer data) 680 731 { 681 sw_view * view = (sw_view *)data;682 sw_sample * sample = view->sample;683 GtkWidget * dialog;684 GtkWidget * main_vbox;685 GtkWidget * label;686 GtkWidget * chooser;687 GtkWidget * button, *ok_button;688 689 gchar * current;732 sw_view *view = (sw_view *) data; 733 sw_sample *sample = view->sample; 734 GtkWidget *dialog; 735 GtkWidget *main_vbox; 736 GtkWidget *label; 737 GtkWidget *chooser; 738 GtkWidget *button, *ok_button; 739 740 gchar *current; 690 741 691 742 dialog = gtk_dialog_new (); 692 gtk_window_set_title (GTK_WINDOW (dialog), _("Sweep: Add/Remove channels"));743 gtk_window_set_title (GTK_WINDOW (dialog), _("Sweep: Add/Remove channels")); 693 744 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); 694 gtk_container_set_border_width (GTK_CONTAINER (dialog), 8);695 696 main_vbox = GTK_DIALOG (dialog)->vbox;745 gtk_container_set_border_width (GTK_CONTAINER (dialog), 8); 746 747 main_vbox = GTK_DIALOG (dialog)->vbox; 697 748 698 749 current = g_strdup_printf (_("Currently: %d channels"), 699 750 sample->sounddata->format->channels); 700 751 label = gtk_label_new (current); 701 gtk_box_pack_start (GTK_BOX (main_vbox), label, TRUE, TRUE, 8);752 gtk_box_pack_start (GTK_BOX (main_vbox), label, TRUE, TRUE, 8); 702 753 gtk_widget_show (label); 703 754 704 755 chooser = channelcount_chooser_new (_("Output channels")); 705 gtk_box_pack_start (GTK_BOX (main_vbox), chooser, TRUE, TRUE, 0);756 gtk_box_pack_start (GTK_BOX (main_vbox), chooser, TRUE, TRUE, 0); 706 757 channelcount_chooser_set_count (chooser, 707 758 sample->sounddata->format->channels); 708 759 gtk_widget_show (chooser); 709 760 710 g_object_set_data (G_OBJECT (dialog), "default", chooser);761 g_object_set_data (G_OBJECT (dialog), "default", chooser); 711 762 712 763 /* OK */ … … 714 765 ok_button = gtk_button_new_with_label (_("OK")); 715 766 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (ok_button), GTK_CAN_DEFAULT); 716 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), ok_button,767 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), ok_button, 717 768 TRUE, TRUE, 0); 718 769 gtk_widget_show (ok_button); 719 g_signal_connect (G_OBJECT(ok_button), "clicked", 720 G_CALLBACK (channels_dialog_ok_cb), 721 sample); 770 g_signal_connect (G_OBJECT (ok_button), "clicked", 771 G_CALLBACK (channels_dialog_ok_cb), sample); 722 772 723 773 /* Cancel */ … … 725 775 button = gtk_button_new_with_label (_("Cancel")); 726 776 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (button), GTK_CAN_DEFAULT); 727 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button,777 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button, 728 778 TRUE, TRUE, 0); 729 779 gtk_widget_show (button); 730 g_signal_connect (G_OBJECT(button), "clicked", 731 G_CALLBACK (channels_dialog_cancel_cb), 732 NULL); 780 g_signal_connect (G_OBJECT (button), "clicked", 781 G_CALLBACK (channels_dialog_cancel_cb), NULL); 733 782 734 783 gtk_widget_grab_default (ok_button); sweep/branches/display-cache/src/channelops.h
r124 r471 23 23 #define __CHANNELOPS_H__ 24 24 25 void 26 dup_stereo_cb (GtkWidget * widget, gpointer data); 25 void dup_stereo_cb (GtkWidget * widget, gpointer data); 27 26 28 void 29 dup_channels_dialog_new_cb (GtkWidget * widget, gpointer data); 27 void dup_channels_dialog_new_cb (GtkWidget * widget, gpointer data); 30 28 31 void 32 mono_mixdown_cb (GtkWidget * widget, gpointer data); 29 void mono_mixdown_cb (GtkWidget * widget, gpointer data); 33 30 34 void 35 remove_left_cb (GtkWidget * widget, gpointer data); 31 void remove_left_cb (GtkWidget * widget, gpointer data); 36 32 37 void 38 remove_right_cb (GtkWidget * widget, gpointer data); 33 void remove_right_cb (GtkWidget * widget, gpointer data); 39 34 40 void 41 stereo_swap_cb (GtkWidget * widget, gpointer data); 35 void stereo_swap_cb (GtkWidget * widget, gpointer data); 42 36 43 void 44 channels_dialog_new_cb (GtkWidget * widget, gpointer data); 37 void channels_dialog_new_cb (GtkWidget * widget, gpointer data); 45 38 46 39 #endif /* __CHANNELOPS_H__ */ sweep/branches/display-cache/src/cursors.c
r387 r471 42 42 #include "../pixmaps/zoom_out_mask.xbm" 43 43 44 GdkCursor * sweep_cursors[SWEEP_CURSOR_MAX];44 GdkCursor *sweep_cursors[SWEEP_CURSOR_MAX]; 45 45 46 46 47 47 void 48 48 create_bitmap_and_mask_from_xpm (GdkBitmap ** bitmap, 49 GdkBitmap ** mask, 50 gchar ** xpm) 49 GdkBitmap ** mask, gchar ** xpm) 51 50 { 52 51 int height, width, colors; 53 char pixmap_buffer [(32 * 32)/8];54 char mask_buffer [(32 * 32)/8];52 char pixmap_buffer[(32 * 32) / 8]; 53 char mask_buffer[(32 * 32) / 8]; 55 54 int x, y, pix; 56 55 int transparent_color, black_color; 57 56 58 sscanf (xpm [0], "%d %d %d %d", &height, &width, &colors, &pix);57 sscanf (xpm[0], "%d %d %d %d", &height, &width, &colors, &pix); 59 58 60 59 g_assert (height == 32); … … 65 64 black_color = '.'; 66 65 67 for (y = 0; y < 32; y++) { 68 for (x = 0; x < 32;) { 69 char value = 0, maskv = 0; 66 for (y = 0; y < 32; y++) 67 { 68 for (x = 0; x < 32;) 69 { 70 char value = 0, maskv = 0; 70 71 71 for (pix = 0; pix < 8; pix++, x++) { 72 if (xpm [4+y][x] != transparent_color) { 73 maskv |= 1 << pix; 72 for (pix = 0; pix < 8; pix++, x++) 73 { 74 if (xpm[4 + y][x] != transparent_color) 75 { 76 maskv |= 1 << pix; 74 77 75 if (xpm [4+y][x] != black_color) { 76 value |= 1 << pix; 77 } 78 if (xpm[4 + y][x] != black_color) 79 { 80 value |= 1 << pix; 81 } 82 } 83 } 84 85 pixmap_buffer[(y * 4 + x / 8) - 1] = value; 86 mask_buffer[(y * 4 + x / 8) - 1] = maskv; 78 87 } 79 }80 81 pixmap_buffer [(y * 4 + x/8) - 1] = value;82 mask_buffer [(y * 4 + x/8) - 1] = maskv;83 88 } 84 }85 89 86 90 *bitmap = gdk_bitmap_create_from_data (NULL, pixmap_buffer, 32, 32); … … 91 95 init_cursors (void) 92 96 { 93 GdkBitmap * bitmap;94 GdkBitmap * mask;95 GdkColor white = { 0, 0xffff, 0xffff, 0xffff};96 GdkColor black = { 0, 0x0000, 0x0000, 0x0000};97 GdkBitmap *bitmap; 98 GdkBitmap *mask; 99 GdkColor white = { 0, 0xffff, 0xffff, 0xffff }; 100 GdkColor black = { 0, 0x0000, 0x0000, 0x0000 }; 97 101 98 102 sweep_cursors[SWEEP_CURSOR_CROSSHAIR] = gdk_cursor_new (GDK_XTERM); 99 /* sweep_cursors[SWEEP_CURSOR_MOVE] = gdk_cursor_new (GDK_FLEUR); */103 /* sweep_cursors[SWEEP_CURSOR_MOVE] = gdk_cursor_new (GDK_FLEUR); */ 100 104 sweep_cursors[SWEEP_CURSOR_PENCIL] = gdk_cursor_new (GDK_PENCIL); 101 105 sweep_cursors[SWEEP_CURSOR_NOISE] = gdk_cursor_new (GDK_SPRAYCAN); 106 sweep_cursors[SWEEP_CURSOR_HAND] = gdk_cursor_new (GDK_HAND1); 102 107 103 108 create_bitmap_and_mask_from_xpm (&bitmap, &mask, horiz_xpm); 104 109 105 110 sweep_cursors[SWEEP_CURSOR_HORIZ] = 106 111 gdk_cursor_new_from_pixmap (bitmap, mask, &white, &black, 8, 8); 107 112 108 113 create_bitmap_and_mask_from_xpm (&bitmap, &mask, horiz_plus_xpm); 109 114 110 115 sweep_cursors[SWEEP_CURSOR_HORIZ_PLUS] = 111 116 gdk_cursor_new_from_pixmap (bitmap, mask, &white, &black, 8, 8); 112 117 113 118 create_bitmap_and_mask_from_xpm (&bitmap, &mask, horiz_minus_xpm); 114 119 115 120 sweep_cursors[SWEEP_CURSOR_HORIZ_MINUS] = 116 121 gdk_cursor_new_from_pixmap (bitmap, mask, &white, &black, 8, 8); sweep/branches/display-cache/src/cursors.h
r124 r471 22 22 #define __CURSORS_H__ 23 23 24 enum { 24 enum 25 { 25 26 SWEEP_CURSOR_CROSSHAIR, 26 27 SWEEP_CURSOR_MOVE, … … 33 34 SWEEP_CURSOR_PENCIL, 34 35 SWEEP_CURSOR_NOISE, 36 SWEEP_CURSOR_HAND, 35 37 SWEEP_CURSOR_MAX 36 38 }; … … 38 40 void 39 41 create_bitmap_and_mask_from_xpm (GdkBitmap ** bitmap, 40 GdkBitmap ** mask, 41 gchar ** xpm); 42 GdkBitmap ** mask, gchar ** xpm); 42 43 43 void 44 init_cursors (void); 44 void init_cursors (void); 45 45 46 46 #endif sweep/branches/display-cache/src/db_ruler.c
r340 r471 55 55 56 56 57 static void db_ruler_class_init (DbRulerClass *klass);58 static void db_ruler_init (DbRuler *db_ruler);57 static void db_ruler_class_init (DbRulerClass * klass); 58 static void db_ruler_init (DbRuler * db_ruler); 59 59 static void db_ruler_realize (GtkWidget * widget); 60 static gint 61 db_ruler_button_press (GtkWidget * widget, GdkEventButton * event);62 static gint 63 db_ruler_button_release (GtkWidget * widget, GdkEventButton * event);64 static gint 65 db_ruler_motion_notify (GtkWidget * widget, GdkEventMotion *event);60 static gint 61 db_ruler_button_press (GtkWidget * widget, GdkEventButton * event); 62 static gint 63 db_ruler_button_release (GtkWidget * widget, GdkEventButton * event); 64 static gint 65 db_ruler_motion_notify (GtkWidget * widget, GdkEventMotion * event); 66 66 static gint 67 67 db_ruler_leave_notify (GtkWidget * widget, GdkEventCrossing * event); 68 68 69 static gboolean db_ruler_scroll_event (GtkWidget * widget, GdkEventScroll *event); 70 71 static void db_ruler_draw_ticks (GtkRuler *ruler); 72 static void db_ruler_draw_pos (GtkRuler *ruler); 73 74 static GtkWidgetClass * parent_class = NULL; 75 76 enum { 69 static gboolean db_ruler_scroll_event (GtkWidget * widget, 70 GdkEventScroll * event); 71 72 static void db_ruler_draw_ticks (GtkRuler * ruler); 73 static void db_ruler_draw_pos (GtkRuler * ruler); 74 75 static GtkWidgetClass *parent_class = NULL; 76 77 enum 78 { 77 79 CHANGED_SIGNAL, 78 80 LAST_SIGNAL … … 88 90 if (!db_ruler_type) 89 91 { 90 static const GTypeInfo db_ruler_info = 91 { 92 92 static const GTypeInfo db_ruler_info = { 93 93 94 sizeof (DbRulerClass), 94 NULL, /* base_init */95 NULL, /* base_finalize */95 NULL, /* base_init */ 96 NULL, /* base_finalize */ 96 97 (GClassInitFunc) db_ruler_class_init, 97 NULL, /* class_finalize */98 NULL, /* class_data */98 NULL, /* class_finalize */ 99 NULL, /* class_data */ 99 100 sizeof (DbRuler), 100 0, /* n_preallocs */101 (GInstanceInitFunc) db_ruler_init, 101 0, /* n_preallocs */ 102 (GInstanceInitFunc) db_ruler_init, 102 103 103 104 }; 104 105 105 db_ruler_type = g_type_register_static (GTK_TYPE_RULER, "DbRuler", &db_ruler_info, 0); 106 db_ruler_type = 107 g_type_register_static (GTK_TYPE_RULER, "DbRuler", &db_ruler_info, 0); 106 108 } 107 109 … … 110 112 111 113 static void 112 db_ruler_class_init (DbRulerClass * klass)114 db_ruler_class_init (DbRulerClass * klass) 113 115 { 114 116 GtkObjectClass *object_class; … … 117 119 118 120 object_class = (GtkObjectClass *) klass; 119 widget_class = (GtkWidgetClass *) klass;120 ruler_class = (GtkRulerClass *) klass;121 widget_class = (GtkWidgetClass *) klass; 122 ruler_class = (GtkRulerClass *) klass; 121 123 122 124 widget_class->realize = db_ruler_realize; … … 133 135 134 136 db_ruler_signals[CHANGED_SIGNAL] = g_signal_new ("changed", 135 G_TYPE_FROM_CLASS (klass),136 G_SIGNAL_RUN_FIRST,137 G_STRUCT_OFFSET (DbRulerClass, changed),138 NULL, 139 NULL, 140 g_cclosure_marshal_VOID__VOID,141 G_TYPE_NONE, 0);137 G_TYPE_FROM_CLASS (klass), 138 G_SIGNAL_RUN_FIRST, 139 G_STRUCT_OFFSET 140 (DbRulerClass, changed), 141 NULL, NULL, 142 g_cclosure_marshal_VOID__VOID, 143 G_TYPE_NONE, 0); 142 144 klass->changed = NULL; 143 145 } 144 146 145 147 static gfloat ruler_scale[MAXIMUM_SCALES] = 146 { 0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 147 3, 6, 12, 15, 30, 60, 300, 600, 1800, 3600, 18000, 36000 }; 148 { 0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 149 3, 6, 12, 15, 30, 60, 300, 600, 1800, 3600, 18000, 36000 150 }; 148 151 149 152 static gint subdivide[MAXIMUM_SUBDIVIDE] = { 1, 5, 20 }; 150 153 151 154 static void 152 db_ruler_init (DbRuler * db_ruler)155 db_ruler_init (DbRuler * db_ruler) 153 156 { 154 157 GtkWidget *widget; … … 158 161 widget->requisition.height = widget->style->ythickness * 2 + 1; 159 162 160 DB_RULER (db_ruler)->dragging = FALSE;163 DB_RULER (db_ruler)->dragging = FALSE; 161 164 } 162 165 … … 164 167 db_ruler_realize (GtkWidget * widget) 165 168 { 166 GtkRuler * ruler;169 GtkRuler *ruler; 167 170 GdkWindowAttr attributes; 168 171 gint attributes_mask; 169 GdkVisual * visual;172 GdkVisual *visual; 170 173 171 174 g_return_if_fail (widget != NULL); … … 174 177 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); 175 178 176 ruler = GTK_RULER (widget);179 ruler = GTK_RULER (widget); 177 180 178 181 attributes.x = widget->allocation.x; … … 196 199 widget->style = gtk_style_attach (widget->style, widget->window); 197 200 198 gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);199 200 gdk_window_set_user_data (widget->window, widget);201 gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); 202 203 gdk_window_set_user_data (widget->window, widget); 201 204 202 205 visual = gdk_window_get_visual (widget->window); 203 206 204 if (ruler->backing_store != NULL) { 205 gdk_pixmap_unref (ruler->backing_store); 206 } 207 if (ruler->backing_store != NULL) 208 { 209 gdk_pixmap_unref (ruler->backing_store); 210 } 207 211 208 212 ruler->backing_store = gdk_pixmap_new (widget->window, … … 215 219 } 216 220 217 GtkWidget *221 GtkWidget * 218 222 db_ruler_new (void) 219 223 { … … 222 226 223 227 static gint 224 db_ruler_motion_notify (GtkWidget * widget, GdkEventMotion *event)228 db_ruler_motion_notify (GtkWidget * widget, GdkEventMotion * event) 225 229 { 226 230 GtkRuler *ruler; … … 240 244 y = event->y; 241 245 242 if (DB_RULER(widget)->dragging && (state & GDK_BUTTON1_MASK)) { 243 ydelta = DB_RULER(widget)->y - y; 244 245 delta = (((ruler->lower - ruler->upper) * ydelta) / widget->allocation.height); 246 247 gtk_ruler_set_range (ruler, ruler->lower + delta, ruler->upper + delta, 248 (ruler->upper - ruler->lower)/2.0, 2.0); 249 250 g_signal_emit_by_name (ruler, "changed"); 251 252 gtk_ruler_draw_ticks (ruler); 253 } 254 255 DB_RULER(widget)->y = y; 246 if (DB_RULER (widget)->dragging && (state & GDK_BUTTON1_MASK)) 247 { 248 ydelta = DB_RULER (widget)->y - y; 249 250 delta = 251 (((ruler->lower - 252 ruler->upper) * ydelta) / widget->allocation.height); 253 254 gtk_ruler_set_range (ruler, ruler->lower + delta, ruler->upper + delta, 255 (ruler->upper - ruler->lower) / 2.0, 2.0); 256 257 g_signal_emit_by_name (ruler, "changed"); 258 259 gtk_ruler_draw_ticks (ruler); 260 } 261 262 DB_RULER (widget)->y = y; 256 263 257 264 ruler->position = … … 264 271 265 272 #if 0 266 printf ("%f\t%f dB\n", ruler->position, 20 * log10 (fabs(ruler->position))); 273 printf ("%f\t%f dB\n", ruler->position, 274 20 * log10 (fabs (ruler->position))); 267 275 #endif 268 276 … … 273 281 db_ruler_button_press (GtkWidget * widget, GdkEventButton * event) 274 282 { 275 int y;283 int y; 276 284 277 285 gdk_window_get_pointer (event->window, NULL, &y, NULL); 278 279 switch (event->button) { 280 case 1: 281 DB_RULER(widget)->y = y; 282 DB_RULER(widget)->dragging = TRUE; 283 break; 284 default: 285 break; 286 } 286 287 switch (event->button) 288 { 289 case 1: 290 DB_RULER (widget)->y = y; 291 DB_RULER (widget)->dragging = TRUE; 292 break; 293 default: 294 break; 295 } 287 296 288 297 return TRUE; … … 292 301 db_ruler_button_release (GtkWidget * widget, GdkEventButton * event) 293 302 { 294 DB_RULER (widget)->dragging = FALSE;303 DB_RULER (widget)->dragging = FALSE; 295 304 296 305 return TRUE; … … 298 307 299 308 static gboolean 300 db_ruler_scroll_event (GtkWidget * widget, GdkEventScroll *event)301 { 302 GtkRuler * ruler = GTK_RULER(widget);309 db_ruler_scroll_event (GtkWidget * widget, GdkEventScroll * event) 310 { 311 GtkRuler *ruler = GTK_RULER (widget); 303 312 float delta; 304 313 305 if (event->direction == GDK_SCROLL_UP) { /* mouse wheel scroll up */ 306 307 delta = ruler->upper - ruler->lower; 308 gtk_ruler_set_range (ruler, ruler->lower + delta/8, ruler->upper - delta/8, 309 (ruler->upper - ruler->lower)/2.0, 2.0); 310 g_signal_emit_by_name (ruler, "changed"); 311 return TRUE; 312 313 } else if (event->direction == GDK_SCROLL_DOWN) { /* mouse wheel scroll down */ 314 315 delta = ruler->upper - ruler->lower; 316 gtk_ruler_set_range (ruler, ruler->lower - delta/8, ruler->upper + delta/8, 317 (ruler->upper - ruler->lower)/2.0, 2.0); 318 g_signal_emit_by_name (ruler, "changed"); 319 return TRUE; 320 } 321 return FALSE; /* redundant? */ 314 if (event->direction == GDK_SCROLL_UP) 315 { /* mouse wheel scroll up */ 316 317 delta = ruler->upper - ruler->lower; 318 gtk_ruler_set_range (ruler, ruler->lower + delta / 8, 319 ruler->upper - delta / 8, 320 (ruler->upper - ruler->lower) / 2.0, 2.0); 321 g_signal_emit_by_name (ruler, "changed"); 322 return TRUE; 323 324 } 325 else if (event->direction == GDK_SCROLL_DOWN) 326 { /* mouse wheel scroll down */ 327 328 delta = ruler->upper - ruler->lower; 329 gtk_ruler_set_range (ruler, ruler->lower - delta / 8, 330 ruler->upper + delta / 8, 331 (ruler->upper - ruler->lower) / 2.0, 2.0); 332 g_signal_emit_by_name (ruler, "changed"); 333 return TRUE; 334 } 335 return FALSE; /* redundant? */ 322 336 } 323 337 … … 325 339 db_ruler_leave_notify (GtkWidget * widget, GdkEventCrossing * event) 326 340 { 327 DB_RULER (widget)->dragging = FALSE;341 DB_RULER (widget)->dragging = FALSE; 328 342 329 343 return TRUE; … … 331 345 332 346 static void 333 db_ruler_draw_ticks (GtkRuler * ruler)347 db_ruler_draw_ticks (GtkRuler * ruler) 334 348 { 335 349 GtkWidget *widget; … … 341 355 gint length, ideal_length; 342 356 gfloat lower, upper; /* Upper and lower limits, in ruler units */ 343 gfloat increment, abs_increment; /* Number of pixels per unit */357 gfloat increment, abs_increment; /* Number of pixels per unit */ 344 358 gint scale; /* Number of units per major unit */ 345 359 gfloat subd_incr; … … 357 371 g_return_if_fail (GTK_IS_DB_RULER (ruler)); 358 372 359 if (!GTK_WIDGET_DRAWABLE (ruler)) 373 if (!GTK_WIDGET_DRAWABLE (ruler)) 360 374 return; 361 375 … … 368 382 ythickness = widget->style->ythickness; 369 383 370 width = widget->allocation.width - ( xthickness * 2);371 /* height = widget->allocation.height - ythickness * 2; */384 width = widget->allocation.width - (xthickness * 2); 385 /* height = widget->allocation.height - ythickness * 2; */ 372 386 height = widget->allocation.height; 373 387 374 388 layout = gtk_widget_create_pango_layout (widget, "012456789dBinf-"); 375 389 pango_layout_get_extents (layout, &ink_rect, &logical_rect); 376 390 377 391 digit_height = PANGO_PIXELS (ink_rect.height) + 2; 378 392 digit_offset = ink_rect.y; 379 393 380 394 gtk_paint_box (widget->style, ruler->backing_store, 381 GTK_STATE_NORMAL, GTK_SHADOW_OUT, 395 GTK_STATE_NORMAL, GTK_SHADOW_OUT, 382 396 NULL, widget, "db_ruler", 383 0, 0, 384 widget->allocation.width, widget->allocation.height); 397 0, 0, widget->allocation.width, widget->allocation.height); 385 398 386 399 gdk_draw_line (ruler->backing_store, gc, 387 400 width + xthickness, 388 ythickness, 389 width + xthickness, 390 height - ythickness); 391 392 upper = ruler->upper / ruler->metric->pixels_per_unit; 393 lower = ruler->lower / ruler->metric->pixels_per_unit; 401 ythickness, width + xthickness, height - ythickness); 402 403 upper = ruler->upper / ruler->metric->pixels_per_unit; 404 lower = ruler->lower / ruler->metric->pixels_per_unit; 394 405 395 406 // upper = ruler->upper; 396 407 // lower = ruler->lower; 397 408 398 if ((upper - lower) == 0) 409 if ((upper - lower) == 0) 399 410 return; 400 411 401 412 increment = (gfloat) height / (upper - lower); 402 abs_increment = (gfloat) fabs ((double)increment);413 abs_increment = (gfloat) fabs ((double) increment); 403 414 404 415 // * strlen (unit_str) 405 text_height =digit_height + 1;416 text_height = digit_height + 1; 406 417 407 418 for (scale = 0; scale < MAXIMUM_SCALES; scale++) 408 /* if (ruler->metric->ruler_scale[scale] * fabs(increment) > 2 * text_height)409 break;*/410 if (ruler_scale[scale] * abs_increment > 2 * digit_height)419 /* if (ruler->metric->ruler_scale[scale] * fabs(increment) > 2 * text_height) 420 break; */ 421 if (ruler_scale[scale] * abs_increment > 2 * digit_height) 411 422 break; 412 423 if (scale == MAXIMUM_SCALES) … … 419 430 420 431 gtk_paint_layout (widget->style, 421 ruler->backing_store, 422 GTK_WIDGET_STATE (widget), 423 FALSE, 424 NULL, 425 widget, 426 "vruler", 427 2, 428 (digit_height/2), 429 layout); 432 ruler->backing_store, 433 GTK_WIDGET_STATE (widget), 434 FALSE, 435 NULL, widget, "vruler", 2, (digit_height / 2), layout); 430 436 431 437 length = 0; 432 438 for (i = MAXIMUM_SUBDIVIDE - 1; i >= 0; i--) 433 439 { 434 subd_incr = (gfloat) ruler_scale[scale] / 435 (gfloat) subdivide[i]; 436 if (subd_incr * fabs(increment) <= MINIMUM_INCR) 440 subd_incr = (gfloat) ruler_scale[scale] / (gfloat) subdivide[i]; 441 if (subd_incr * fabs (increment) <= MINIMUM_INCR) 437 442 continue; 438 443 … … 447 452 { 448 453 start = floor (lower / subd_incr) * subd_incr; 449 end = ceil(upper / subd_incr) * subd_incr;454 end = ceil (upper / subd_incr) * subd_incr; 450 455 } 451 456 else 452 457 { 453 458 start = floor (upper / subd_incr) * subd_incr; 454 end = ceil(lower / subd_incr) * subd_incr;459 end = ceil (lower / subd_incr) * subd_incr; 455 460 } 456 461 … … 464 469 465 470 /* draw label */ 466 if (i == 0 && cur < upper && cur > lower) { 467 float a_cur = fabs(cur), db_cur; 468 469 /* ensure inf. stays as 'inf.', not nearby large values */ 470 if (a_cur < subd_incr/2) a_cur = 0.0; 471 db_cur = 20 * log10 (a_cur); 472 473 if (db_cur > -10.0) { 474 snprintf (unit_str, UNIT_STR_LEN, "%1.1f", db_cur); 475 } else { 476 snprintf (unit_str, UNIT_STR_LEN, "%2.0f", db_cur); 477 } 478 479 pango_layout_set_text (layout, unit_str, -1); 480 481 gtk_paint_layout (widget->style, 482 ruler->backing_store, 483 GTK_WIDGET_STATE (widget), 484 FALSE, 485 NULL, 486 widget, 487 "vruler", 488 2, 489 pos - (digit_height), 490 layout); 471 if (i == 0 && cur < upper && cur > lower) 472 { 473 float a_cur = fabs (cur), db_cur; 474 475 /* ensure inf. stays as 'inf.', not nearby large values */ 476 if (a_cur < subd_incr / 2) 477 a_cur = 0.0; 478 db_cur = 20 * log10 (a_cur); 479 480 if (db_cur > -10.0) 481 { 482 snprintf (unit_str, UNIT_STR_LEN, "%1.1f", db_cur); 483 } 484 else 485 { 486 snprintf (unit_str, UNIT_STR_LEN, "%2.0f", db_cur); 487 } 488 489 pango_layout_set_text (layout, unit_str, -1); 490 491 gtk_paint_layout (widget->style, 492 ruler->backing_store, 493 GTK_WIDGET_STATE (widget), 494 FALSE, 495 NULL, 496 widget, 497 "vruler", 2, pos - (digit_height), layout); 491 498 } 492 499 } 493 494 } 495 500 501 } 502 496 503 } 497 504 498 505 static void 499 db_ruler_draw_pos (GtkRuler * ruler)506 db_ruler_draw_pos (GtkRuler * ruler) 500 507 { 501 508 GtkWidget *widget; … … 530 537 if (ruler->backing_store && ruler->non_gr_exp_gc) 531 538 gdk_draw_drawable (ruler->widget.window, 532 ruler->non_gr_exp_gc, 533 ruler->backing_store, 534 ruler->xsrc, ruler->ysrc, 535 ruler->xsrc, ruler->ysrc, 536 bs_width, bs_height); 539 ruler->non_gr_exp_gc, 540 ruler->backing_store, 541 ruler->xsrc, ruler->ysrc, 542 ruler->xsrc, ruler->ysrc, bs_width, bs_height); 537 543 538 544 increment = (gfloat) height / (ruler->upper - ruler->lower); 539 545 540 546 x = (width - bs_width) + xthickness - 2; 541 y = DB_RULER (ruler)->y;547 y = DB_RULER (ruler)->y; 542 548 543 549 for (i = 0; i < bs_width; i++) 544 550 gdk_draw_line (widget->window, gc, 545 x + i, y + i, 546 x + i, y + bs_height - 1 - i); 551 x + i, y + i, x + i, y + bs_height - 1 - i); 547 552 548 553 ruler->xsrc = x; sweep/branches/display-cache/src/db_ruler.h
r213 r471 43 43 44 44 #ifdef __cplusplus 45 extern "C" { 46 #endif /* __cplusplus */ 45 extern "C" 46 { 47 #endif /* __cplusplus */ 47 48 48 49 … … 52 53 53 54 54 typedef struct _DbRulerDbRuler;55 typedef struct _DbRulerClassDbRulerClass;55 typedef struct _DbRuler DbRuler; 56 typedef struct _DbRulerClass DbRulerClass; 56 57 57 struct _DbRuler58 {59 GtkRuler ruler;58 struct _DbRuler 59 { 60 GtkRuler ruler; 60 61 61 gfloat y;62 gboolean dragging;63 };62 gfloat y; 63 gboolean dragging; 64 }; 64 65 65 struct _DbRulerClass66 {67 GtkRulerClass parent_class;66 struct _DbRulerClass 67 { 68 GtkRulerClass parent_class; 68 69 69 void (*changed) (DbRuler * ruler);70 };70 void (*changed) (DbRuler * ruler); 71 }; 71 72 72 73 73 GTypedb_ruler_get_type (void);74 GtkWidget* db_ruler_new(void);74 GType db_ruler_get_type (void); 75 GtkWidget *db_ruler_new (void); 75 76 76 77 #ifdef __cplusplus 77 78 } 78 #endif /* __cplusplus */79 #endif /* __cplusplus */ 79 80 80 81 81 #endif /* __DB_RULER_H__ */82 #endif /* __DB_RULER_H__ */ sweep/branches/display-cache/src/db_slider.c
r298 r471 42 42 #include "db_slider.h" 43 43 44 enum { 44 enum 45 { 45 46 VALUE_CHANGED_SIGNAL, 46 47 LAST_SIGNAL … … 50 51 51 52 static void 52 db_slider_class_init (DbSliderClass * klass)53 db_slider_class_init (DbSliderClass * klass) 53 54 { 54 55 GtkObjectClass *object_class; … … 57 58 58 59 db_slider_signals[VALUE_CHANGED_SIGNAL] = g_signal_new ("value-changed", 59 G_TYPE_FROM_CLASS (klass), 60 G_SIGNAL_RUN_FIRST, 61 G_STRUCT_OFFSET (DbSliderClass, value_changed), 62 NULL, 63 NULL, 64 g_cclosure_marshal_VOID__FLOAT, 65 G_TYPE_NONE, 1, G_TYPE_FLOAT); 60 G_TYPE_FROM_CLASS 61 (klass), 62 G_SIGNAL_RUN_FIRST, 63 G_STRUCT_OFFSET 64 (DbSliderClass, 65 value_changed), 66 NULL, NULL, 67 g_cclosure_marshal_VOID__FLOAT, 68 G_TYPE_NONE, 1, 69 G_TYPE_FLOAT); 66 70 klass->value_changed = NULL; 67 71 } … … 73 77 74 78 GType 75 db_slider_get_type ()79 db_slider_get_type () 76 80 { 77 81 static GType db_slider_type = 0; 78 82 79 if (!db_slider_type) { 80 static const GTypeInfo db_slider_info = 81 { 82 sizeof(DbSliderClass), 83 NULL, /* base_init */ 84 NULL, /* base_finalize */ 85 (GClassInitFunc) db_slider_class_init, 86 NULL, /* class_finalize */ 87 NULL, /* class_data */ 88 sizeof (DbSlider), 89 0, 90 (GInstanceInitFunc) db_slider_init, 91 92 }; 93 94 db_slider_type = g_type_register_static(GTK_TYPE_VBOX, "DbSlider" ,&db_slider_info, 0); 95 96 } 83 if (!db_slider_type) 84 { 85 static const GTypeInfo db_slider_info = { 86 sizeof (DbSliderClass), 87 NULL, /* base_init */ 88 NULL, /* base_finalize */ 89 (GClassInitFunc) db_slider_class_init, 90 NULL, /* class_finalize */ 91 NULL, /* class_data */ 92 sizeof (DbSlider), 93 0, 94 (GInstanceInitFunc) db_slider_init, 95 96 }; 97 98 db_slider_type = 99 g_type_register_static (GTK_TYPE_VBOX, "DbSlider", &db_slider_info, 100 0); 101 102 } 97 103 98 104 return db_slider_type; … … 103 109 slider_get_value (GtkWidget * slider) 104 110 { 105 return 106 GPOINTER_TO_INT (g_object_get_data (G_OBJECT(slider), "value")); 111 return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (slider), "value")); 107 112 } 108 113 … … 110 115 slider_set_value (GtkWidget * slider, int value) 111 116 { 112 GtkWidget * combo_entry;117 GtkWidget *combo_entry; 113 118 int i; 114 119 115 120 combo_entry = 116 GTK_WIDGET (g_object_get_data (G_OBJECT(slider), "combo_entry")); 117 118 for (i = 0; choices[i].name != NULL; i++) { 119 if (value == choices[i].value) { 120 gtk_entry_set_text (GTK_ENTRY(combo_entry), choices[i].name); 121 return value; 122 } 123 } 121 GTK_WIDGET (g_object_get_data (G_OBJECT (slider), "combo_entry")); 122 123 for (i = 0; choices[i].name != NULL; i++) 124 { 125 if (value == choices[i].value) 126 { 127 gtk_entry_set_text (GTK_ENTRY (combo_entry), choices[i].name); 128 return value; 129 } 130 } 124 131 125 132 /* not in the entry -- assume first choice is "Custom" and set that */ 126 gtk_entry_set_text (GTK_ENTRY (combo_entry), choices[0].name);133 gtk_entry_set_text (GTK_ENTRY (combo_entry), choices[0].name); 127 134 128 135 return slider_set_value_direct (slider, value);; … … 141 148 db_slider_get_value (DbSlider * slider) 142 149 { 143 return ADJ_TO_VALUE (GTK_ADJUSTMENT(slider->adj)->value);150 return ADJ_TO_VALUE (GTK_ADJUSTMENT (slider->adj)->value); 144 151 } 145 152 … … 147 154 db_slider_set_value (DbSlider * slider, gfloat value) 148 155 { 149 gtk_adjustment_set_value (GTK_ADJUSTMENT (slider->adj),150 VALUE_TO_ADJ (value));156 gtk_adjustment_set_value (GTK_ADJUSTMENT (slider->adj), 157 VALUE_TO_ADJ (value)); 151 158 } 152 159 … … 154 161 db_slider_value_changed_cb (GtkWidget * widget, gpointer data) 155 162 { 156 GtkWidget * slider = (GtkWidget *)data;163 GtkWidget *slider = (GtkWidget *) data; 157 164 gfloat value, db_value; 158 gchar * db_text;159 160 value = db_slider_get_value (DB_SLIDER (slider));165 gchar *db_text; 166 167 value = db_slider_get_value (DB_SLIDER (slider)); 161 168 db_value = VALUE_TO_DB (value); 162 169 163 if (db_value > -10.0) { 164 db_text = g_strdup_printf ("%1.1f dB", db_value); 165 } else { 166 db_text = g_strdup_printf ("%2.0f dB", db_value); 167 } 168 169 gtk_label_set_text (GTK_LABEL(DB_SLIDER(slider)->db_label), db_text); 170 if (db_value > -10.0) 171 { 172 db_text = g_strdup_printf ("%1.1f dB", db_value); 173 } 174 else 175 { 176 db_text = g_strdup_printf ("%2.0f dB", db_value); 177 } 178 179 gtk_label_set_text (GTK_LABEL (DB_SLIDER (slider)->db_label), db_text); 170 180 171 181 g_free (db_text); 172 182 173 g_signal_emit_by_name (GTK_OBJECT(slider), "value-changed", 174 value); 183 g_signal_emit_by_name (GTK_OBJECT (slider), "value-changed", value); 175 184 } 176 185 … … 178 187 db_slider_build (GtkWidget * slider, gchar * title, gfloat value) 179 188 { 180 GtkWidget * vbox;181 GtkWidget * label;182 GtkWidget * vscale;183 184 GtkObject * adj;185 186 gchar * range_text;189 GtkWidget *vbox; 190 GtkWidget *label; 191 GtkWidget *vscale; 192 193 GtkObject *adj; 194 195 gchar *range_text; 187 196 188 197 vbox = gtk_vbox_new (FALSE, 0); 189 gtk_container_add (GTK_CONTAINER (slider), vbox);198 gtk_container_add (GTK_CONTAINER (slider), vbox); 190 199 gtk_widget_show (vbox); 191 200 192 201 label = gtk_label_new (NULL); 193 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);202 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); 194 203 gtk_widget_show (label); 195 204 196 DB_SLIDER (slider)->db_label = label;197 198 adj = gtk_adjustment_new (VALUE_TO_ADJ (value),/* value */199 VALUE_TO_ADJ (DB_SLIDER(slider)->upper),/* lower */200 VALUE_TO_ADJ (DB_SLIDER(slider)->lower),/* upper */201 0.3, /* step incr */202 3.0, /* page incr */203 0.0 /* page size */204 );205 206 vscale = gtk_vscale_new (GTK_ADJUSTMENT (adj));207 gtk_scale_set_draw_value (GTK_SCALE (vscale), FALSE);208 gtk_range_set_update_policy (GTK_RANGE (vscale), GTK_UPDATE_CONTINUOUS);209 gtk_widget_set_size_request (vscale, -1, gdk_screen_height () / 8);210 gtk_box_pack_start (GTK_BOX (vbox), vscale, TRUE, TRUE, 0);205 DB_SLIDER (slider)->db_label = label; 206 207 adj = gtk_adjustment_new (VALUE_TO_ADJ (value), /* value */ 208 VALUE_TO_ADJ (DB_SLIDER (slider)->upper), /* lower */ 209 VALUE_TO_ADJ (DB_SLIDER (slider)->lower), /* upper */ 210 0.3, /* step incr */ 211 3.0, /* page incr */ 212 0.0 /* page size */ 213 ); 214 215 vscale = gtk_vscale_new (GTK_ADJUSTMENT (adj)); 216 gtk_scale_set_draw_value (GTK_SCALE (vscale), FALSE); 217 gtk_range_set_update_policy (GTK_RANGE (vscale), GTK_UPDATE_CONTINUOUS); 218 gtk_widget_set_size_request (vscale, -1, gdk_screen_height () / 8); 219 gtk_box_pack_start (GTK_BOX (vbox), vscale, TRUE, TRUE, 0); 211 220 gtk_widget_show (vscale); 212 221 213 g_signal_connect (G_OBJECT (adj), "value_changed",214 G_CALLBACK(db_slider_value_changed_cb), slider);215 216 DB_SLIDER (slider)->adj = adj;222 g_signal_connect (G_OBJECT (adj), "value_changed", 223 G_CALLBACK (db_slider_value_changed_cb), slider); 224 225 DB_SLIDER (slider)->adj = adj; 217 226 218 227 db_slider_value_changed_cb (NULL, slider); … … 220 229 range_text = g_strdup_printf ("%s\n[%2.0f to %2.0f dB]", 221 230 title, 222 VALUE_TO_DB (DB_SLIDER(slider)->lower),223 VALUE_TO_DB (DB_SLIDER(slider)->upper));231 VALUE_TO_DB (DB_SLIDER (slider)->lower), 232 VALUE_TO_DB (DB_SLIDER (slider)->upper)); 224 233 225 234 label = gtk_label_new (range_text); 226 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);227 gtk_widget_show (label); 235 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); 236 gtk_widget_show (label); 228 237 } 229 238 … … 232 241 db_slider_new (gchar * title, gfloat value, gfloat lower, gfloat upper) 233 242 { 234 DbSlider * slider = DB_SLIDER (g_object_new (db_slider_get_type (), NULL));243 DbSlider *slider = DB_SLIDER (g_object_new (db_slider_get_type (), NULL)); 235 244 236 245 slider->lower = lower; sweep/branches/display-cache/src/db_slider.h
r215 r471 32 32 typedef struct _DbSliderClass DbSliderClass; 33 33 34 struct _DbSlider { 34 struct _DbSlider 35 { 35 36 GtkEventBox ebox; 36 37 37 GtkObject * adj;38 GtkWidget * db_label;38 GtkObject *adj; 39 GtkWidget *db_label; 39 40 40 41 gfloat lower; … … 42 43 }; 43 44 44 struct _DbSliderClass { 45 struct _DbSliderClass 46 { 45 47 GtkVBoxClass parent_class; 46 48 47 49 void (*value_changed) (DbSlider * slider, gfloat value); 48 50 }; 49 51 50 52 GType db_slider_get_type (void); 51 GtkWidget * db_slider_new (gchar * title, gfloat value, gfloat lower,52 gfloat upper);53 GtkWidget *db_slider_new (gchar * title, gfloat value, gfloat lower, 54 gfloat upper); 53 55 gfloat db_slider_get_value (DbSlider * slider); 54 56 void db_slider_set_value (DbSlider * slider, gfloat value); sweep/branches/display-cache/src/display-cache.c
r425 r471 32 32 33 33 #ifdef HAVE_LIBSAMPLERATE 34 #include <samplerate.h>34 #include <samplerate.h> 35 35 #endif 36 36 37 37 #include "display-cache.h" 38 38 #include "sweep_app.h" 39 40 /* XXX Warning!!!! 41 * 42 * This is development code so it isnt fully tested. 43 * Application may crash or corupt your data, You have been warned! 44 * 45 * OK, it's not so bad :) 46 */ 39 47 40 48 #define STEP_MAX 256 … … 46 54 //#define DEBUG_VERY_VERBOSE_CUST 47 55 48 static void display_cache_add_sample(DisplayCache *dc, sw_sample *sample) 49 { 50 sample->dispcaches = g_list_append(sample->dispcaches, dc); 51 dc->sample = sample; 52 dc->ops = sample->dcops; 56 static void 57 display_cache_add_sample (DisplayCache * dc, sw_sample * sample) 58 { 59 sample->dispcaches = g_list_append (sample->dispcaches, dc); 60 dc->sample = sample; 61 dc->ops = sample->dcops; 53 62 } 54 63 55 static void display_cache_remove_sample(DisplayCache *dc) 56 { 57 dc->sample->dispcaches = g_list_remove(dc->sample->dispcaches, dc); 58 dc->sample = NULL; 64 static void 65 display_cache_remove_sample (DisplayCache * dc) 66 { 67 dc->sample->dispcaches = g_list_remove (dc->sample->dispcaches, dc); 68 dc->sample = NULL; 59 69 } 60 70 61 71 // len - number of frames 62 static void display_cache_realloc(DisplayCache *dc, gint len) 63 { 64 g_free(dc->min); 65 g_free(dc->max); 66 g_free(dc->rms); 67 g_free(dc->points); 68 69 dc->min = g_malloc0(len * dc->channels * sizeof(sw_audio_t)); 70 dc->max = g_malloc0(len * dc->channels * sizeof(sw_audio_t)); 71 dc->rms = g_malloc0(len * dc->channels * sizeof(sw_audio_t)); 72 dc->points = g_malloc0(len * dc->channels * sizeof(gboolean)); 73 74 dc->len = len; 72 static void 73 display_cache_realloc (DisplayCache * dc, gint len) 74 { 75 g_free (dc->min); 76 g_free (dc->max); 77 g_free (dc->rms); 78 g_free (dc->points); 79 80 dc->min = g_malloc0 (len * dc->channels * sizeof (sw_audio_t)); 81 dc->max = g_malloc0 (len * dc->channels * sizeof (sw_audio_t)); 82 dc->rms = g_malloc0 (len * dc->channels * sizeof (sw_audio_t)); 83 dc->points = g_malloc0 (len * dc->channels * sizeof (gboolean)); 84 85 dc->len = len; 75 86 }; 76 87 77 static void display_cache_right_realloc(DisplayCache *dc, gint len) 78 { 79 sw_audio_t *tmp; 80 gboolean *tmpb; 81 gint l1 = (len + dc->len) * dc->channels; 82 gint l2 = dc->len * dc->channels; 83 84 #ifdef DEBUG_VERBOSE 85 g_print("display_cache_right_realloc(%p): l1:%i l2:%i len:%i\n", dc, l1, l2, len); 86 #endif 87 88 tmp = g_malloc0(l1 * sizeof(sw_audio_t)); 89 g_memmove(tmp, dc->min, l2 * sizeof(sw_audio_t)); 90 g_free(dc->min); 91 dc->min = tmp; 92 93 tmp = g_malloc0(l1 * sizeof(sw_audio_t)); 94 g_memmove(tmp, dc->max, l2 * sizeof(sw_audio_t)); 95 g_free(dc->max); 96 dc->max = tmp; 97 98 tmp = g_malloc0(l1 * sizeof(sw_audio_t)); 99 g_memmove(tmp, dc->rms, l2 * sizeof(sw_audio_t)); 100 g_free(dc->rms); 101 dc->rms = tmp; 102 103 tmpb = g_malloc0(l1 * sizeof(gboolean)); 104 g_memmove(tmpb, dc->points, l2 * sizeof(gboolean)); 105 g_free(dc->points); 106 dc->points = tmpb; 107 108 dc->len += len; 88 static void 89 display_cache_right_realloc (DisplayCache * dc, gint len) 90 { 91 sw_audio_t *tmp; 92 gboolean *tmpb; 93 gint l1 = (len + dc->len) * dc->channels; 94 gint l2 = dc->len * dc->channels; 95 96 #ifdef DEBUG_VERBOSE 97 g_print ("display_cache_right_realloc(%p): l1:%i l2:%i len:%i\n", dc, l1, 98 l2, len); 99 #endif 100 101 tmp = g_malloc0 (l1 * sizeof (sw_audio_t)); 102 g_memmove (tmp, dc->min, l2 * sizeof (sw_audio_t)); 103 g_free (dc->min); 104 dc->min = tmp; 105 106 tmp = g_malloc0 (l1 * sizeof (sw_audio_t)); 107 g_memmove (tmp, dc->max, l2 * sizeof (sw_audio_t)); 108 g_free (dc->max); 109 dc->max = tmp; 110 111 tmp = g_malloc0 (l1 * sizeof (sw_audio_t)); 112 g_memmove (tmp, dc->rms, l2 * sizeof (sw_audio_t)); 113 g_free (dc->rms); 114 dc->rms = tmp; 115 116 tmpb = g_malloc0 (l1 * sizeof (gboolean)); 117 g_memmove (tmpb, dc->points, l2 * sizeof (gboolean)); 118 g_free (dc->points); 119 dc->points = tmpb; 120 121 dc->len += len; 109 122 } 110 123 111 void display_cache_left_realloc(DisplayCache *dc, gint len) 112 { 113 sw_audio_t *tmp; 114 gboolean *tmpb; 115 gint l1 = len * dc->channels; 116 gint l2 = dc->len * dc->channels; 117 118 #ifdef DEBUG_VERBOSE 119 g_print("display_cache_left_realloc: l1:%i l2:%i len:%i\n",l1, l2, len); 120 #endif 121 122 tmp = g_malloc0((l1 + l2) * sizeof(sw_audio_t)); 123 g_memmove(tmp + l1, dc->min, l2 * sizeof(sw_audio_t)); 124 g_free(dc->min); 125 dc->min = tmp; 126 127 tmp = g_malloc0((l1 + l2) * sizeof(sw_audio_t)); 128 g_memmove(tmp + l1, dc->max, l2 * sizeof(sw_audio_t)); 129 g_free(dc->max); 130 dc->max = tmp; 131 132 tmp = g_malloc0((l1 + l2) * sizeof(sw_audio_t)); 133 g_memmove(tmp + l1, dc->rms, l2 * sizeof(sw_audio_t)); 134 g_free(dc->rms); 135 dc->rms = tmp; 136 137 tmpb = g_malloc0((l1 + l2) * sizeof(gboolean)); 138 g_memmove(tmpb + l1, dc->points, l2 * sizeof(gboolean)); 139 g_free(dc->points); 140 dc->points = tmpb; 141 142 dc->len += len; 124 void 125 display_cache_left_realloc (DisplayCache * dc, gint len) 126 { 127 sw_audio_t *tmp; 128 gboolean *tmpb; 129 gint l1 = len * dc->channels; 130 gint l2 = dc->len * dc->channels; 131 132 #ifdef DEBUG_VERBOSE 133 g_print ("display_cache_left_realloc: l1:%i l2:%i len:%i\n", l1, l2, len); 134 #endif 135 136 tmp = g_malloc0 ((l1 + l2) * sizeof (sw_audio_t)); 137 g_memmove (tmp + l1, dc->min, l2 * sizeof (sw_audio_t)); 138 g_free (dc->min); 139 dc->min = tmp; 140 141 tmp = g_malloc0 ((l1 + l2) * sizeof (sw_audio_t)); 142 g_memmove (tmp + l1, dc->max, l2 * sizeof (sw_audio_t)); 143 g_free (dc->max); 144 dc->max = tmp; 145 146 tmp = g_malloc0 ((l1 + l2) * sizeof (sw_audio_t)); 147 g_memmove (tmp + l1, dc->rms, l2 * sizeof (sw_audio_t)); 148 g_free (dc->rms); 149 dc->rms = tmp; 150 151 tmpb = g_malloc0 ((l1 + l2) * sizeof (gboolean)); 152 g_memmove (tmpb + l1, dc->points, l2 * sizeof (gboolean)); 153 g_free (dc->points); 154 dc->points = tmpb; 155 156 dc->len += len; 143 157 } 144 158 145 159 // len - number of frames 146 DisplayCache * display_cache_new (gint len) 147 { 148 DisplayCache *tmp; 149 150 tmp = g_malloc(sizeof(DisplayCache)); 151 152 tmp->fpp = 1.0; 153 tmp->start = 0; 154 tmp->end = len; 155 tmp->channels = 1; 156 tmp->ops = DC_OPS_INVALID; 157 tmp->len = len; 158 tmp->sample = NULL; 159 160 tmp->min = g_malloc0(len * sizeof(sw_audio_t)); 161 tmp->max = g_malloc0(len * sizeof(sw_audio_t)); 162 tmp->rms = g_malloc0(len * sizeof(sw_audio_t)); 163 tmp->points = g_malloc0(len * sizeof(gboolean)); 164 tmp->dcmutex = g_mutex_new(); 165 166 return tmp; 160 DisplayCache * 161 display_cache_new (gint len) 162 { 163 DisplayCache *tmp; 164 165 tmp = g_malloc (sizeof (DisplayCache)); 166 167 tmp->fpp = 1.0; 168 tmp->start = 0; 169 tmp->end = len; 170 tmp->channels = 1; 171 tmp->ops = DC_OPS_INVALID; 172 tmp->len = len; 173 tmp->sample = NULL; 174 175 tmp->min = g_malloc0 (len * sizeof (sw_audio_t)); 176 tmp->max = g_malloc0 (len * sizeof (sw_audio_t)); 177 tmp->rms = g_malloc0 (len * sizeof (sw_audio_t)); 178 tmp->points = g_malloc0 (len * sizeof (gboolean)); 179 tmp->dcmutex = g_mutex_new (); 180 181 return tmp; 167 182 }; 168 183 169 void display_cache_delete (DisplayCache *dc) 170 { 171 if (!dc) 172 return; 173 174 display_cache_remove_sample(dc); 175 176 g_free(dc->min); 177 g_free(dc->max); 178 g_free(dc->rms); 179 g_free(dc->points); 180 g_mutex_free(dc->dcmutex); 181 g_free(dc); 184 void 185 display_cache_delete (DisplayCache * dc) 186 { 187 if (!dc) 188 return; 189 190 display_cache_remove_sample (dc); 191 192 g_free (dc->min); 193 g_free (dc->max); 194 g_free (dc->rms); 195 g_free (dc->points); 196 g_mutex_free (dc->dcmutex); 197 g_free (dc); 182 198 }; 183 199 184 void display_cache_invalidate_start (sw_sample *sample) 185 { 186 GList * gl; 187 DisplayCache * dc; 188 189 if (!sample) 190 return; 191 192 #ifdef DEBUG 193 g_print("display_cache_invalidate_start "); 194 #endif 195 196 sample->dcops = DC_OPS_INPROGRESS; 197 198 for (gl = sample->dispcaches; gl; gl = gl->next) 199 { 200 dc = (DisplayCache *)gl->data; 201 g_mutex_lock(dc->dcmutex); 202 dc->ops = DC_OPS_INPROGRESS; 203 g_mutex_unlock(dc->dcmutex); 204 #ifdef DEBUG 205 g_print("%p ",dc); 206 #endif 207 } 208 #ifdef DEBUG 209 g_print("\n"); 200 void 201 display_cache_invalidate_start (sw_sample * sample) 202 { 203 GList *gl; 204 DisplayCache *dc; 205 206 if (!sample) 207 return; 208 209 #ifdef DEBUG 210 g_print ("display_cache_invalidate_start "); 211 #endif 212 213 sample->dcops = DC_OPS_INPROGRESS; 214 215 for (gl = sample->dispcaches; gl; gl = gl->next) 216 { 217 dc = (DisplayCache *) gl->data; 218 g_mutex_lock (dc->dcmutex); 219 dc->ops = DC_OPS_INPROGRESS; 220 g_mutex_unlock (dc->dcmutex); 221 #ifdef DEBUG 222 g_print ("%p ", dc); 223 #endif 224 } 225 #ifdef DEBUG 226 g_print ("\n"); 210 227 #endif 211 228 }; 212 229 213 void display_cache_invalidate_end (sw_sample *sample) 214 { 215 GList * gl; 216 DisplayCache * dc; 217 218 if (!sample) 219 return; 220 221 #ifdef DEBUG 222 g_print("display_cache_invalidate_end\n"); 223 #endif 224 225 for (gl = sample->dispcaches; gl; gl = gl->next) 226 { 227 dc = (DisplayCache *)gl->data; 228 g_mutex_lock(dc->dcmutex); 229 dc->ops = DC_OPS_DONE; 230 sample->dcops = DC_OPS_DONE; 231 g_mutex_unlock(dc->dcmutex); 232 } 230 void 231 display_cache_invalidate_end (sw_sample * sample) 232 { 233 GList *gl; 234 DisplayCache *dc; 235 236 if (!sample) 237 return; 238 239 #ifdef DEBUG 240 g_print ("display_cache_invalidate_end\n"); 241 #endif 242 243 for (gl = sample->dispcaches; gl; gl = gl->next) 244 { 245 dc = (DisplayCache *) gl->data; 246 g_mutex_lock (dc->dcmutex); 247 dc->ops = DC_OPS_DONE; 248 sample->dcops = DC_OPS_DONE; 249 g_mutex_unlock (dc->dcmutex); 250 } 233 251 }; 234 252 235 void display_cache_normalize (sw_audio_t *data, gint length) 236 { 237 gdouble max = 0; 238 gint a; 239 for (a = 0; a < length; a++) 240 max = MAX(fabs(data[a]), max); 241 #ifdef DEBUG_VERBOSE 242 g_print("display_cache_normalize: MAX: %f\n", max); 243 #endif 244 if (max > SW_AUDIO_T_MAX) 245 { 246 max = SW_AUDIO_T_MAX / max; 247 #ifdef DEBUG_VERBOSE 248 g_print("display_cache_normalize: COEFF: %f\n", max); 249 #endif 250 for (a = 0; a < length; a++) 251 data[a] = data[a] * max; 252 } 253 void 254 display_cache_normalize (sw_audio_t * data, gint length) 255 { 256 gdouble max = 0; 257 gint a; 258 for (a = 0; a < length; a++) 259 max = MAX (fabs (data[a]), max); 260 #ifdef DEBUG_VERBOSE 261 g_print ("display_cache_normalize: MAX: %f\n", max); 262 #endif 263 if (max > SW_AUDIO_T_MAX) 264 { 265 max = SW_AUDIO_T_MAX / max; 266 #ifdef DEBUG_VERBOSE 267 g_print ("display_cache_normalize: COEFF: %f\n", max); 268 #endif 269 for (a = 0; a < length; a++) 270 data[a] = data[a] * max; 271 } 253 272 } 254 273 255 void display_cache_compute_minmaxrms (DisplayCache *dc, sw_sample *sample, 256 gint offset, gint start, gint end, gint length, gfloat fpp) 257 { 258 sw_framecount_t step, channel, numd, i, x0, x1, n; 259 sw_audio_t d, maxd, mind, avgd; 260 261 step = MAX (1, dc->fpp / STEP_MAX); 262 // step = 1; 263 264 for (channel = 0; channel < dc->channels; channel++) 265 { 266 for (n = 0; n < length; n++) 274 void 275 display_cache_compute_minmaxrms (DisplayCache * dc, sw_sample * sample, 276 gint offset, gint start, gint end, 277 gint length, gfloat fpp) 278 { 279 sw_framecount_t step, channel, numd, i, x0, x1, n; 280 sw_audio_t d, maxd, mind, avgd; 281 282 step = MAX (1, dc->fpp / STEP_MAX); 283 // step = 1; 284 285 for (channel = 0; channel < dc->channels; channel++) 286 { 287 for (n = 0; n < length; n++) 288 { 289 maxd = 2 * SW_AUDIO_T_MIN; 290 mind = 2 * SW_AUDIO_T_MAX; 291 avgd = 0; 292 numd = 0; 293 294 //g_mutex_lock (sample->ops_mutex); 295 g_mutex_lock (sample->sounddata->data_mutex); 296 297 x0 = n * 1.0 * dc->fpp; 298 x1 = x0 + dc->fpp + 0.5; 299 300 for (i = start + x0; i < start + x1; i += step) 301 { 302 d = 303 ((sw_audio_t *) sample->sounddata->data)[i * dc->channels + 304 channel]; 305 #ifdef DEBUG_VERY_VERBOSE 306 g_print 307 ("display_cache_prepare_minmax: channel:%i i:%i d[%i]: %f\n", 308 channel, i, i * dc->channels + channel, d); 309 #endif 310 if (d > maxd) 267 311 { 268 maxd = 2 * SW_AUDIO_T_MIN; 269 mind = 2 * SW_AUDIO_T_MAX; 270 avgd = 0; 271 numd = 0; 272 273 //g_mutex_lock (sample->ops_mutex); 274 g_mutex_lock (sample->sounddata->data_mutex); 275 276 x0 = n * 1.0 * dc->fpp; 277 x1 = x0 + dc->fpp + 0.5; 278 279 for (i = start + x0; i < start + x1; i += step) 280 { 281 d = ((sw_audio_t *)sample->sounddata->data)[i * dc->channels + channel]; 282 #ifdef DEBUG_VERY_VERBOSE 283 g_print("display_cache_prepare_minmax: channel:%i i:%i d[%i]: %f\n", channel, i, i * dc->channels + channel, d); 284 #endif 285 if (d > maxd) { maxd = d; } 286 if (d < mind) { mind = d; } 287 avgd += d; 288 numd++; 289 } 290 291 //g_mutex_unlock (sample->ops_mutex); 292 g_mutex_unlock (sample->sounddata->data_mutex); 293 294 avgd /= numd; 295 296 #ifdef DEBUG_VERBOSE 297 g_print("display_cache_prepare_minmax(%p): n:%i channel:%i offset:%i min:%f max:%f rms:%f\n", 298 dc, n, channel, (n + offset) * dc->channels + channel, mind, maxd, avgd); 299 #endif 300 301 dc->min[(n + offset) * dc->channels + channel] = mind; 302 dc->max[(n + offset) * dc->channels + channel] = maxd; 303 dc->rms[(n + offset) * dc->channels + channel] = avgd; 312 maxd = d; 304 313 } 305 } 314 if (d < mind) 315 { 316 mind = d; 317 } 318 avgd += d; 319 numd++; 320 } 321 322 //g_mutex_unlock (sample->ops_mutex); 323 g_mutex_unlock (sample->sounddata->data_mutex); 324 325 avgd /= numd; 326 327 #ifdef DEBUG_VERBOSE 328 g_print 329 ("display_cache_prepare_minmax(%p): n:%i channel:%i offset:%i min:%f max:%f rms:%f\n", 330 dc, n, channel, (n + offset) * dc->channels + channel, mind, 331 maxd, avgd); 332 #endif 333 334 dc->min[(n + offset) * dc->channels + channel] = mind; 335 dc->max[(n + offset) * dc->channels + channel] = maxd; 336 dc->rms[(n + offset) * dc->channels + channel] = avgd; 337 } 338 } 306 339 } 307 340 308 341 #ifdef HAVE_LIBSAMPLERATE 309 void display_cache_compute_interpolation(DisplayCache *dc, sw_sample *sample, 310 gint offset, gint start, gint end, gint length, gfloat fpp) 311 { 312 gint channel, x, p, off; 313 SRC_DATA src_data; 314 315 src_data.data_in = sample->sounddata->data + start * dc->channels * sizeof(sw_audio_t); 316 src_data.input_frames = end - start; 317 // we'll use min array for output data 318 src_data.data_out = dc->min + offset * dc->channels; 319 src_data.output_frames = length; 320 src_data.src_ratio = length * 1.0 / (end - start); 321 322 #ifdef DEBUG_VERBOSE 323 g_print("DisplayCacheSINC: src_data.data_in: %p\n", src_data.data_in); 324 g_print("DisplayCacheSINC: src_data.input_frames: %li\n", src_data.input_frames); 325 g_print("DisplayCacheSINC: src_data.output_frames: %li\n", src_data.output_frames); 326 g_print("DisplayCacheSINC: src_data.src_ratio: %f\n", src_data.src_ratio); 327 #endif 328 329 g_mutex_lock(sample->sounddata->data_mutex); 330 331 src_simple(&src_data, SRC_SINC_FASTEST, dc->channels); 332 333 g_mutex_unlock(sample->sounddata->data_mutex); 334 335 display_cache_normalize (dc->min + offset * dc->channels, length * dc->channels); 336 337 for (channel = 0; channel < dc->channels; channel++) 338 { 339 p = 0; 340 for (x = 0; x < length; x++) 341 { 342 off = (x + offset) * dc->channels + channel; 343 dc->max[off] = dc->min[off]; 344 dc->rms[off] = 0; 345 if (x == ceil(p / fpp + 0.5)) 346 { 347 p++; 348 dc->points[off] = TRUE; 349 } else { 350 dc->points[off] = FALSE; 351 } 352 #ifdef DEBUG_VERBOSE 353 g_print("display_cache_prepare_sinc: x:%i channel:%i offset:%i min:%f max:%f points:%i\n", 354 x, channel, off, dc->min[off], dc->max[off], dc->points[off]); 355 #endif 356 } 357 } 342 void 343 display_cache_compute_interpolation (DisplayCache * dc, sw_sample * sample, 344 gint offset, gint start, gint end, 345 gint length, gfloat fpp) 346 { 347 gint channel, x, p, off; 348 SRC_DATA src_data; 349 350 src_data.data_in = 351 sample->sounddata->data + start * dc->channels * sizeof (sw_audio_t); 352 src_data.input_frames = end - start; 353 // we'll use min array for output data 354 src_data.data_out = dc->min + offset * dc->channels; 355 src_data.output_frames = length; 356 src_data.src_ratio = length * 1.0 / (end - start); 357 358 #ifdef DEBUG_VERBOSE 359 g_print ("DisplayCacheSINC: src_data.data_in: %p\n", src_data.data_in); 360 g_print ("DisplayCacheSINC: src_data.input_frames: %li\n", 361 src_data.input_frames); 362 g_print ("DisplayCacheSINC: src_data.output_frames: %li\n", 363 src_data.output_frames); 364 g_print ("DisplayCacheSINC: src_data.src_ratio: %f\n", src_data.src_ratio); 365 #endif 366 367 g_mutex_lock (sample->sounddata->data_mutex); 368 369 src_simple (&src_data, SRC_SINC_FASTEST, dc->channels); 370 371 g_mutex_unlock (sample->sounddata->data_mutex); 372 373 display_cache_normalize (dc->min + offset * dc->channels, 374 length * dc->channels); 375 376 for (channel = 0; channel < dc->channels; channel++) 377 { 378 p = 0; 379 for (x = 0; x < length; x++) 380 { 381 off = (x + offset) * dc->channels + channel; 382 dc->max[off] = dc->min[off]; 383 dc->rms[off] = 0; 384 if (x == ceil (p / fpp + 0.5)) 385 { 386 p++; 387 dc->points[off] = TRUE; 388 } 389 else 390 { 391 dc->points[off] = FALSE; 392 } 393 #ifdef DEBUG_VERBOSE 394 g_print 395 ("display_cache_prepare_sinc: x:%i channel:%i offset:%i min:%f max:%f points:%i\n", 396 x, channel, off, dc->min[off], dc->max[off], dc->points[off]); 397 #endif 398 } 399 } 358 400 } 359 401 #endif … … 364 406 // end: last sample frame on view 365 407 // length: required number of prepared data frames (width of view) 366 void display_cache_prepare (DisplayCache *dc, sw_sample *sample, 367 sw_framecount_t start, sw_framecount_t end, sw_framecount_t length) 368 { 369 gfloat fpp; 370 sw_framecount_t cstart, cend, clength; 371 gint offset; 372 373 #ifdef DEBUG_VERBOSE 374 g_print("display_cache_prepare(%p): sample:%p length:%i start:%i end:%i\n",dc, sample, length, start, end); 375 #endif 376 377 // return when we have uninitialised data 378 if (!dc || !sample || !length || (start == end)) 379 return; 380 381 if (dc->sample != sample) 382 display_cache_add_sample(dc, sample); 383 384 fpp = (end - start) * 1.0 / length; 385 386 #ifdef DEBUG_VERBOSE 387 g_print("DisplayCache: fpp:%f\n",fpp); 388 g_print("DisplayCache: dc->fpp:%f\n",dc->fpp); 389 g_print("DisplayCache: start:%i\n",start); 390 g_print("DisplayCache: dc->start:%i\n",dc->start); 391 g_print("DisplayCache: dc->psoff:%i\n",dc->psoff); 392 g_print("DisplayCache: end:%i\n",end); 393 g_print("DisplayCache: dc->end:%i\n",dc->end); 394 g_print("DisplayCache: dc->peoff:%i\n",dc->peoff); 395 g_print("DisplayCache: sample->sounddata->format->channels:%i\n",sample->sounddata->format->channels); 396 g_print("DisplayCache: dc->channels:%i\n",dc->channels); 397 g_print("DisplayCache: sample->sounddata->nr_frames:%i\n",sample->sounddata->nr_frames); 398 g_print("DisplayCache: length:%i\n",length); 399 g_print("DisplayCache: dc->len:%i\n",dc->len); 400 static gchar *DC_OPS_NONE_SRT = "DC_OPS_NONE"; 401 static gchar *DC_OPS_INVALID_SRT = "DC_OPS_INVALID"; 402 static gchar *DC_OPS_INPROGRESS_SRT = "DC_OPS_INPROGRESS"; 403 static gchar *DC_OPS_DONE_SRT = "DC_OPS_DONE"; 404 gchar *tmp; 405 switch (dc->ops) 406 { 407 case DC_OPS_NONE: tmp = DC_OPS_NONE_SRT; 408 break; 409 case DC_OPS_INVALID: tmp = DC_OPS_INVALID_SRT; 410 break; 411 case DC_OPS_INPROGRESS: tmp = DC_OPS_INPROGRESS_SRT; 412 break; 413 case DC_OPS_DONE: tmp = DC_OPS_DONE_SRT; 414 break; 415 default: tmp = ""; 416 } 417 g_print("DisplayCache: dc->ops:%s\n",tmp); 418 #endif 419 420 g_mutex_lock(dc->dcmutex); 421 422 if (dc->ops == DC_OPS_NONE && 423 dc->fpp == fpp && 424 dc->start <= start && 425 dc->end >= end && 426 dc->channels == sample->sounddata->format->channels) 427 { 428 // we have cached all data 429 // and cache is valid 408 void 409 display_cache_prepare (DisplayCache * dc, sw_sample * sample, 410 sw_framecount_t start, sw_framecount_t end, 411 sw_framecount_t length) 412 { 413 gfloat fpp; 414 sw_framecount_t cstart, cend, clength; 415 gint offset; 416 417 #ifdef DEBUG_VERBOSE 418 g_print ("display_cache_prepare(%p): sample:%p length:%i start:%i end:%i\n", 419 dc, sample, length, start, end); 420 #endif 421 422 // return when we have uninitialised data 423 if (!dc || !sample || !length || (start == end)) 424 return; 425 426 if (dc->sample != sample) 427 display_cache_add_sample (dc, sample); 428 429 fpp = (end - start) * 1.0 / length; 430 431 #ifdef DEBUG_VERBOSE 432 g_print ("DisplayCache: fpp:%f\n", fpp); 433 g_print ("DisplayCache: dc->fpp:%f\n", dc->fpp); 434 g_print ("DisplayCache: start:%i\n", start); 435 g_print ("DisplayCache: dc->start:%i\n", dc->start); 436 g_print ("DisplayCache: dc->psoff:%i\n", dc->psoff); 437 g_print ("DisplayCache: end:%i\n", end); 438 g_print ("DisplayCache: dc->end:%i\n", dc->end); 439 g_print ("DisplayCache: dc->peoff:%i\n", dc->peoff); 440 g_print ("DisplayCache: sample->sounddata->format->channels:%i\n", 441 sample->sounddata->format->channels); 442 g_print ("DisplayCache: dc->channels:%i\n", dc->channels); 443 g_print ("DisplayCache: sample->sounddata->nr_frames:%i\n", 444 sample->sounddata->nr_frames); 445 g_print ("DisplayCache: length:%i\n", length); 446 g_print ("DisplayCache: dc->len:%i\n", dc->len); 447 static gchar *DC_OPS_NONE_SRT = "DC_OPS_NONE"; 448 static gchar *DC_OPS_INVALID_SRT = "DC_OPS_INVALID"; 449 static gchar *DC_OPS_INPROGRESS_SRT = "DC_OPS_INPROGRESS"; 450 static gchar *DC_OPS_DONE_SRT = "DC_OPS_DONE"; 451 gchar *tmp; 452 switch (dc->ops) 453 { 454 case DC_OPS_NONE: 455 tmp = DC_OPS_NONE_SRT; 456 break; 457 case DC_OPS_INVALID: 458 tmp = DC_OPS_INVALID_SRT; 459 break; 460 case DC_OPS_INPROGRESS: 461 tmp = DC_OPS_INPROGRESS_SRT; 462 break; 463 case DC_OPS_DONE: 464 tmp = DC_OPS_DONE_SRT; 465 break; 466 default: 467 tmp = ""; 468 } 469 g_print ("DisplayCache: dc->ops:%s\n", tmp); 470 #endif 471 472 g_mutex_lock (dc->dcmutex); 473 474 if (dc->ops == DC_OPS_NONE && 475 dc->fpp == fpp && 476 dc->start <= start && 477 dc->end >= end && dc->channels == sample->sounddata->format->channels) 478 { 479 // we have cached all data 480 // and cache is valid 430 481 431 482 #ifdef DEBUG_CUST 432 g_print("DisplayCache: HIT\n"); 433 #endif 434 435 // compute prepared view offset 436 dc->psoff = (start - dc->start) / dc->fpp; 437 dc->peoff = dc->psoff + length; 438 439 #ifdef DEBUG 440 g_print("DisplayCache: dc->psoff:%i\n",dc->psoff); 441 g_print("DisplayCache: dc->peoff:%i\n",dc->peoff); 442 #endif 443 444 g_mutex_unlock(dc->dcmutex); 445 446 return; 447 448 } else { 483 g_print ("DisplayCache: HIT\n"); 484 #endif 485 486 // compute prepared view offset 487 dc->psoff = (start - dc->start) / dc->fpp; 488 dc->peoff = dc->psoff + length; 489 490 #ifdef DEBUG 491 g_print ("DisplayCache: dc->psoff:%i\n", dc->psoff); 492 g_print ("DisplayCache: dc->peoff:%i\n", dc->peoff); 493 #endif 494 495 g_mutex_unlock (dc->dcmutex); 496 497 return; 498 499 } 500 else 501 { 449 502 450 503 #ifdef DEBUG_CUST 451 g_print("DisplayCache: MISS\n"); 452 #endif 453 454 if (dc->fpp != fpp || dc->channels != sample->sounddata->format->channels) 455 { 456 // changing major cache parameters 457 // so we have to drop present data 458 // and alocate new cache 504 g_print ("DisplayCache: MISS\n"); 505 #endif 506 507 if (dc->fpp != fpp 508 || dc->channels != sample->sounddata->format->channels) 509 { 510 // changing major cache parameters 511 // so we have to drop present data 512 // and alocate new cache 459 513 460 514 #ifdef DEBUG_CUST 461 g_print("DisplayCache: MAJOR CHANGE\n"); 462 #endif 463 464 dc->fpp = fpp; 465 dc->start = start; 466 dc->end = end; 467 cstart = start; 468 dc->psoff = 0; 469 dc->peoff = length; 470 cend = end; 471 clength = length; 472 dc->channels = sample->sounddata->format->channels; 473 offset = 0; 474 475 display_cache_realloc(dc, clength); 476 477 } else 478 479 if (start < dc->end && end > dc->end) 480 { 481 // expand cache right 482 // TODO: make valid parameters for sinc interpolation 515 g_print ("DisplayCache: MAJOR CHANGE\n"); 516 #endif 517 518 dc->fpp = fpp; 519 dc->start = start; 520 dc->end = end; 521 cstart = start; 522 dc->psoff = 0; 523 dc->peoff = length; 524 cend = end; 525 clength = length; 526 dc->channels = sample->sounddata->format->channels; 527 offset = 0; 528 529 display_cache_realloc (dc, clength); 530 531 } 532 else if (start < dc->end && end > dc->end) 533 { 534 // expand cache right 535 // TODO: make valid parameters for sinc interpolation 483 536 484 537 #ifdef DEBUG_CUST 485 g_print("DisplayCache: EXPAND CACHE RIGHT\n");486 #endif 487 488 dc->psoff = (start - dc->start) * 1.0 / dc->fpp;489 dc->peoff = dc->psoff + length;490 cstart = dc->end;491 clength = (end - dc->end) * 1.0 / dc->fpp + 1.0;492 offset = dc->end * 1.0 / dc->fpp;493 cend = end;494 dc->end = end;495 496 display_cache_right_realloc(dc, clength);497 498 if (dc->fpp < 1){499 cstart = start;500 clength = length;501 offset = start * 1.0 / dc->fpp;502 }503 504 } else 505 506 if (end > dc->start && start < dc->start)507 {508 // expand cache left509 // TODO: make valid parameters for sinc interpolation538 g_print ("DisplayCache: EXPAND CACHE RIGHT\n"); 539 #endif 540 541 dc->psoff = (start - dc->start) * 1.0 / dc->fpp; 542 dc->peoff = dc->psoff + length; 543 cstart = dc->end; 544 clength = (end - dc->end) * 1.0 / dc->fpp + 1.0; 545 offset = dc->end * 1.0 / dc->fpp; 546 cend = end; 547 dc->end = end; 548 549 display_cache_right_realloc (dc, clength); 550 551 if (dc->fpp < 1) 552 { 553 cstart = start; 554 clength = length; 555 offset = start * 1.0 / dc->fpp; 556 } 557 558 } 559 else if (end > dc->start && start < dc->start) 560 { 561 // expand cache left 562 // TODO: make valid parameters for sinc interpolation 510 563 511 564 #ifdef DEBUG_CUST 512 g_print("DisplayCache: EXPAND CACHE LEFT\n"); 513 #endif 514 515 dc->psoff = 0; 516 dc->peoff = dc->psoff + length; 517 cend = dc->start; 518 clength = (dc->start - start) * 1.0 / dc->fpp + 1.0; 519 offset = 0; 520 cstart = start; 521 dc->start = start; 522 523 display_cache_left_realloc(dc, clength); 524 525 if (dc->fpp < 1){ 526 cend = end; 527 clength = length; 528 } 529 530 } else { 531 // we have only dirty cache 532 // or jump out of present cache 565 g_print ("DisplayCache: EXPAND CACHE LEFT\n"); 566 #endif 567 568 dc->psoff = 0; 569 dc->peoff = dc->psoff + length; 570 cend = dc->start; 571 clength = (dc->start - start) * 1.0 / dc->fpp + 1.0; 572 offset = 0; 573 cstart = start; 574 dc->start = start; 575 576 display_cache_left_realloc (dc, clength); 577 578 if (dc->fpp < 1) 579 { 580 cend = end; 581 clength = length; 582 } 583 584 } 585 else 586 { 587 // we have only dirty cache 588 // or jump out of present cache 533 589 534 590 #ifdef DEBUG_CUST 535 g_print("DisplayCache: DIRTY/MISS CACHE\n"); 536 #endif 537 538 dc->start = start; 539 dc->end = end; 540 dc->psoff = 0; 541 dc->peoff = length; 542 543 cstart = dc->start; 544 cend = dc->end; 545 clength = length; 546 offset = 0; 547 548 display_cache_realloc(dc, clength); 549 550 } 551 552 if (dc->ops != DC_OPS_INPROGRESS) 553 dc->ops = DC_OPS_NONE; 554 555 #ifdef DEBUG 556 g_print("DisplayCache: dc->fpp:%f\n",dc->fpp); 557 g_print("DisplayCache: dc->start:%i\n",dc->start); 558 g_print("DisplayCache: dc->psoff:%i\n",dc->psoff); 559 g_print("DisplayCache: dc->end:%i\n",dc->end); 560 g_print("DisplayCache: dc->peoff:%i\n",dc->peoff); 561 g_print("DisplayCache: dc->channels:%i\n",dc->channels); 562 g_print("DisplayCache: dc->len:%i\n",dc->len); 563 g_print("DisplayCache: cstart:%i\n",cstart); 564 g_print("DisplayCache: cend:%i\n",cend); 565 g_print("DisplayCache: clength:%i\n",clength); 566 g_print("DisplayCache: offset:%i\n",offset); 567 switch (dc->ops) 568 { 569 case DC_OPS_NONE: tmp = DC_OPS_NONE_SRT; 570 break; 571 case DC_OPS_INVALID: tmp = DC_OPS_INVALID_SRT; 572 break; 573 case DC_OPS_INPROGRESS: tmp = DC_OPS_INPROGRESS_SRT; 574 break; 575 case DC_OPS_DONE: tmp = DC_OPS_DONE_SRT; 576 break; 577 } 578 g_print("DisplayCache: dc->ops:%s\n",tmp); 591 g_print ("DisplayCache: DIRTY/MISS CACHE\n"); 592 #endif 593 594 dc->start = start; 595 dc->end = end; 596 dc->psoff = 0; 597 dc->peoff = length; 598 599 cstart = dc->start; 600 cend = dc->end; 601 clength = length; 602 offset = 0; 603 604 display_cache_realloc (dc, clength); 605 606 } 607 608 if (dc->ops != DC_OPS_INPROGRESS) 609 dc->ops = DC_OPS_NONE; 610 611 #ifdef DEBUG 612 g_print ("DisplayCache: dc->fpp:%f\n", dc->fpp); 613 g_print ("DisplayCache: dc->start:%i\n", dc->start); 614 g_print ("DisplayCache: dc->psoff:%i\n", dc->psoff); 615 g_print ("DisplayCache: dc->end:%i\n", dc->end); 616 g_print ("DisplayCache: dc->peoff:%i\n", dc->peoff); 617 g_print ("DisplayCache: dc->channels:%i\n", dc->channels); 618 g_print ("DisplayCache: dc->len:%i\n", dc->len); 619 g_print ("DisplayCache: cstart:%i\n", cstart); 620 g_print ("DisplayCache: cend:%i\n", cend); 621 g_print ("DisplayCache: clength:%i\n", clength); 622 g_print ("DisplayCache: offset:%i\n", offset); 623 switch (dc->ops) 624 { 625 case DC_OPS_NONE: 626 tmp = DC_OPS_NONE_SRT; 627 break; 628 case DC_OPS_INVALID: 629 tmp = DC_OPS_INVALID_SRT; 630 break; 631 case DC_OPS_INPROGRESS: 632 tmp = DC_OPS_INPROGRESS_SRT; 633 break; 634 case DC_OPS_DONE: 635 tmp = DC_OPS_DONE_SRT; 636 break; 637 } 638 g_print ("DisplayCache: dc->ops:%s\n", tmp); 579 639 #endif 580 640 581 641 #ifdef HAVE_LIBSAMPLERATE 582 // TODO: implement linear interpolation in case of unavailable 583 // libsamplerate, it shoudn't be a problem 584 if (fpp > 1){ 585 // means more samples then pixels 586 #endif 587 588 #ifdef DEBUG 589 g_print("DisplayCache: MINMAX CONVERTION\n"); 590 #endif 591 592 display_cache_compute_minmaxrms(dc, sample, offset, cstart, cend, clength, fpp); 593 642 // TODO: implement linear interpolation in case of unavailable 643 // libsamplerate, it shoudn't be a problem 644 if (fpp > 1) 645 { 646 // means more samples then pixels 647 #endif 648 649 #ifdef DEBUG 650 g_print ("DisplayCache: MINMAX CONVERTION\n"); 651 #endif 652 653 display_cache_compute_minmaxrms (dc, sample, offset, cstart, cend, 654 clength, fpp); 655 594 656 #ifdef HAVE_LIBSAMPLERATE 595 } else { 596 #ifdef DEBUG 597 g_print("DisplayCache: SINC CONVERTION\n"); 598 #endif 599 600 display_cache_compute_interpolation(dc, sample, offset, cstart, cend, clength, fpp); 601 602 } 603 #endif 604 } 605 606 g_mutex_unlock(dc->dcmutex); 657 } 658 else 659 { 660 #ifdef DEBUG 661 g_print ("DisplayCache: SINC CONVERTION\n"); 662 #endif 663 664 display_cache_compute_interpolation (dc, sample, offset, cstart, 665 cend, clength, fpp); 666 667 } 668 #endif 669 } 670 671 g_mutex_unlock (dc->dcmutex); 607 672 608 673 }; 609 674 610 void display_cache_get_minmax (DisplayCache *dc, 611 sw_audio_t **min, sw_audio_t **max, gboolean **points, 612 gint offset, sw_framecount_t length) 613 { 614 gint off; 615 616 g_return_if_fail(dc); 617 g_return_if_fail(min); 618 g_return_if_fail(max); 619 g_return_if_fail(points); 620 621 if ( offset + length > dc->peoff ) 622 { 623 #ifdef DEBUG 624 g_print("DisplayCacheMinMax: WRONG DATA offset:%i length:%i\n",offset,length); 625 #endif 626 g_mutex_lock(dc->dcmutex); 627 dc->ops = DC_OPS_INVALID; 628 g_mutex_unlock(dc->dcmutex); 629 return; 630 } 631 632 off = (dc->psoff + offset) * dc->channels; 633 *min = dc->min + off; 634 *max = dc->max + off; 635 *points = dc->points + off; 636 637 #ifdef DEBUG 638 g_print("DisplayCacheMinMax: exit\n"); 675 void 676 display_cache_get_minmax (DisplayCache * dc, 677 sw_audio_t ** min, sw_audio_t ** max, 678 gboolean ** points, gint offset, 679 sw_framecount_t length) 680 { 681 gint off; 682 683 g_return_if_fail (dc); 684 g_return_if_fail (min); 685 g_return_if_fail (max); 686 g_return_if_fail (points); 687 688 if (offset + length > dc->peoff) 689 { 690 #ifdef DEBUG 691 g_print ("DisplayCacheMinMax: WRONG DATA offset:%i length:%i\n", offset, 692 length); 693 #endif 694 g_mutex_lock (dc->dcmutex); 695 dc->ops = DC_OPS_INVALID; 696 g_mutex_unlock (dc->dcmutex); 697 return; 698 } 699 700 off = (dc->psoff + offset) * dc->channels; 701 *min = dc->min + off; 702 *max = dc->max + off; 703 *points = dc->points + off; 704 705 #ifdef DEBUG 706 g_print ("DisplayCacheMinMax: exit\n"); 639 707 #endif 640 708 }; 641 709 642 void display_cache_get_minmaxrms (DisplayCache *dc, 643 sw_audio_t **min, sw_audio_t **max, sw_audio_t **rms, gboolean **points, 644 gint offset, sw_framecount_t length) 645 { 646 gint off; 647 648 g_return_if_fail(dc); 649 g_return_if_fail(min); 650 g_return_if_fail(max); 651 g_return_if_fail(rms); 652 g_return_if_fail(points); 653 654 if ( offset + length > dc->peoff ) 655 { 656 #ifdef DEBUG 657 g_print("DisplayCacheMinMaxRms: WRONG DATA offset:%i length:%i\n",offset,length); 658 #endif 659 g_mutex_lock(dc->dcmutex); 660 dc->ops = DC_OPS_INVALID; 661 g_mutex_unlock(dc->dcmutex); 662 return; 663 } 664 665 off = (dc->psoff + offset) * dc->channels; 666 #ifdef DEBUG 667 g_print("DisplayCacheMinMaxRms(%p): off:%i length:%i\n",dc,off,length); 668 #endif 669 *min = dc->min + off; 670 *max = dc->max + off; 671 *rms = dc->rms + off; 672 *points = dc->points + off; 673 674 #ifdef DEBUG 675 g_print("DisplayCacheMinMaxRms: exit\n"); 710 void 711 display_cache_get_minmaxrms (DisplayCache * dc, 712 sw_audio_t ** min, sw_audio_t ** max, 713 sw_audio_t ** rms, gboolean ** points, 714 gint offset, sw_framecount_t length) 715 { 716 gint off; 717 718 g_return_if_fail (dc); 719 g_return_if_fail (min); 720 g_return_if_fail (max); 721 g_return_if_fail (rms); 722 g_return_if_fail (points); 723 724 if (offset + length > dc->peoff) 725 { 726 #ifdef DEBUG 727 g_print ("DisplayCacheMinMaxRms: WRONG DATA offset:%i length:%i\n", 728 offset, length); 729 #endif 730 g_mutex_lock (dc->dcmutex); 731 dc->ops = DC_OPS_INVALID; 732 g_mutex_unlock (dc->dcmutex); 733 return; 734 } 735 736 off = (dc->psoff + offset) * dc->channels; 737 #ifdef DEBUG 738 g_print ("DisplayCacheMinMaxRms(%p): off:%i length:%i\n", dc, off, length); 739 #endif 740 *min = dc->min + off; 741 *max = dc->max + off; 742 *rms = dc->rms + off; 743 *points = dc->points + off; 744 745 #ifdef DEBUG 746 g_print ("DisplayCacheMinMaxRms: exit\n"); 676 747 #endif 677 748 }; sweep/branches/display-cache/src/display-cache.h
r425 r471 30 30 // DC_OPS_INPROGRESS - operation which invalidate cache is in progress -> always invalidate cache 31 31 // DC_OPS_DONE - operation which invalidated cache is done - we can make cache valid and set 32 // flag to DC_OPS_NONE32 // flag to DC_OPS_NONE 33 33 // 34 enum { 35 DC_OPS_NONE, 36 DC_OPS_INVALID, 37 DC_OPS_INPROGRESS, 38 DC_OPS_DONE 34 enum 35 { 36 DC_OPS_NONE, 37 DC_OPS_INVALID, 38 DC_OPS_INPROGRESS, 39 DC_OPS_DONE 39 40 }; 40 41 41 typedef struct _DisplayCache DisplayCache;42 typedef struct _DisplayCache DisplayCache; 42 43 43 44 struct _DisplayCache 44 45 { 45 gdouble fpp;// frames per pixel (display resolution)46 sw_framecount_t start;// first cached sample (in frames)47 sw_framecount_t end;// last cached sample (in frames)48 gint channels;// number of channels49 sw_framecount_t psoff;// start offset in prepare50 sw_framecount_t peoff;// end offset in prepare46 gdouble fpp; // frames per pixel (display resolution) 47 sw_framecount_t start; // first cached sample (in frames) 48 sw_framecount_t end; // last cached sample (in frames) 49 gint channels; // number of channels 50 sw_framecount_t psoff; // start offset in prepare 51 sw_framecount_t peoff; // end offset in prepare 51 52 52 sw_framecount_t len;// length of cache (frames) arrays length = len * channels * sizeof(one element)53 GMutex *dcmutex;// mutex for acces to ->ops or displaycache structure in general54 gint ops;// indicate working or done operation which invalidate cache55 sw_sample *sample;// cached sample56 57 sw_audio_t *min;// min data58 sw_audio_t *max;// max data59 sw_audio_t *rms;// rms data (average)60 gboolean *points;// display sample points53 sw_framecount_t len; // length of cache (frames) arrays length = len * channels * sizeof(one element) 54 GMutex *dcmutex; // mutex for acces to ->ops or displaycache structure in general 55 gint ops; // indicate working or done operation which invalidate cache 56 sw_sample *sample; // cached sample 57 58 sw_audio_t *min; // min data 59 sw_audio_t *max; // max data 60 sw_audio_t *rms; // rms data (average) 61 gboolean *points; // display sample points 61 62 }; 62 63 63 64 // len: number of cached data frames 64 DisplayCache * display_cache_new (sw_framecount_t len);65 void display_cache_delete (DisplayCache * dc);66 void display_cache_invalidate_start (sw_sample * sample);67 void display_cache_invalidate_end (sw_sample * sample);65 DisplayCache *display_cache_new (sw_framecount_t len); 66 void display_cache_delete (DisplayCache * dc); 67 void display_cache_invalidate_start (sw_sample * sample); 68 void display_cache_invalidate_end (sw_sample * sample); 68 69 69 70 // *dc: pointer to DisplayCache structure … … 72 73 // end: last sample frame on view 73 74 // length: required number of prepared data frames (width of view) 74 void display_cache_prepare (DisplayCache *dc, sw_sample *sample, sw_framecount_t start, sw_framecount_t end, sw_framecount_t length); 75 void display_cache_prepare (DisplayCache * dc, sw_sample * sample, 76 sw_framecount_t start, sw_framecount_t end, 77 sw_framecount_t length); 75 78 76 79 // *dc: pointer to DisplayCache structure … … 79 82 // **points: pointer to array for sample points indications 80 83 // length: length of required data (only for checking) 81 void display_cache_get_minmax (DisplayCache *dc, sw_audio_t **min, sw_audio_t **max, gboolean **points, 82 gint offset, sw_framecount_t length); 84 void display_cache_get_minmax (DisplayCache * dc, sw_audio_t ** min, 85 sw_audio_t ** max, gboolean ** points, 86 gint offset, sw_framecount_t length); 83 87 84 88 // *dc: pointer to DisplayCache structure … … 89 93 // length: length of prepared arrays 90 94 // channel: channel number 91 void display_cache_get_minmaxrms (DisplayCache *dc, sw_audio_t **min, sw_audio_t **max, sw_audio_t **rms, gboolean **points, 92 sw_framecount_t offset, sw_framecount_t length); 95 void display_cache_get_minmaxrms (DisplayCache * dc, sw_audio_t ** min, 96 sw_audio_t ** max, sw_audio_t ** rms, 97 gboolean ** points, sw_framecount_t offset, 98 sw_framecount_t length); 93 99 94 100 #endif /* _DISPLAY_CACHE_H */ sweep/branches/display-cache/src/driver.c
r272 r471 43 43 #include "driver.h" 44 44 45 extern sw_driver * driver_alsa;46 extern sw_driver * driver_oss;47 extern sw_driver * driver_solaris;48 49 extern GMutex * play_mutex;45 extern sw_driver *driver_alsa; 46 extern sw_driver *driver_oss; 47 extern sw_driver *driver_solaris; 48 49 extern GMutex *play_mutex; 50 50 51 51 /* preferred driver */ … … 54 54 }; 55 55 56 static sw_driver * pref = &_driver_null;56 static sw_driver *pref = &_driver_null; 57 57 58 58 #include "preferences.h" … … 62 62 pcmio_get_default_main_dev (void) 63 63 { 64 GList * names = NULL, *gl;64 GList *names = NULL, *gl; 65 65 66 66 if (pref->get_names) 67 67 names = pref->get_names (); 68 68 69 if ((gl = names) != NULL) { 70 return (char *)gl->data; 71 } 69 if ((gl = names) != NULL) 70 { 71 return (char *) gl->data; 72 } 72 73 73 74 return NULL; … … 77 78 pcmio_get_default_monitor_dev (void) 78 79 { 79 GList * names = NULL, *gl;80 GList *names = NULL, *gl; 80 81 81 82 if (pref->get_names) 82 83 names = pref->get_names (); 83 84 84 if ((gl = names) != NULL) { 85 if ((gl = gl->next) != NULL) { 86 return (char *)gl->data; 87 } 88 } 85 if ((gl = names) != NULL) 86 { 87 if ((gl = gl->next) != NULL) 88 { 89 return (char *) gl->data; 90 } 91 } 89 92 90 93 return NULL; … … 94 97 pcmio_get_main_dev (void) 95 98 { 96 char * main_dev;99 char *main_dev; 97 100 98 101 main_dev = prefs_get_string (DEV_KEY); 99 102 100 if (main_dev == NULL) return pcmio_get_default_main_dev(); 101 103 if (main_dev == NULL) 104 return pcmio_get_default_main_dev (); 105 102 106 return main_dev; 103 107 } … … 106 110 pcmio_get_monitor_dev (void) 107 111 { 108 char * monitor_dev;112 char *monitor_dev; 109 113 110 114 monitor_dev = prefs_get_string (MONITOR_DEV_KEY); 111 115 112 if (monitor_dev == NULL) return pcmio_get_default_monitor_dev (); 113 116 if (monitor_dev == NULL) 117 return pcmio_get_default_monitor_dev (); 118 114 119 return monitor_dev; 115 120 } … … 118 123 pcmio_get_use_monitor (void) 119 124 { 120 int * use_monitor;125 int *use_monitor; 121 126 122 127 use_monitor = prefs_get_int (USE_MONITOR_KEY); 123 128 124 if (use_monitor == NULL) return DEFAULT_USE_MONITOR; 125 else return (*use_monitor != 0); 129 if (use_monitor == NULL) 130 return DEFAULT_USE_MONITOR; 131 else 132 return (*use_monitor != 0); 126 133 } 127 134 … … 129 136 pcmio_get_log_frags (void) 130 137 { 131 int * log_frags;138 int *log_frags; 132 139 133 140 log_frags = prefs_get_int (LOG_FRAGS_KEY); 134 141 135 if (log_frags == NULL) return DEFAULT_LOG_FRAGS; 136 else return (*log_frags); 137 } 138 139 extern GtkStyle * style_bw; 140 static GtkWidget * dialog = NULL; 141 static GtkWidget * main_combo; 142 static GtkWidget * monitor_combo; 143 static GtkObject * adj; 142 if (log_frags == NULL) 143 return DEFAULT_LOG_FRAGS; 144 else 145 return (*log_frags); 146 } 147 148 extern GtkStyle *style_bw; 149 static GtkWidget *dialog = NULL; 150 static GtkWidget *main_combo; 151 static GtkWidget *monitor_combo; 152 static GtkObject *adj; 144 153 145 154 … … 147 156 monitor_checked (GtkWidget * dialog) 148 157 { 149 GtkWidget * monitor_chb;158 GtkWidget *monitor_chb; 150 159 151 160 monitor_chb = 152 GTK_WIDGET (g_object_get_data (G_OBJECT(dialog), "monitor_chb"));161 GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), "monitor_chb")); 153 162 154 163 return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (monitor_chb)); … … 158 167 config_dev_dsp_dialog_ok_cb (GtkWidget * widget, gpointer data) 159 168 { 160 GtkWidget * dialog = GTK_WIDGET (data);161 GtkAdjustment * adj;162 G_CONST_RETURN gchar * main_dev, *monitor_dev;163 164 adj = g_object_get_data (G_OBJECT (dialog), "buff_adj");169 GtkWidget *dialog = GTK_WIDGET (data); 170 GtkAdjustment *adj; 171 G_CONST_RETURN gchar *main_dev, *monitor_dev; 172 173 adj = g_object_get_data (G_OBJECT (dialog), "buff_adj"); 165 174 166 175 prefs_set_int (LOG_FRAGS_KEY, adj->value); 167 176 168 main_dev = 169 gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry)); 170 171 prefs_set_string (DEV_KEY, (gchar *)main_dev); 172 173 if (monitor_checked (dialog)) { 174 monitor_dev = 175 gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry)); 176 prefs_set_string (MONITOR_DEV_KEY, (gchar *)monitor_dev); 177 178 prefs_set_int (USE_MONITOR_KEY, 1); 179 } else { 180 prefs_set_int (USE_MONITOR_KEY, 0); 181 } 177 main_dev = gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (main_combo)->entry)); 178 179 prefs_set_string (DEV_KEY, (gchar *) main_dev); 180 181 if (monitor_checked (dialog)) 182 { 183 monitor_dev = 184 gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (monitor_combo)->entry)); 185 prefs_set_string (MONITOR_DEV_KEY, (gchar *) monitor_dev); 186 187 prefs_set_int (USE_MONITOR_KEY, 1); 188 } 189 else 190 { 191 prefs_set_int (USE_MONITOR_KEY, 0); 192 } 182 193 183 194 gtk_widget_hide (dialog); … … 187 198 config_dev_dsp_dialog_cancel_cb (GtkWidget * widget, gpointer data) 188 199 { 189 GtkWidget * dialog;200 GtkWidget *dialog; 190 201 191 202 dialog = gtk_widget_get_toplevel (widget); … … 196 207 update_ok_button (GtkWidget * widget, gpointer data) 197 208 { 198 GtkWidget * dialog = GTK_WIDGET(data);199 GtkWidget * ok_button;200 gchar * main_devname, *monitor_devname;209 GtkWidget *dialog = GTK_WIDGET (data); 210 GtkWidget *ok_button; 211 gchar *main_devname, *monitor_devname; 201 212 gboolean ok = FALSE; 202 213 203 ok_button = 204 GTK_WIDGET(g_object_get_data (G_OBJECT(dialog), "ok_button")); 205 206 if (monitor_checked (dialog)) { 207 main_devname = (gchar *) 208 gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry)); 209 monitor_devname = (gchar *) 210 gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry)); 211 212 ok = (strcmp (main_devname, monitor_devname) != 0); 213 } else { 214 ok = TRUE; 215 } 214 ok_button = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), "ok_button")); 215 216 if (monitor_checked (dialog)) 217 { 218 main_devname = (gchar *) 219 gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (main_combo)->entry)); 220 monitor_devname = (gchar *) 221 gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (monitor_combo)->entry)); 222 223 ok = (strcmp (main_devname, monitor_devname) != 0); 224 } 225 else 226 { 227 ok = TRUE; 228 } 216 229 217 230 gtk_widget_set_sensitive (ok_button, ok); … … 221 234 set_monitor_widgets (GtkWidget * dialog, gboolean use_monitor) 222 235 { 223 GtkWidget * monitor_chb, * monitor_widget, *swap;236 GtkWidget *monitor_chb, *monitor_widget, *swap; 224 237 225 238 monitor_chb = 226 GTK_WIDGET (g_object_get_data (G_OBJECT(dialog), "monitor_chb"));227 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (monitor_chb), use_monitor);228 229 monitor_widget = g_object_get_data (G_OBJECT (dialog), "monitor_widget");239 GTK_WIDGET (g_object_get_data (G_OBJECT (dialog), "monitor_chb")); 240 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (monitor_chb), use_monitor); 241 242 monitor_widget = g_object_get_data (G_OBJECT (dialog), "monitor_widget"); 230 243 gtk_widget_set_sensitive (monitor_widget, use_monitor); 231 244 232 swap = g_object_get_data (G_OBJECT (dialog), "swap");245 swap = g_object_get_data (G_OBJECT (dialog), "swap"); 233 246 gtk_widget_set_sensitive (swap, use_monitor); 234 247 … … 238 251 set_buff_adj (GtkWidget * dialog, gint logfrags) 239 252 { 240 GtkAdjustment * adj;241 242 adj = g_object_get_data (G_OBJECT (dialog), "buff_adj");253 GtkAdjustment *adj; 254 255 adj = g_object_get_data (G_OBJECT (dialog), "buff_adj"); 243 256 gtk_adjustment_set_value (adj, logfrags); 244 257 } … … 247 260 pcmio_devname_swap_cb (GtkWidget * widget, gpointer data) 248 261 { 249 GtkWidget * dialog = GTK_WIDGET (data);250 gchar * main_dev, *monitor_dev;262 GtkWidget *dialog = GTK_WIDGET (data); 263 gchar *main_dev, *monitor_dev; 251 264 252 265 main_dev = 253 g_strdup (gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry))); 254 monitor_dev = (gchar *)gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry)); 255 256 gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry), monitor_dev); 257 gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry), main_dev); 266 g_strdup (gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (main_combo)->entry))); 267 monitor_dev = 268 (gchar *) 269 gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (monitor_combo)->entry)); 270 271 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (main_combo)->entry), monitor_dev); 272 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (monitor_combo)->entry), main_dev); 258 273 259 274 g_free (main_dev); 260 275 261 set_monitor_widgets (dialog, pcmio_get_use_monitor ());276 set_monitor_widgets (dialog, pcmio_get_use_monitor ()); 262 277 263 278 update_ok_button (widget, data); … … 267 282 pcmio_devname_reset_cb (GtkWidget * widget, gpointer data) 268 283 { 269 GtkWidget * dialog = GTK_WIDGET (data);270 char * main_dev, *monitor_dev;284 GtkWidget *dialog = GTK_WIDGET (data); 285 char *main_dev, *monitor_dev; 271 286 272 287 main_dev = pcmio_get_main_dev (); 273 288 monitor_dev = pcmio_get_monitor_dev (); 274 289 275 gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry), main_dev); 276 gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry), monitor_dev); 277 278 set_monitor_widgets (dialog, pcmio_get_use_monitor()); 290 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (main_combo)->entry), main_dev); 291 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (monitor_combo)->entry), 292 monitor_dev); 293 294 set_monitor_widgets (dialog, pcmio_get_use_monitor ()); 279 295 280 296 update_ok_button (widget, data); … … 284 300 pcmio_devname_default_cb (GtkWidget * widget, gpointer data) 285 301 { 286 GtkWidget * dialog = GTK_WIDGET (data); 287 char * name; 288 289 if ((name = pcmio_get_default_main_dev ()) != NULL) { 290 gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(main_combo)->entry), name); 291 } 292 293 if ((name = pcmio_get_default_monitor_dev ()) != NULL) { 294 gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry), name); 295 } 302 GtkWidget *dialog = GTK_WIDGET (data); 303 char *name; 304 305 if ((name = pcmio_get_default_main_dev ()) != NULL) 306 { 307 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (main_combo)->entry), name); 308 } 309 310 if ((name = pcmio_get_default_monitor_dev ()) != NULL) 311 { 312 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (monitor_combo)->entry), name); 313 } 296 314 297 315 set_monitor_widgets (dialog, DEFAULT_USE_MONITOR); … … 303 321 monitor_enable_cb (GtkWidget * widget, gpointer data) 304 322 { 305 GtkWidget * dialog = GTK_WIDGET (data);323 GtkWidget *dialog = GTK_WIDGET (data); 306 324 gboolean active; 307 325 308 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));326 active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 309 327 310 328 set_monitor_widgets (dialog, active); … … 314 332 pcmio_buffering_reset_cb (GtkWidget * widget, gpointer data) 315 333 { 316 GtkWidget * dialog = GTK_WIDGET (data);317 318 set_buff_adj (dialog, pcmio_get_log_frags ());334 GtkWidget *dialog = GTK_WIDGET (data); 335 336 set_buff_adj (dialog, pcmio_get_log_frags ()); 319 337 } 320 338 … … 322 340 pcmio_buffering_default_cb (GtkWidget * widget, gpointer data) 323 341 { 324 GtkWidget * dialog = GTK_WIDGET (data);342 GtkWidget *dialog = GTK_WIDGET (data); 325 343 326 344 set_buff_adj (dialog, DEFAULT_LOG_FRAGS); … … 330 348 create_devices_combo (void) 331 349 { 332 GtkWidget * combo;333 GList * cbitems = NULL;350 GtkWidget *combo; 351 GList *cbitems = NULL; 334 352 335 353 if (pref->get_names) 336 cbitems = pref->get_names ();337 354 cbitems = pref->get_names (); 355 338 356 combo = gtk_combo_new (); 339 340 gtk_combo_set_popdown_strings (GTK_COMBO (combo), cbitems);357 358 gtk_combo_set_popdown_strings (GTK_COMBO (combo), cbitems); 341 359 342 360 return combo; … … 346 364 device_config (void) 347 365 { 348 GtkWidget * ebox; 349 GtkWidget * notebook; 350 GtkWidget * separator; 351 GtkWidget * hbox, * hbox2; 352 GtkWidget * vbox; 353 GtkWidget * label; 354 GtkWidget * checkbutton; 355 GtkWidget * hscale; 356 GtkWidget * ok_button; 357 GtkWidget * button; 358 359 GtkTooltips * tooltips; 360 361 if (dialog == NULL) { 362 363 dialog = gtk_dialog_new (); 364 gtk_window_set_title (GTK_WINDOW(dialog), _("Sweep: audio device configuration")); 365 gtk_window_set_position (GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE); 366 367 /* OK */ 368 369 ok_button = gtk_button_new_with_label (_("OK")); 370 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (ok_button), GTK_CAN_DEFAULT); 371 gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->action_area), ok_button, 372 TRUE, TRUE, 0); 373 gtk_widget_show (ok_button); 374 g_signal_connect (G_OBJECT(ok_button), "clicked", 375 G_CALLBACK (config_dev_dsp_dialog_ok_cb), 376 dialog); 377 378 g_object_set_data (G_OBJECT (dialog), "ok_button", ok_button); 379 380 /* Cancel */ 381 382 button = gtk_button_new_with_label (_("Cancel")); 383 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (button), GTK_CAN_DEFAULT); 384 gtk_box_pack_start (GTK_BOX (GTK_DIALOG(dialog)->action_area), button, 385 TRUE, TRUE, 0); 386 gtk_widget_show (button); 387 g_signal_connect (G_OBJECT(button), "clicked", 388 G_CALLBACK (config_dev_dsp_dialog_cancel_cb), 389 NULL); 390 391 gtk_widget_grab_default (ok_button); 392 393 394 ebox = gtk_event_box_new (); 395 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), ebox, 396 TRUE, TRUE, 0); 397 gtk_widget_set_style (ebox, style_bw); 398 gtk_widget_show (ebox); 399 400 vbox = gtk_vbox_new (FALSE, 0); 401 gtk_container_add (GTK_CONTAINER(ebox), vbox); 402 gtk_widget_show (vbox); 403 404 /* Changes ... info */ 405 label = gtk_label_new (_("Changes to device settings will take effect on" 406 " next playback.")); 407 gtk_box_pack_start (GTK_BOX(vbox), label, TRUE, TRUE, 8); 408 gtk_widget_show (label); 409 410 411 /* Notebook */ 412 413 notebook = gtk_notebook_new (); 414 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook, 415 TRUE, TRUE, 4); 416 gtk_widget_show (notebook); 417 418 /* Device name */ 419 label = gtk_label_new (_("Device name")); 420 vbox = gtk_vbox_new (FALSE, 0); 421 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label); 422 gtk_container_set_border_width (GTK_CONTAINER(vbox), 4); 423 gtk_widget_show (vbox); 424 425 label = gtk_label_new (_("Set the main device for playback and recording")); 426 gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 4); 427 gtk_widget_show (label); 428 429 /* Main output */ 430 hbox = gtk_hbox_new (FALSE, 8); 431 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, TRUE, 8); 432 gtk_container_set_border_width (GTK_CONTAINER(hbox), 12); 433 gtk_widget_show (hbox); 434 435 label = gtk_label_new (_("Main device:")); 436 gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0); 437 gtk_widget_show (label); 438 439 main_combo = create_devices_combo (); 440 gtk_box_pack_start (GTK_BOX(hbox), main_combo, TRUE, TRUE, 0); 441 gtk_widget_show (main_combo); 442 443 g_signal_connect (G_OBJECT(GTK_COMBO(main_combo)->entry), "changed", 444 G_CALLBACK(update_ok_button), dialog); 445 446 g_object_set_data (G_OBJECT (dialog), "main_combo", main_combo); 366 GtkWidget *ebox; 367 GtkWidget *notebook; 368 GtkWidget *separator; 369 GtkWidget *hbox, *hbox2; 370 GtkWidget *vbox; 371 GtkWidget *label; 372 GtkWidget *checkbutton; 373 GtkWidget *hscale; 374 GtkWidget *ok_button; 375 GtkWidget *button; 376 377 GtkTooltips *tooltips; 378 379 if (dialog == NULL) 380 { 381 382 dialog = gtk_dialog_new (); 383 gtk_window_set_title (GTK_WINDOW (dialog), 384 _("Sweep: audio device configuration")); 385 gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE); 386 387 /* OK */ 388 389 ok_button = gtk_button_new_with_label (_("OK")); 390 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (ok_button), GTK_CAN_DEFAULT); 391 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), 392 ok_button, TRUE, TRUE, 0); 393 gtk_widget_show (ok_button); 394 g_signal_connect (G_OBJECT (ok_button), "clicked", 395 G_CALLBACK (config_dev_dsp_dialog_ok_cb), dialog); 396 397 g_object_set_data (G_OBJECT (dialog), "ok_button", ok_button); 398 399 /* Cancel */ 400 401 button = gtk_button_new_with_label (_("Cancel")); 402 GTK_WIDGET_SET_FLAGS (GTK_WIDGET (button), GTK_CAN_DEFAULT); 403 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button, 404 TRUE, TRUE, 0); 405 gtk_widget_show (button); 406 g_signal_connect (G_OBJECT (button), "clicked", 407 G_CALLBACK (config_dev_dsp_dialog_cancel_cb), NULL); 408 409 gtk_widget_grab_default (ok_button); 410 411 412 ebox = gtk_event_box_new (); 413 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), ebox, 414 TRUE, TRUE, 0); 415 gtk_widget_set_style (ebox, style_bw); 416 gtk_widget_show (ebox); 417 418 vbox = gtk_vbox_new (FALSE, 0); 419 gtk_container_add (GTK_CONTAINER (ebox), vbox); 420 gtk_widget_show (vbox); 421 422 /* Changes ... info */ 423 label = 424 gtk_label_new (_ 425 ("Changes to device settings will take effect on" 426 " next playback.")); 427 gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 8); 428 gtk_widget_show (label); 429 430 431 /* Notebook */ 432 433 notebook = gtk_notebook_new (); 434 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, 435 TRUE, TRUE, 4); 436 gtk_widget_show (notebook); 437 438 /* Device name */ 439 label = gtk_label_new (_("Device name")); 440 vbox = gtk_vbox_new (FALSE, 0); 441 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label); 442 gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); 443 gtk_widget_show (vbox); 444 445 label = 446 gtk_label_new (_("Set the main device for playback and recording")); 447 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4); 448 gtk_widget_show (label); 449 450 /* Main output */ 451 hbox = gtk_hbox_new (FALSE, 8); 452 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 8); 453 gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); 454 gtk_widget_show (hbox); 455 456 label = gtk_label_new (_("Main device:")); 457 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); 458 gtk_widget_show (label); 459 460 main_combo = create_devices_combo (); 461 gtk_box_pack_start (GTK_BOX (hbox), main_combo, TRUE, TRUE, 0); 462 gtk_widget_show (main_combo); 463 464 g_signal_connect (G_OBJECT (GTK_COMBO (main_combo)->entry), "changed", 465 G_CALLBACK (update_ok_button), dialog); 466 467 g_object_set_data (G_OBJECT (dialog), "main_combo", main_combo); 447 468 448 469 #if 0 449 button = gtk_button_new_with_label (_("Default"));450 gtk_box_pack_start (GTK_BOX(hbox), button, FALSE, FALSE, 0);451 gtk_widget_show (button);452 g_signal_connect (G_OBJECT(button), "clicked",453 G_CALLBACK (default_devicename_cb), NULL);470 button = gtk_button_new_with_label (_("Default")); 471 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); 472 gtk_widget_show (button); 473 g_signal_connect (G_OBJECT (button), "clicked", 474 G_CALLBACK (default_devicename_cb), NULL); 454 475 #endif 455 476 456 separator = gtk_hseparator_new (); 457 gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 8); 458 gtk_widget_show (separator); 459 460 /* Monitor */ 461 checkbutton = 462 gtk_check_button_new_with_label (_("Use a different device for monitoring")); 463 gtk_box_pack_start (GTK_BOX(vbox), checkbutton, FALSE, FALSE, 4); 464 gtk_widget_show (checkbutton); 465 466 g_signal_connect (G_OBJECT(checkbutton), "toggled", 467 G_CALLBACK(update_ok_button), dialog); 468 469 hbox = gtk_hbox_new (FALSE, 8); 470 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, TRUE, 8); 471 gtk_container_set_border_width (GTK_CONTAINER(hbox), 12); 472 gtk_widget_show (hbox); 473 474 label = gtk_label_new (_("Monitor output:")); 475 gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0); 476 gtk_widget_show (label); 477 478 monitor_combo = create_devices_combo (); 479 gtk_box_pack_start (GTK_BOX(hbox), monitor_combo, TRUE, TRUE, 0); 480 gtk_widget_show (monitor_combo); 481 482 g_signal_connect (G_OBJECT(GTK_COMBO(monitor_combo)->entry), "changed", 483 G_CALLBACK(update_ok_button), dialog); 484 485 g_signal_connect (G_OBJECT(checkbutton), "toggled", 486 G_CALLBACK(monitor_enable_cb), dialog); 487 488 g_object_set_data (G_OBJECT (dialog), "monitor_chb", checkbutton); 489 g_object_set_data (G_OBJECT (dialog), "monitor_widget", hbox); 490 491 492 /* Swap / Remember / Reset device names*/ 493 494 hbox = gtk_hbox_new (FALSE, 4); 495 gtk_box_pack_end (GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 496 gtk_container_set_border_width (GTK_CONTAINER(hbox), 12); 497 gtk_widget_show (hbox); 498 499 button = gtk_button_new_with_label (_("Swap")); 500 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 4); 501 g_signal_connect (G_OBJECT(button), "clicked", 502 G_CALLBACK(pcmio_devname_swap_cb), dialog); 503 gtk_widget_show (button); 504 505 tooltips = gtk_tooltips_new (); 506 gtk_tooltips_set_tip (tooltips, button, 507 _("Swap main and monitor devices."), 508 NULL); 509 510 g_object_set_data (G_OBJECT (dialog), "swap", button); 511 512 hbox2 = gtk_hbox_new (TRUE, 4); 513 gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, TRUE, 0); 514 gtk_widget_show (hbox2); 515 516 button = gtk_button_new_with_label (_("Reset")); 517 gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, TRUE, 4); 518 g_signal_connect (G_OBJECT(button), "clicked", 519 G_CALLBACK(pcmio_devname_reset_cb), dialog); 520 gtk_widget_show (button); 521 522 tooltips = gtk_tooltips_new (); 523 gtk_tooltips_set_tip (tooltips, button, 524 _("Reset to the last remembered device names."), 525 NULL); 526 527 /* Call the reset callback now to set remembered options */ 528 pcmio_devname_reset_cb (button, dialog); 529 530 button = gtk_button_new_with_label (_("Defaults")); 531 gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, TRUE, 4); 532 g_signal_connect (G_OBJECT(button), "clicked", 533 G_CALLBACK(pcmio_devname_default_cb), dialog); 534 gtk_widget_show (button); 535 536 tooltips = gtk_tooltips_new (); 537 gtk_tooltips_set_tip (tooltips, button, 538 _("Set to default device names."), 539 NULL); 540 541 542 separator = gtk_hseparator_new (); 543 gtk_box_pack_end (GTK_BOX (vbox), separator, FALSE, FALSE, 8); 544 gtk_widget_show (separator); 545 546 547 /* Buffering */ 548 549 label = gtk_label_new (_("Device buffering")); 550 vbox = gtk_vbox_new (FALSE, 0); 551 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label); 552 gtk_container_set_border_width (GTK_CONTAINER(vbox), 4); 553 gtk_widget_show (vbox); 554 555 hbox = gtk_hbox_new (FALSE, 8); 556 gtk_box_pack_start (GTK_BOX(vbox), hbox, TRUE, TRUE, 8); 557 gtk_widget_show (hbox); 558 559 label = gtk_label_new (_("Low latency /\nMore dropouts")); 560 gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 8); 561 gtk_widget_show (label); 562 563 adj = gtk_adjustment_new (pcmio_get_log_frags (), /* value */ 564 LOG_FRAGS_MIN, /* lower */ 565 LOG_FRAGS_MAX+1, /* upper */ 566 1, /* step incr */ 567 1, /* page incr */ 568 1 /* page size */ 569 ); 570 571 g_object_set_data (G_OBJECT(dialog), "buff_adj", adj); 572 573 hscale = gtk_hscale_new (GTK_ADJUSTMENT(adj)); 574 gtk_box_pack_start (GTK_BOX(hbox), hscale, TRUE, TRUE, 4); 575 gtk_scale_set_draw_value (GTK_SCALE(hscale), TRUE); 576 gtk_scale_set_digits (GTK_SCALE(hscale), 0); 577 gtk_range_set_update_policy (GTK_RANGE(hscale), GTK_UPDATE_CONTINUOUS); 578 gtk_widget_set_size_request(hscale, 160, -1); 579 gtk_widget_show (hscale); 580 581 label = gtk_label_new (_("High latency /\nFewer dropouts")); 582 gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 8); 583 gtk_widget_show (label); 584 585 label = gtk_label_new (_("Varying this slider controls the lag between " 586 "cursor movements and playback. This is " 587 "particularly noticeable when \"scrubbing\" " 588 "during playback.\n\nLower values improve " 589 "responsiveness but may degrade audio quality " 590 "on heavily-loaded systems.")); 591 gtk_label_set_line_wrap (GTK_LABEL(label), TRUE); 592 gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 8); 593 gtk_widget_show (label); 594 595 /* Remember / Reset device buffering */ 596 597 hbox = gtk_hbox_new (FALSE, 4); 598 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 599 gtk_container_set_border_width (GTK_CONTAINER(hbox), 12); 600 gtk_widget_show (hbox); 477 separator = gtk_hseparator_new (); 478 gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 8); 479 gtk_widget_show (separator); 480 481 /* Monitor */ 482 checkbutton = 483 gtk_check_button_new_with_label (_ 484 ("Use a different device for monitoring")); 485 gtk_box_pack_start (GTK_BOX (vbox), checkbutton, FALSE, FALSE, 4); 486 gtk_widget_show (checkbutton); 487 488 g_signal_connect (G_OBJECT (checkbutton), "toggled", 489 G_CALLBACK (update_ok_button), dialog); 490 491 hbox = gtk_hbox_new (FALSE, 8); 492 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 8); 493 gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); 494 gtk_widget_show (hbox); 495 496 label = gtk_label_new (_("Monitor output:")); 497 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); 498 gtk_widget_show (label); 499 500 monitor_combo = create_devices_combo (); 501 gtk_box_pack_start (GTK_BOX (hbox), monitor_combo, TRUE, TRUE, 0); 502 gtk_widget_show (monitor_combo); 503 504 g_signal_connect (G_OBJECT (GTK_COMBO (monitor_combo)->entry), 505 "changed", G_CALLBACK (update_ok_button), dialog); 506 507 g_signal_connect (G_OBJECT (checkbutton), "toggled", 508 G_CALLBACK (monitor_enable_cb), dialog); 509 510 g_object_set_data (G_OBJECT (dialog), "monitor_chb", checkbutton); 511 g_object_set_data (G_OBJECT (dialog), "monitor_widget", hbox); 512 513 514 /* Swap / Remember / Reset device names */ 515 516 hbox = gtk_hbox_new (FALSE, 4); 517 gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); 518 gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); 519 gtk_widget_show (hbox); 520 521 button = gtk_button_new_with_label (_("Swap")); 522 gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, TRUE, 4); 523 g_signal_connect (G_OBJECT (button), "clicked", 524 G_CALLBACK (pcmio_devname_swap_cb), dialog); 525 gtk_widget_show (button); 526 527 tooltips = gtk_tooltips_new (); 528 gtk_tooltips_set_tip (tooltips, button, 529 _("Swap main and monitor devices."), NULL); 530 531 g_object_set_data (G_OBJECT (dialog), "swap", button); 532 533 hbox2 = gtk_hbox_new (TRUE, 4); 534 gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, TRUE, 0); 535 gtk_widget_show (hbox2); 536 537 button = gtk_button_new_with_label (_("Reset")); 538 gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, TRUE, 4); 539 g_signal_connect (G_OBJECT (button), "clicked", 540 G_CALLBACK (pcmio_devname_reset_cb), dialog); 541 gtk_widget_show (button); 542 543 tooltips = gtk_tooltips_new (); 544 gtk_tooltips_set_tip (tooltips, button, 545 _("Reset to the last remembered device names."), 546 NULL); 547 548 /* Call the reset callback now to set remembered options */ 549 pcmio_devname_reset_cb (button, dialog); 550 551 button = gtk_button_new_with_label (_("Defaults")); 552 gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, TRUE, 4); 553 g_signal_connect (G_OBJECT (button), "clicked", 554 G_CALLBACK (pcmio_devname_default_cb), dialog); 555 gtk_widget_show (button); 556 557 tooltips = gtk_tooltips_new (); 558 gtk_tooltips_set_tip (tooltips, button, 559 _("Set to default device names."), NULL); 560 561 562 separator = gtk_hseparator_new (); 563 gtk_box_pack_end (GTK_BOX (vbox), separator, FALSE, FALSE, 8); 564 gtk_widget_show (separator); 565 566 567 /* Buffering */ 568 569 label = gtk_label_new (_("Device buffering")); 570 vbox = gtk_vbox_new (FALSE, 0); 571 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, label); 572 gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); 573 gtk_widget_show (vbox); 574 575 hbox = gtk_hbox_new (FALSE, 8); 576 gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 8); 577 gtk_widget_show (hbox); 578 579 label = gtk_label_new (_("Low latency /\nMore dropouts")); 580 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 8); 581 gtk_widget_show (label); 582 583 adj = gtk_adjustment_new (pcmio_get_log_frags (), /* value */ 584 LOG_FRAGS_MIN, /* lower */ 585 LOG_FRAGS_MAX + 1, /* upper */ 586 1, /* step incr */ 587 1, /* page incr */ 588 1 /* page size */ 589 ); 590 591 g_object_set_data (G_OBJECT (dialog), "buff_adj", adj); 592 593 hscale = gtk_hscale_new (GTK_ADJUSTMENT (adj)); 594 gtk_box_pack_start (GTK_BOX (hbox), hscale, TRUE, TRUE, 4); 595 gtk_scale_set_draw_value (GTK_SCALE (hscale), TRUE); 596 gtk_scale_set_digits (GTK_SCALE (hscale), 0); 597 gtk_range_set_update_policy (GTK_RANGE (hscale), GTK_UPDATE_CONTINUOUS); 598 gtk_widget_set_size_request (hscale, 160, -1); 599 gtk_widget_show (hscale); 600 601 label = gtk_label_new (_("High latency /\nFewer dropouts")); 602 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 8); 603 gtk_widget_show (label); 604 605 label = gtk_label_new (_("Varying this slider controls the lag between " 606 "cursor movements and playback. This is " 607 "particularly noticeable when \"scrubbing\" " 608 "during playback.\n\nLower values improve " 609 "responsiveness but may degrade audio quality " 610 "on heavily-loaded systems.")); 611 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); 612 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 8); 613 gtk_widget_show (label); 614 615 /* Remember / Reset device buffering */ 616 617 hbox = gtk_hbox_new (FALSE, 4); 618 gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); 619 gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); 620 gtk_widget_show (hbox); 601 621 602 622 #if 0 603 checkbutton =604 gtk_check_button_new_with_label (_("Remember these options"));605 gtk_box_pack_start (GTK_BOX (hbox), checkbutton, TRUE, TRUE, 0);606 gtk_widget_show (checkbutton);607 608 g_object_set_data (G_OBJECT (dialog), "rem_options_chb", checkbutton);609 610 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(checkbutton), TRUE);623 checkbutton = 624 gtk_check_button_new_with_label (_("Remember these options")); 625 gtk_box_pack_start (GTK_BOX (hbox), checkbutton, TRUE, TRUE, 0); 626 gtk_widget_show (checkbutton); 627 628 g_object_set_data (G_OBJECT (dialog), "rem_options_chb", checkbutton); 629 630 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton), TRUE); 611 631 #endif 612 632 613 hbox2 = gtk_hbox_new (TRUE, 4);614 gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, TRUE, 0);615 gtk_widget_show (hbox2);616 617 button = gtk_button_new_with_label (_("Reset"));618 gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, TRUE, 4);619 g_signal_connect (G_OBJECT(button), "clicked",620 G_CALLBACK (pcmio_buffering_reset_cb), dialog);621 gtk_widget_show (button);622 623 tooltips = gtk_tooltips_new ();624 gtk_tooltips_set_tip (tooltips, button,625 _("Reset to the last remembered device buffering."),626 NULL);627 628 /* Call the reset callback now to set remembered options */ 629 pcmio_buffering_reset_cb (button, dialog);630 631 button = gtk_button_new_with_label (_("Default")); 632 gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, TRUE, 4);633 g_signal_connect (G_OBJECT(button), "clicked",634 G_CALLBACK(pcmio_buffering_default_cb), dialog); 635 gtk_widget_show (button);636 637 tooltips = gtk_tooltips_new (); 638 gtk_tooltips_set_tip (tooltips, button,639 _("Set to default device buffering."),640 NULL);641 }642 643 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO(main_combo)->entry),633 hbox2 = gtk_hbox_new (TRUE, 4); 634 gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, TRUE, 0); 635 gtk_widget_show (hbox2); 636 637 button = gtk_button_new_with_label (_("Reset")); 638 gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, TRUE, 4); 639 g_signal_connect (G_OBJECT (button), "clicked", 640 G_CALLBACK (pcmio_buffering_reset_cb), dialog); 641 gtk_widget_show (button); 642 643 tooltips = gtk_tooltips_new (); 644 gtk_tooltips_set_tip (tooltips, button, 645 _ 646 ("Reset to the last remembered device buffering."), 647 NULL); 648 649 /* Call the reset callback now to set remembered options */ 650 pcmio_buffering_reset_cb (button, dialog); 651 652 button = gtk_button_new_with_label (_("Default")); 653 gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, TRUE, 4); 654 g_signal_connect (G_OBJECT (button), "clicked", 655 G_CALLBACK (pcmio_buffering_default_cb), dialog); 656 gtk_widget_show (button); 657 658 tooltips = gtk_tooltips_new (); 659 gtk_tooltips_set_tip (tooltips, button, 660 _("Set to default device buffering."), NULL); 661 } 662 663 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (main_combo)->entry), 644 664 pcmio_get_main_dev ()); 645 665 646 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO(monitor_combo)->entry),666 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (monitor_combo)->entry), 647 667 pcmio_get_monitor_dev ()); 648 668 649 gtk_adjustment_set_value (GTK_ADJUSTMENT(adj), pcmio_get_log_frags ()); 650 651 if (!GTK_WIDGET_VISIBLE(dialog)) { 652 gtk_widget_show(dialog); 653 } else { 654 gdk_window_raise(dialog->window); 655 } 669 gtk_adjustment_set_value (GTK_ADJUSTMENT (adj), pcmio_get_log_frags ()); 670 671 if (!GTK_WIDGET_VISIBLE (dialog)) 672 { 673 gtk_widget_show (dialog); 674 } 675 else 676 { 677 gdk_window_raise (dialog->window); 678 } 656 679 } 657 680 sweep/branches/display-cache/src/driver.h
r124 r471 31 31 typedef struct _sw_driver sw_driver; 32 32 33 struct _sw_handle { 33 struct _sw_handle 34 { 34 35 int driver_flags; 35 36 int driver_fd; 36 37 int driver_channels; 37 38 int driver_rate; 38 void * custom_data;39 void *custom_data; 39 40 }; 40 41 41 struct _sw_driver { 42 GList * (*get_names) (void); 43 sw_handle * (*open) (int cueing, int flags); 42 struct _sw_driver 43 { 44 GList *(*get_names) (void); 45 sw_handle *(*open) (int cueing, int flags); 44 46 void (*setup) (sw_handle * handle, sw_format * format); 45 47 int (*wait) (sw_handle * handle); 46 ssize_t (*read) (sw_handle * handle, sw_audio_t * buf, size_t count);47 ssize_t (*write) (sw_handle * handle, sw_audio_t * buf, size_t count,48 sw_framecount_t offset);49 sw_framecount_t (*offset) (sw_handle * handle);48 ssize_t (*read) (sw_handle * handle, sw_audio_t * buf, size_t count); 49 ssize_t (*write) (sw_handle * handle, sw_audio_t * buf, size_t count, 50 sw_framecount_t offset); 51 sw_framecount_t (*offset) (sw_handle * handle); 50 52 void (*reset) (sw_handle * handle); 51 53 void (*flush) (sw_handle * handle); … … 54 56 }; 55 57 56 void 57 device_config (void); 58 void device_config (void); 58 59 59 sw_handle * 60 device_open (int cueing, int flags); 60 sw_handle *device_open (int cueing, int flags); 61 61 62 void 63 device_setup (sw_handle * handle, sw_format * format); 62 void device_setup (sw_handle * handle, sw_format * format); 64 63 65 int 66 device_wait (sw_handle * handle); 64 int device_wait (sw_handle * handle); 67 65 68 66 /* 69 67 * For recording, ie. reading pcm data from the device. 70 68 */ 71 ssize_t 72 device_read (sw_handle * handle, sw_audio_t * buf, size_t count); 69 ssize_t device_read (sw_handle * handle, sw_audio_t * buf, size_t count); 73 70 74 71 ssize_t … … 93 90 * PortAudio. So for now, just return -1. 94 91 */ 95 sw_framecount_t 96 device_offset (sw_handle * handle); 92 sw_framecount_t device_offset (sw_handle * handle); 97 93 98 94 /* … … 102 98 * it can accept new parameters, but sweep's not actually making use of that. 103 99 */ 104 void 105 device_reset (sw_handle * handle); 100 void device_reset (sw_handle * handle); 106 101 107 void 108 device_flush (sw_handle * handle); 102 void device_flush (sw_handle * handle); 109 103 110 104 /* … … 112 106 * (otherwise you often lose the last bit of sound when closing the device). 113 107 */ 114 void 115 device_drain (sw_handle * handle); 108 void device_drain (sw_handle * handle); 116 109 117 void 118 device_close (sw_handle * handle); 110 void device_close (sw_handle * handle); 119 111 120 void 121 init_devices (void); 112 void init_devices (void); 122 113 123 void 124 stop_playback (sw_sample * s) ; 114 void stop_playback (sw_sample * s); 125 115 126 116 #endif /* __DRIVER_H__ */ sweep/branches/display-cache/src/driver_alsa.c
r198 r471 65 65 #endif 66 66 67 void print_pcm_state (snd_pcm_t * pcm) 68 { 69 switch (snd_pcm_state(pcm)) { 67 void 68 print_pcm_state (snd_pcm_t * pcm) 69 { 70 switch (snd_pcm_state (pcm)) 71 { 70 72 case SND_PCM_STATE_OPEN: 71 73 fprintf (stderr, "sweep: print_pcm_state: state is OPEN\n"); … … 93 95 break; 94 96 default: 95 fprintf (stderr, "sweep: print_pcm_state: state is unknown! THIS SHOULD NEVER HAPPEN!\n"); 96 } 97 fprintf (stderr, 98 "sweep: print_pcm_state: state is unknown! THIS SHOULD NEVER HAPPEN!\n"); 99 } 97 100 } 98 101 … … 100 103 alsa_get_names (void) 101 104 { 102 GList * names = NULL; 103 char * name; 104 105 if ((name = getenv ("SWEEP_ALSA_PCM")) != 0) { 106 names = g_list_append (names, name); 107 } 105 GList *names = NULL; 106 char *name; 107 108 if ((name = getenv ("SWEEP_ALSA_PCM")) != 0) 109 { 110 names = g_list_append (names, name); 111 } 108 112 109 113 /* The standard command line options for this are -D or --device. … … 122 126 { 123 127 int err; 124 char * alsa_pcm_name;125 snd_pcm_t * pcm_handle;126 sw_handle * handle;128 char *alsa_pcm_name; 129 snd_pcm_t *pcm_handle; 130 sw_handle *handle; 127 131 snd_pcm_stream_t stream; 128 132 129 if (monitoring) { 130 if (pcmio_get_use_monitor()) 131 alsa_pcm_name = pcmio_get_monitor_dev (); 132 else 133 if (monitoring) 134 { 135 if (pcmio_get_use_monitor ()) 136 alsa_pcm_name = pcmio_get_monitor_dev (); 137 else 138 return NULL; 139 } 140 else 141 { 142 alsa_pcm_name = pcmio_get_main_dev (); 143 } 144 145 if (flags == O_RDONLY) 146 { 147 stream = SND_PCM_STREAM_CAPTURE; 148 } 149 else if (flags == O_WRONLY) 150 { 151 stream = SND_PCM_STREAM_PLAYBACK; 152 } 153 else 154 { 133 155 return NULL; 134 } else { 135 alsa_pcm_name = pcmio_get_main_dev (); 136 } 137 138 if (flags == O_RDONLY) { 139 stream = SND_PCM_STREAM_CAPTURE; 140 } else if (flags == O_WRONLY) { 141 stream = SND_PCM_STREAM_PLAYBACK; 142 } else { 143 return NULL; 144 } 145 146 if ((err = snd_pcm_open(&pcm_handle, alsa_pcm_name, stream, 0)) < 0) { 147 sweep_perror (errno, 148 "Error opening ALSA device %s", 149 alsa_pcm_name /*, snd_strerror (err)*/); 150 return NULL; 151 } 156 } 157 158 if ((err = snd_pcm_open (&pcm_handle, alsa_pcm_name, stream, 0)) < 0) 159 { 160 sweep_perror (errno, 161 "Error opening ALSA device %s", 162 alsa_pcm_name /*, snd_strerror (err) */ ); 163 return NULL; 164 } 152 165 153 166 handle = g_malloc0 (sizeof (sw_handle)); … … 165 178 { 166 179 int err; 167 snd_pcm_t * pcm_handle = (snd_pcm_t *)handle->custom_data;168 snd_pcm_hw_params_t * hwparams;180 snd_pcm_t *pcm_handle = (snd_pcm_t *) handle->custom_data; 181 snd_pcm_hw_params_t *hwparams; 169 182 int dir; 170 183 unsigned int rate = format->rate; 171 184 unsigned int channels = format->channels; 172 185 unsigned int periods; 173 snd_pcm_uframes_t period_size = PBUF_SIZE /format->channels;186 snd_pcm_uframes_t period_size = PBUF_SIZE / format->channels; 174 187 175 188 #if 1 176 if (handle->driver_flags == O_RDONLY) { 177 dir = (int)SND_PCM_STREAM_CAPTURE; 178 } else if (handle->driver_flags == O_WRONLY) { 179 dir = (int)SND_PCM_STREAM_PLAYBACK; 180 } else { 181 return; 182 } 189 if (handle->driver_flags == O_RDONLY) 190 { 191 dir = (int) SND_PCM_STREAM_CAPTURE; 192 } 193 else if (handle->driver_flags == O_WRONLY) 194 { 195 dir = (int) SND_PCM_STREAM_PLAYBACK; 196 } 197 else 198 { 199 return; 200 } 183 201 #else 184 202 dir = 0; … … 187 205 snd_pcm_hw_params_alloca (&hwparams); 188 206 189 if ((err = snd_pcm_hw_params_any (pcm_handle, hwparams)) < 0) { 190 fprintf(stderr, 191 "sweep: alsa_setup: can't get PCM hw params (%s)\n", 192 snd_strerror(err)); 193 return; 194 } 207 if ((err = snd_pcm_hw_params_any (pcm_handle, hwparams)) < 0) 208 { 209 fprintf (stderr, 210 "sweep: alsa_setup: can't get PCM hw params (%s)\n", 211 snd_strerror (err)); 212 return; 213 } 195 214 196 215 if ((err = snd_pcm_hw_params_set_access 197 (pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) { 198 fprintf(stderr, 199 "sweep: alsa_setup: can't set interleaved access (%s)\n", 200 snd_strerror(err)); 201 return; 202 } 216 (pcm_handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) 217 { 218 fprintf (stderr, 219 "sweep: alsa_setup: can't set interleaved access (%s)\n", 220 snd_strerror (err)); 221 return; 222 } 203 223 204 224 if ((err = snd_pcm_hw_params_set_format 205 (pcm_handle, hwparams, SND_PCM_FORMAT_FLOAT)) < 0) {206 fprintf (stderr,207 "sweep: alsa_setup: audio interface does not support " 208 "host endian 32 bit float samples (%s)\n",209 snd_strerror(err));210 return;211 }225 (pcm_handle, hwparams, SND_PCM_FORMAT_FLOAT)) < 0) 226 { 227 fprintf (stderr, 228 "sweep: alsa_setup: audio interface does not support " 229 "host endian 32 bit float samples (%s)\n", snd_strerror (err)); 230 return; 231 } 212 232 213 233 if ((err = snd_pcm_hw_params_set_rate_near 214 (pcm_handle, hwparams, &rate, 0 /* dir */ )) < 0) {215 fprintf (stderr,216 "sweep: alsa_setup: audio interface does not support " 217 "sample rate of %d (%s)\n",218 format->rate, snd_strerror (err));219 /*return;*/220 }234 (pcm_handle, hwparams, &rate, 0 /* dir */ )) < 0) 235 { 236 fprintf (stderr, 237 "sweep: alsa_setup: audio interface does not support " 238 "sample rate of %d (%s)\n", format->rate, snd_strerror (err)); 239 /*return; */ 240 } 221 241 222 242 if ((err = snd_pcm_hw_params_set_channels_near 223 (pcm_handle, hwparams, &channels)) < 0) {224 fprintf (stderr,225 "sweep: alsa_setup: audio interface does not support " 226 "%d channels (%s)\n",227 format->channels, snd_strerror (err));228 /*return;*/229 }243 (pcm_handle, hwparams, &channels)) < 0) 244 { 245 fprintf (stderr, 246 "sweep: alsa_setup: audio interface does not support " 247 "%d channels (%s)\n", format->channels, snd_strerror (err)); 248 /*return; */ 249 } 230 250 231 251 if ((err = snd_pcm_hw_params_set_period_size_near 232 (pcm_handle, hwparams, &period_size, 0)) < 0) { 233 fprintf (stderr, 234 "sweep: alsa_setup: audio interface does not support " 235 "period size of %ld (%s)\n", period_size, snd_strerror (err)); 236 return; 237 } 238 239 periods = LOGFRAGS_TO_FRAGS(pcmio_get_log_frags()); 252 (pcm_handle, hwparams, &period_size, 0)) < 0) 253 { 254 fprintf (stderr, 255 "sweep: alsa_setup: audio interface does not support " 256 "period size of %ld (%s)\n", period_size, snd_strerror (err)); 257 return; 258 } 259 260 periods = LOGFRAGS_TO_FRAGS (pcmio_get_log_frags ()); 240 261 241 262 if ((err = snd_pcm_hw_params_set_periods_near 242 (pcm_handle, hwparams, &periods, 0)) < 0) { 243 fprintf (stderr, 244 "sweep: alsa_setup: audio interface does not support " 245 "period size of %d (%s) - suprising that we get this err!\n", 246 periods, snd_strerror (err)); 247 return; 248 } 263 (pcm_handle, hwparams, &periods, 0)) < 0) 264 { 265 fprintf (stderr, 266 "sweep: alsa_setup: audio interface does not support " 267 "period size of %d (%s) - suprising that we get this err!\n", 268 periods, snd_strerror (err)); 269 return; 270 } 249 271 250 272 // see alsa-lib html docs (may have to build them) for methods doco … … 257 279 // params.buffer_size = 3 * params.frag_size; 258 280 259 if ((err = snd_pcm_hw_params (pcm_handle, hwparams)) < 0) { 260 fprintf (stderr, 261 "sweep: alsa_setup: audio interface could not be configured " 262 "with specified parameters\n"); 263 return; 264 } 281 if ((err = snd_pcm_hw_params (pcm_handle, hwparams)) < 0) 282 { 283 fprintf (stderr, 284 "sweep: alsa_setup: audio interface could not be configured " 285 "with specified parameters\n"); 286 return; 287 } 265 288 //printf ("sweep: alsa_setup 9\n"); 266 289 … … 269 292 int dir = 0; 270 293 271 if ((err = snd_pcm_hw_params_get_rate (hwparams, &r, &dir)) < 0) { 272 fprintf (stderr, 273 "sweep: alsa_setup: error getting PCM rate (%s)\n", 274 snd_strerror (err)); 275 } 276 277 if ((err = snd_pcm_hw_params_get_channels (hwparams, &c)) < 0) { 278 fprintf (stderr, 279 "sweep: alsa_setup: error getting PCM channels (%s)\n", 280 snd_strerror (err)); 281 } 294 if ((err = snd_pcm_hw_params_get_rate (hwparams, &r, &dir)) < 0) 295 { 296 fprintf (stderr, 297 "sweep: alsa_setup: error getting PCM rate (%s)\n", 298 snd_strerror (err)); 299 } 300 301 if ((err = snd_pcm_hw_params_get_channels (hwparams, &c)) < 0) 302 { 303 fprintf (stderr, 304 "sweep: alsa_setup: error getting PCM channels (%s)\n", 305 snd_strerror (err)); 306 } 282 307 283 308 #ifdef DEBUG … … 289 314 } 290 315 291 if (snd_pcm_prepare (pcm_handle) < 0) { 292 fprintf (stderr, "audio interface could not be prepared for playback\n"); 293 return; 294 } 316 if (snd_pcm_prepare (pcm_handle) < 0) 317 { 318 fprintf (stderr, 319 "audio interface could not be prepared for playback\n"); 320 return; 321 } 295 322 } 296 323 … … 298 325 alsa_device_wait (sw_handle * handle) 299 326 { 300 snd_pcm_t * pcm_handle = (snd_pcm_t *)handle->custom_data; 301 302 if (snd_pcm_wait (pcm_handle, 1000) < 0) { 303 fprintf (stderr, "poll failed (%s)\n", strerror (errno)); 304 } 327 snd_pcm_t *pcm_handle = (snd_pcm_t *) handle->custom_data; 328 329 if (snd_pcm_wait (pcm_handle, 1000) < 0) 330 { 331 fprintf (stderr, "poll failed (%s)\n", strerror (errno)); 332 } 305 333 306 334 return 0; … … 312 340 alsa_device_read (sw_handle * handle, sw_audio_t * buf, size_t count) 313 341 { 314 snd_pcm_t * pcm_handle = (snd_pcm_t *)handle->custom_data;342 snd_pcm_t *pcm_handle = (snd_pcm_t *) handle->custom_data; 315 343 snd_pcm_uframes_t uframes; 316 344 int err; … … 325 353 static ssize_t 326 354 alsa_device_write (sw_handle * handle, sw_audio_t * buf, size_t count, 327 sw_framecount_t offset)328 { 329 snd_pcm_t * pcm_handle = (snd_pcm_t *)handle->custom_data;355 sw_framecount_t offset) 356 { 357 snd_pcm_t *pcm_handle = (snd_pcm_t *) handle->custom_data; 330 358 snd_pcm_uframes_t uframes; 331 snd_pcm_status_t * status;359 snd_pcm_status_t *status; 332 360 int err; 333 361 334 362 #if 0 335 gint16 * bbuf;363 gint16 *bbuf; 336 364 size_t byte_count; 337 365 ssize_t bytes_written; … … 339 367 int i; 340 368 341 if (handle == NULL) { 369 if (handle == NULL) 370 { 342 371 #ifdef DEBUG 343 g_print ("handle NULL in write()\n");344 #endif 345 return -1;346 }372 g_print ("handle NULL in write()\n"); 373 #endif 374 return -1; 375 } 347 376 348 377 byte_count = count * sizeof (gint16); 349 378 bbuf = alloca (byte_count); 350 379 351 for (i = 0; i < count; i++) { 352 bbuf[i] = (gint16)(PLAYBACK_SCALE * buf[i]); 353 } 354 355 err = snd_pcm_writei(pcm_handle, bbuf, uframes); 380 for (i = 0; i < count; i++) 381 { 382 bbuf[i] = (gint16) (PLAYBACK_SCALE * buf[i]); 383 } 384 385 err = snd_pcm_writei (pcm_handle, bbuf, uframes); 356 386 #else 357 /*printf ("sweep: alsa_write \n"); */387 /*printf ("sweep: alsa_write \n"); */ 358 388 359 389 uframes = count / handle->driver_channels; … … 361 391 362 392 // this basicaly ripped straight out of alsaplayer alsa-final driver: 363 err = snd_pcm_writei(pcm_handle, buf, uframes); 364 #endif 365 366 if (err == -EPIPE) { 367 snd_pcm_status_alloca(&status); 368 if ((err = snd_pcm_status(pcm_handle, status))<0) { 369 fprintf(stderr, "sweep: alsa_write: xrun. can't determine length\n"); 370 } else { 371 if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) { 372 struct timeval now, diff, tstamp; 373 gettimeofday(&now, 0); 374 snd_pcm_status_get_trigger_tstamp(status, &tstamp); 375 timersub(&now, &tstamp, &diff); 376 fprintf(stderr, "sweep: alsa_write: xrun of at least %.3f msecs. " 377 "resetting stream\n", diff.tv_sec * 1000 + diff.tv_usec / 1000.0); 378 } else { 379 fprintf(stderr, "sweep: alsa_write: xrun. can't determine length\n"); 380 } 381 } 382 snd_pcm_prepare(pcm_handle); 383 err = snd_pcm_writei(pcm_handle, buf, uframes); 384 if (err != uframes) { 385 fprintf(stderr, "sweep: alsa_write: %s\n", snd_strerror(err)); 386 return 0; 387 } else if (err < 0) { 388 fprintf(stderr, "sweep: alsa_write: %s\n", snd_strerror(err)); 389 return 0; 390 } 391 } 393 err = snd_pcm_writei (pcm_handle, buf, uframes); 394 #endif 395 396 if (err == -EPIPE) 397 { 398 snd_pcm_status_alloca (&status); 399 if ((err = snd_pcm_status (pcm_handle, status)) < 0) 400 { 401 fprintf (stderr, 402 "sweep: alsa_write: xrun. can't determine length\n"); 403 } 404 else 405 { 406 if (snd_pcm_status_get_state (status) == SND_PCM_STATE_XRUN) 407 { 408 struct timeval now, diff, tstamp; 409 gettimeofday (&now, 0); 410 snd_pcm_status_get_trigger_tstamp (status, &tstamp); 411 timersub (&now, &tstamp, &diff); 412 fprintf (stderr, 413 "sweep: alsa_write: xrun of at least %.3f msecs. " 414 "resetting stream\n", 415 diff.tv_sec * 1000 + diff.tv_usec / 1000.0); 416 } 417 else 418 { 419 fprintf (stderr, 420 "sweep: alsa_write: xrun. can't determine length\n"); 421 } 422 } 423 snd_pcm_prepare (pcm_handle); 424 err = snd_pcm_writei (pcm_handle, buf, uframes); 425 if (err != uframes) 426 { 427 fprintf (stderr, "sweep: alsa_write: %s\n", snd_strerror (err)); 428 return 0; 429 } 430 else if (err < 0) 431 { 432 fprintf (stderr, "sweep: alsa_write: %s\n", snd_strerror (err)); 433 return 0; 434 } 435 } 392 436 393 437 return 1; … … 397 441 alsa_device_offset (sw_handle * handle) 398 442 { 399 /*printf ("sweep: alsa_offset\n"); */443 /*printf ("sweep: alsa_offset\n"); */ 400 444 return -1; 401 445 } … … 404 448 alsa_device_reset (sw_handle * handle) 405 449 { 406 /*printf ("sweep: alsa_reset\n"); */450 /*printf ("sweep: alsa_reset\n"); */ 407 451 } 408 452 … … 410 454 alsa_device_flush (sw_handle * handle) 411 455 { 412 /*printf ("sweep: alsa_flush\n"); */456 /*printf ("sweep: alsa_flush\n"); */ 413 457 } 414 458 … … 421 465 alsa_device_drain (sw_handle * handle) 422 466 { 423 snd_pcm_t * pcm_handle = (snd_pcm_t *)handle->custom_data; 424 425 if (snd_pcm_drop (pcm_handle) < 0) { 426 fprintf (stderr, "audio interface could not be stopped\n"); 427 return; 428 } 429 if (snd_pcm_prepare (pcm_handle) < 0) { 430 fprintf (stderr, "audio interface could not be re-prepared\n"); 431 return; 432 } 467 snd_pcm_t *pcm_handle = (snd_pcm_t *) handle->custom_data; 468 469 if (snd_pcm_drop (pcm_handle) < 0) 470 { 471 fprintf (stderr, "audio interface could not be stopped\n"); 472 return; 473 } 474 if (snd_pcm_prepare (pcm_handle) < 0) 475 { 476 fprintf (stderr, "audio interface could not be re-prepared\n"); 477 return; 478 } 433 479 } 434 480 … … 436 482 alsa_device_close (sw_handle * handle) 437 483 { 438 snd_pcm_t * pcm_handle = (snd_pcm_t *)handle->custom_data;439 484 snd_pcm_t *pcm_handle = (snd_pcm_t *) handle->custom_data; 485 440 486 snd_pcm_close (pcm_handle); 441 487 } … … 463 509 #endif 464 510 465 sw_driver * driver_alsa = &_driver_alsa;511 sw_driver *driver_alsa = &_driver_alsa; sweep/branches/display-cache/src/driver_oss.c
r124 r471 60 60 typedef struct _oss_play_offset oss_play_offset; 61 61 62 struct _oss_play_offset { 62 struct _oss_play_offset 63 { 63 64 int framenr; 64 65 sw_framecount_t offset; … … 66 67 67 68 68 static oss_play_offset offsets[1 <<LOG_FRAGS_MAX];69 static oss_play_offset offsets[1 << LOG_FRAGS_MAX]; 69 70 70 71 static int nfrags = 0; … … 84 85 oss_get_names (void) 85 86 { 86 GList * names = NULL;87 GList *names = NULL; 87 88 88 89 names = g_list_append (names, "/dev/dsp"); … … 96 97 open_dev_dsp (int monitoring, int flags) 97 98 { 98 char * dev_name;99 char *dev_name; 99 100 int dev_dsp; 100 sw_handle * handle;101 sw_handle *handle; 101 102 int i; 102 103 103 if (monitoring) { 104 if (pcmio_get_use_monitor()) 105 dev_name = pcmio_get_monitor_dev (); 106 else 104 if (monitoring) 105 { 106 if (pcmio_get_use_monitor ()) 107 dev_name = pcmio_get_monitor_dev (); 108 else 109 return NULL; 110 } 111 else 112 { 113 dev_name = pcmio_get_main_dev (); 114 } 115 116 flags &= O_RDONLY | O_WRONLY | O_RDWR; /* mask out direction flags */ 117 118 if ((dev_dsp = open (dev_name, flags, 0)) == -1) 119 { 120 sweep_perror (errno, "Unable to open device %s", dev_name); 107 121 return NULL; 108 } else { 109 dev_name = pcmio_get_main_dev (); 110 } 111 112 flags &= O_RDONLY|O_WRONLY|O_RDWR; /* mask out direction flags */ 113 114 if((dev_dsp = open(dev_name, flags, 0)) == -1) { 115 sweep_perror (errno, "Unable to open device %s", dev_name); 116 return NULL; 117 } 122 } 118 123 119 124 handle = g_malloc0 (sizeof (sw_handle)); … … 123 128 oindex = 0; 124 129 current_frame = 0; 125 for (i = 0; i < (LOGFRAGS_TO_FRAGS(LOG_FRAGS_MAX)); i++) { 126 offsets[i].framenr = 0; 127 offsets[i].offset = -1; 128 } 130 for (i = 0; i < (LOGFRAGS_TO_FRAGS (LOG_FRAGS_MAX)); i++) 131 { 132 offsets[i].framenr = 0; 133 offsets[i].offset = -1; 134 } 129 135 frame = 0; 130 136 … … 136 142 { 137 143 int dev_dsp; 138 /* int mask, format, stereo, frequency; */144 /* int mask, format, stereo, frequency; */ 139 145 140 146 int stereo = 0; … … 146 152 int fmt; 147 153 148 if (handle == NULL) { 149 #ifdef DEBUG 150 g_print ("handle NULL in setup()\n"); 151 #endif 152 return; 153 } 154 if (handle == NULL) 155 { 156 #ifdef DEBUG 157 g_print ("handle NULL in setup()\n"); 158 #endif 159 return; 160 } 154 161 155 162 dev_dsp = handle->driver_fd; 156 163 157 if (ioctl (dev_dsp, SNDCTL_DSP_STEREO, &stereo) == -1) { 158 /* Fatal error */ 159 perror("open_dsp_device 2 ") ; 160 exit (1); 161 } ; 162 163 if (ioctl (dev_dsp, SNDCTL_DSP_RESET, 0)) { 164 perror ("open_dsp_device 3 ") ; 165 exit (1) ; 166 } ; 167 168 nfrags = LOGFRAGS_TO_FRAGS(pcmio_get_log_frags()); 164 if (ioctl (dev_dsp, SNDCTL_DSP_STEREO, &stereo) == -1) 165 { 166 /* Fatal error */ 167 perror ("open_dsp_device 2 "); 168 exit (1); 169 }; 170 171 if (ioctl (dev_dsp, SNDCTL_DSP_RESET, 0)) 172 { 173 perror ("open_dsp_device 3 "); 174 exit (1); 175 }; 176 177 nfrags = LOGFRAGS_TO_FRAGS (pcmio_get_log_frags ()); 169 178 fragsize = 8; 170 179 frag = (nfrags << 16) | fragsize; 171 if ((error = ioctl (dev_dsp, SNDCTL_DSP_SETFRAGMENT, &frag)) != 0) { 172 perror ("OSS: error setting fragments"); 173 } 180 if ((error = ioctl (dev_dsp, SNDCTL_DSP_SETFRAGMENT, &frag)) != 0) 181 { 182 perror ("OSS: error setting fragments"); 183 } 174 184 175 185 fragsize = (frag & 0xffff); 176 nfrags = (frag & 0x7fff000) >>16;186 nfrags = (frag & 0x7fff000) >> 16; 177 187 #ifdef DEBUG 178 188 g_print ("Got %d frags of size 2^%d\n", nfrags, fragsize); 179 189 #endif 180 181 bits = 16 ; 182 if ((error = ioctl (dev_dsp, SOUND_PCM_WRITE_BITS, &bits)) != 0) { 183 perror ("open_dsp_device 4 "); 184 exit (1); 185 } 186 187 for (i=1; i <= format->channels; i *= 2) { 188 channels = format->channels / i; 189 want_channels = channels; 190 191 if ((error = ioctl (dev_dsp, SOUND_PCM_WRITE_CHANNELS, &channels)) == -1) { 192 perror ("open_dsp_device 5 ") ; 193 exit (1) ; 194 } 195 196 if (channels == want_channels) break; 197 } 190 191 bits = 16; 192 if ((error = ioctl (dev_dsp, SOUND_PCM_WRITE_BITS, &bits)) != 0) 193 { 194 perror ("open_dsp_device 4 "); 195 exit (1); 196 } 197 198 for (i = 1; i <= format->channels; i *= 2) 199 { 200 channels = format->channels / i; 201 want_channels = channels; 202 203 if ((error = 204 ioctl (dev_dsp, SOUND_PCM_WRITE_CHANNELS, &channels)) == -1) 205 { 206 perror ("open_dsp_device 5 "); 207 exit (1); 208 } 209 210 if (channels == want_channels) 211 break; 212 } 198 213 199 214 handle->driver_channels = channels; … … 201 216 srate = format->rate; 202 217 203 if ((error = ioctl (dev_dsp, SOUND_PCM_WRITE_RATE, &srate)) != 0) { 204 perror ("open_dsp_device 6 ") ; 205 exit (1) ; 206 } 218 if ((error = ioctl (dev_dsp, SOUND_PCM_WRITE_RATE, &srate)) != 0) 219 { 220 perror ("open_dsp_device 6 "); 221 exit (1); 222 } 207 223 208 224 handle->driver_rate = srate; 209 225 210 if ((error = ioctl (dev_dsp, SNDCTL_DSP_SYNC, 0)) != 0) { 211 perror ("open_dsp_device 7 ") ; 212 exit (1) ; 213 } 226 if ((error = ioctl (dev_dsp, SNDCTL_DSP_SYNC, 0)) != 0) 227 { 228 perror ("open_dsp_device 7 "); 229 exit (1); 230 } 214 231 215 232 fmt = AFMT_QUERY; 216 if ((error = ioctl (dev_dsp, SOUND_PCM_SETFMT, &fmt)) != 0) { 217 perror ("open_dsp_device 8") ; 218 exit (1) ; 219 } 220 221 handle->custom_data = GINT_TO_POINTER(0); 233 if ((error = ioctl (dev_dsp, SOUND_PCM_SETFMT, &fmt)) != 0) 234 { 235 perror ("open_dsp_device 8"); 236 exit (1); 237 } 238 239 handle->custom_data = GINT_TO_POINTER (0); 222 240 223 241 #ifdef WORDS_BIGENDIAN 224 if (fmt == AFMT_S16_LE || fmt == AFMT_U16_LE) { 225 handle->custom_data = GINT_TO_POINTER(1); 226 } 242 if (fmt == AFMT_S16_LE || fmt == AFMT_U16_LE) 243 { 244 handle->custom_data = GINT_TO_POINTER (1); 245 } 227 246 #else 228 if (fmt == AFMT_S16_BE || fmt == AFMT_U16_BE) { 229 handle->custom_data = GINT_TO_POINTER(1); 230 } 247 if (fmt == AFMT_S16_BE || fmt == AFMT_U16_BE) 248 { 249 handle->custom_data = GINT_TO_POINTER (1); 250 } 231 251 #endif 232 252 … … 235 255 int caps; 236 256 237 if (ioctl (dev_dsp, SNDCTL_DSP_GETCAPS, &caps) == -1) { 238 sweep_perror (errno, "OSS: Unable to get device capabilities"); 239 } 257 if (ioctl (dev_dsp, SNDCTL_DSP_GETCAPS, &caps) == -1) 258 { 259 sweep_perror (errno, "OSS: Unable to get device capabilities"); 260 } 240 261 /* CAP_REALTIME tells whether or not this device can give exact 241 262 * DMA pointers via GETOSPACE/GETISPACE. If this is true, then … … 261 282 read_dev_dsp (sw_handle * handle, sw_audio_t * buf, size_t count) 262 283 { 263 gint16 * bbuf;284 gint16 *bbuf; 264 285 size_t byte_count; 265 286 ssize_t bytes_read; … … 271 292 bytes_read = read (handle->driver_fd, bbuf, byte_count); 272 293 273 if (bytes_read == -1) { 274 sweep_perror (errno, "Error reading from OSS audio device"); 275 return -1; 276 } 277 278 need_bswap = GPOINTER_TO_INT(handle->custom_data); 279 280 if (need_bswap) { 281 unsigned char * ucptr = (unsigned char *)bbuf; 282 unsigned char temp; 283 284 for (i = 0; i < count; i++) { 285 temp = ucptr[2 * i]; 286 ucptr[2 * i] = ucptr [2 * i + 1]; 287 ucptr[2 * i + 1] = temp; 288 } 289 } 290 291 for (i = 0; i < count; i++) { 292 buf[i] = (sw_audio_t)(bbuf[i] * RECORD_SCALE); 293 } 294 if (bytes_read == -1) 295 { 296 sweep_perror (errno, "Error reading from OSS audio device"); 297 return -1; 298 } 299 300 need_bswap = GPOINTER_TO_INT (handle->custom_data); 301 302 if (need_bswap) 303 { 304 unsigned char *ucptr = (unsigned char *) bbuf; 305 unsigned char temp; 306 307 for (i = 0; i < count; i++) 308 { 309 temp = ucptr[2 * i]; 310 ucptr[2 * i] = ucptr[2 * i + 1]; 311 ucptr[2 * i + 1] = temp; 312 } 313 } 314 315 for (i = 0; i < count; i++) 316 { 317 buf[i] = (sw_audio_t) (bbuf[i] * RECORD_SCALE); 318 } 294 319 295 320 return (bytes_read / sizeof (gint16)); … … 302 327 sw_framecount_t play_offset) 303 328 { 304 gint16 * bbuf;329 gint16 *bbuf; 305 330 size_t byte_count; 306 331 ssize_t bytes_written; … … 308 333 int i; 309 334 310 if (handle == NULL) { 311 #ifdef DEBUG 312 g_print ("handle NULL in write()\n"); 313 #endif 314 return -1; 315 } 335 if (handle == NULL) 336 { 337 #ifdef DEBUG 338 g_print ("handle NULL in write()\n"); 339 #endif 340 return -1; 341 } 316 342 317 343 current_frame += count; 318 344 offsets[oindex].framenr = current_frame; 319 345 offsets[oindex].offset = play_offset; 320 oindex++; oindex %= nfrags; 346 oindex++; 347 oindex %= nfrags; 321 348 322 349 byte_count = count * sizeof (gint16); 323 350 bbuf = alloca (byte_count); 324 351 325 for (i = 0; i < count; i++) { 326 bbuf[i] = (gint16)(PLAYBACK_SCALE * buf[i]); 327 } 328 329 need_bswap = GPOINTER_TO_INT(handle->custom_data); 330 331 if (need_bswap) { 332 unsigned char * ucptr = (unsigned char *)bbuf; 333 unsigned char temp; 334 335 for (i = 0; i < count; i++) { 336 temp = ucptr[2 * i]; 337 ucptr[2 * i] = ucptr [2 * i + 1]; 338 ucptr[2 * i + 1] = temp; 339 } 340 } 352 for (i = 0; i < count; i++) 353 { 354 bbuf[i] = (gint16) (PLAYBACK_SCALE * buf[i]); 355 } 356 357 need_bswap = GPOINTER_TO_INT (handle->custom_data); 358 359 if (need_bswap) 360 { 361 unsigned char *ucptr = (unsigned char *) bbuf; 362 unsigned char temp; 363 364 for (i = 0; i < count; i++) 365 { 366 temp = ucptr[2 * i]; 367 ucptr[2 * i] = ucptr[2 * i + 1]; 368 ucptr[2 * i + 1] = temp; 369 } 370 } 341 371 342 372 bytes_written = write (handle->driver_fd, bbuf, byte_count); 343 373 344 if (bytes_written == -1) { 345 sweep_perror (errno, "Error writing to OSS audio device"); 346 return -1; 347 } else { 348 return (bytes_written / sizeof(gint16)); 349 } 374 if (bytes_written == -1) 375 { 376 sweep_perror (errno, "Error writing to OSS audio device"); 377 return -1; 378 } 379 else 380 { 381 return (bytes_written / sizeof (gint16)); 382 } 350 383 } 351 384 … … 356 389 int i, o; 357 390 358 if (handle == NULL) { 359 #ifdef DEBUG 360 g_print ("handle NULL in offset()\n"); 361 #endif 362 return -1; 363 } 364 365 if (ioctl (handle->driver_fd, SNDCTL_DSP_GETOPTR, &info) == -1) { 391 if (handle == NULL) 392 { 393 #ifdef DEBUG 394 g_print ("handle NULL in offset()\n"); 395 #endif 396 return -1; 397 } 398 399 if (ioctl (handle->driver_fd, SNDCTL_DSP_GETOPTR, &info) == -1) 400 { 366 401 #ifdef DEBUG_OFFSET 367 g_print ("error in GETOPTR\n");368 #endif 369 return -1;370 }402 g_print ("error in GETOPTR\n"); 403 #endif 404 return -1; 405 } 371 406 372 407 frame = info.bytes; … … 375 410 #endif 376 411 377 o = oindex+1; 378 for (i = 0; i < nfrags; i++) { 379 o %= nfrags; 412 o = oindex + 1; 413 for (i = 0; i < nfrags; i++) 414 { 415 o %= nfrags; 380 416 #ifdef DEBUG_OFFSET 381 g_print ("\t(%d) Checking %d: %d\n", frame, o, offsets[o].framenr); 382 #endif 383 if (offsets[o].framenr >= frame) { 384 return offsets[o].offset; 385 } 386 o++; 387 } 417 g_print ("\t(%d) Checking %d: %d\n", frame, o, offsets[o].framenr); 418 #endif 419 if (offsets[o].framenr >= frame) 420 { 421 return offsets[o].offset; 422 } 423 o++; 424 } 388 425 389 426 return -1; … … 393 430 reset_dev_dsp (sw_handle * handle) 394 431 { 395 if (handle == NULL) { 396 #ifdef DEBUG 397 g_print ("handle NULL in reset()\n"); 398 #endif 399 return; 400 } 401 402 if(ioctl (handle->driver_fd, SNDCTL_DSP_RESET, 0) == -1) { 403 sweep_perror (errno, "Error resetting OSS audio device"); 404 } 432 if (handle == NULL) 433 { 434 #ifdef DEBUG 435 g_print ("handle NULL in reset()\n"); 436 #endif 437 return; 438 } 439 440 if (ioctl (handle->driver_fd, SNDCTL_DSP_RESET, 0) == -1) 441 { 442 sweep_perror (errno, "Error resetting OSS audio device"); 443 } 405 444 } 406 445 … … 413 452 drain_dev_dsp (sw_handle * handle) 414 453 { 415 if (handle == NULL) { 416 g_print ("handle NULL in drain ()\n"); 417 return; 418 } 419 420 if(ioctl (handle->driver_fd, SNDCTL_DSP_POST, 0) == -1) { 421 sweep_perror (errno, "POST error on OSS audio device"); 422 } 423 424 if (ioctl (handle->driver_fd, SNDCTL_DSP_SYNC, 0) == -1) { 425 sweep_perror (errno, "SYNC error on OSS audio device"); 426 } 454 if (handle == NULL) 455 { 456 g_print ("handle NULL in drain ()\n"); 457 return; 458 } 459 460 if (ioctl (handle->driver_fd, SNDCTL_DSP_POST, 0) == -1) 461 { 462 sweep_perror (errno, "POST error on OSS audio device"); 463 } 464 465 if (ioctl (handle->driver_fd, SNDCTL_DSP_SYNC, 0) == -1) 466 { 467 sweep_perror (errno, "SYNC error on OSS audio device"); 468 } 427 469 } 428 470 … … 455 497 #endif 456 498 457 sw_driver * driver_oss = &_driver_oss;499 sw_driver *driver_oss = &_driver_oss; sweep/branches/display-cache/src/driver_solaris.c
r124 r471 52 52 { 53 53 int dev_audio; 54 sw_handle * handle;54 sw_handle *handle; 55 55 56 if (cueing) return NULL; 56 if (cueing) 57 return NULL; 57 58 58 if((dev_audio = open(DEV_AUDIO, O_WRONLY, 0)) == -1) { 59 sweep_perror (errno, "Unable to open device " DEV_AUDIO); 60 return NULL; 61 } 59 if ((dev_audio = open (DEV_AUDIO, O_WRONLY, 0)) == -1) 60 { 61 sweep_perror (errno, "Unable to open device " DEV_AUDIO); 62 return NULL; 63 } 62 64 63 65 handle = g_malloc0 (sizeof (sw_handle)); … … 73 75 audio_info_t info; 74 76 75 AUDIO_INITINFO (&info);77 AUDIO_INITINFO (&info); 76 78 info.play.precision = 16; /* cs4231 doesn't handle 16-bit linear PCM */ 77 79 info.play.encoding = AUDIO_ENCODING_LINEAR; 78 80 info.play.channels = format->channels; 79 81 info.play.sample_rate = format->rate; 80 if (ioctl(handle->driver_fd, AUDIO_SETINFO, &info) < 0)81 sweep_perror (errno, "Unable to configure audio device");82 if (ioctl (handle->driver_fd, AUDIO_SETINFO, &info) < 0) 83 sweep_perror (errno, "Unable to configure audio device"); 82 84 83 85 handle->driver_channels = info.play.channels; … … 85 87 86 88 static ssize_t 87 write_dev_audio (sw_handle * handle, void * buf, size_t count)89 write_dev_audio (sw_handle * handle, void *buf, size_t count) 88 90 { 89 91 return write (handle->driver_fd, buf, count); … … 98 100 flush_dev_audio (sw_handle * handle) 99 101 { 100 if (ioctl (handle->driver_fd, I_FLUSH, FLUSHW) == -1)101 perror ("I_FLUSH");102 if (ioctl (handle->driver_fd, I_FLUSH, FLUSHW) == -1) 103 perror ("I_FLUSH"); 102 104 } 103 105 … … 105 107 drain_dev_audio (sw_handle * handle) 106 108 { 107 if (ioctl(handle->driver_fd, AUDIO_DRAIN, 0) == -1)108 perror("AUDIO_DRAIN");109 if (ioctl (handle->driver_fd, AUDIO_DRAIN, 0) == -1) 110 perror ("AUDIO_DRAIN"); 109 111 } 110 112 … … 116 118 117 119 static sw_driver _driver_solaris = { 118 NULL, /* config */120 NULL, /* config */ 119 121 open_dev_audio, 120 122 setup_dev_audio, … … 135 137 #endif 136 138 137 sw_driver * driver_solaris = &_driver_solaris;139 sw_driver *driver_solaris = &_driver_solaris; sweep/branches/display-cache/src/edit.c
r124 r471 45 45 46 46 47 sw_edit_buffer * ebuf = NULL;47 sw_edit_buffer *ebuf = NULL; 48 48 49 49 void * 50 sweep_large_alloc_data (size_t len, void * data, int prot)51 { 52 void * ptr;50 sweep_large_alloc_data (size_t len, void *data, int prot) 51 { 52 void *ptr; 53 53 54 54 #if HAVE_MMAP 55 FILE * f;55 FILE *f; 56 56 int fd; 57 57 58 if ((f = tmpfile ()) == NULL) { 59 perror ("tmpfile failed in sweep_large_alloc_data"); 60 return NULL; 61 } 62 63 if (fwrite (data, len, 1, f) != 1) { 64 perror ("short fwrite in sweep_large_alloc_data"); 65 return NULL; 66 } 67 68 if (fseek (f, 0, SEEK_SET) == -1) { 69 perror ("fseek failed in sweep_large_alloc_data"); 70 return NULL; 71 } 72 73 if ((fd = fileno (f)) == -1) { 74 perror ("fileno failed in sweep_large_alloc_data"); 75 return NULL; 76 } 77 78 if ((ptr = mmap (NULL, len, prot, MAP_PRIVATE, fd, 0)) == MAP_FAILED) { 79 perror ("mmap failed in sweep_large_alloc_data"); 80 return NULL; 81 } 58 if ((f = tmpfile ()) == NULL) 59 { 60 perror ("tmpfile failed in sweep_large_alloc_data"); 61 return NULL; 62 } 63 64 if (fwrite (data, len, 1, f) != 1) 65 { 66 perror ("short fwrite in sweep_large_alloc_data"); 67 return NULL; 68 } 69 70 if (fseek (f, 0, SEEK_SET) == -1) 71 { 72 perror ("fseek failed in sweep_large_alloc_data"); 73 return NULL; 74 } 75 76 if ((fd = fileno (f)) == -1) 77 { 78 perror ("fileno failed in sweep_large_alloc_data"); 79 return NULL; 80 } 81 82 if ((ptr = mmap (NULL, len, prot, MAP_PRIVATE, fd, 0)) == MAP_FAILED) 83 { 84 perror ("mmap failed in sweep_large_alloc_data"); 85 return NULL; 86 } 82 87 #else 83 88 ptr = g_malloc (len); … … 92 97 sweep_large_alloc_zero (size_t len, int prot) 93 98 { 94 void * ptr;99 void *ptr; 95 100 96 101 #if HAVE_MMAP 97 102 int fd; 98 103 99 if ((fd = open ("/dev/zero", O_RDWR)) == -1) { 100 perror ("open failed in sweep_large_alloc_zero"); 101 return NULL; 102 } 103 104 if (lseek (fd, len+1, SEEK_SET) == (off_t)-1) { 105 perror ("lseek failed in sweep_large_alloc_zero"); 106 return NULL; 107 } 108 109 if (write (fd, "", 1) == -1) { 110 perror ("write failed in sweep_large_alloc_zero"); 111 return NULL; 112 } 113 114 if (lseek (fd, 0, SEEK_SET) == (off_t)-1) { 115 perror ("lseek failed in sweep_large_alloc_zero"); 116 return NULL; 117 } 118 119 if ((ptr = mmap (NULL, len, prot, MAP_PRIVATE, fd, 0)) == MAP_FAILED) { 120 perror ("mmap failed in sweep_large_alloc_zero"); 121 return NULL; 122 } 104 if ((fd = open ("/dev/zero", O_RDWR)) == -1) 105 { 106 perror ("open failed in sweep_large_alloc_zero"); 107 return NULL; 108 } 109 110 if (lseek (fd, len + 1, SEEK_SET) == (off_t) - 1) 111 { 112 perror ("lseek failed in sweep_large_alloc_zero"); 113 return NULL; 114 } 115 116 if (write (fd, "", 1) == -1) 117 { 118 perror ("write failed in sweep_large_alloc_zero"); 119 return NULL; 120 } 121 122 if (lseek (fd, 0, SEEK_SET) == (off_t) - 1) 123 { 124 perror ("lseek failed in sweep_large_alloc_zero"); 125 return NULL; 126 } 127 128 if ((ptr = mmap (NULL, len, prot, MAP_PRIVATE, fd, 0)) == MAP_FAILED) 129 { 130 perror ("mmap failed in sweep_large_alloc_zero"); 131 return NULL; 132 } 123 133 #else 124 134 ptr = g_malloc0 (len); … … 129 139 130 140 void 131 sweep_large_free (void * ptr, size_t len)141 sweep_large_free (void *ptr, size_t len) 132 142 { 133 143 #if HAVE_MMAP … … 143 153 sw_framecount_t end, gpointer data) 144 154 { 145 sw_edit_region * er;155 sw_edit_region *er; 146 156 sw_framecount_t len; 147 157 148 er = g_malloc (sizeof (sw_edit_region));158 er = g_malloc (sizeof (sw_edit_region)); 149 159 150 160 er->start = start; 151 161 er->end = end; 152 162 153 len = frames_to_bytes (format, end -start);163 len = frames_to_bytes (format, end - start); 154 164 er->data = sweep_large_alloc_data (len, data, PROT_READ); 155 165 … … 165 175 166 176 offset = frames_to_bytes (format, start); 167 o2 = (int) offset;/* XXX */168 169 return edit_region_new (format, start, end, data0 +o2);177 o2 = (int) offset; /* XXX */ 178 179 return edit_region_new (format, start, end, data0 + o2); 170 180 } 171 181 … … 173 183 edit_region_copy (sw_format * format, sw_edit_region * oer) 174 184 { 175 sw_edit_region * er;185 sw_edit_region *er; 176 186 177 187 er = edit_region_new (format, oer->start, oer->end, oer->data); … … 183 193 edit_buffer_new (sw_format * format) 184 194 { 185 sw_edit_buffer * eb;186 187 eb = g_malloc0 (sizeof (sw_edit_buffer));195 sw_edit_buffer *eb; 196 197 eb = g_malloc0 (sizeof (sw_edit_buffer)); 188 198 eb->format = format_copy (format); 189 199 eb->regions = NULL; … … 196 206 edit_buffer_copy (sw_edit_buffer * oeb) 197 207 { 198 sw_edit_buffer * eb;199 GList * gl;200 sw_edit_region * oer, *er;208 sw_edit_buffer *eb; 209 GList *gl; 210 sw_edit_region *oer, *er; 201 211 202 212 eb = edit_buffer_new (oeb->format); 203 213 204 for (gl = oeb->regions; gl; gl = gl->next) { 205 oer = (sw_edit_region *)gl->data; 206 207 er = edit_region_copy (oeb->format, oer); 208 209 eb->regions = g_list_append (eb->regions, er); 210 } 214 for (gl = oeb->regions; gl; gl = gl->next) 215 { 216 oer = (sw_edit_region *) gl->data; 217 218 er = edit_region_copy (oeb->format, oer); 219 220 eb->regions = g_list_append (eb->regions, er); 221 } 211 222 212 223 return eb; … … 223 234 edit_buffer_clear (sw_edit_buffer * eb) 224 235 { 225 GList * gl;226 sw_edit_region * er;236 GList *gl; 237 sw_edit_region *er; 227 238 size_t len; 228 239 229 if (!eb) return; 230 231 for (gl = eb->regions; gl; gl = gl->next) { 232 er = (sw_edit_region *)gl->data; 233 if (er) { 234 len = frames_to_bytes (eb->format, er->end - er->start); 235 sweep_large_free (er->data, len); 236 } 237 } 240 if (!eb) 241 return; 242 243 for (gl = eb->regions; gl; gl = gl->next) 244 { 245 er = (sw_edit_region *) gl->data; 246 if (er) 247 { 248 len = frames_to_bytes (eb->format, er->end - er->start); 249 sweep_large_free (er->data, len); 250 } 251 } 238 252 g_list_free (eb->regions); 239 253 … … 249 263 { 250 264 eb->refcount--; 251 if (eb->refcount > 0) return; 265 if (eb->refcount > 0) 266 return; 252 267 253 268 edit_buffer_clear (eb); … … 258 273 ebuf_clear (void) 259 274 { 260 if (!ebuf) return; 275 if (!ebuf) 276 return; 261 277 262 278 edit_buffer_destroy (ebuf); … … 268 284 edit_buffer_length (sw_edit_buffer * eb) 269 285 { 270 GList * gl;271 sw_edit_region * er;286 GList *gl; 287 sw_edit_region *er; 272 288 sw_framecount_t length = 0; 273 289 274 for (gl = eb->regions; gl; gl = gl->next) { 275 er = (sw_edit_region *)gl->data; 276 277 length += (er->end - er->start); 278 } 290 for (gl = eb->regions; gl; gl = gl->next) 291 { 292 er = (sw_edit_region *) gl->data; 293 294 length += (er->end - er->start); 295 } 279 296 280 297 return length; … … 284 301 edit_buffer_width (sw_edit_buffer * eb) 285 302 { 286 GList * gl;287 sw_edit_region * er;303 GList *gl; 304 sw_edit_region *er; 288 305 sw_framecount_t start, end; 289 306 290 if (eb == NULL) return 0; 291 292 if ((gl = eb->regions) == NULL) return 0; 293 er = (sw_edit_region *)gl->data; 307 if (eb == NULL) 308 return 0; 309 310 if ((gl = eb->regions) == NULL) 311 return 0; 312 er = (sw_edit_region *) gl->data; 294 313 start = er->start; 295 314 296 315 gl = g_list_last (eb->regions); 297 er = (sw_edit_region *) gl->data;316 er = (sw_edit_region *) gl->data; 298 317 end = er->end; 299 318 300 319 return (end - start); 301 320 } … … 310 329 edit_buffer_from_sounddata_sels (sw_sounddata * sounddata, GList * sels) 311 330 { 312 sw_edit_buffer * eb;313 GList * gl;314 sw_sel * sel;315 sw_edit_region * er;331 sw_edit_buffer *eb; 332 GList *gl; 333 sw_sel *sel; 334 sw_edit_region *er; 316 335 317 336 eb = edit_buffer_new (sounddata->format); 318 337 319 for (gl = sels; gl; gl = gl->next) {320 sel = (sw_sel *)gl->data;321 322 er = edit_region_new0 (eb->format, 323 sel->sel_start, sel->sel_end,324 sounddata->data);338 for (gl = sels; gl; gl = gl->next) 339 { 340 sel = (sw_sel *) gl->data; 341 342 er = edit_region_new0 (eb->format, 343 sel->sel_start, sel->sel_end, sounddata->data); 325 344 326 345 #ifdef DEBUG 327 printf("adding eb region [%ld - %ld]\n", sel->sel_start, sel->sel_end);346 printf ("adding eb region [%ld - %ld]\n", sel->sel_start, sel->sel_end); 328 347 #endif 329 348 330 eb->regions = g_list_append (eb->regions, er);331 }349 eb->regions = g_list_append (eb->regions, er); 350 } 332 351 333 352 return eb; … … 349 368 sels_from_edit_buffer_offset (sw_edit_buffer * eb, sw_framecount_t offset) 350 369 { 351 GList * gl, *sels = NULL;352 sw_edit_region * er;370 GList *gl, *sels = NULL; 371 sw_edit_region *er; 353 372 sw_framecount_t start; 354 373 355 374 gl = eb->regions; 356 if (!gl) return NULL; 357 358 er = (sw_edit_region *)gl->data; 375 if (!gl) 376 return NULL; 377 378 er = (sw_edit_region *) gl->data; 359 379 start = er->start; 360 380 361 for (gl = eb->regions; gl; gl = gl->next) { 362 er = (sw_edit_region *)gl->data; 363 364 sels = sels_add_selection_1 (sels, er->start - start + offset, 365 er->end - start + offset); 366 } 381 for (gl = eb->regions; gl; gl = gl->next) 382 { 383 er = (sw_edit_region *) gl->data; 384 385 sels = sels_add_selection_1 (sels, er->start - start + offset, 386 er->end - start + offset); 387 } 367 388 368 389 return sels; … … 372 393 sample_from_edit_buffer (sw_edit_buffer * eb) 373 394 { 374 sw_sample * s;375 GList * gl;376 sw_edit_region * er;395 sw_sample *s; 396 GList *gl; 397 sw_edit_region *er; 377 398 sw_framecount_t offset0 = 0, start, length; 378 399 sw_framecount_t offset, len; … … 381 402 gl = eb->regions; 382 403 383 if (!gl) return NULL; 384 385 er = (sw_edit_region *)gl->data; 404 if (!gl) 405 return NULL; 406 407 er = (sw_edit_region *) gl->data; 386 408 start = er->start; 387 409 388 410 for (; gl->next; gl = gl->next); 389 er = (sw_edit_region *) gl->data;411 er = (sw_edit_region *) gl->data; 390 412 length = er->end - start; 391 413 392 s = sample_new_empty (NULL, 393 eb->format->channels, 394 eb->format->rate, 395 length); 414 s = sample_new_empty (NULL, eb->format->channels, eb->format->rate, length); 396 415 397 416 offset0 = frames_to_bytes (eb->format, start); 398 417 399 for (gl = eb->regions; gl; gl = gl->next) { 400 er = (sw_edit_region *)gl->data; 401 offset = frames_to_bytes (eb->format, er->start) - offset0; 402 len = frames_to_bytes (eb->format, er->end - er->start); 403 404 memcpy ((gpointer)(s->sounddata->data + offset), er->data, len); 405 406 sounddata_add_selection_1 (s->sounddata, er->start - start, 407 er->end - start); 418 for (gl = eb->regions; gl; gl = gl->next) 419 { 420 er = (sw_edit_region *) gl->data; 421 offset = frames_to_bytes (eb->format, er->start) - offset0; 422 len = frames_to_bytes (eb->format, er->end - er->start); 423 424 memcpy ((gpointer) (s->sounddata->data + offset), er->data, len); 425 426 sounddata_add_selection_1 (s->sounddata, er->start - start, 427 er->end - start); 408 428 409 429 #ifdef DEBUG 410 printf("Adding sample region [%ld - %ld]\n", er->start, er->end);430 printf ("Adding sample region [%ld - %ld]\n", er->start, er->end); 411 431 #endif 412 }432 } 413 433 414 434 return s; … … 419 439 sw_framecount_t upper, sw_framecount_t amount) 420 440 { 421 if (head == NULL) return; 441 if (head == NULL) 442 return; 422 443 423 444 g_mutex_lock (head->head_mutex); … … 435 456 head_inc_if_gt (sw_head * head, sw_framecount_t lower, sw_framecount_t amount) 436 457 { 437 if (head == NULL) return; 458 if (head == NULL) 459 return; 438 460 439 461 g_mutex_lock (head->head_mutex); … … 452 474 sw_framecount_t upper, sw_framecount_t value) 453 475 { 454 if (head == NULL) return; 476 if (head == NULL) 477 return; 455 478 456 479 g_mutex_lock (head->head_mutex); … … 458 481 if (head->stop_offset >= lower && head->stop_offset <= upper) 459 482 head->stop_offset = value; 460 483 461 484 if (head->offset >= lower && head->offset <= upper) 462 485 head->offset = value; … … 469 492 splice_out_sel (sw_sample * sample) 470 493 { 471 sw_sounddata * sounddata = sample->sounddata;472 sw_format * f = sounddata->format;494 sw_sounddata *sounddata = sample->sounddata; 495 sw_format *f = sounddata->format; 473 496 gint length; 474 GList * gl;475 sw_sel * osel, *sel;476 /*sw_sounddata * out; */497 GList *gl; 498 sw_sel *osel, *sel; 499 /*sw_sounddata * out; */ 477 500 gpointer d; 478 501 sw_framecount_t offset, len, sel_length = 0; 479 502 sw_framecount_t move_length, run_length; 480 503 481 if (!sounddata->sels) { 482 printf ("Nothing to splice out.\n"); 483 return sample; 484 } 504 if (!sounddata->sels) 505 { 506 printf ("Nothing to splice out.\n"); 507 return sample; 508 } 485 509 486 510 length = sounddata->nr_frames - sounddata_selection_nr_frames (sounddata); … … 488 512 489 513 #ifdef DEBUG 490 printf ("Splice out: remaining length %d\n", length);514 printf ("Splice out: remaining length %d\n", length); 491 515 #endif 492 516 … … 502 526 503 527 gl = sounddata->sels; 504 sel = osel = (sw_sel *)gl->data; 505 if (osel->sel_start > 0) { 506 507 if (sample->user_offset >= sel->sel_start && 508 sample->user_offset <= sel->sel_end) { 509 sample->user_offset = sel->sel_start - sel_length;; 510 } 511 512 head_set_if_within (sample->play_head, sel->sel_start, sel->sel_end, 513 sel->sel_start - sel_length); 514 515 head_set_if_within (sample->rec_head, sel->sel_start, sel->sel_end, 516 sel->sel_start - sel_length); 517 518 sel_length = osel->sel_end - osel->sel_start; 519 520 move_length = osel->sel_start; 521 522 len = frames_to_bytes (f, move_length); 523 d += len; 524 525 run_length += move_length; 526 sample_set_progress_percent (sample, run_length / (length/100)); 527 } 528 for (gl = gl->next; gl; gl = gl->next) { 529 sel = (sw_sel *)gl->data; 530 531 /* Move user offset */ 532 if (sample->user_offset > osel->sel_end && 533 sample->user_offset < sel->sel_start) { 528 sel = osel = (sw_sel *) gl->data; 529 if (osel->sel_start > 0) 530 { 531 532 if (sample->user_offset >= sel->sel_start && 533 sample->user_offset <= sel->sel_end) 534 { 535 sample->user_offset = sel->sel_start - sel_length;; 536 } 537 538 head_set_if_within (sample->play_head, sel->sel_start, sel->sel_end, 539 sel->sel_start - sel_length); 540 541 head_set_if_within (sample->rec_head, sel->sel_start, sel->sel_end, 542 sel->sel_start - sel_length); 543 544 sel_length = osel->sel_end - osel->sel_start; 545 546 move_length = osel->sel_start; 547 548 len = frames_to_bytes (f, move_length); 549 d += len; 550 551 run_length += move_length; 552 sample_set_progress_percent (sample, run_length / (length / 100)); 553 } 554 for (gl = gl->next; gl; gl = gl->next) 555 { 556 sel = (sw_sel *) gl->data; 557 558 /* Move user offset */ 559 if (sample->user_offset > osel->sel_end && 560 sample->user_offset < sel->sel_start) 561 { 562 sample->user_offset -= sel_length; 563 } 564 565 if (sample->user_offset >= sel->sel_start && 566 sample->user_offset <= sel->sel_end) 567 { 568 sample->user_offset = sel->sel_start - sel_length;; 569 } 570 571 head_dec_if_within (sample->play_head, osel->sel_end, sel->sel_start, 572 sel_length); 573 head_set_if_within (sample->play_head, sel->sel_start, sel->sel_end, 574 sel->sel_start - sel_length); 575 576 head_dec_if_within (sample->rec_head, osel->sel_end, sel->sel_start, 577 sel_length); 578 head_set_if_within (sample->rec_head, sel->sel_start, sel->sel_end, 579 sel->sel_start - sel_length); 580 581 sel_length += sel->sel_end - sel->sel_start; 582 583 offset = frames_to_bytes (f, osel->sel_end); 584 585 move_length = sel->sel_start - osel->sel_end; 586 len = frames_to_bytes (f, move_length); 587 g_memmove (d, (gpointer) (sounddata->data + offset), len); 588 d += len; 589 590 run_length += move_length; 591 sample_set_progress_percent (sample, run_length / (length / 100)); 592 593 osel = sel; 594 } 595 596 /* Move offsets occuring after last sel */ 597 if (sample->user_offset > sel->sel_end) 598 { 534 599 sample->user_offset -= sel_length; 535 600 } 536 537 if (sample->user_offset >= sel->sel_start &&538 sample->user_offset <= sel->sel_end) {539 sample->user_offset = sel->sel_start - sel_length;;540 }541 542 head_dec_if_within (sample->play_head, osel->sel_end, sel->sel_start,543 sel_length);544 head_set_if_within (sample->play_head, sel->sel_start, sel->sel_end,545 sel->sel_start - sel_length);546 547 head_dec_if_within (sample->rec_head, osel->sel_end, sel->sel_start,548 sel_length);549 head_set_if_within (sample->rec_head, sel->sel_start, sel->sel_end,550 sel->sel_start - sel_length);551 552 sel_length += sel->sel_end - sel->sel_start;553 554 offset = frames_to_bytes (f, osel->sel_end);555 556 move_length = sel->sel_start - osel->sel_end;557 len = frames_to_bytes (f, move_length);558 g_memmove (d, (gpointer)(sounddata->data + offset), len);559 d += len;560 561 run_length += move_length;562 sample_set_progress_percent (sample, run_length / (length/100));563 564 osel = sel;565 }566 567 /* Move offsets occuring after last sel */568 if (sample->user_offset > sel->sel_end) {569 sample->user_offset -= sel_length;570 }571 601 572 602 head_dec_if_within (sample->play_head, sel->sel_end, FRAMECOUNT_MAX, … … 576 606 sel_length); 577 607 578 if (sel->sel_end != sounddata->nr_frames) { 579 offset = frames_to_bytes (f, sel->sel_end); 580 581 move_length = sounddata->nr_frames - sel->sel_end; 582 583 len = frames_to_bytes (f, move_length); 584 g_memmove (d, (gpointer)(sounddata->data + offset), len); 585 586 run_length += move_length; 587 sample_set_progress_percent (sample, run_length / (length/100)); 588 } 589 590 d = g_realloc (sounddata->data, frames_to_bytes(f, length)); 608 if (sel->sel_end != sounddata->nr_frames) 609 { 610 offset = frames_to_bytes (f, sel->sel_end); 611 612 move_length = sounddata->nr_frames - sel->sel_end; 613 614 len = frames_to_bytes (f, move_length); 615 g_memmove (d, (gpointer) (sounddata->data + offset), len); 616 617 run_length += move_length; 618 sample_set_progress_percent (sample, run_length / (length / 100)); 619 } 620 621 d = g_realloc (sounddata->data, frames_to_bytes (f, length)); 591 622 sounddata->data = d; 592 623 sounddata->nr_frames = length; … … 604 635 sounddata_set_sel_from_eb (sw_sounddata * sounddata, sw_edit_buffer * eb) 605 636 { 606 GList * gl;607 sw_edit_region * er;637 GList *gl; 638 sw_edit_region *er; 608 639 609 640 if (sounddata->sels) 610 641 sounddata_clear_selection (sounddata); 611 642 612 if (!eb) return; 613 614 for (gl = eb->regions; gl; gl = gl->next) { 615 er = (sw_edit_region *)gl->data; 616 617 if (er->start > sounddata->nr_frames) break; 618 619 sounddata_add_selection_1 (sounddata, er->start, MIN(er->end, sounddata->nr_frames)); 620 } 643 if (!eb) 644 return; 645 646 for (gl = eb->regions; gl; gl = gl->next) 647 { 648 er = (sw_edit_region *) gl->data; 649 650 if (er->start > sounddata->nr_frames) 651 break; 652 653 sounddata_add_selection_1 (sounddata, er->start, 654 MIN (er->end, sounddata->nr_frames)); 655 } 621 656 } 622 657 … … 625 660 splice_in_eb_data (sw_sample * sample, sw_edit_buffer * eb) 626 661 { 627 sw_sounddata * sounddata = sample->sounddata;628 sw_format * f = sounddata->format;662 sw_sounddata *sounddata = sample->sounddata; 663 sw_format *f = sounddata->format; 629 664 gint length; 630 GList * gl;631 sw_edit_region * er;665 GList *gl; 666 sw_edit_region *er; 632 667 sw_framecount_t prev_start = 0; 633 668 sw_framecount_t er_width; … … 635 670 sw_framecount_t len; 636 671 637 if (!eb) { 638 return sample; 639 } 672 if (!eb) 673 { 674 return sample; 675 } 640 676 641 677 g_mutex_lock (sample->ops_mutex); … … 657 693 658 694 gl = g_list_last (eb->regions); 659 er = (sw_edit_region *)gl->data; 660 if (er->start >= sounddata->nr_frames) { 661 len = frames_to_bytes (f, er->end - er->start); 662 d -= len; 663 memcpy (d, er->data, len); 664 prev_start = er->start; 665 gl = gl->prev; 666 } 667 668 for (; gl; gl = gl->prev) { 669 er = (sw_edit_region *)gl->data; 670 671 /* Move the sample data in */ 672 len = frames_to_bytes (f, prev_start - er->end); 673 di -= len; 674 d -= len; 675 memmove (d, di, len); 676 677 /* Copy edit_region data in */ 678 len = frames_to_bytes (f, er->end - er->start); 679 d -= len; 680 memcpy (d, er->data, len); 681 prev_start = er->start; 682 } 695 er = (sw_edit_region *) gl->data; 696 if (er->start >= sounddata->nr_frames) 697 { 698 len = frames_to_bytes (f, er->end - er->start); 699 d -= len; 700 memcpy (d, er->data, len); 701 prev_start = er->start; 702 gl = gl->prev; 703 } 704 705 for (; gl; gl = gl->prev) 706 { 707 er = (sw_edit_region *) gl->data; 708 709 /* Move the sample data in */ 710 len = frames_to_bytes (f, prev_start - er->end); 711 di -= len; 712 d -= len; 713 memmove (d, di, len); 714 715 /* Copy edit_region data in */ 716 len = frames_to_bytes (f, er->end - er->start); 717 d -= len; 718 memcpy (d, er->data, len); 719 prev_start = er->start; 720 } 683 721 684 722 /* The head of the sounddata remains intact */ … … 686 724 /* Move offset markers */ 687 725 688 for (gl = eb->regions; gl; gl = gl->next) { 689 er = (sw_edit_region *)gl->data; 690 691 er_width = er->end - er->start; 692 693 if (sample->user_offset > er->end) 694 sample->user_offset += er_width; 695 696 head_inc_if_gt (sample->play_head, er->end, er_width); 697 head_inc_if_gt (sample->rec_head, er->end, er_width); 698 } 726 for (gl = eb->regions; gl; gl = gl->next) 727 { 728 er = (sw_edit_region *) gl->data; 729 730 er_width = er->end - er->start; 731 732 if (sample->user_offset > er->end) 733 sample->user_offset += er_width; 734 735 head_inc_if_gt (sample->play_head, er->end, er_width); 736 head_inc_if_gt (sample->rec_head, er->end, er_width); 737 } 699 738 700 739 sounddata->nr_frames = length; … … 719 758 crop_in_eb_data (sw_sounddata * sounddata, sw_edit_buffer * eb) 720 759 { 721 sw_format * f = sounddata->format;760 sw_format *f = sounddata->format; 722 761 sw_framecount_t length, byte_length, o_byte_length; 723 GList * gl;724 sw_edit_region * er1, * er2, *er;762 GList *gl; 763 sw_edit_region *er1, *er2, *er; 725 764 sw_framecount_t len1 = 0, len2 = 0; 726 765 sw_framecount_t byte_len1, byte_len2; 727 766 gpointer d; 728 767 729 if (!eb) { 730 return sounddata; 731 } 768 if (!eb) 769 { 770 return sounddata; 771 } 732 772 733 773 o_byte_length = frames_to_bytes (f, sounddata->nr_frames); 734 774 735 775 gl = eb->regions; 736 er1 = (sw_edit_region *)gl->data; 737 if (er1->start == 0) { 738 len1 = er1->end; 739 } 776 er1 = (sw_edit_region *) gl->data; 777 if (er1->start == 0) 778 { 779 len1 = er1->end; 780 } 740 781 byte_len1 = frames_to_bytes (f, len1); 741 782 742 783 gl = g_list_last (eb->regions); 743 er2 = (sw_edit_region *)gl->data; 744 if (er2->end > sounddata->nr_frames) { 745 len2 = er2->end - er2->start; 746 } 784 er2 = (sw_edit_region *) gl->data; 785 if (er2->end > sounddata->nr_frames) 786 { 787 len2 = er2->end - er2->start; 788 } 747 789 byte_len2 = frames_to_bytes (f, len2); 748 790 749 if (len1 + len2 > 0) { 750 length = sounddata->nr_frames + len1 + len2; 751 byte_length = frames_to_bytes (f, length); 752 753 d = g_realloc (sounddata->data, byte_length); 754 sounddata->data = d; 755 sounddata->nr_frames = length; 756 757 if (len1 > 0) { 758 /* Move middle region in place */ 759 memmove ((gpointer)(d + byte_len1), d, o_byte_length); 760 761 /* Copy (prepend) first region */ 762 memcpy (d, er1->data, byte_len1); 763 } else { 764 /* Overwrite first region in place */ 791 if (len1 + len2 > 0) 792 { 793 length = sounddata->nr_frames + len1 + len2; 794 byte_length = frames_to_bytes (f, length); 795 796 d = g_realloc (sounddata->data, byte_length); 797 sounddata->data = d; 798 sounddata->nr_frames = length; 799 800 if (len1 > 0) 801 { 802 /* Move middle region in place */ 803 memmove ((gpointer) (d + byte_len1), d, o_byte_length); 804 805 /* Copy (prepend) first region */ 806 memcpy (d, er1->data, byte_len1); 807 } 808 else 809 { 810 /* Overwrite first region in place */ 811 gl = eb->regions; 812 er = (sw_edit_region *) gl->data; 813 memcpy ((gpointer) (d + frames_to_bytes (f, er->start)), 814 er->data, frames_to_bytes (f, er->end - er->start)); 815 } 816 817 /* Overwrite with in-between regions */ 765 818 gl = eb->regions; 766 er = (sw_edit_region *)gl->data; 767 memcpy ((gpointer)(d + frames_to_bytes (f, er->start)), 768 er->data, frames_to_bytes (f, er->end - er->start)); 769 } 770 771 /* Overwrite with in-between regions */ 772 gl = eb->regions; 773 for (gl = gl->next; gl && gl->next; gl = gl->next) { 774 er = (sw_edit_region *)gl->data; 775 memcpy ((gpointer)(d + frames_to_bytes (f, er->start)), 776 er->data, frames_to_bytes (f, er->end - er->start)); 777 } 778 779 if (len2 > 0) { 780 /* Copy (append) last_region */ 781 memcpy ((gpointer)(d + o_byte_length + byte_len1), er2->data, byte_len2); 782 } else if (gl) { 783 /* Overwrite last region in place */ 784 er = (sw_edit_region *)gl->data; 785 memcpy ((gpointer)(d + frames_to_bytes (f, er->start)), 786 er->data, frames_to_bytes (f, er->end - er->start)); 787 } 788 789 } else { 790 d = sounddata->data; 791 for (gl = eb->regions; gl; gl = gl->next) { 792 er = (sw_edit_region *)gl->data; 793 memcpy ((gpointer)(d + frames_to_bytes (f, er->start)), 794 er->data, frames_to_bytes (f, er->end - er->start)); 795 } 796 } 819 for (gl = gl->next; gl && gl->next; gl = gl->next) 820 { 821 er = (sw_edit_region *) gl->data; 822 memcpy ((gpointer) (d + frames_to_bytes (f, er->start)), 823 er->data, frames_to_bytes (f, er->end - er->start)); 824 } 825 826 if (len2 > 0) 827 { 828 /* Copy (append) last_region */ 829 memcpy ((gpointer) (d + o_byte_length + byte_len1), er2->data, 830 byte_len2); 831 } 832 else if (gl) 833 { 834 /* Overwrite last region in place */ 835 er = (sw_edit_region *) gl->data; 836 memcpy ((gpointer) (d + frames_to_bytes (f, er->start)), 837 er->data, frames_to_bytes (f, er->end - er->start)); 838 } 839 840 } 841 else 842 { 843 d = sounddata->data; 844 for (gl = eb->regions; gl; gl = gl->next) 845 { 846 er = (sw_edit_region *) gl->data; 847 memcpy ((gpointer) (d + frames_to_bytes (f, er->start)), 848 er->data, frames_to_bytes (f, er->end - er->start)); 849 } 850 } 797 851 798 852 return sounddata; … … 802 856 crop_in (sw_sample * sample, sw_edit_buffer * eb) 803 857 { 804 sw_sounddata * sounddata;805 GList * gl;806 sw_edit_region * er;858 sw_sounddata *sounddata; 859 GList *gl; 860 sw_edit_region *er; 807 861 sw_framecount_t delta; 808 862 … … 811 865 812 866 gl = eb->regions; 813 er = (sw_edit_region *)gl->data; 814 if (er->start == 0) { 815 delta = er->end; 816 817 g_mutex_lock (sounddata->sels_mutex); 818 sounddata_selection_translate (sounddata, delta); 819 g_mutex_unlock (sounddata->sels_mutex); 820 821 g_mutex_lock (sample->play_mutex); 822 sample->user_offset += delta; 823 g_mutex_unlock (sample->play_mutex); 824 825 g_mutex_lock (sample->play_head->head_mutex); 826 sample->play_head->offset += delta; 827 sample->play_head->stop_offset += delta; 828 g_mutex_unlock (sample->play_head->head_mutex); 829 830 if (sample->rec_head) { 831 g_mutex_lock (sample->rec_head->head_mutex); 832 sample->rec_head->offset += delta; 833 sample->rec_head->stop_offset += delta; 834 g_mutex_unlock (sample->rec_head->head_mutex); 835 } 836 } 867 er = (sw_edit_region *) gl->data; 868 if (er->start == 0) 869 { 870 delta = er->end; 871 872 g_mutex_lock (sounddata->sels_mutex); 873 sounddata_selection_translate (sounddata, delta); 874 g_mutex_unlock (sounddata->sels_mutex); 875 876 g_mutex_lock (sample->play_mutex); 877 sample->user_offset += delta; 878 g_mutex_unlock (sample->play_mutex); 879 880 g_mutex_lock (sample->play_head->head_mutex); 881 sample->play_head->offset += delta; 882 sample->play_head->stop_offset += delta; 883 g_mutex_unlock (sample->play_head->head_mutex); 884 885 if (sample->rec_head) 886 { 887 g_mutex_lock (sample->rec_head->head_mutex); 888 sample->rec_head->offset += delta; 889 sample->rec_head->stop_offset += delta; 890 g_mutex_unlock (sample->rec_head->head_mutex); 891 } 892 } 837 893 838 894 return sample; … … 843 899 edit_clear_sel (sw_sample * sample) 844 900 { 845 sw_sounddata * sounddata = sample->sounddata;846 sw_format * f = sounddata->format;847 GList * gl;848 sw_sel * sel;901 sw_sounddata *sounddata = sample->sounddata; 902 sw_format *f = sounddata->format; 903 GList *gl; 904 sw_sel *sel; 849 905 sw_framecount_t offset, len; 850 906 sw_framecount_t sel_total, run_total; … … 853 909 854 910 sel_total = sounddata_selection_nr_frames (sounddata) / 100; 855 if (sel_total == 0) sel_total = 1; 911 if (sel_total == 0) 912 sel_total = 1; 856 913 run_total = 0; 857 914 858 for (gl = sounddata->sels; active && gl; gl = gl->next) { 859 g_mutex_lock (sample->ops_mutex); 860 861 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) { 862 active = FALSE; 863 } else { 864 sel = (sw_sel *)gl->data; 865 866 offset = frames_to_bytes (f, sel->sel_start); 867 len = frames_to_bytes (f, sel->sel_end - sel->sel_start); 868 869 memset ((gpointer)(sounddata->data + offset), 0, (size_t)len); 870 871 run_total += sel->sel_end - sel->sel_start; 872 sample_set_progress_percent (sample, run_total / sel_total); 873 } 874 875 g_mutex_unlock (sample->ops_mutex); 876 } 915 for (gl = sounddata->sels; active && gl; gl = gl->next) 916 { 917 g_mutex_lock (sample->ops_mutex); 918 919 if (sample->edit_state == SWEEP_EDIT_STATE_CANCEL) 920 { 921 active = FALSE; 922 } 923 else 924 { 925 sel = (sw_sel *) gl->data; 926 927 offset = frames_to_bytes (f, sel->sel_start); 928 len = frames_to_bytes (f, sel->sel_end - sel->sel_start); 929 930 memset ((gpointer) (sounddata->data + offset), 0, (size_t) len); 931 932 run_total += sel->sel_end - sel->sel_start; 933 sample_set_progress_percent (sample, run_total / sel_total); 934 } 935 936 g_mutex_unlock (sample->ops_mutex); 937 } 877 938 } 878 939 … … 881 942 crop_out (sw_sample * sample) 882 943 { 883 sw_sounddata * sounddata = sample->sounddata;884 sw_format * f = sounddata->format;944 sw_sounddata *sounddata = sample->sounddata; 945 sw_format *f = sounddata->format; 885 946 sw_framecount_t length; 886 GList * gl;887 sw_sel * sel1, * sel2, * osel, *sel;888 /*sw_sounddata * out; */947 GList *gl; 948 sw_sel *sel1, *sel2, *osel, *sel; 949 /*sw_sounddata * out; */ 889 950 gpointer d; 890 951 sw_framecount_t offset, len; 891 952 sw_framecount_t byte_length; 892 953 893 if (!sounddata->sels) { 894 return sample; 895 } 954 if (!sounddata->sels) 955 { 956 return sample; 957 } 896 958 897 959 898 960 #ifdef DEBUG 899 printf ("Splice out: remaining length %d\n", length);961 printf ("Splice out: remaining length %d\n", length); 900 962 #endif 901 963 … … 910 972 911 973 gl = sounddata->sels; 912 sel1 = (sw_sel *) gl->data;974 sel1 = (sw_sel *) gl->data; 913 975 914 976 gl = g_list_last (sounddata->sels); 915 sel2 = (sw_sel *)gl->data; 916 917 if (sel1->sel_start <= 0 && sel2->sel_end >= sounddata->nr_frames) { 918 d = sounddata->data; 919 goto zero_out; 920 } 977 sel2 = (sw_sel *) gl->data; 978 979 if (sel1->sel_start <= 0 && sel2->sel_end >= sounddata->nr_frames) 980 { 981 d = sounddata->data; 982 goto zero_out; 983 } 921 984 922 985 sample_set_progress_percent (sample, 13); … … 928 991 d = sounddata->data; 929 992 930 if (sel1->sel_start > 0) { 931 /* Need to move */ 932 offset = frames_to_bytes (f, sel1->sel_start); 933 g_memmove (d, (gpointer)(d + offset), byte_length); 934 } 993 if (sel1->sel_start > 0) 994 { 995 /* Need to move */ 996 offset = frames_to_bytes (f, sel1->sel_start); 997 g_memmove (d, (gpointer) (d + offset), byte_length); 998 } 935 999 936 1000 sample_set_progress_percent (sample, 37); … … 943 1007 /* Fix offsets */ 944 1008 sample->user_offset -= sel1->sel_start; 945 sample->user_offset = CLAMP (sample->user_offset, 0, length);1009 sample->user_offset = CLAMP (sample->user_offset, 0, length); 946 1010 947 1011 g_mutex_lock (sample->play_head->head_mutex); 948 1012 949 1013 sample->play_head->offset -= sel1->sel_start; 950 sample->play_head->offset = 951 CLAMP(sample->play_head->offset, 0, length); 1014 sample->play_head->offset = CLAMP (sample->play_head->offset, 0, length); 952 1015 953 1016 sample->play_head->stop_offset -= sel1->sel_start; 954 1017 sample->play_head->stop_offset = 955 CLAMP (sample->play_head->stop_offset, 0, length);1018 CLAMP (sample->play_head->stop_offset, 0, length); 956 1019 957 1020 g_mutex_unlock (sample->play_head->head_mutex); 958 1021 959 if (sample->rec_head) {960 g_mutex_lock (sample->rec_head->head_mutex);961 962 sample->rec_head->offset -= sel1->sel_start; 963 sample->rec_head->offset =964 CLAMP(sample->rec_head->offset, 0, length);965 966 sample->rec_head->stop_offset -= sel1->sel_start;967 sample->rec_head->stop_offset =968 CLAMP(sample->rec_head->stop_offset, 0, length);969 970 g_mutex_unlock (sample->rec_head->head_mutex);971 }1022 if (sample->rec_head) 1023 { 1024 g_mutex_lock (sample->rec_head->head_mutex); 1025 1026 sample->rec_head->offset -= sel1->sel_start; 1027 sample->rec_head->offset = CLAMP (sample->rec_head->offset, 0, length); 1028 1029 sample->rec_head->stop_offset -= sel1->sel_start; 1030 sample->rec_head->stop_offset = 1031 CLAMP (sample->rec_head->stop_offset, 0, length); 1032 1033 g_mutex_unlock (sample->rec_head->head_mutex); 1034 } 972 1035 973 1036 /* Fix selection */ 974 1037 sounddata_selection_translate (sounddata, -(sel1->sel_start)); 975 1038 976 zero_out:1039 zero_out: 977 1040 /* Zero out data between selections */ 978 1041 gl = sounddata->sels; 979 osel = (sw_sel *)gl->data; 980 981 for (gl = gl->next; gl; gl = gl->next) { 982 sel = (sw_sel *)gl->data; 983 984 offset = frames_to_bytes (f, osel->sel_end); 985 len = frames_to_bytes (f, sel->sel_start) - offset; 986 memset ((gpointer)(d + offset), 0, len); 987 988 osel = sel; 989 } 1042 osel = (sw_sel *) gl->data; 1043 1044 for (gl = gl->next; gl; gl = gl->next) 1045 { 1046 sel = (sw_sel *) gl->data; 1047 1048 offset = frames_to_bytes (f, osel->sel_end); 1049 len = frames_to_bytes (f, sel->sel_start) - offset; 1050 memset ((gpointer) (d + offset), 0, len); 1051 1052 osel = sel; 1053 } 990 1054 991 1055 sample_set_progress_percent (sample, 100); … … 1001 1065 sw_framecount_t paste_offset) 1002 1066 { 1003 sw_sounddata * sounddata = sample->sounddata;1004 sw_format * f = sounddata->format;1067 sw_sounddata *sounddata = sample->sounddata; 1068 sw_format *f = sounddata->format; 1005 1069 sw_framecount_t paste_delta = 0, len; 1006 1070 sw_framecount_t length, paste_length, sel_length = 0; 1007 GList * gl;1008 sw_edit_region * er;1071 GList *gl; 1072 sw_edit_region *er; 1009 1073 gpointer d; 1010 1074 … … 1012 1076 1013 1077 paste_length = edit_buffer_length (eb); 1014 length = MAX (sounddata->nr_frames, paste_offset) + paste_length;1078 length = MAX (sounddata->nr_frames, paste_offset) + paste_length; 1015 1079 1016 1080 d = g_realloc (sounddata->data, frames_to_bytes (f, length)); 1017 1081 sounddata->data = d; 1018 1082 1019 d = (gpointer) (sounddata->data + frames_to_bytes(f, length));1083 d = (gpointer) (sounddata->data + frames_to_bytes (f, length)); 1020 1084 1021 1085 /* Copy in the tail end of the sounddata */ 1022 if (paste_offset < sounddata->nr_frames) { 1023 len = frames_to_bytes (f, sounddata->nr_frames) - paste_delta; 1024 d -= len; 1025 memmove (d, (gpointer)(sounddata->data + paste_delta), len); 1026 } 1086 if (paste_offset < sounddata->nr_frames) 1087 { 1088 len = frames_to_bytes (f, sounddata->nr_frames) - paste_delta; 1089 d -= len; 1090 memmove (d, (gpointer) (sounddata->data + paste_delta), len); 1091 } 1027 1092 1028 1093 /* Copy in the contents of the edit buffer */ 1029 for (gl = g_list_last(eb->regions); gl; gl = gl->prev) { 1030 er = (sw_edit_region *)gl->data; 1031 1032 len = frames_to_bytes (f, er->end - er->start); 1033 sel_length += (er->end - er->start); 1034 1035 d -= len; 1036 memcpy (d, er->data, len); 1037 } 1094 for (gl = g_list_last (eb->regions); gl; gl = gl->prev) 1095 { 1096 er = (sw_edit_region *) gl->data; 1097 1098 len = frames_to_bytes (f, er->end - er->start); 1099 sel_length += (er->end - er->start); 1100 1101 d -= len; 1102 memcpy (d, er->data, len); 1103 } 1038 1104 1039 1105 /* If paste point is beyond the previous sounddata length, 1040 1106 add some silence */ 1041 if (paste_offset > sounddata->nr_frames) { 1042 len = paste_delta - frames_to_bytes (f, sounddata->nr_frames); 1043 d -= len; 1044 memset (d, 0, len); 1045 } 1107 if (paste_offset > sounddata->nr_frames) 1108 { 1109 len = paste_delta - frames_to_bytes (f, sounddata->nr_frames); 1110 d -= len; 1111 memset (d, 0, len); 1112 } 1046 1113 1047 1114 /* The head of the sounddata remains intact */ … … 1061 1128 sample->play_head->stop_offset += sel_length; 1062 1129 1063 if (sample->rec_head) { 1064 if (sample->rec_head->offset > paste_offset) 1065 sample->rec_head->offset += sel_length; 1066 if (sample->rec_head->stop_offset > paste_offset) 1067 sample->rec_head->stop_offset += sel_length; 1068 } 1130 if (sample->rec_head) 1131 { 1132 if (sample->rec_head->offset > paste_offset) 1133 sample->rec_head->offset += sel_length; 1134 if (sample->rec_head->stop_offset > paste_offset) 1135 sample->rec_head->stop_offset += sel_length; 1136 } 1069 1137 1070 1138 sounddata->nr_frames = length; … … 1077 1145 paste_over (sw_sample * sample, sw_edit_buffer * eb) 1078 1146 { 1079 sw_format * f = sample->sounddata->format;1147 sw_format *f = sample->sounddata->format; 1080 1148 sw_framecount_t offset, len; 1081 1149 sw_framecount_t length; 1082 GList * gl; 1083 sw_edit_region * er; 1084 1085 if (!eb) return sample; 1150 GList *gl; 1151 sw_edit_region *er; 1152 1153 if (!eb) 1154 return sample; 1086 1155 1087 1156 length = sample->sounddata->nr_frames; 1088 1157 1089 for (gl = eb->regions; gl; gl = gl->next) { 1090 er = (sw_edit_region *)gl->data; 1091 1092 if (er->start > length) break; 1093 1094 offset = frames_to_bytes (f, er->start); 1095 len = frames_to_bytes (f, MIN(er->end, length) - er->start); 1096 memcpy ((gpointer)(sample->sounddata->data + offset), er->data, len); 1097 } 1158 for (gl = eb->regions; gl; gl = gl->next) 1159 { 1160 er = (sw_edit_region *) gl->data; 1161 1162 if (er->start > length) 1163 break; 1164 1165 offset = frames_to_bytes (f, er->start); 1166 len = frames_to_bytes (f, MIN (er->end, length) - er->start); 1167 memcpy ((gpointer) (sample->sounddata->data + offset), er->data, len); 1168 } 1098 1169 1099 1170 return sample; … … 1105 1176 sw_framecount_t paste_offset, gdouble src_gain, gdouble dest_gain) 1106 1177 { 1107 sw_format * f = sample->sounddata->format;1178 sw_format *f = sample->sounddata->format; 1108 1179 sw_framecount_t length, eb_delta; 1109 GList * gl;1110 sw_edit_region * er;1111 sw_audio_t * d, *e;1180 GList *gl; 1181 sw_edit_region *er; 1182 sw_audio_t *d, *e; 1112 1183 sw_framecount_t offset, remaining, n, i; 1113 1184 sw_framecount_t run_total, eb_total; … … 1120 1191 #endif 1121 1192 1122 if (eb == NULL || eb->regions == NULL) return sample; 1193 if (eb == NULL || eb->regions == NULL) 1194 return sample; 1123 1195 1124 1196 length = sample->sounddata->nr_frames; … … 1127 1199 eb_total = edit_buffer_length (eb); 1128 1200 1129 eb_delta = ((sw_edit_region *)eb->regions->data)->start; 1130 1131 for (gl = eb->regions; active && gl; gl = gl->next) { 1132 er = (sw_edit_region *)gl->data; 1133
