Show
Ignore:
Timestamp:
01/16/07 19:23:06 (5 years ago)
Author:
radekk
Message:

Indenting source code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sweep/branches/display-cache/include/sweep/sweep.h

    r124 r471  
    3333#include <sweep/sweep_filter.h> 
    3434 
    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  
    2626                                   sw_framecount_t nr_frames, 
    2727                                   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); 
     28sw_op_instance *perform_filter_region_op (sw_sample * sample, char *desc, 
     29                                         SweepFilterRegion func, 
     30                                        sw_param_set pset, 
     31                                         gpointer custom_data); 
    3232 
    33 sw_op_instance * 
    34 perform_filter_op (sw_sample * sample, char * desc, SweepFilter func
    35                    sw_param_set pset, gpointer custom_data); 
     33sw_op_instance *perform_filter_op (sw_sample * sample, char *desc, 
     34                                  SweepFilter func, sw_param_set pset
     35                                  gpointer custom_data); 
    3636 
    3737 
  • sweep/branches/display-cache/include/sweep/sweep_sample.h

    r124 r471  
    2424#include <sweep/sweep_types.h> 
    2525 
    26 sw_sample * 
    27 sample_new_empty(char * pathname, gint nr_channels, gint sample_rate, 
    28                  gint sample_length); 
     26sw_sample *sample_new_empty (char *pathname, gint nr_channels, 
     27                             gint sample_rate, gint sample_length); 
    2928 
    30 sw_sample * 
    31 sample_new_copy(sw_sample * s); 
     29sw_sample *sample_new_copy (sw_sample * s); 
    3230 
    33 void 
    34 sample_destroy (sw_sample * s); 
     31void sample_destroy (sw_sample * s); 
    3532 
    36 sw_sounddata * 
    37 sample_get_sounddata (sw_sample * s); 
     33sw_sounddata *sample_get_sounddata (sw_sample * s); 
    3834 
    39 void 
    40 sample_set_file_format (sw_sample * s, sw_file_format_t file_format); 
     35void sample_set_file_format (sw_sample * s, sw_file_format_t file_format); 
    4136 
    42 void 
    43 sample_set_pathname (sw_sample * s, char * pathname); 
     37void sample_set_pathname (sw_sample * s, char *pathname); 
    4438 
    45 GList * 
    46 sample_bank_list_names (void); 
     39GList *sample_bank_list_names (void); 
    4740 
    48 sw_sample * 
    49 sample_bank_find_byname (const gchar * name); 
     41sw_sample *sample_bank_find_byname (const gchar * name); 
    5042 
    51 gboolean 
    52 sample_bank_contains (sw_sample *s); 
     43gboolean sample_bank_contains (sw_sample * s); 
    5344 
    54 void 
    55 sample_bank_add (sw_sample * s); 
     45void sample_bank_add (sw_sample * s); 
    5646 
    57 void 
    58 sample_bank_remove (sw_sample * s); 
     47void sample_bank_remove (sw_sample * s); 
    5948 
    60 void 
    61 sample_refresh_views (sw_sample * s); 
     49void sample_refresh_views (sw_sample * s); 
    6250 
    63 void 
    64 sample_start_marching_ants (sw_sample * s); 
     51void sample_start_marching_ants (sw_sample * s); 
    6552 
    66 void 
    67 sample_stop_marching_ants (sw_sample * s); 
     53void sample_stop_marching_ants (sw_sample * s); 
    6854 
    69 void 
    70 sample_set_edit_state (sw_sample * s, sw_edit_state edit_state); 
     55void sample_set_edit_state (sw_sample * s, sw_edit_state edit_state); 
    7156 
    72 void 
    73 sample_set_edit_mode (sw_sample * s, sw_edit_mode edit_mode); 
     57void sample_set_edit_mode (sw_sample * s, sw_edit_mode edit_mode); 
    7458 
    75 void 
    76 sample_refresh_playmode (sw_sample * s); 
     59void sample_refresh_playmode (sw_sample * s); 
    7760 
    78 void 
    79 sample_set_previewing (sw_sample * s, gboolean previewing); 
     61void sample_set_previewing (sw_sample * s, gboolean previewing); 
    8062 
    81 void 
    82 sample_set_stop_offset (sw_sample * s); 
     63void sample_set_stop_offset (sw_sample * s); 
    8364 
    8465void 
     
    8667                       gboolean by_user); 
    8768 
    88 void 
    89 sample_set_rec_marker (sw_sample * s, sw_framecount_t offset); 
     69void sample_set_rec_marker (sw_sample * s, sw_framecount_t offset); 
    9070 
    91 void 
    92 sample_set_scrubbing (sw_sample * s, gboolean scrubbing); 
     71void sample_set_scrubbing (sw_sample * s, gboolean scrubbing); 
    9372 
    94 void 
    95 sample_set_looping (sw_sample * s, gboolean looping); 
     73void sample_set_looping (sw_sample * s, gboolean looping); 
    9674 
    97 void 
    98 sample_set_playrev (sw_sample * s, gboolean reverse); 
     75void sample_set_playrev (sw_sample * s, gboolean reverse); 
    9976 
    100 void 
    101 sample_set_mute (sw_sample * s, gboolean mute); 
     77void sample_set_mute (sw_sample * s, gboolean mute); 
    10278 
    103 void 
    104 sample_set_color (sw_sample * s, gint color); 
     79void sample_set_color (sw_sample * s, gint color); 
    10580 
    106 void 
    107 sample_set_progress_text (sw_sample * s, gchar * text); 
     81void sample_set_progress_text (sw_sample * s, gchar * text); 
    10882 
    109 void 
    110 sample_set_progress_percent (sw_sample * s, gint percent); 
     83void sample_set_progress_percent (sw_sample * s, gint percent); 
    11184 
    112 void 
    113 sample_refresh_progress_percent (sw_sample * s); 
     85void sample_refresh_progress_percent (sw_sample * s); 
    11486 
    115 int 
    116 sample_set_progress_ready (sw_sample * s); 
     87int sample_set_progress_ready (sw_sample * s); 
    11788 
    118 void 
    119 sample_set_tmp_message (sw_sample * s, const char * fmt, ...); 
     89void sample_set_tmp_message (sw_sample * s, const char *fmt, ...); 
    12090 
    12191/* 
     
    12999 * 
    130100 */ 
    131 void 
    132 sample_replace_throughout (sw_sample * os, sw_sample * s); 
     101void sample_replace_throughout (sw_sample * os, sw_sample * s); 
    133102 
    134103 
    135104/* Selection handling */ 
    136105 
    137 gboolean 
    138 sample_offset_in_sel (sw_sample * s, sw_framecount_t offset); 
     106gboolean sample_offset_in_sel (sw_sample * s, sw_framecount_t offset); 
    139107 
    140 guint 
    141 sample_sel_nr_regions (sw_sample * s); 
     108guint sample_sel_nr_regions (sw_sample * s); 
    142109 
    143 void 
    144 sample_clear_selection (sw_sample * s); 
     110void sample_clear_selection (sw_sample * s); 
    145111 
    146 void 
    147 sample_add_selection (sw_sample * s, sw_sel * sel); 
     112void sample_add_selection (sw_sample * s, sw_sel * sel); 
    148113 
    149 sw_sel * 
    150 sample_add_selection_1 (sw_sample * s, 
    151                         sw_framecount_t start, sw_framecount_t end); 
     114sw_sel *sample_add_selection_1 (sw_sample * s, 
     115                                sw_framecount_t start, sw_framecount_t end); 
    152116 
    153 void 
    154 sample_set_selection (sw_sample * s, GList * gl); 
     117void sample_set_selection (sw_sample * s, GList * gl); 
    155118 
    156 sw_sel * 
    157 sample_set_selection_1 (sw_sample * s, 
    158                         sw_framecount_t start, sw_framecount_t end); 
     119sw_sel *sample_set_selection_1 (sw_sample * s, 
     120                                sw_framecount_t start, sw_framecount_t end); 
    159121 
    160122 
     
    164126                         sw_framecount_t new_start, sw_framecount_t new_end); 
    165127 
    166 void 
    167 sample_selection_invert (sw_sample * s); 
     128void sample_selection_invert (sw_sample * s); 
    168129 
    169 void 
    170 sample_selection_select_all (sw_sample * s); 
     130void sample_selection_select_all (sw_sample * s); 
    171131 
    172 void 
    173 sample_selection_select_none (sw_sample * s); 
     132void sample_selection_select_none (sw_sample * s); 
    174133 
    175 void 
    176 sample_selection_halve (sw_sample * s); 
     134void sample_selection_halve (sw_sample * s); 
    177135 
    178 void 
    179 sample_selection_double (sw_sample * s); 
     136void sample_selection_double (sw_sample * s); 
    180137 
    181 void 
    182 sample_selection_shift_left (sw_sample * s); 
     138void sample_selection_shift_left (sw_sample * s); 
    183139 
    184 void 
    185 sample_selection_shift_right (sw_sample * s); 
     140void sample_selection_shift_right (sw_sample * s); 
    186141 
    187142/* info dialog */ 
    188 void 
    189 sample_show_info_dialog (sw_sample * sample); 
     143void sample_show_info_dialog (sw_sample * sample); 
    190144 
    191145 
  • sweep/branches/display-cache/include/sweep/sweep_selection.h

    r124 r471  
    2222#define __SWEEP_SELECTION_H__ 
    2323 
    24 sw_sel * 
    25 sel_new (sw_framecount_t start, sw_framecount_t end); 
     24sw_sel *sel_new (sw_framecount_t start, sw_framecount_t end); 
    2625 
    27 sw_sel * 
    28 sel_copy (sw_sel * sel); 
     26sw_sel *sel_copy (sw_sel * sel); 
    2927 
    30 GList * 
    31 sels_add_selection (GList * sels, sw_sel * sel); 
     28GList *sels_add_selection (GList * sels, sw_sel * sel); 
    3229 
    33 GList * 
    34 sels_add_selection_1 (GList * sels, sw_framecount_t start, sw_framecount_t end); 
     30GList *sels_add_selection_1 (GList * sels, sw_framecount_t start, 
     31                            sw_framecount_t end); 
    3532 
    3633/* 
     
    4037 * return > 0 if s1 comes after s2 in the sort order. 
    4138 */ 
    42 gint 
    43 sel_cmp (sw_sel * s1, sw_sel * s2); 
     39gint sel_cmp (sw_sel * s1, sw_sel * s2); 
    4440 
    4541/* 
     
    4844 * returns a copy of sels 
    4945 */ 
    50 GList * 
    51 sels_copy (GList * sels); 
     46GList *sels_copy (GList * sels); 
    5247 
    5348/* 
     
    5651 * inverts sels in place 
    5752 */ 
    58 GList * 
    59 sels_invert (GList * sels, sw_framecount_t nr_frames); 
     53GList *sels_invert (GList * sels, sw_framecount_t nr_frames); 
    6054 
    61 sw_op_instance * 
    62 perform_selection_op (sw_sample * s, char * desc, SweepFilter func
    63                       sw_param_set pset, gpointer custom_data); 
     55sw_op_instance *perform_selection_op (sw_sample * s, char *desc, 
     56                                     SweepFilter func, sw_param_set pset
     57                                    gpointer custom_data); 
    6458 
    6559#endif /* __SWEEP_SELECTION_H__ */ 
  • sweep/branches/display-cache/include/sweep/sweep_sounddata.h

    r124 r471  
    2222#define __SWEEP_SOUNDDATA_H__ 
    2323 
    24 sw_sounddata * 
    25 sounddata_new_empty(gint nr_channels, gint sample_rate, gint sample_length); 
     24sw_sounddata *sounddata_new_empty (gint nr_channels, gint sample_rate, 
     25                                  gint sample_length); 
    2626 
    27 void 
    28 sounddata_destroy (sw_sounddata * sounddata); 
     27void sounddata_destroy (sw_sounddata * sounddata); 
    2928 
    30 void 
    31 sounddata_lock_selection (sw_sounddata * sounddata); 
     29void sounddata_lock_selection (sw_sounddata * sounddata); 
    3230 
    33 void 
    34 sounddata_unlock_selection (sw_sounddata * sounddata); 
     31void sounddata_unlock_selection (sw_sounddata * sounddata); 
    3532 
    36 void 
    37 sounddata_clear_selection (sw_sounddata * sounddata); 
     33void sounddata_clear_selection (sw_sounddata * sounddata); 
    3834 
    3935/* 
     
    4440 */ 
    4541 
    46 void 
    47 sounddata_normalise_selection (sw_sounddata * sounddata); 
     42void sounddata_normalise_selection (sw_sounddata * sounddata); 
    4843 
    49 void 
    50 sounddata_add_selection (sw_sounddata * sounddata, sw_sel * sel); 
     44void sounddata_add_selection (sw_sounddata * sounddata, sw_sel * sel); 
    5145 
    52 sw_sel * 
    53 sounddata_add_selection_1 (sw_sounddata * sounddata
    54                            sw_framecount_t start, sw_framecount_t end); 
     46sw_sel *sounddata_add_selection_1 (sw_sounddata * sounddata, 
     47                                  sw_framecount_t start
     48                                  sw_framecount_t end); 
    5549 
    56 sw_sel * 
    57 sounddata_set_selection_1 (sw_sounddata * sounddata
    58                            sw_framecount_t start, sw_framecount_t end); 
     50sw_sel *sounddata_set_selection_1 (sw_sounddata * sounddata, 
     51                                  sw_framecount_t start
     52                                  sw_framecount_t end); 
    5953 
    60 guint 
    61 sounddata_selection_nr_regions (sw_sounddata * sounddata); 
     54guint sounddata_selection_nr_regions (sw_sounddata * sounddata); 
    6255 
    63 gint 
    64 sounddata_selection_nr_frames (sw_sounddata * sounddata); 
     56gint sounddata_selection_nr_frames (sw_sounddata * sounddata); 
    6557 
    66 gint 
    67 sounddata_selection_width (sw_sounddata * sounddata); 
     58gint sounddata_selection_width (sw_sounddata * sounddata); 
    6859 
    69 void 
    70 sounddata_selection_translate (sw_sounddata * sounddata, gint delta); 
     60void sounddata_selection_translate (sw_sounddata * sounddata, gint delta); 
    7161 
    72 void 
    73 sounddata_selection_scale (sw_sounddata * sounddata, gfloat scale); 
     62void sounddata_selection_scale (sw_sounddata * sounddata, gfloat scale); 
    7463 
    7564/* 
  • sweep/branches/display-cache/include/sweep/sweep_typeconvert.h

    r57 r471  
    2626 * in a given format. 
    2727 */ 
    28 glong 
    29 frames_to_samples (sw_format * format, sw_framecount_t nr_frames); 
     28glong frames_to_samples (sw_format * format, sw_framecount_t nr_frames); 
    3029 
    3130/* 
    3231 * Determine the size in bytes of a number of frames of a given format. 
    3332 */ 
    34 glong 
    35 frames_to_bytes (sw_format * format, sw_framecount_t nr_frames); 
     33glong frames_to_bytes (sw_format * format, sw_framecount_t nr_frames); 
    3634 
    3735/* 
    3836 * Convert a number of frames to seconds 
    3937 */ 
    40 sw_time_t 
    41 frames_to_time (sw_format * format, sw_framecount_t nr_frames); 
     38sw_time_t frames_to_time (sw_format * format, sw_framecount_t nr_frames); 
    4239 
    4340/* 
    4441 * Convert seconds to frames 
    4542 */ 
    46 sw_framecount_t 
    47 time_to_frames (sw_format * format, sw_time_t time); 
     43sw_framecount_t time_to_frames (sw_format * format, sw_time_t time); 
    4844 
    4945#endif /* __SWEEP_TYPE_CONVERT_H__ */ 
  • sweep/branches/display-cache/include/sweep/sweep_types.h

    r304 r471  
    2323 
    2424#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 */ 
    2727 
    2828#include <sys/types.h> 
     
    5454#if 0 
    5555 
    56 #if (SIZEOF_OFF_T == 8)  
     56#if (SIZEOF_OFF_T == 8) 
    5757/* For libsndfile version 1 */ 
    5858typedef off_t sw_framecount_t; 
     
    9090 * 
    9191 */ 
    92 struct _sw_sel { 
     92struct _sw_sel 
     93
    9394  sw_framecount_t sel_start; 
    9495  sw_framecount_t sel_end; 
     
    100101 * Multichannel data is interleaved: Stereo is stored LR. 
    101102 */ 
    102 struct _sw_format { 
    103   gint channels;  /* nr channels per frame */ 
    104   gint rate;      /* sampling rate (Hz) */ 
    105 }; 
    106  
    107 struct _sw_sounddata { 
     103struct _sw_format 
     104
     105  gint channels;                /* nr channels per frame */ 
     106  gint rate;                    /* sampling rate (Hz) */ 
     107}; 
     108 
     109struct _sw_sounddata 
     110
    108111  int refcount; 
    109112 
    110   sw_format * format; 
    111   sw_framecount_t nr_frames;    /* nr frames */ 
     113  sw_format *format; 
     114  sw_framecount_t nr_frames;   /* nr frames */ 
    112115 
    113116  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 */ 
    118121}; 
    119122 
     
    121124 
    122125 
    123 typedef enum { 
     126typedef enum 
     127
    124128  SWEEP_EDIT_MODE_READY, 
    125   SWEEP_EDIT_MODE_META, /* modifying metadata: sels etc. */ 
     129  SWEEP_EDIT_MODE_META,                /* modifying metadata: sels etc. */ 
    126130  SWEEP_EDIT_MODE_FILTER, 
    127131  SWEEP_EDIT_MODE_ALLOC, 
    128132} sw_edit_mode; 
    129133 
    130 typedef enum { 
     134typedef enum 
     135
    131136  SWEEP_EDIT_STATE_IDLE, 
    132137  SWEEP_EDIT_STATE_PENDING, 
     
    136141} sw_edit_state; 
    137142 
    138 typedef enum { 
     143typedef enum 
     144
    139145  SWEEP_TRANSPORT_STOP, 
    140146  SWEEP_TRANSPORT_PLAY, 
     
    143149 
    144150/* File formats */ 
    145 typedef enum { 
    146   SWEEP_FILE_FORMAT_NONE=0, 
    147   SWEEP_FILE_FORMAT_BY_EXTENSION=0, 
     151typedef enum 
     152
     153  SWEEP_FILE_FORMAT_NONE = 0, 
     154  SWEEP_FILE_FORMAT_BY_EXTENSION = 0, 
    148155  SWEEP_FILE_FORMAT_RAW, 
    149156  SWEEP_FILE_FORMAT_WAV, 
     
    165172 * The length of data available *data is (end - start) 
    166173 */ 
    167 struct _sw_edit_region { 
     174struct _sw_edit_region 
     175
    168176  sw_framecount_t start; 
    169177  sw_framecount_t end; 
     
    172180}; 
    173181 
    174 struct _sw_edit_buffer { 
    175   sw_format * format; 
    176   GList * regions; 
     182struct _sw_edit_buffer 
     183
     184  sw_format *format; 
     185  GList *regions; 
    177186  gint refcount; 
    178187}; 
     
    186195typedef struct _sw_op_instance sw_op_instance; 
    187196 
    188 struct _sw_operation { 
     197struct _sw_operation 
     198
    189199  sw_edit_mode edit_mode; 
    190200  SweepCallback _do_; 
     
    196206}; 
    197207 
    198 struct _sw_op_instance { 
    199   sw_sample * sample; 
    200   char * description; 
    201   sw_operation * op; 
     208struct _sw_op_instance 
     209
     210  sw_sample *sample; 
     211  char *description; 
     212  sw_operation *op; 
    202213  gpointer do_data; 
    203214  gpointer undo_data; 
     
    208219 * Basic types for parameters 
    209220 */ 
    210 typedef enum { 
     221typedef enum 
     222
    211223  SWEEP_TYPE_BOOL = 0, 
    212224  SWEEP_TYPE_INT, 
     
    218230typedef gint sw_int; 
    219231typedef gdouble sw_float; 
    220 typedef gchar * sw_string; 
     232typedef gchar *sw_string; 
    221233 
    222234 
     
    225237 */ 
    226238typedef union _sw_param sw_param; 
    227 typedef sw_param * sw_param_set; 
    228  
    229 union _sw_param { 
     239typedef sw_param *sw_param_set; 
     240 
     241union _sw_param 
     242
    230243  sw_bool b; 
    231   sw_int i; 
     244  sw_int i; 
    232245  sw_float f; 
    233246  sw_string s; 
     
    243256 * the usage of the sw_constraint. 
    244257 */ 
    245 typedef enum { 
     258typedef enum 
     259
    246260/* 
    247261 * SW_PARAM_CONSTRAINED_NOT indicates that the parameter is completely 
     
    253267 *     How free is its life, how wretched its lot! 
    254268 */ 
    255   SW_PARAM_CONSTRAINED_NOT=0, 
     269  SW_PARAM_CONSTRAINED_NOT = 0, 
    256270 
    257271/* 
     
    303317#define SW_RANGE_STEP_VALID (1<<2) 
    304318 
    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) 
    306320 
    307321/* 
     
    335349 */ 
    336350#define SW_PARAM_HINT_FILENAME     (1<<3) 
    337   
     351 
    338352 
    339353typedef struct _sw_param_spec sw_param_spec; 
     
    355369 * string parameters. 
    356370 */ 
    357 struct _sw_param_range { 
     371struct _sw_param_range 
     372
    358373  int valid_mask; 
    359374  sw_param lower; 
     
    369384 * All constraints are disregarded for boolean parameters. 
    370385 */ 
    371 union _sw_constraint { 
     386union _sw_constraint 
     387
    372388  /* 
    373389   * param_list: Values are constrained to those within a list of 
     
    376392   * ie. this length = constraint->param_list[0].i 
    377393   */ 
    378   sw_param * list; 
     394  sw_param *list; 
    379395 
    380396  /* 
    381397   * param_range, as described above. 
    382398   */ 
    383   sw_param_range * range;  /* param range */ 
     399  sw_param_range *range;       /* param range */ 
    384400}; 
    385401 
     
    388404 * sw_param_spec: specification for a parameter. 
    389405 */ 
    390 struct _sw_param_spec { 
     406struct _sw_param_spec 
     407
    391408  /* A short name for this parameter */ 
    392   gchar * name; 
     409  gchar *name; 
    393410 
    394411  /* A longer description of the parameter's purpose and usage */ 
    395   gchar * desc; 
     412  gchar *desc; 
    396413 
    397414  /* The type of the parameter */ 
     
    414431typedef struct _sw_plugin sw_plugin; 
    415432 
    416 struct _sw_procedure { 
    417   gchar * name; 
    418   gchar * description; 
    419   gchar * author; 
    420   gchar * copyright; 
    421   gchar * url; 
    422  
    423   gchar * identifier; 
     433struct _sw_procedure 
     434
     435  gchar *name; 
     436  gchar *description; 
     437  gchar *author; 
     438  gchar *copyright; 
     439  gchar *url; 
     440 
     441  gchar *identifier; 
    424442 
    425443  /* Key bindings */ 
     
    428446 
    429447  gint nr_params; 
    430   sw_param_spec * param_specs; 
     448  sw_param_spec *param_specs; 
    431449 
    432450  /* suggest sets suggested values for the members of pset, 
     
    446464   * If nr_params is 0 then this function will be passed a NULL pset. 
    447465   */ 
    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); 
    450468 
    451469  /* custom data to pass to the suggest and apply functions */ 
     
    453471}; 
    454472 
    455 struct _sw_plugin { 
     473struct _sw_plugin 
     474
    456475  /* plugin_init () returns a list of procedures */ 
    457   GList * (*plugin_init) (void); 
     476  GList *(*plugin_init) (void); 
    458477 
    459478  /* plugin_cleanup() frees the plugin's private data structures */ 
     
    461480}; 
    462481 
    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  
     482typedef 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  
    2424#include "sweep_types.h" 
    2525 
    26 gint 
    27 update_edit_progress (gpointer data); 
     26gint update_edit_progress (gpointer data); 
    2827 
    29 sw_op_instance * 
    30 sw_op_instance_new (sw_sample * sample, char * description, 
    31                     sw_operation * operation); 
     28sw_op_instance *sw_op_instance_new (sw_sample * sample, char *description, 
     29                                    sw_operation * operation); 
    3230 
    3331void 
    34 schedule_operation (sw_sample * sample, char * description, 
    35                     sw_operation * operation, void * do_data); 
     32schedule_operation (sw_sample * sample, char *description, 
     33                    sw_operation * operation, void *do_data); 
    3634 
    37 void 
    38 register_operation (sw_sample * s, sw_op_instance * inst); 
     35void register_operation (sw_sample * s, sw_op_instance * inst); 
    3936 
    40 void 
    41 trim_registered_ops (sw_sample * s, int length); 
     37void trim_registered_ops (sw_sample * s, int length); 
    4238 
    43 void 
    44 undo_current (sw_sample * s); 
     39void undo_current (sw_sample * s); 
    4540 
    46 void 
    47 redo_current (sw_sample * s); 
     41void redo_current (sw_sample * s); 
    4842 
    49 void 
    50 revert_op (sw_sample * sample, GList * op_gl); 
     43void revert_op (sw_sample * sample, GList * op_gl); 
    5144 
    52 void 
    53 set_active_op (sw_sample * s, sw_op_instance * inst); 
     45void set_active_op (sw_sample * s, sw_op_instance * inst); 
    5446 
    55 void 
    56 cancel_active_op (sw_sample * s); 
     47void cancel_active_op (sw_sample * s); 
    5748 
    5849/* Stock undo functions */ 
     
    6152typedef struct _replace_data replace_data; 
    6253 
    63 struct _replace_data { 
    64   sw_sample * old_sample; 
    65   sw_sample * new_sample; 
     54struct _replace_data 
     55
     56  sw_sample *old_sample; 
     57  sw_sample *new_sample; 
    6658}; 
    6759 
    68 replace_data * 
    69 replace_data_new (sw_sample * old_sample, sw_sample * new_sample); 
     60replace_data *replace_data_new (sw_sample * old_sample, 
     61                               sw_sample * new_sample); 
    7062 
    71 void 
    72 undo_by_replace (replace_data * r); 
     63void undo_by_replace (replace_data * r); 
    7364 
    74 void 
    75 redo_by_replace (replace_data * r); 
     65void redo_by_replace (replace_data * r); 
    7666#endif 
    7767 
    7868typedef struct _sounddata_replace_data sounddata_replace_data; 
    7969 
    80 struct _sounddata_replace_data { 
    81   sw_sample * sample; 
    82   sw_sounddata * old_sounddata; 
    83   sw_sounddata * new_sounddata; 
     70struct _sounddata_replace_data 
     71
     72  sw_sample *sample; 
     73  sw_sounddata *old_sounddata; 
     74  sw_sounddata *new_sounddata; 
    8475}; 
    8576 
    86 sounddata_replace_data * 
    87 sounddata_replace_data_new (sw_sample * sample, 
    88                             sw_sounddata * old_sounddata, 
    89                             sw_sounddata * new_sounddata); 
     77sounddata_replace_data *sounddata_replace_data_new (sw_sample * sample, 
     78                                                    sw_sounddata * 
     79                                                    old_sounddata, 
     80                                                    sw_sounddata * 
     81                                                    new_sounddata); 
    9082 
    91 void 
    92 sounddata_replace_data_destroy (sounddata_replace_data * sr); 
     83void sounddata_replace_data_destroy (sounddata_replace_data * sr); 
    9384 
    94 void 
    95 undo_by_sounddata_replace (sw_sample * s, sounddata_replace_data * sr); 
     85void undo_by_sounddata_replace (sw_sample * s, sounddata_replace_data * sr); 
    9686 
    97 void 
    98 redo_by_sounddata_replace (sw_sample * s, sounddata_replace_data * sr); 
     87void redo_by_sounddata_replace (sw_sample * s, sounddata_replace_data * sr); 
    9988 
    10089 
    10190typedef struct _paste_over_data paste_over_data; 
    10291 
    103 struct _paste_over_data { 
    104   sw_sample * sample; 
    105   sw_edit_buffer * old_eb; 
    106   sw_edit_buffer * new_eb; 
     92struct _paste_over_data 
     93
     94  sw_sample *sample; 
     95  sw_edit_buffer *old_eb; 
     96  sw_edit_buffer *new_eb; 
    10797}; 
    10898 
    109 paste_over_data * 
    110 paste_over_data_new (sw_edit_buffer * old_eb, sw_edit_buffer * new_eb); 
     99paste_over_data *paste_over_data_new (sw_edit_buffer * old_eb, 
     100                                    sw_edit_buffer * new_eb); 
    111101 
    112 void 
    113 paste_over_data_destroy (paste_over_data * p); 
     102void paste_over_data_destroy (paste_over_data * p); 
    114103 
    115 void 
    116 undo_by_paste_over (sw_sample * s, paste_over_data * p); 
     104void undo_by_paste_over (sw_sample * s, paste_over_data * p); 
    117105 
    118 void 
    119 redo_by_paste_over (sw_sample * s, paste_over_data * p); 
     106void redo_by_paste_over (sw_sample * s, paste_over_data * p); 
    120107 
    121108 
    122109typedef struct _splice_data splice_data; 
    123110 
    124 struct _splice_data { 
    125   sw_sample * sample; 
    126   sw_edit_buffer * eb; 
    127   GList * sels; /* Previous sels of sounddata */ 
     111struct _splice_data 
     112
     113  sw_sample *sample; 
     114  sw_edit_buffer *eb; 
     115  GList *sels;                  /* Previous sels of sounddata */ 
    128116}; 
    129117 
    130 splice_data * 
    131 splice_data_new (sw_edit_buffer * eb, GList * sels); 
     118splice_data *splice_data_new (sw_edit_buffer * eb, GList * sels); 
    132119 
    133 void 
    134 splice_data_destroy (splice_data * s); 
     120void splice_data_destroy (splice_data * s); 
    135121 
    136 void 
    137 undo_by_splice_in (sw_sample * s, splice_data * sp); 
     122void undo_by_splice_in (sw_sample * s, splice_data * sp); 
    138123 
    139 void 
    140 redo_by_splice_out (sw_sample * s, splice_data * sp); 
     124void redo_by_splice_out (sw_sample * s, splice_data * sp); 
    141125 
    142 void 
    143 undo_by_splice_out (sw_sample * s, splice_data * sp); 
     126void undo_by_splice_out (sw_sample * s, splice_data * sp); 
    144127 
    145 void 
    146 redo_by_splice_in (sw_sample * s, splice_data * sp); 
     128void redo_by_splice_in (sw_sample * s, splice_data * sp); 
    147129 
    148 void 
    149 undo_by_splice_over (sw_sample * s, splice_data * sp); 
     130void undo_by_splice_over (sw_sample * s, splice_data * sp); 
    150131 
    151 void 
    152 redo_by_splice_over (sw_sample * s, splice_data * sp); 
     132void redo_by_splice_over (sw_sample * s, splice_data * sp); 
    153133 
    154 void 
    155 undo_by_crop_in (sw_sample * s, splice_data * sp); 
     134void undo_by_crop_in (sw_sample * s, splice_data * sp); 
    156135 
    157 void 
    158 redo_by_crop_out (sw_sample * s, splice_data * sp); 
     136void redo_by_crop_out (sw_sample * s, splice_data * sp); 
    159137 
    160138#endif /* __SWEEP_UNDO_H__ */ 
  • sweep/branches/display-cache/intl/bindtextdom.c

    r183 r471  
    7070/* Lock variable to protect the global data in the gettext implementation.  */ 
    7171__libc_rwlock_define (extern, _nl_state_lock attribute_hidden) 
    72  
    73  
    7472/* Names for the libintl functions are a problem.  They must not clash 
    7573   with existing names and they should follow ANSI C.  But this source 
     
    8684# define BIND_TEXTDOMAIN_CODESET libintl_bind_textdomain_codeset 
    8785#endif 
    88  
    8986/* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP 
    9087   to be used for the DOMAINNAME message catalog. 
     
    9390   If DIRNAMEP or CODESETP is NULL, the corresponding attribute is neither 
    9491   modified nor returned.  */ 
    95 static void 
    96 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) 
    9895{ 
    9996  struct binding *binding; 
     
    114111  modified = 0; 
    115112 
    116   for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next) 
     113  for (binding = _nl_domain_bindings; binding != NULL; 
     114       binding = binding->next) 
    117115    { 
    118116      int compare = strcmp (domainname, binding->domainname); 
     
    140138            { 
    141139              /* The domain is already bound.  If the new value and the old 
    142                 one are equal we simply do nothing.  Otherwise replace the 
    143                 old binding.  */ 
     140                one are equal we simply do nothing.  Otherwise replace the 
     141                old binding.  */ 
    144142              char *result = binding->dirname; 
    145143              if (strcmp (dirname, result) != 0) 
    146144                { 
    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); 
    149147                  else 
    150148                    { 
     
    161159                  if (__builtin_expect (result != NULL, 1)) 
    162160                    { 
    163                       if (binding->dirname != INTUSE(_nl_default_dirname)) 
     161                      if (binding->dirname != INTUSE (_nl_default_dirname)) 
    164162                        free (binding->dirname); 
    165163 
     
    182180            { 
    183181              /* The domain is already bound.  If the new value and the old 
    184                 one are equal we simply do nothing.  Otherwise replace the 
    185                 old binding.  */ 
     182                one are equal we simply do nothing.  Otherwise replace the 
     183                old binding.  */ 
    186184              char *result = binding->codeset; 
    187185              if (result == NULL || strcmp (codeset, result) != 0) 
     
    215213      /* Simply return the default values.  */ 
    216214      if (dirnamep) 
    217         *dirnamep = INTUSE(_nl_default_dirname); 
     215        *dirnamep = INTUSE (_nl_default_dirname); 
    218216      if (codesetp) 
    219217        *codesetp = NULL; 
     
    224222      size_t len = strlen (domainname) + 1; 
    225223      struct binding *new_binding = 
    226         (struct binding *) malloc (offsetof (struct binding, domainname) + len); 
     224        (struct binding *) malloc (offsetof (struct binding, domainname) + 
     225                                   len); 
    227226 
    228227      if (__builtin_expect (new_binding == NULL, 0)) 
     
    237236          if (dirname == NULL) 
    238237            /* The default value.  */ 
    239             dirname = INTUSE(_nl_default_dirname); 
     238            dirname = INTUSE (_nl_default_dirname); 
    240239          else 
    241240            { 
    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); 
    244243              else 
    245244                { 
     
    264263      else 
    265264        /* The default value.  */ 
    266         new_binding->dirname = (char *) INTUSE(_nl_default_dirname); 
     265        new_binding->dirname = (char *) INTUSE (_nl_default_dirname); 
    267266 
    268267      new_binding->codeset_cntr = 0; 
     
    320319        { 
    321320        failed_codeset: 
    322           if (new_binding->dirname != INTUSE(_nl_default_dirname)) 
     321          if (new_binding->dirname != INTUSE (_nl_default_dirname)) 
    323322            free (new_binding->dirname); 
    324323        failed_dirname: 
  • sweep/branches/display-cache/intl/dcgettext.c

    r183 r471  
    5252#ifdef _LIBC 
    5353/* Alias for function name in GNU C Library.  */ 
    54 INTDEF(__dcgettext) 
    55 weak_alias (__dcgettext, dcgettext); 
     54INTDEF (__dcgettext) weak_alias (__dcgettext, dcgettext); 
    5655#endif 
  • sweep/branches/display-cache/intl/dcigettext.c

    r183 r471  
    4242#  else 
    4343#   ifdef _AIX 
    44  #pragma alloca 
     44#pragma alloca 
    4545#   else 
    4646#    ifndef alloca 
     
    291291/* Value used as the default domain for gettext(3).  */ 
    292292const char *_nl_current_default_domain attribute_hidden 
    293      = _nl_default_default_domain; 
     293  = _nl_default_default_domain; 
    294294 
    295295/* Contains the default location of the message catalogs.  */ 
     
    300300INTVARDEF (_nl_default_dirname) 
    301301#endif 
    302  
    303302/* List with bindings of specific domains created by bindtextdomain() 
    304303   calls.  */ 
    305 struct binding *_nl_domain_bindings; 
     304     struct binding *_nl_domain_bindings; 
    306305 
    307306/* 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; 
    315314#ifdef _LIBC 
    316315# include "../locale/localeinfo.h" 
    317316# define category_to_name(category)     _nl_category_names[category] 
    318317#else 
    319 static const char *category_to_name (int category) internal_function; 
     318     static const char *category_to_name (int category) internal_function; 
    320319#endif 
    321320 
     
    325324#ifdef HAVE_ALLOCA 
    326325/* 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_list 
    332 
    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     }; 
    336335# define ADD_BLOCK(list, addr)                                                \ 
    337336  do {                                                                        \ 
     
    357356# define alloca(size) (malloc (size)) 
    358357# define freea(p) free (p) 
    359 #endif /* have alloca */ 
     358#endif /* have alloca */ 
    360359 
    361360 
    362361#ifdef _LIBC 
    363362/* List of blocks allocated for translations.  */ 
    364 typedef struct transmem_list 
    365 
    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; 
    372371#endif 
    373372 
     
    387386__libc_rwlock_define_initialized (, _nl_state_lock attribute_hidden) 
    388387#endif 
    389  
    390388/* Checking whether the binaries runs SUID must be done and glibc provides 
    391389   easier methods therefore we make a difference here.  */ 
     
    406404#  define getegid() getgid() 
    407405# endif 
    408 static int enable_secure; 
     406     static int enable_secure; 
    409407# define ENABLE_SECURE (enable_secure == 1) 
    410408# define DETERMINE_SECURE \ 
     
    424422   CATEGORY locale and, if PLURAL is nonzero, search over string 
    425423   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) 
    429427{ 
    430428#ifndef HAVE_ALLOCA 
     
    454452  if (category < 0 || category >= __LC_LAST || category == LC_ALL) 
    455453    /* Bogus.  */ 
    456     return (plural == 0 
    457             ? (char *) msgid1 
     454    return (plural == 0 ? (char *) msgid1 
    458455            /* Use the Germanic plural rule.  */ 
    459456            : n == 1 ? (char *) msgid1 : (char *) msgid2); 
     
    480477     some time.  */ 
    481478  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); 
    483480  memcpy (search->msgid, msgid1, msgid_len); 
    484481  search->domainname = (char *) domainname; 
     
    508505 
    509506  /* 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) 
    511509    { 
    512510      int compare = strcmp (domainname, binding->domainname); 
     
    523521 
    524522  if (binding == NULL) 
    525     dirname = (char *) INTUSE(_nl_default_dirname); 
     523    dirname = (char *) INTUSE (_nl_default_dirname); 
    526524  else if (IS_ABSOLUTE_PATH (binding->dirname)) 
    527525    dirname = binding->dirname; 
     
    563561 
    564562  domainname_len = strlen (domainname); 
    565   xdomainname = (char *) alloca (strlen (categoryname) 
    566                                  + domainname_len + 5); 
     563  xdomainname = (char *) alloca (strlen (categoryname) + domainname_len + 5); 
    567564  ADD_BLOCK (block_list, xdomainname); 
    568565 
    569566  stpcpy (mempcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"), 
    570                   domainname, domainname_len), 
    571           ".mo"); 
     567                   domainname, domainname_len), ".mo"); 
    572568 
    573569  /* Creating working area.  */ 
     
    607603 
    608604      /* If the current locale value is C (or POSIX) we don't load a 
    609         domain.  Return the MSGID.  */ 
     605        domain.  Return the MSGID.  */ 
    610606      if (strcmp (single_locale, "C") == 0 
    611607          || strcmp (single_locale, "POSIX") == 0) 
     
    613609 
    614610      /* Find structure describing the message catalog matching the 
    615         DOMAINNAME and CATEGORY.  */ 
     611        DOMAINNAME and CATEGORY.  */ 
    616612      domain = _nl_find_domain (dirname, single_locale, xdomainname, binding); 
    617613 
     
    640636            { 
    641637              /* Found the translation of MSGID1 in domain DOMAIN: 
    642                 starting at RETVAL, RETLEN bytes.  */ 
     638                starting at RETVAL, RETLEN bytes.  */ 
    643639              FREE_BLOCKS (block_list); 
    644640#if defined HAVE_TSEARCH || defined _LIBC 
     
    655651                      newp->domainname = 
    656652                        mempcpy (newp->msgid, msgid1, msgid_len); 
    657                       memcpy (newp->domainname, domainname, domainname_len + 1); 
     653                      memcpy (newp->domainname, domainname, 
     654                              domainname_len + 1); 
    658655                      newp->category = category; 
    659656                      newp->counter = _nl_msg_cat_cntr; 
     
    692689    } 
    693690 
    694  return_untranslated: 
     691return_untranslated: 
    695692  /* Return the untranslated MSGID.  */ 
    696693  FREE_BLOCKS (block_list); 
     
    701698      extern void _nl_log_untranslated (const char *logfilename, 
    702699                                        const char *domainname, 
    703                                         const char *msgid1, const char *msgid2, 
    704                                         int plural); 
     700                                        const char *msgid1, 
     701                                        const char *msgid2, int plural); 
    705702      const char *logfilename = getenv ("GETTEXT_LOG_UNTRANSLATED"); 
    706703 
    707704      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); 
    709707    } 
    710708#endif 
    711709  __set_errno (saved_errno); 
    712   return (plural == 0 
    713           ? (char *) msgid1 
     710  return (plural == 0 ? (char *) msgid1 
    714711          /* Use the Germanic plural rule.  */ 
    715712          : n == 1 ? (char *) msgid1 : (char *) msgid2); 
     
    717714 
    718715 
    719 char * 
    720 internal_function 
     716char *internal_function 
    721717_nl_find_msg (struct loaded_l10nfile *domain_file, 
    722718              struct binding *domainbinding, const char *msgid, 
    723               size_t *lengthp) 
     719              size_t * lengthp) 
    724720{ 
    725721  struct loaded_domain *domain; 
     
    764760          if (nstr < nstrings 
    765761              ? 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) 
    770766              : 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)) 
    774770            { 
    775771              act = nstr; 
     
    787783    { 
    788784      /* Try the default method:  binary search in the sorted array of 
    789         messages.  */ 
     785        messages.  */ 
    790786      size_t top, bottom; 
    791787 
     
    811807    } 
    812808 
    813  found: 
     809found: 
    814810  /* The translation was found at index ACT.  If we have to convert the 
    815811     string to use a different character set, this is the time.  */ 
     
    831827    { 
    832828      /* The domain's codeset has changed through bind_textdomain_codeset() 
    833         since the message catalog was initialized or last accessed.  We 
    834         have to reinitialize the converter.  */ 
     829        since the message catalog was initialized or last accessed.  We 
     830        have to reinitialize the converter.  */ 
    835831      _nl_free_domain_conv (domain); 
    836832      _nl_init_domain_conv (domain_file, domain, domainbinding); 
     
    839835  if ( 
    840836# ifdef _LIBC 
    841       domain->conv != (__gconv_t) -
     837      domain->conv != (__gconv_t) -
    842838# else 
    843839#  if HAVE_ICONV 
    844       domain->conv != (iconv_t) -
     840      domain->conv != (iconv_t) -
    845841#  endif 
    846842# endif 
    847      
     843   
    848844    { 
    849845      /* We are supposed to do a conversion.  First allocate an 
    850         appropriate table with the same structure as the table 
    851         of translations in the file, where we can put the pointers 
    852         to the converted strings in. 
    853         There is a slight complication with plural entries.  They 
    854         are represented by consecutive NUL terminated strings.  We 
    855         handle this case by converting RESULTLEN bytes, including 
    856         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.  */ 
    857853 
    858854      if (domain->conv_tab == NULL 
    859855          && ((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)) 
    863858        /* Mark that we didn't succeed allocating a table.  */ 
    864859        domain->conv_tab = (char **) -1; 
     
    932927              if (iconv (domain->conv, 
    933928                         (ICONV_CONST char **) &inptr, &inleft, 
    934                          &outptr, &outleft) 
    935                   != (size_t) (-1)) 
     929                         &outptr, &outleft) != (size_t) (-1)) 
    936930                { 
    937931                  outbuf = (unsigned char *) outptr; 
     
    982976# ifdef _LIBC 
    983977              /* Add the block to the list of blocks we have to free 
    984                  at some point.  */ 
     978                at some point.  */ 
    985979              newmem->next = transmem_list; 
    986980              transmem_list = newmem; 
     
    1004998          freemem = outbuf; 
    1005999          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); 
    10071001 
    10081002          __libc_lock_unlock (lock); 
     
    10101004 
    10111005      /* Now domain->conv_tab[act] contains the translation of all 
    1012         the plural variants.  */ 
     1006        the plural variants.  */ 
    10131007      result = domain->conv_tab[act] + sizeof (size_t); 
    10141008      resultlen = *(size_t *) domain->conv_tab[act]; 
    10151009    } 
    10161010 
    1017  converted: 
     1011converted: 
    10181012  /* The result string is converted.  */ 
    10191013 
     
    10261020 
    10271021/* Look up a plural variant.  */ 
    1028 static char * 
    1029 internal_function 
     1022static char *internal_function 
    10301023plural_lookup (struct loaded_l10nfile *domain, unsigned long int n, 
    10311024               const char *translation, size_t translation_len) 
     
    10641057#ifndef _LIBC 
    10651058/* Return string representation of locale CATEGORY.  */ 
    1066 static const char * 
    1067 internal_function 
     1059static const char *internal_function 
    10681060category_to_name (int category) 
    10691061{ 
     
    10711063 
    10721064  switch (category) 
    1073  
     1065   
    10741066#ifdef LC_COLLATE 
    1075   case LC_COLLATE: 
    1076     retval = "LC_COLLATE"; 
    1077     break; 
     1067    case LC_COLLATE: 
     1068      retval = "LC_COLLATE"; 
     1069      break; 
    10781070#endif 
    10791071#ifdef LC_CTYPE 
    1080   case LC_CTYPE: 
    1081     retval = "LC_CTYPE"; 
    1082     break; 
     1072    case LC_CTYPE: 
     1073      retval = "LC_CTYPE"; 
     1074      break; 
    10831075#endif 
    10841076#ifdef LC_MONETARY 
    1085   case LC_MONETARY: 
    1086     retval = "LC_MONETARY"; 
    1087     break; 
     1077    case LC_MONETARY: 
     1078      retval = "LC_MONETARY"; 
     1079      break; 
    10881080#endif 
    10891081#ifdef LC_NUMERIC 
    1090   case LC_NUMERIC: 
    1091     retval = "LC_NUMERIC"; 
    1092     break; 
     1082    case LC_NUMERIC: 
     1083      retval = "LC_NUMERIC"; 
     1084      break; 
    10931085#endif 
    10941086#ifdef LC_TIME 
    1095   case LC_TIME: 
    1096     retval = "LC_TIME"; 
    1097     break; 
     1087    case LC_TIME: 
     1088      retval = "LC_TIME"; 
     1089      break; 
    10981090#endif 
    10991091#ifdef LC_MESSAGES 
    1100   case LC_MESSAGES: 
    1101     retval = "LC_MESSAGES"; 
    1102     break; 
     1092    case LC_MESSAGES: 
     1093      retval = "LC_MESSAGES"; 
     1094      break; 
    11031095#endif 
    11041096#ifdef LC_RESPONSE 
    1105   case LC_RESPONSE: 
    1106     retval = "LC_RESPONSE"; 
    1107     break; 
     1097    case LC_RESPONSE: 
     1098      retval = "LC_RESPONSE"; 
     1099      break; 
    11081100#endif 
    11091101#ifdef LC_ALL 
    1110   case LC_ALL: 
    1111     /* This might not make sense but is perhaps better than any other 
    1112        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   
    11201112 
    11211113  return retval; 
     
    11251117/* Guess value of current locale from value of the environment variables 
    11261118   or system-dependent defaults.  */ 
    1127 static const char * 
    1128 internal_function 
     1119static const char *internal_function 
    11291120guess_category_value (int category, const char *categoryname) 
    11301121{ 
     
    11381129  /* We use the settings in the following order: 
    11391130     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. 
    11411132     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. 
    11441135     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. 
    11461137     4. A system-dependent default locale name. 
    11471138     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.  */ 
    11511142 
    11521143  /* Fetch the locale name, through the POSIX method of looking to `LC_ALL', 
     
    11681159     to "C" because 
    11691160     1. "C" locale usually uses the ASCII encoding, and most international 
    1170        messages use non-ASCII characters. These characters get displayed 
    1171        as question marks (if using glibc's iconv()) or as invalid 8-bit 
    1172        characters (because other iconv()s refuse to convert most non-ASCII 
    1173        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. 
    11741165     2. The precise output of some programs in the "C" locale is specified 
    1175        by POSIX and should not depend on environment variables like 
    1176        "LANGUAGE" or system-dependent information.  We allow such programs 
    1177         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().  */ 
    11781169  if (strcmp (locale, "C") == 0) 
    11791170    return locale; 
     
    11911182      language_default = _nl_language_preferences_default (); 
    11921183      if (language_default != NULL) 
    1193         return language_default; 
     1184       return language_default; 
    11941185    } 
    11951186  /* The least priority value is the locale name, if defaulted.  */ 
     
    12341225      struct binding *oldp = _nl_domain_bindings; 
    12351226      _nl_domain_bindings = _nl_domain_bindings->next; 
    1236       if (oldp->dirname != INTUSE(_nl_default_dirname)) 
     1227      if (oldp->dirname != INTUSE (_nl_default_dirname)) 
    12371228        /* Yes, this is a pointer comparison.  */ 
    12381229        free (oldp->dirname); 
  • sweep/branches/display-cache/intl/eval-plural.h

    r183 r471  
    2222 
    2323/* Evaluate the plural expression and return an index value.  */ 
    24 STATIC 
    25 unsigned long int 
    26 internal_function 
     24STATIC unsigned long int internal_function 
    2725plural_eval (struct expression *pexp, unsigned long int n) 
    2826{ 
     
    4543        /* pexp->operation must be lnot.  */ 
    4644        unsigned long int arg = plural_eval (pexp->val.args[0], n); 
    47         return ! arg; 
     45        return !arg; 
    4846      } 
    4947    case 2: 
  • sweep/branches/display-cache/intl/explodename.c

    r183 r471  
    5656                  const char **sponsor, const char **revision) 
    5757{ 
    58   enum { undecided, xpg, cen } syntax; 
     58  enum 
     59  { undecided, xpg, cen } syntax; 
    5960  char *cp; 
    6061  int mask; 
     
    136137      if (cp[0] == '+') 
    137138        { 
    138         /* Next is special application (CEN syntax).  */ 
     139        /* Next is special application (CEN syntax).  */ 
    139140          cp[0] = '\0'; 
    140141          *special = ++cp; 
     
    148149      if (cp[0] == ',') 
    149150        { 
    150         /* Next is sponsor (CEN syntax).  */ 
     151        /* Next is sponsor (CEN syntax).  */ 
    151152          cp[0] = '\0'; 
    152153          *sponsor = ++cp; 
     
    160161      if (cp[0] == '_') 
    161162        { 
    162         /* Next is revision (CEN syntax).  */ 
     163        /* Next is revision (CEN syntax).  */ 
    163164          cp[0] = '\0'; 
    164165          *revision = ++cp; 
  • sweep/branches/display-cache/intl/finddomain.c

    r183 r471  
    4646   the DOMAINNAME and CATEGORY parameters with respect to the currently 
    4747   established bindings.  */ 
    48 struct loaded_l10nfile * 
    49 internal_function 
     48struct loaded_l10nfile *internal_function 
    5049_nl_find_domain (const char *dirname, char *locale, 
    5150                 const char *domainname, struct binding *domainbinding) 
     
    6564  /* LOCALE can consist of up to four recognized parts for the XPG syntax: 
    6665 
    67                language[_territory[.codeset]][@modifier] 
     66     language[_territory[.codeset]][@modifier] 
    6867 
    6968     and six parts for the CEN syntax: 
    7069 
    71        language[_territory][+audience][+special][,[sponsor][_revision]] 
     70     language[_territory][+audience][+special][,[sponsor][_revision]] 
    7271 
    7372     Beside the first part all of them are allowed to be missing.  If 
     
    7574     looked for.  The various parts will be stripped off according to 
    7675     the following order: 
    77                (1) revision 
    78                (2) sponsor 
    79                (3) special 
    80                (4) codeset 
    81                (5) normalized codeset 
    82                (6) territory 
    83                (7) audience/modifier 
     76     (1) revision 
     77     (2) sponsor 
     78     (3) special 
     79     (4) codeset 
     80     (5) normalized codeset 
     81     (6) territory 
     82     (7) audience/modifier 
    8483   */ 
    8584 
     
    113112 
    114113  /* See whether the locale value is an alias.  If yes its value 
    115      *overwrites* the alias name.  No test for the original value is 
    116      done.  */ 
     114   *overwrites* the alias name.  No test for the original value is 
     115   done.  */ 
    117116  alias_value = _nl_expand_alias (locale); 
    118117  if (alias_value != NULL) 
     
    142141     generalization.  */ 
    143142  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); 
    147147  if (retval == NULL) 
    148148    /* This means we are out of core.  */ 
  • sweep/branches/display-cache/intl/gettextP.h

    r183 r471  
    141141  struct binding *next; 
    142142  char *dirname; 
    143   int codeset_cntr;     /* Incremented each time codeset changes.  */ 
     143  int codeset_cntr;            /* Incremented each time codeset changes.  */ 
    144144  char *codeset; 
    145145  char domainname[ZERO]; 
     
    158158#endif 
    159159 
    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); 
     160struct 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); 
    203201#else 
    204202/* Declare the exported libintl_* functions, in a way that allows us to 
     
    208206# define _INTL_REDIRECT_MACROS 
    209207# 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); 
    214212#endif 
    215213 
  • sweep/branches/display-cache/intl/gmo.h

    r183 r471  
    6464  /* The following line is intended to throw an error.  Using #error is 
    6565     not portable enough.  */ 
    66   "Cannot determine unsigned 32-bit data type." 
     66"Cannot determine unsigned 32-bit data type." 
    6767#  endif 
    6868# endif 
    6969#endif 
    70  
    71  
    7270/* Header for binary .mo file format.  */ 
    73 struct mo_file_header 
     71  struct mo_file_header 
    7472{ 
    7573  /* The magic number.  */ 
     
    147145/* @@ begin of epilog @@ */ 
    148146 
    149 #endif /* gettext.h  */ 
     147#endif /* gettext.h  */ 
  • sweep/branches/display-cache/intl/intl-compat.c

    r183 r471  
    5757 
    5858 
    59 DLL_EXPORTED 
    60 char * 
     59DLL_EXPORTED char * 
    6160gettext (const char *msgid) 
    6261{ 
     
    6564 
    6665 
    67 DLL_EXPORTED 
    68 char * 
     66DLL_EXPORTED char * 
    6967dgettext (const char *domainname, const char *msgid) 
    7068{ 
     
    7371 
    7472 
    75 DLL_EXPORTED 
    76 char * 
     73DLL_EXPORTED char * 
    7774dcgettext (const char *domainname, const char *msgid, int category) 
    7875{ 
     
    8178 
    8279 
    83 DLL_EXPORTED 
    84 char * 
     80DLL_EXPORTED char * 
    8581ngettext (const char *msgid1, const char *msgid2, unsigned long int n) 
    8682{ 
     
    8985 
    9086 
    91 DLL_EXPORTED 
    92 char * 
     87DLL_EXPORTED char * 
    9388dngettext (const char *domainname, 
    9489           const char *msgid1, const char *msgid2, unsigned long int n) 
     
    9893 
    9994 
    100 DLL_EXPORTED 
    101 char * 
     95DLL_EXPORTED char * 
    10296dcngettext (const char *domainname, 
    10397            const char *msgid1, const char *msgid2, unsigned long int n, 
     
    108102 
    109103 
    110 DLL_EXPORTED 
    111 char * 
     104DLL_EXPORTED char * 
    112105textdomain (const char *domainname) 
    113106{ 
     
    116109 
    117110 
    118 DLL_EXPORTED 
    119 char * 
     111DLL_EXPORTED char * 
    120112bindtextdomain (const char *domainname, const char *dirname) 
    121113{ 
     
    124116 
    125117 
    126 DLL_EXPORTED 
    127 char * 
     118DLL_EXPORTED char * 
    128119bind_textdomain_codeset (const char *domainname, const char *codeset) 
    129120{ 
  • sweep/branches/display-cache/intl/l10nflist.c

    r183 r471  
    9898  return count; 
    9999} 
     100 
    100101# undef __argz_count 
    101102# define __argz_count(argz, len) argz_count__ (argz, len) 
     
    104105#  define __argz_count(argz, len) INTUSE(__argz_count) (argz, len) 
    105106# endif 
    106 #endif /* !_LIBC && !HAVE___ARGZ_COUNT */ 
     107#endif /* !_LIBC && !HAVE___ARGZ_COUNT */ 
    107108 
    108109#if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY 
     
    121122    } 
    122123} 
     124 
    123125# undef __argz_stringify 
    124126# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep) 
     
    128130  INTUSE(__argz_stringify) (argz, len, sep) 
    129131# endif 
    130 #endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */ 
     132#endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */ 
    131133 
    132134#if !defined _LIBC && !defined HAVE___ARGZ_NEXT 
     
    137139    { 
    138140      if (entry < argz + argz_len) 
    139         entry = strchr (entry, '\0') + 1; 
     141       entry = strchr (entry, '\0') + 1; 
    140142 
    141143      return entry >= argz + argz_len ? NULL : (char *) entry; 
    142144    } 
     145  else if (argz_len > 0) 
     146    return argz; 
    143147  else 
    144     if (argz_len > 0) 
    145       return argz; 
    146     else 
    147       return 0; 
    148 
     148    return 0; 
     149
     150 
    149151# undef __argz_next 
    150152# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry) 
    151 #endif /* !_LIBC && !HAVE___ARGZ_NEXT */ 
     153#endif /* !_LIBC && !HAVE___ARGZ_NEXT */ 
    152154 
    153155 
     
    164166  return x; 
    165167} 
    166  
    167168  
     169 
    168170struct loaded_l10nfile * 
    169171_nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, 
     
    243245    { 
    244246      /* 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 `@'.  */ 
    246248      *cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@'; 
    247249      cp = stpcpy (cp, modifier); 
  • sweep/branches/display-cache/intl/langprefs.c

    r183 r471  
    4444_nl_language_preferences_default (void) 
    4545{ 
    46 #if HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.2 or newer */ 
     46#if HAVE_CFPREFERENCESCOPYAPPVALUE     /* MacOS X 10.2 or newer */ 
    4747  { 
    4848    /* Cache the preferences list, since CoreFoundation calls are expensive.  */ 
     
    5858            && CFGetTypeID (preferences) == CFArrayGetTypeID ()) 
    5959          { 
    60             CFArrayRef prefArray = (CFArrayRef)preferences; 
     60            CFArrayRef prefArray = (CFArrayRef) preferences; 
    6161            int n = CFArrayGetCount (prefArray); 
    6262            char buf[256]; 
     
    6969                if (element != NULL 
    7070                    && CFGetTypeID (element) == CFStringGetTypeID () 
    71                     && CFStringGetCString ((CFStringRef)element, 
     71                    && CFStringGetCString ((CFStringRef) element, 
    7272                                           buf, sizeof (buf), 
    7373                                           kCFStringEncodingASCII)) 
     
    9999                          CFArrayGetValueAtIndex (prefArray, i); 
    100100                        if (element != NULL 
    101                             && CFGetTypeID (element) == CFStringGetTypeID () 
    102                             && CFStringGetCString ((CFStringRef)element, 
     101                           && CFGetTypeID (element) == CFStringGetTypeID () 
     102                            && CFStringGetCString ((CFStringRef) element, 
    103103                                                   buf, sizeof (buf), 
    104104                                                   kCFStringEncodingASCII)) 
  • sweep/branches/display-cache/intl/loadinfo.h

    r183 r471  
    9999   furthermore its ->successor[] field contains a list of other lookup 
    100100   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); 
     101extern 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); 
    109117 
    110118/* Lookup the real locale name for a locale alias NAME, or NULL if 
     
    143151extern char *_nl_find_language (const char *name); 
    144152 
    145 #endif /* loadinfo.h */ 
     153#endif /* loadinfo.h */ 
  • sweep/branches/display-cache/intl/loadmsgcat.c

    r183 r471  
    4747#  else 
    4848#   ifdef _AIX 
    49  #pragma alloca 
     49#pragma alloca 
    5050#   else 
    5151#    ifndef alloca 
     
    468468   some additional code emulating it.  */ 
    469469#ifdef HAVE_ALLOCA 
    470 # define freea(p) /* nothing */ 
     470# define freea(p)              /* nothing */ 
    471471#else 
    472472# define alloca(n) malloc (n) 
     
    754754#if defined _LIBC || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) 
    755755      /* The 'I' flag, in numeric format directives, replaces ASCII digits 
    756         with the 'outdigits' defined in the LC_CTYPE locale facet.  This is 
    757         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.  */ 
    758758      return "I"; 
    759759#else 
     
    767767/* Initialize the codeset dependent parts of an opened message catalog. 
    768768   Return the header entry.  */ 
    769 const char * 
    770 internal_function 
     769const char *internal_function 
    771770_nl_init_domain_conv (struct loaded_l10nfile *domain_file, 
    772771                      struct loaded_domain *domain, 
     
    785784    (domainbinding != NULL ? domainbinding->codeset_cntr : 0); 
    786785#ifdef _LIBC 
    787   domain->conv = (__gconv_t) -1; 
     786  domain->conv = (__gconv_t) - 1; 
    788787#else 
    789788# if HAVE_ICONV 
    790   domain->conv = (iconv_t) -1; 
     789  domain->conv = (iconv_t) - 1; 
    791790# endif 
    792791#endif 
     
    847846          charset = norm_add_slashes (charset, NULL); 
    848847          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; 
    852850# else 
    853851#  if HAVE_ICONV 
     
    885883 
    886884/* Frees the codeset dependent parts of an opened message catalog.  */ 
    887 void 
    888 internal_function 
     885void internal_function 
    889886_nl_free_domain_conv (struct loaded_domain *domain) 
    890887{ 
     
    893890 
    894891#ifdef _LIBC 
    895   if (domain->conv != (__gconv_t) -1) 
     892  if (domain->conv != (__gconv_t) - 1) 
    896893    __gconv_close (domain->conv); 
    897894#else 
    898895# if HAVE_ICONV 
    899   if (domain->conv != (iconv_t) -1) 
     896  if (domain->conv != (iconv_t) - 1) 
    900897    iconv_close (domain->conv); 
    901898# endif 
     
    905902/* Load the message catalogs specified by FILENAME.  If it is no valid 
    906903   message catalog do nothing.  */ 
    907 void 
    908 internal_function 
     904void internal_function 
    909905_nl_load_domain (struct loaded_l10nfile *domain_file, 
    910906                 struct binding *domainbinding) 
     
    945941  if ( 
    946942#ifdef _LIBC 
    947       __builtin_expect (fstat64 (fd, &st) != 0, 0) 
     943      __builtin_expect (fstat64 (fd, &st) != 0, 0) 
    948944#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)) 
    953949    { 
    954950      /* Something went wrong.  */ 
     
    10061002  /* Using the magic number we can test whether it really is a message 
    10071003     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)) 
    10101006    { 
    10111007      /* The magic number is wrong: not a message catalog file.  */ 
     
    10461042        (domain->hash_size > 2 
    10471043         ? (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)) 
    10491045         : NULL); 
    10501046      domain->must_swap_hash_tab = domain->must_swap; 
     
    10671063              goto invalid; 
    10681064 
    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); 
    10711066            if (n_sysdep_strings > 0) 
    10721067              { 
     
    11061101                      } 
    11071102 
    1108                     sysdep_segment_values[i] = get_sysdep_segment_value (name); 
     1103                    sysdep_segment_values[i] = 
     1104                      get_sysdep_segment_value (name); 
    11091105                  } 
    11101106 
     
    11311127                        const struct sysdep_string *sysdep_string = 
    11321128                          (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])); 
    11381133                        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) 
    11421139                          for (p = sysdep_string->segments;; p++) 
    11431140                            { 
     
    11641161                                } 
    11651162 
    1166                               need += strlen (sysdep_segment_values[sysdepref]); 
     1163                              need += 
     1164                                strlen (sysdep_segment_values[sysdepref]); 
    11671165                            } 
    11681166 
     
    11791177                  } 
    11801178                memneed += 2 * n_inmem_sysdep_strings 
    1181                           * sizeof (struct sysdep_string_desc); 
     1179                  * sizeof (struct sysdep_string_desc); 
    11821180 
    11831181                if (n_inmem_sysdep_strings > 0) 
     
    11931191                    inmem_orig_sysdep_tab = (struct sysdep_string_desc *) mem; 
    11941192                    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); 
    11991199                    inmem_hash_tab = (nls_uint32 *) mem; 
    12001200                    mem += domain->hash_size * sizeof (nls_uint32); 
     
    12101210                            const struct sysdep_string *sysdep_string = 
    12111211                              (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])); 
    12171216                            const struct segment_pair *p = 
    12181217                              sysdep_string->segments; 
     
    12291228                                    break; 
    12301229 
    1231                                   if (sysdep_segment_values[sysdepref] == NULL) 
     1230                                  if (sysdep_segment_values[sysdepref] == 
     1231                                      NULL) 
    12321232                                    { 
    12331233                                      /* This particular string pair is 
    1234                                         invalid.  */ 
     1234                                        invalid.  */ 
    12351235                                      valid = 0; 
    12361236                                      break; 
     
    12481248                                const struct sysdep_string *sysdep_string = 
    12491249                                  (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])); 
    12551254                                const char *static_segments = 
    12561255                                  (char *) data 
    1257                                   + W (domain->must_swap, sysdep_string->offset); 
     1256                                  + W (domain->must_swap, 
     1257                                       sysdep_string->offset); 
    12581258                                const struct segment_pair *p = 
    12591259                                  sysdep_string->segments; 
     
    12661266                                  (j == 0 
    12671267                                   ? inmem_orig_sysdep_tab 
    1268                                    : inmem_trans_sysdep_tab) 
    1269                                   + k; 
     1268                                   : inmem_trans_sysdep_tab) + k; 
    12701269 
    12711270                                if (W (domain->must_swap, p->sysdepref) 
     
    12751274                                    inmem_tab_entry->length = 
    12761275                                      W (domain->must_swap, p->segsize); 
    1277                                     inmem_tab_entry->pointer = static_segments; 
     1276                                    inmem_tab_entry->pointer = 
     1277                                      static_segments; 
    12781278                                  } 
    12791279                                else 
     
    12911291                                        if (segsize > 0) 
    12921292                                          { 
    1293                                             memcpy (mem, static_segments, segsize); 
     1293                                            memcpy (mem, static_segments, 
     1294                                                    segsize); 
    12941295                                            mem += segsize; 
    12951296                                            static_segments += segsize; 
     
    12991300                                          break; 
    13001301 
    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); 
    13031308                                        mem += n; 
    13041309                                      } 
     
    13321337                              { 
    13331338                                /* 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; 
    13351341                                break; 
    13361342                              } 
     
    13971403 
    13981404#ifdef _LIBC 
    1399 void 
    1400 internal_function 
     1405void internal_function 
    14011406_nl_unload_domain (struct loaded_domain *domain) 
    14021407{ 
  • sweep/branches/display-cache/intl/localcharset.c

    r409 r471  
    4242 
    4343#if defined _WIN32 || defined __WIN32__ 
    44 # undef WIN32   /* avoid warning on mingw32 */ 
     44# undef WIN32                  /* avoid warning on mingw32 */ 
    4545# define WIN32 
    4646#endif 
     
    9999   are atomic. But I don't know what will happen if the two assignments mix.  */ 
    100100#if __STDC__ != 1 
    101 # define volatile /* empty */ 
     101# define volatile              /* empty */ 
    102102#endif 
    103103/* Pointer to the contents of the charset.alias file, if it has already been 
    104104   read, else NULL.  Its format is: 
    105105   ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0'  */ 
    106 static const char * volatile charset_aliases; 
     106static const char *volatile charset_aliases; 
    107107 
    108108/* Return a pointer to the contents of the charset.alias file.  */ 
     
    122122 
    123123      /* 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".  */ 
    125125      dir = getenv ("CHARSETALIASDIR"); 
    126126      if (dir == NULL || dir[0] == '\0') 
     
    154154            { 
    155155              int c; 
    156               char buf1[50+1]; 
    157               char buf2[50+1]; 
     156              char buf1[50 + 1]; 
     157              char buf2[50 + 1]; 
    158158              size_t l1, l2; 
    159159              char *old_res_ptr; 
     
    218218# if defined VMS 
    219219      /* 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.  */ 
    221221      /* 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".  */ 
    224224      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"; 
    241238# endif 
    242239 
    243240# if defined WIN32 
    244241      /* To avoid the troubles of installing a separate file in the same 
    245         directory as the DLL and of retrieving the DLL's directory at 
    246         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.  */ 
    247244 
    248245      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"; 
    263259# endif 
    264260#endif 
     
    363359            { 
    364360              memcpy (buf, dot, modifier - dot); 
    365               buf [modifier - dot] = '\0'; 
     361              buf[modifier - dot] = '\0'; 
    366362              return buf; 
    367363            } 
  • sweep/branches/display-cache/intl/localcharset.h

    r183 r471  
    2323 
    2424#ifdef __cplusplus 
    25 extern "C" { 
     25extern "C" 
     26
    2627#endif 
    2728 
     
    3233   If the canonical name cannot be determined, the result is a non-canonical 
    3334   name.  */ 
    34 extern const char * locale_charset (void); 
     35  extern const char *locale_charset (void); 
    3536 
    3637 
     
    4041 
    4142 
    42 #endif /* _LOCALCHARSET_H */ 
     43#endif                         /* _LOCALCHARSET_H */ 
  • sweep/branches/display-cache/intl/localealias.c

    r183 r471  
    4848#  else 
    4949#   ifdef _AIX 
    50  #pragma alloca 
     50#pragma alloca 
    5151#   else 
    5252#    ifndef alloca 
     
    105105   some additional code emulating it.  */ 
    106106#ifdef HAVE_ALLOCA 
    107 # define freea(p) /* nothing */ 
     107# define freea(p)              /* nothing */ 
    108108#else 
    109109# define alloca(n) malloc (n) 
     
    141141 
    142142/* 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) 
     143static size_t 
     144read_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) 
    152152{ 
    153153  static const char *locale_alias_path; 
     
    172172        retval = (struct alias_map *) bsearch (&item, map, nmap, 
    173173                                               sizeof (struct alias_map), 
    174                                                (int (*) (const void *, 
    175                                                         const void *
    176                                                ) alias_compare); 
     174                                               (int (*)(const void *, 
     175                                                        const void *)
     176                                              alias_compare); 
    177177      else 
    178178        retval = NULL; 
     
    213213 
    214214 
    215 static size_t 
    216 internal_function 
     215static size_t internal_function 
    217216read_alias_file (const char *fname, int fname_len) 
    218217{ 
     
    245244    { 
    246245      /* It is a reasonable approach to use a fix buffer here because 
    247         a) we are only interested in the first two fields 
    248         b) these fields must be usable as file names and so must not 
    249            be that long 
    250         We avoid a multi-kilobyte buffer here since this would use up 
    251         stack space which we might not have if the program ran out of 
    252         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.  */ 
    253252      char buf[400]; 
    254253      char *alias; 
     
    345344 
    346345      /* Possibly not the whole line fits into the buffer.  Ignore 
    347         the rest of the line.  */ 
     346        the rest of the line.  */ 
    348347      while (strchr (buf, '\n') == NULL) 
    349348        if (FGETS (buf, sizeof buf, fp) == NULL) 
     
    359358  if (added > 0) 
    360359    qsort (map, nmap, sizeof (struct alias_map), 
    361            (int (*) (const void *, const void *)) alias_compare); 
     360           (int (*)(const void *, const void *)) alias_compare); 
    362361 
    363362  return added; 
     
    400399    { 
    401400      /* 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.  */ 
    403402      c1 = isupper (*p1) ? tolower (*p1) : *p1; 
    404403      c2 = isupper (*p2) ? tolower (*p2) : *p2; 
  • sweep/branches/display-cache/intl/localename.c

    r183 r471  
    3939 
    4040#if defined _WIN32 || defined __WIN32__ 
    41 # undef WIN32   /* avoid warning on mingw32 */ 
     41# undef WIN32                  /* avoid warning on mingw32 */ 
    4242# define WIN32 
    4343#endif 
     
    714714     MacOS X 10.3.8 function 
    715715     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; 
    718722  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"
    850854  }; 
    851855 
    852856  /* Convert new-style locale names with language tags (ISO 639 and ISO 15924) 
    853857     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; 
    856864  static const langtag_entry langtag_table[] = { 
    857865    /* MacOS X has "az-Arab", "az-Cyrl", "az-Latn". 
    858866       The default script for az on Unix is Latin.  */ 
    859     { "az-Latn", "az" }, 
     867    {"az-Latn", "az"}, 
    860868    /* MacOS X has "ga-dots".  Does not yet exist on Unix.  */ 
    861     { "ga-dots", "ga" }, 
     869    {"ga-dots", "ga"}, 
    862870    /* MacOS X has "kk-Cyrl".  Does not yet exist on Unix.  */ 
    863871    /* MacOS X has "mn-Cyrl", "mn-Mong". 
    864872       The default script for mn on Unix is Cyrillic.  */ 
    865     { "mn-Cyrl", "mn" }, 
     873    {"mn-Cyrl", "mn"}, 
    866874    /* MacOS X has "ms-Arab", "ms-Latn". 
    867875       The default script for ms on Unix is Latin.  */ 
    868     { "ms-Latn", "ms" }, 
     876    {"ms-Latn", "ms"}, 
    869877    /* MacOS X has "tg-Cyrl". 
    870878       The default script for tg on Unix is Cyrillic.  */ 
    871     { "tg-Cyrl", "tg" }, 
     879    {"tg-Cyrl", "tg"}, 
    872880    /* MacOS X has "tk-Cyrl".  Does not yet exist on Unix.  */ 
    873881    /* MacOS X has "tt-Cyrl". 
    874882       The default script for tt on Unix is Cyrillic.  */ 
    875     { "tt-Cyrl", "tt" }, 
     883    {"tt-Cyrl", "tt"}, 
    876884    /* MacOS X has "zh-Hans", "zh-Hant". 
    877885       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"
    880888  }; 
    881889 
    882890  /* Convert script names (ISO 15924) to Unix conventions. 
    883891     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; 
    886898  static const script_entry script_table[] = { 
    887     { "Arab", "arabic" }, 
    888     { "Cyrl", "cyrillic" }, 
    889     { "Mong", "mongolian"
     899    {"Arab", "arabic"}, 
     900    {"Cyrl", "cyrillic"}, 
     901    {"Mong", "mongolian"
    890902  }; 
    891903 
     
    10171029  /* POSIX:2001 says: 
    10181030     "All implementations shall define a locale as the default locale, to be 
    1019       invoked when no environment variables are set, or set to the empty 
    1020       string.  This default locale can be the POSIX locale or any other 
    1021       implementation-defined locale.  Some implementations may provide 
    1022       facilities for local installation administrators to set the default 
    1023       locale, customizing it for each location.  POSIX:2001 does not require 
    1024       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.  */ 
    10251037 
    10261038#if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined(WIN32)) 
     
    10461058      { 
    10471059        char namebuf[256]; 
    1048 #  if HAVE_CFLOCALECOPYCURRENT /* MacOS X 10.3 or newer */ 
     1060#  if HAVE_CFLOCALECOPYCURRENT /* MacOS X 10.3 or newer */ 
    10491061        CFLocaleRef locale = CFLocaleCopyCurrent (); 
    10501062        CFStringRef name = CFLocaleGetIdentifier (locale); 
    10511063 
    1052         if (CFStringGetCString (name, namebuf, sizeof(namebuf), 
     1064        if (CFStringGetCString (name, namebuf, sizeof (namebuf), 
    10531065                                kCFStringEncodingASCII)) 
    10541066          { 
     
    10571069          } 
    10581070        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); 
    10631074        if (value != NULL 
    10641075            && CFGetTypeID (value) == CFStringGetTypeID () 
    1065             && CFStringGetCString ((CFStringRef)value, namebuf, sizeof(namebuf)
    1066                                    kCFStringEncodingASCII)) 
     1076            && CFStringGetCString ((CFStringRef) value, namebuf
     1077                                   sizeof (namebuf), kCFStringEncodingASCII)) 
    10671078          { 
    10681079            _nl_locale_name_canonicalize (namebuf); 
     
    10781089# endif 
    10791090 
    1080 # if defined(WIN32) /* WIN32 */ 
     1091# if defined(WIN32)            /* WIN32 */ 
    10811092  { 
    10821093    LCID lcid; 
     
    10991110    switch (primary) 
    11001111      { 
    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"; 
    11041118      case LANG_ARABIC: 
    11051119        switch (sub) 
    11061120          { 
    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"; 
    11231153          } 
    11241154        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"; 
    11271159      case LANG_AZERI: 
    11281160        switch (sub) 
    11291161          { 
    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"; 
    11331167          } 
    11341168        return "az"; 
     
    11361170        switch (sub) 
    11371171          { 
    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"; 
    11421178      case LANG_BENGALI: 
    11431179        switch (sub) 
    11441180          { 
    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"; 
    11471185          } 
    11481186        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"; 
    11541197      case LANG_CHINESE: 
    11551198        switch (sub) 
    11561199          { 
    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"; 
    11621210          } 
    11631211        return "zh"; 
    1164       case LANG_CROATIAN:       /* LANG_CROATIAN == LANG_SERBIAN 
     1212      case LANG_CROATIAN:      /* LANG_CROATIAN == LANG_SERBIAN 
    11651213                                 * What used to be called Serbo-Croatian 
    11661214                                 * should really now be two separate 
     
    11721220        switch (sub) 
    11731221          { 
    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"; 
    11771228          } 
    11781229        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"; 
    11821236      case LANG_DUTCH: 
    11831237        switch (sub) 
    11841238          { 
    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"; 
    11871243          } 
    11881244        return "nl"; 
    1189       case LANG_EDO: return "bin_NG"; 
     1245      case LANG_EDO: 
     1246        return "bin_NG"; 
    11901247      case LANG_ENGLISH: 
    11911248        switch (sub) 
    11921249          { 
    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"; 
    12151290          } 
    12161291        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"; 
    12211300      case LANG_FRENCH: 
    12221301        switch (sub) 
    12231302          { 
    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"; 
    12391333          } 
    12401334        return "fr"; 
    1241       case LANG_FRISIAN: return "fy_NL"; 
     1335      case LANG_FRISIAN: 
     1336        return "fy_NL"; 
    12421337      case LANG_FULFULDE: 
    12431338        /* Spoken in Nigeria, Guinea, Senegal, Mali, Niger, Cameroon, Benin.  */ 
     
    12461341        switch (sub) 
    12471342          { 
    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"; 
    12501347          } 
    12511348        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"; 
    12541353      case LANG_GERMAN: 
    12551354        switch (sub) 
    12561355          { 
    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"; 
    12621366          } 
    12631367        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"; 
    12681376      case LANG_HAWAIIAN: 
    12691377        /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers) 
    12701378           or Hawaii Creole English ("cpe_US", 600000 speakers)?  */ 
    12711379        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"; 
    12801396      case LANG_ITALIAN: 
    12811397        switch (sub) 
    12821398          { 
    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"; 
    12851403          } 
    12861404        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"; 
    12901411      case LANG_KASHMIRI: 
    12911412        switch (sub) 
    12921413          { 
    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"; 
    12951418          } 
    12961419        return "ks"; 
    1297       case LANG_KAZAK: return "kk_KZ"; 
     1420      case LANG_KAZAK: 
     1421        return "kk_KZ"; 
    12981422      case LANG_KONKANI: 
    12991423        /* FIXME: Adjust this when such locales appear on Unix.  */ 
    13001424        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"; 
    13081439      case LANG_MALAY: 
    13091440        switch (sub) 
    13101441          { 
    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"; 
    13131446          } 
    13141447        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"; 
    13171452      case LANG_MANIPURI: 
    13181453        /* FIXME: Adjust this when such locales appear on Unix.  */ 
    13191454        return "mni_IN"; 
    1320       case LANG_MARATHI: return "mr_IN"; 
     1455      case LANG_MARATHI: 
     1456        return "mr_IN"; 
    13211457      case LANG_MONGOLIAN: 
    13221458        switch (sub) 
    13231459          { 
    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".  */ 
    13271464      case LANG_NEPALI: 
    13281465        switch (sub) 
    13291466          { 
    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"; 
    13321471          } 
    13331472        return "ne"; 
     
    13351474        switch (sub) 
    13361475          { 
    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"; 
    13391480          } 
    13401481        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"; 
    13441488      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"; 
    13471492      case LANG_PORTUGUESE: 
    13481493        switch (sub) 
    13491494          { 
    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"; 
    13541501          } 
    13551502        return "pt"; 
     
    13571504        switch (sub) 
    13581505          { 
    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 */ 
    13611510          } 
    13621511        return "pa"; 
    1363       case LANG_RHAETO_ROMANCE: return "rm_CH"; 
     1512      case LANG_RHAETO_ROMANCE: 
     1513        return "rm_CH"; 
    13641514      case LANG_ROMANIAN: 
    13651515        switch (sub) 
    13661516          { 
    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"; 
    13691521          } 
    13701522        return "ro"; 
     
    13721524        switch (sub) 
    13731525          { 
    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"; 
    13791534      case LANG_SINDHI: 
    13801535        switch (sub) 
    13811536          { 
    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"; 
    13841541          } 
    13851542        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"; 
    13901551      case LANG_SORBIAN: 
    13911552        /* FIXME: Adjust this when such locales appear on Unix.  */ 
     
    13941555        switch (sub) 
    13951556          { 
    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"; 
    13981561          case SUBLANG_SPANISH_MODERN: 
    13991562            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"; 
    14171597          } 
    14181598        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"; 
    14211603      case LANG_SWEDISH: 
    14221604        switch (sub) 
    14231605          { 
    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"; 
    14261610          } 
    14271611        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"; 
    14311618      case LANG_TAMAZIGHT: 
    14321619        switch (sub) 
    14331620          { 
    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"; 
    14371626          } 
    14381627        return "ber_MA"; 
     
    14401629        switch (sub) 
    14411630          { 
    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"; 
    14491643      case LANG_TIGRINYA: 
    14501644        switch (sub) 
    14511645          { 
    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"; 
    14541650          } 
    14551651        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"; 
    14611662      case LANG_URDU: 
    14621663        switch (sub) 
    14631664          { 
    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"; 
    14661669          } 
    14671670        return "ur"; 
     
    14691672        switch (sub) 
    14701673          { 
    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"; 
    14731678          } 
    14741679        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"; 
    14841698      } 
    14851699  } 
  • sweep/branches/display-cache/intl/log.c

    r183 r471  
    2929/* Print an ASCII string with quotes and escape sequences where needed.  */ 
    3030static void 
    31 print_escaped (FILE *stream, const char *str) 
     31print_escaped (FILE * stream, const char *str) 
    3232{ 
    3333  putc ('"', stream); 
  • sweep/branches/display-cache/intl/os2compat.c

    r183 r471  
    2727 
    2828/* A version of getenv() that works from DLLs */ 
    29 extern unsigned long DosScanEnv (const unsigned char *pszName, unsigned char **ppszValue); 
     29extern unsigned long DosScanEnv (const unsigned char *pszName, 
     30                                 unsigned char **ppszValue); 
    3031 
    3132char * 
     
    4041 
    4142/* A fixed size buffer.  */ 
    42 char libintl_nl_default_dirname[MAXPATHLEN+1]; 
     43char libintl_nl_default_dirname[MAXPATHLEN + 1]; 
    4344 
    4445char *_nlos2_libdir = NULL; 
     
    4647char *_nlos2_localedir = NULL; 
    4748 
    48 static __attribute__((constructor)) void 
    49 nlos2_initialize () 
     49static __attribute__ ((constructor)) 
     50     void nlos2_initialize () 
    5051{ 
    5152  char *root = getenv ("UNIXROOT"); 
     
    5657    { 
    5758      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       
    6465      else 
    65         _nlos2_libdir = LIBDIR; 
     66       _nlos2_libdir = LIBDIR; 
    6667    } 
    6768 
     
    7071    { 
    7172      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; 
    8083    } 
    8184 
     
    8487    { 
    8588      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       
    9295      else 
    93         _nlos2_localedir = LOCALEDIR; 
     96       _nlos2_localedir = LOCALEDIR; 
    9497    } 
    9598 
  • sweep/branches/display-cache/intl/plural-exp.c

    r183 r471  
    3333/* These structs are the constant expression for the germanic plural 
    3434   form determination.  It represents the expression  "n != 1".  */ 
    35 static const struct expression plvar = 
    36 
     35static const struct expression plvar = { 
    3736  .nargs = 0, 
    3837  .operation = var, 
    3938}; 
    40 static const struct expression plone = 
    41 
     39static const struct expression plone = { 
    4240  .nargs = 0, 
    4341  .operation = num, 
    44   .val = 
    45   { 
    46     .num = 1 
    47   } 
     42  .val = { 
     43          .num = 1} 
    4844}; 
    49 struct expression GERMANIC_PLURAL = 
    50 
     45struct expression GERMANIC_PLURAL = { 
    5146  .nargs = 2, 
    5247  .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          } 
    6153}; 
    6254 
     
    9587#endif 
    9688 
    97 void 
    98 internal_function 
     89void internal_function 
    9990EXTRACT_PLURAL_EXPRESSION (const char *nullentry, struct expression **pluralp, 
    10091                           unsigned long int *npluralsp) 
  • sweep/branches/display-cache/intl/plural-exp.h

    r183 r471  
    102102#endif 
    103103 
    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; 
     104extern void 
     105FREE_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; 
    112113 
    113114#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); 
    116117#endif 
    117118 
  • sweep/branches/display-cache/intl/plural.c

    r183 r471  
    22   by GNU bison 1.35.  */ 
    33 
    4 #define YYBISON 1  /* Identify Bison output.  */ 
     4#define YYBISON 1              /* Identify Bison output.  */ 
    55 
    66#define yyparse __gettextparse 
     
    4343   because <config.h> may include arbitrary system headers.  */ 
    4444#if defined _AIX && !defined __GNUC__ 
    45  #pragma alloca 
     45#pragma alloca 
    4646#endif 
    4747 
     
    6565#line 49 "plural.y" 
    6666#ifndef YYSTYPE 
    67 typedef union { 
     67typedef union 
     68
    6869  unsigned long int num; 
    69   enum operator op; 
     70  enum operator op; 
    7071  struct expression *exp; 
    7172} yystype; 
     
    7677 
    7778/* Prototypes for local functions.  */ 
    78 static int yylex (YYSTYPE *lval, const char **pexp); 
     79static int yylex (YYSTYPE * lval, const char **pexp); 
    7980static void yyerror (const char *str); 
    8081 
     
    8283 
    8384static struct expression * 
    84 new_exp (int nargs, enum operator op, struct expression * const *args) 
     85new_exp (int nargs, enum operator op, struct expression *const *args) 
    8586{ 
    8687  int i; 
     
    103104    } 
    104105 
    105  fail: 
     106fail: 
    106107  for (i = nargs - 1; i >= 0; i--) 
    107108    FREE_EXPRESSION (args[i]); 
     
    111112 
    112113static inline struct expression * 
    113 new_exp_0 (enum operator op) 
     114new_exp_0 (enum operator op) 
    114115{ 
    115116  return new_exp (0, op, NULL); 
     
    117118 
    118119static inline struct expression * 
    119 new_exp_1 (enum operator op, struct expression *right) 
     120new_exp_1 (enum operator op, struct expression *right) 
    120121{ 
    121122  struct expression *args[1]; 
     
    126127 
    127128static struct expression * 
    128 new_exp_2 (enum operator op, struct expression *left, struct expression *right) 
     129new_exp_2 (enum operator  op, struct expression *left, 
     130           struct expression *right) 
    129131{ 
    130132  struct expression *args[2]; 
     
    136138 
    137139static inline struct expression * 
    138 new_exp_3 (enum operator op, struct expression *bexp, 
     140new_exp_3 (enum operator op, struct expression *bexp, 
    139141           struct expression *tbranch, struct expression *fbranch) 
    140142{ 
     
    161163 
    162164/* 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 
     165static 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 
    192193}; 
    193194 
    194195#if YYDEBUG 
    195 static const short yyprhs[] = 
    196 
    197        0,     0,     2,     8,    12,    16,    20,    24,    28,    32, 
    198       35,    37,    39 
     196static const short yyprhs[] = { 
     197  0, 0, 2, 8, 12, 16, 20, 24, 28, 32, 
     198  35, 37, 39 
    199199}; 
    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 
     200static 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 
    207206}; 
    208207 
     
    211210#if YYDEBUG 
    212211/* 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 
     212static const short yyrline[] = { 
     213  0, 150, 158, 162, 166, 170, 174, 178, 182, 186, 
     214  190, 194, 199 
    217215}; 
    218216#endif 
     
    222220 
    223221/* 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'", "'('", "')'",  
     222static const char *const yytname[] = { 
     223  "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2", 
     224  "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'", 
    228225  "start", "exp", 0 
    229226}; 
     
    231228 
    232229/* 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 
     230static const short yyr1[] = { 
     231  0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 
     232  17, 17, 17 
    237233}; 
    238234 
    239235/* 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 
     236static const short yyr2[] = { 
     237  0, 1, 5, 3, 3, 3, 3, 3, 3, 2, 
     238  1, 1, 3 
    244239}; 
    245240 
     
    247242   doesn't specify something else to do.  Zero means the default is an 
    248243   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 
     244static 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 
    254248}; 
    255249 
    256 static const short yydefgoto[] = 
    257 
    258       25,     5 
     250static const short yydefgoto[] = { 
     251  25, 5 
    259252}; 
    260253 
    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 
     254static 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 
    266258}; 
    267259 
    268 static const short yypgoto[] = 
    269 
    270   -32768,    -1 
     260static const short yypgoto[] = { 
     261  -32768, -1 
    271262}; 
    272263 
     
    275266 
    276267 
    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 
     268static 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 
    285275}; 
    286276 
    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 
     277static 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 
    295284}; 
     285 
    296286#define YYPURE 1 
    297287 
     
    359349# else 
    360350#  if defined (__STDC__) || defined (__cplusplus) 
    361 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 
     351#   include <stdlib.h>         /* INFRINGES ON USER NAME SPACE */ 
    362352#   define YYSIZE_T size_t 
    363353#  endif 
     
    442432#if ! defined (YYSIZE_T) 
    443433# if defined (__STDC__) || defined (__cplusplus) 
    444 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 
     434#  include <stddef.h>          /* INFRINGES ON USER NAME SPACE */ 
    445435#  define YYSIZE_T size_t 
    446436# endif 
     
    512502#   define YYLEX                yylex (&yylval) 
    513503#  endif 
    514 # endif /* !YYLSP_NEEDED */ 
     504# endif        /* !YYLSP_NEEDED */ 
    515505#else /* !YYPURE */ 
    516506# define YYLEX                  yylex () 
     
    522512 
    523513# ifndef YYFPRINTF 
    524 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 
     514#  include <stdio.h>           /* INFRINGES ON USER NAME SPACE */ 
    525515#  define YYFPRINTF fprintf 
    526516# endif 
     
    670660#if !YYPURE 
    671661YY_DECL_VARIABLES 
    672 #endif  /* !YYPURE */ 
    673  
    674 int 
     662#endif /* !YYPURE */ 
     663  int 
    675664yyparse (YYPARSE_PARAM_ARG) 
    676      YYPARSE_PARAM_DECL 
     665  YYPARSE_PARAM_DECL 
    677666{ 
    678667  /* If reentrant, generate the variables here. */ 
    679668#if YYPURE 
    680669  YY_DECL_VARIABLES 
    681 #endif  /* !YYPURE */ 
    682  
     670#endif /* !YYPURE */ 
    683671  register int yystate; 
    684672  register int yyn; 
     
    698686 
    699687  /* The state stack. */ 
    700   short        yyssa[YYINITDEPTH]; 
     688  short yyssa[YYINITDEPTH]; 
    701689  short *yyss = yyssa; 
    702690  register short *yyssp; 
     
    756744| yynewstate -- Push a new state, which is found in yystate.  | 
    757745`------------------------------------------------------------*/ 
    758  yynewstate: 
     746yynewstate: 
    759747  /* In all cases, when you get here, the value and location stacks 
    760748     have just been pushed. so pushing a state here evens the stacks. 
    761      */ 
     749   */ 
    762750  yyssp++; 
    763751 
    764  yysetstate: 
     752yysetstate: 
    765753  *yyssp = yystate; 
    766754 
     
    787775                    &yyss1, yysize * sizeof (*yyssp), 
    788776                    &yyvs1, yysize * sizeof (*yyvsp), 
    789                     &yyls1, yysize * sizeof (*yylsp), 
    790                     &yystacksize); 
     777                    &yyls1, yysize * sizeof (*yylsp), &yystacksize); 
    791778        yyls = yyls1; 
    792779# else 
    793780        yyoverflow ("parser stack overflow", 
    794781                    &yyss1, yysize * sizeof (*yyssp), 
    795                     &yyvs1, yysize * sizeof (*yyvsp), 
    796                     &yystacksize); 
     782                    &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); 
    797783# endif 
    798784        yyss = yyss1; 
     
    814800        union yyalloc *yyptr = 
    815801          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 
    816         if (! yyptr) 
     802        if (!yyptr) 
    817803          goto yyoverflowlab; 
    818804        YYSTACK_RELOCATE (yyss); 
     
    886872 
    887873#if YYDEBUG 
    888      /* We have to keep this `#if YYDEBUG', since we use variables 
    889        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.  */ 
    890876      if (yydebug) 
    891877        { 
     
    911897     Negative => reduce, -yyn is rule number. 
    912898     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. 
    915901     0, or most negative number => error.  */ 
    916902 
     
    929915 
    930916  /* 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])); 
    933918 
    934919  /* Discard the token being shifted unless it is eof.  */ 
     
    975960     unconditionally makes the parser a bit smaller, and it avoids a 
    976961     GCC warning that YYVAL may be used uninitialized.  */ 
    977   yyval = yyvsp[1-yylen]; 
     962  yyval = yyvsp[1 - yylen]; 
    978963 
    979964#if YYLSP_NEEDED 
    980965  /* Similarly for the default location.  Let the user run additional 
    981966     commands if for instance locations are ranges.  */ 
    982   yyloc = yylsp[1-yylen]; 
     967  yyloc = yylsp[1 - yylen]; 
    983968  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); 
    984969#endif 
     
    1001986#endif 
    1002987 
    1003   switch (yyn) { 
    1004  
    1005 case 1: 
     988  switch (yyn) 
     989    { 
     990 
     991    case 1: 
    1006992#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: 
    10141000#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: 
    10201007#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: 
    10261013#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: 
    10321019#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: 
    10381025#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: 
    10441031#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: 
    10501037#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: 
    10561043#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: 
    10621049#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: 
    10681055#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: 
    10751062#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   
    10811068 
    10821069#line 705 "/home/haible/gnu/arch/linuxlibc6/share/bison/bison.simple" 
    1083  
    10841070  
     1071 
    10851072  yyvsp -= yylen; 
    10861073  yyssp -= yylen; 
     
    11611148                    if (yycheck[yyx + yyn] == yyx) 
    11621149                      { 
    1163                         const char *yyq = ! yycount ? ", expecting " : " or "; 
     1150                        const char *yyq = !yycount ? ", expecting " : " or "; 
    11641151                        yyp = yystpcpy (yyp, yyq); 
    11651152                        yyp = yystpcpy (yyp, yytname[yyx]); 
     
    11871174    { 
    11881175      /* If just tried and failed to reuse lookahead token after an 
    1189         error, discard it.  */ 
     1176        error, discard it.  */ 
    11901177 
    11911178      /* return failure if at end of input */ 
     
    13111298  return yyresult; 
    13121299} 
     1300 
    13131301#line 205 "plural.y" 
    13141302 
    13151303 
    1316 void 
    1317 internal_function 
     1304void internal_function 
    13181305FREE_EXPRESSION (struct expression *exp) 
    13191306{ 
     
    13421329 
    13431330static int 
    1344 yylex (YYSTYPE *lval, const char **pexp) 
     1331yylex (YYSTYPE * lval, const char **pexp) 
    13451332{ 
    13461333  const char *exp = *pexp; 
     
    13641351  switch (result) 
    13651352    { 
    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': 
    13681363      { 
    13691364        unsigned long int n = result - '0'; 
  • sweep/branches/display-cache/intl/printf-args.c

    r183 r471  
    2727STATIC 
    2828#endif 
    29 int 
    30 printf_fetchargs (va_list args, arguments *a) 
     29  int 
     30printf_fetchargs (va_list args, arguments * a) 
    3131{ 
    3232  size_t i; 
     
    3737      { 
    3838      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); 
    4040        break; 
    4141      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); 
    4343        break; 
    4444      case TYPE_SHORT: 
    45         ap->a.a_short = va_arg (args, /*short*/ int); 
     45        ap->a.a_short = va_arg (args, /*short */ int); 
    4646        break; 
    4747      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); 
    4949        break; 
    5050      case TYPE_INT: 
  • sweep/branches/display-cache/intl/printf-args.h

    r183 r471  
    7171  TYPE_COUNT_LONGINT_POINTER 
    7272#ifdef HAVE_LONG_LONG 
    73 , TYPE_COUNT_LONGLONGINT_POINTER 
     73    , TYPE_COUNT_LONGLONGINT_POINTER 
    7474#endif 
    7575} arg_type; 
     
    8181  union 
    8282  { 
    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; 
    9191#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; 
    9494#endif 
    95     float                      a_float; 
    96     double                     a_double; 
     95    float a_float; 
     96    double a_double; 
    9797#ifdef HAVE_LONG_DOUBLE 
    98     long double                        a_longdouble; 
     98    long double a_longdouble; 
    9999#endif 
    100     int                                a_char; 
     100    int a_char; 
    101101#ifdef HAVE_WINT_T 
    102     wint_t                     a_wide_char; 
     102    wint_t a_wide_char; 
    103103#endif 
    104     const char*                        a_string; 
     104    const char *a_string; 
    105105#ifdef HAVE_WCHAR_T 
    106     const wchar_t*             a_wide_string; 
     106    const wchar_t *a_wide_string; 
    107107#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; 
    113113#ifdef HAVE_LONG_LONG 
    114     long long int *            a_count_longlongint_pointer; 
     114    long long int *a_count_longlongint_pointer; 
    115115#endif 
    116116  } 
     
    133133extern 
    134134#endif 
    135 int printf_fetchargs (va_list args, arguments *a); 
     135int printf_fetchargs (va_list args, arguments * a); 
    136136 
    137137#endif /* _PRINTF_ARGS_H */ 
  • sweep/branches/display-cache/intl/printf-parse.c

    r183 r471  
    6060STATIC 
    6161#endif 
    62 int 
    63 PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) 
     62  int 
     63PRINTF_PARSE (const CHAR_T * format, DIRECTIVES * d, arguments * a) 
    6464{ 
    65   const CHAR_T *cp = format;           /* pointer into format */ 
     65  const CHAR_T *cp = format;    /* pointer into format */ 
    6666  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 */ 
    6969  size_t max_width_length = 0; 
    7070  size_t max_precision_length = 0; 
     
    119119        { 
    120120          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 */ 
    122122 
    123123          /* Initialize the next directive.  */ 
     
    349349                    { 
    350350                      /* 'z' is standardized in ISO C 99, but glibc uses 'Z' 
    351                         because the warning facility in gcc-2.95.2 understands 
    352                         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).  */ 
    353353                      if (sizeof (size_t) > sizeof (long)) 
    354354                        { 
     
    385385              switch (c) 
    386386                { 
    387                 case 'd': case 'i': 
     387                case 'd': 
     388                case 'i': 
    388389#ifdef HAVE_LONG_LONG 
    389390                  if (flags >= 16 || (flags & 4)) 
     
    400401                    type = TYPE_INT; 
    401402                  break; 
    402                 case 'o': case 'u': case 'x': case 'X': 
     403                case 'o': 
     404                case 'u': 
     405                case 'x': 
     406                case 'X': 
    403407#ifdef HAVE_LONG_LONG 
    404408                  if (flags >= 16 || (flags & 4)) 
     
    415419                    type = TYPE_UINT; 
    416420                  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': 
    419429#ifdef HAVE_LONG_DOUBLE 
    420430                  if (flags >= 16 || (flags & 4)) 
     
    422432                  else 
    423433#endif 
    424                   type = TYPE_DOUBLE; 
     434                    type = TYPE_DOUBLE; 
    425435                  break; 
    426436                case 'c': 
  • sweep/branches/display-cache/intl/printf-parse.h

    r183 r471  
    3737typedef struct 
    3838{ 
    39   const char* dir_start; 
    40   const char* dir_end; 
     39  const char *dir_start; 
     40  const char *dir_end; 
    4141  int flags; 
    42   const char* width_start; 
    43   const char* width_end; 
     42  const char *width_start; 
     43  const char *width_end; 
    4444  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; 
    4747  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 */ 
    4949  size_t arg_index; 
    5050} 
     
    7171extern 
    7272#endif 
    73 int printf_parse (const char *format, char_directives *d, arguments *a); 
     73int printf_parse (const char *format, char_directives * d, arguments * a); 
    7474 
    7575#endif /* _PRINTF_PARSE_H */ 
  • sweep/branches/display-cache/intl/printf.c

    r409 r471  
    3434#  else 
    3535#   ifdef _AIX 
    36  #pragma alloca 
     36#pragma alloca 
    3737#   else 
    3838#    ifndef alloca 
     
    7171#define vasnprintf libintl_vasnprintf 
    7272#include "vasnprintf.c" 
    73 #if 0 /* not needed */ 
     73#if 0                          /* not needed */ 
    7474#define asnprintf libintl_asnprintf 
    7575#include "asnprintf.c" 
    7676#endif 
    7777 
    78 DLL_EXPORTED 
    79 int 
    80 libintl_vfprintf (FILE *stream, const char *format, va_list args) 
     78DLL_EXPORTED int 
     79libintl_vfprintf (FILE * stream, const char *format, va_list args) 
    8180{ 
    8281  if (strchr (format, '$') == NULL) 
     
    9796} 
    9897 
    99 DLL_EXPORTED 
    100 int 
    101 libintl_fprintf (FILE *stream, const char *format, ...) 
     98DLL_EXPORTED int 
     99libintl_fprintf (FILE * stream, const char *format, ...) 
    102100{ 
    103101  va_list args; 
     
    110108} 
    111109 
    112 DLL_EXPORTED 
    113 int 
     110DLL_EXPORTED int 
    114111libintl_vprintf (const char *format, va_list args) 
    115112{ 
     
    117114} 
    118115 
    119 DLL_EXPORTED 
    120 int 
     116DLL_EXPORTED int 
    121117libintl_printf (const char *format, ...) 
    122118{ 
     
    140136# endif 
    141137 
    142 DLL_EXPORTED 
    143 int 
    144 libintl_vsnprintf (char *resultbuf, size_t length, const char *format, va_list args) 
     138DLL_EXPORTED int 
     139libintl_vsnprintf (char *resultbuf, size_t length, const char *format, 
     140                  va_list args) 
    145141{ 
    146142  if (strchr (format, '$') == NULL) 
     
    167163} 
    168164 
    169 DLL_EXPORTED 
    170 int 
     165DLL_EXPORTED int 
    171166libintl_snprintf (char *resultbuf, size_t length, const char *format, ...) 
    172167{ 
     
    184179#if HAVE_ASPRINTF 
    185180 
    186 DLL_EXPORTED 
    187 int 
     181DLL_EXPORTED int 
    188182libintl_vasprintf (char **resultp, const char *format, va_list args) 
    189183{ 
     
    196190} 
    197191 
    198 DLL_EXPORTED 
    199 int 
     192DLL_EXPORTED int 
    200193libintl_asprintf (char **resultp, const char *format, ...) 
    201194{ 
     
    223216#define vasnwprintf libintl_vasnwprintf 
    224217#include "vasnprintf.c" 
    225 #if 0 /* not needed */ 
     218#if 0                          /* not needed */ 
    226219#define asnwprintf libintl_asnwprintf 
    227220#include "asnprintf.c" 
     
    236229# endif 
    237230 
    238 DLL_EXPORTED 
    239 int 
    240 libintl_vfwprintf (FILE *stream, const wchar_t *format, va_list args) 
     231DLL_EXPORTED int 
     232libintl_vfwprintf (FILE * stream, const wchar_t * format, va_list args) 
    241233{ 
    242234  if (wcschr (format, '$') == NULL) 
     
    261253} 
    262254 
    263 DLL_EXPORTED 
    264 int 
    265 libintl_fwprintf (FILE *stream, const wchar_t *format, ...) 
     255DLL_EXPORTED int 
     256libintl_fwprintf (FILE * stream, const wchar_t * format, ...) 
    266257{ 
    267258  va_list args; 
     
    274265} 
    275266 
    276 DLL_EXPORTED 
    277 int 
    278 libintl_vwprintf (const wchar_t *format, va_list args) 
     267DLL_EXPORTED int 
     268libintl_vwprintf (const wchar_t * format, va_list args) 
    279269{ 
    280270  return libintl_vfwprintf (stdout, format, args); 
    281271} 
    282272 
    283 DLL_EXPORTED 
    284 int 
    285 libintl_wprintf (const wchar_t *format, ...) 
     273DLL_EXPORTED int 
     274libintl_wprintf (const wchar_t * format, ...) 
    286275{ 
    287276  va_list args; 
     
    294283} 
    295284 
    296 DLL_EXPORTED 
    297 int 
    298 libintl_vswprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, va_list args) 
     285DLL_EXPORTED int 
     286libintl_vswprintf (wchar_t * resultbuf, size_t length, const wchar_t * format, 
     287                  va_list args) 
    299288{ 
    300289  if (wcschr (format, '$') == NULL) 
     
    303292    { 
    304293      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); 
    306296      if (result != resultbuf) 
    307297        { 
     
    321311} 
    322312 
    323 DLL_EXPORTED 
    324 int 
    325 libintl_swprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, ...) 
     313DLL_EXPORTED int 
     314libintl_swprintf (wchar_t * resultbuf, size_t length, const wchar_t * format, 
     315                ...) 
    326316{ 
    327317  va_list args; 
  • sweep/branches/display-cache/intl/relocatable.c

    r183 r471  
    109109  if (orig_prefix_arg != NULL && curr_prefix_arg != NULL 
    110110      /* Optimization: if orig_prefix and curr_prefix are equal, the 
    111         relocation is a nop.  */ 
     111        relocation is a nop.  */ 
    112112      && strcmp (orig_prefix_arg, curr_prefix_arg) != 0) 
    113113    { 
     
    142142   instead of "/").  */ 
    143143void 
    144 set_relocation_prefix (const char *orig_prefix_arg, const char *curr_prefix_arg) 
     144set_relocation_prefix (const char *orig_prefix_arg, 
     145                       const char *curr_prefix_arg) 
    145146{ 
    146147  set_this_relocation_prefix (orig_prefix_arg, curr_prefix_arg); 
     
    170171const char * 
    171172compute_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) 
    174174{ 
    175175  const char *curr_installdir; 
     
    182182     This is simply the difference between orig_installprefix and 
    183183     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) 
    186186    /* Shouldn't happen - nothing should be installed outside $(prefix).  */ 
    187187    return NULL; 
     
    190190  /* Determine the current installation directory.  */ 
    191191  { 
    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); 
    193194    const char *p = curr_pathname + strlen (curr_pathname); 
    194195    char *q; 
     
    341342 
    342343                  ungetc (c, fp); 
    343                   shared_library_fullname = NULL; size = 0; 
     344                  shared_library_fullname = NULL; 
     345                  size = 0; 
    344346                  len = getline (&shared_library_fullname, &size, fp); 
    345347                  if (len >= 0) 
     
    393395    { 
    394396      /* At this point, orig_prefix and curr_prefix likely have already been 
    395         set through the main program's set_program_name_and_installdir 
    396         function.  This is sufficient in the case that the library has 
    397         initially been installed in the same orig_prefix.  But we can do 
    398         better, to also cover the cases that 1. it has been installed 
    399         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 from 
    401         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.  */ 
    402404      const char *orig_installprefix = INSTALLPREFIX; 
    403405      const char *orig_installdir = INSTALLDIR; 
  • sweep/branches/display-cache/intl/relocatable.h

    r183 r471  
    2222 
    2323#ifdef __cplusplus 
    24 extern "C" { 
     24extern "C" 
     25
    2526#endif 
    2627 
     
    4344   prefixes should be directory names without trailing slash (i.e. use "" 
    4445   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); 
    4848 
    4949/* Returns the pathname, relocated according to the current installation 
    5050   directory.  */ 
    51 extern const char * relocate (const char *pathname); 
     51  extern const char *relocate (const char *pathname); 
    5252 
    5353/* Memory management: relocate() leaks memory, because it has to construct 
     
    5959   installation prefix, the original installation directory of a particular 
    6060   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); 
    6464 
    6565#else 
     
    7575#endif 
    7676 
    77 #endif /* _RELOCATABLE_H */ 
     77#endif                         /* _RELOCATABLE_H */ 
  • sweep/branches/display-cache/intl/textdomain.c

    r183 r471  
    7373/* Lock variable to protect the global data in the gettext implementation.  */ 
    7474__libc_rwlock_define (extern, _nl_state_lock attribute_hidden) 
    75  
    7675/* Set the current default message catalog to DOMAINNAME. 
    7776   If DOMAINNAME is null, return the current default. 
    7877   If DOMAINNAME is "", reset to the default of "messages".  */ 
    79 char * 
    80 TEXTDOMAIN (const char *domainname) 
     78     char *TEXTDOMAIN (const char *domainname) 
    8179{ 
    8280  char *new_domain; 
     
    105103    { 
    106104      /* If the following malloc fails `_nl_current_default_domain' 
    107         will be NULL.  This value will be returned and so signals we 
    108         are out of core.  */ 
     105        will be NULL.  This value will be returned and so signals we 
     106        are out of core.  */ 
    109107#if defined _LIBC || defined HAVE_STRDUP 
    110108      new_domain = strdup (domainname); 
     
    127125      ++_nl_msg_cat_cntr; 
    128126 
    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) 
    130129        free (old_domain); 
    131130    } 
  • sweep/branches/display-cache/intl/vasnprintf.c

    r409 r471  
    3838#endif 
    3939 
    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 */ 
    4646#if WIDE_CHAR_VERSION 
    4747# include "wprintf-parse.h" 
     
    6969#   define local_wcslen_defined 1 
    7070static size_t 
    71 local_wcslen (const wchar_t *s) 
     71local_wcslen (const wchar_t * s) 
    7272{ 
    7373  const wchar_t *ptr; 
     
    113113 
    114114CHAR_T * 
    115 VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list args) 
     115VASNPRINTF (CHAR_T * resultbuf, size_t * lengthp, const CHAR_T * format, 
     116            va_list args) 
    116117{ 
    117118  DIRECTIVES d; 
     
    210211      } 
    211212 
    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++) 
    213214      { 
    214215        if (cp != dp->dir_start) 
     
    259260#ifdef HAVE_LONG_LONG 
    260261                  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; 
    262264                    break; 
    263265#endif 
     
    307309                  case TYPE_ULONGLONGINT: 
    308310                    *p++ = 'l'; 
    309                     /*FALLTHROUGH*/ 
     311                    /*FALLTHROUGH*/ 
    310312#endif 
    311313                  case TYPE_LONGINT: 
     
    342344                    if (!(a.arg[dp->width_arg_index].type == TYPE_INT)) 
    343345                      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; 
    345348                  } 
    346349                if (dp->precision_arg_index != ARG_NONE) 
     
    348351                    if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) 
    349352                      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; 
    351355                  } 
    352356 
     
    436440                      case TYPE_ULONGINT: 
    437441                        { 
    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; 
    439444                          SNPRINTF_BUF (arg); 
    440445                        } 
     
    443448                      case TYPE_LONGLONGINT: 
    444449                        { 
    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; 
    446452                          SNPRINTF_BUF (arg); 
    447453                        } 
     
    449455                      case TYPE_ULONGLONGINT: 
    450456                        { 
    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; 
    452459                          SNPRINTF_BUF (arg); 
    453460                        } 
     
    463470                      case TYPE_LONGDOUBLE: 
    464471                        { 
    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; 
    466474                          SNPRINTF_BUF (arg); 
    467475                        } 
     
    491499                      case TYPE_WIDE_STRING: 
    492500                        { 
    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; 
    494503                          SNPRINTF_BUF (arg); 
    495504                        } 
     
    568577                    if (count >= tmp_length) 
    569578                      /* tmp_length was incorrectly calculated - fix the 
    570                         code above!  */ 
     579                        code above!  */ 
    571580                      abort (); 
    572581#endif 
  • sweep/branches/display-cache/intl/vasnprintf.h

    r183 r471  
    2929/* This feature is available in gcc versions 2.5 and later.  */ 
    3030# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ 
    31 #  define __attribute__(Spec) /* empty */ 
     31#  define __attribute__(Spec)  /* empty */ 
    3232# endif 
    3333/* The __-protected variants of `format' and `printf' attributes 
     
    4040 
    4141#ifdef  __cplusplus 
    42 extern "C" { 
     42extern "C" 
     43
    4344#endif 
    4445 
     
    6768            } 
    6869  */ 
    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))); 
    7376 
    7477#ifdef  __cplusplus 
     
    7679#endif 
    7780 
    78 #endif /* _VASNPRINTF_H */ 
     81#endif                         /* _VASNPRINTF_H */ 
  • sweep/branches/display-cache/intl/vasnwprintf.h

    r183 r471  
    2727 
    2828#ifdef  __cplusplus 
    29 extern "C" { 
     29extern "C" 
     30
    3031#endif 
    3132 
     
    3738   number of resulting bytes, excluding the trailing NUL.  Upon error, set 
    3839   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); 
    4144 
    4245#ifdef  __cplusplus 
     
    4447#endif 
    4548 
    46 #endif /* _VASNWPRINTF_H */ 
     49#endif                         /* _VASNWPRINTF_H */ 
  • sweep/branches/display-cache/intl/wprintf-parse.h

    r183 r471  
    3737typedef struct 
    3838{ 
    39   const wchar_t* dir_start; 
    40   const wchar_t* dir_end; 
     39  const wchar_t *dir_start; 
     40  const wchar_t *dir_end; 
    4141  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; 
    4444  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; 
    4747  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 */ 
    4949  size_t arg_index; 
    5050} 
     
    7171extern 
    7272#endif 
    73 int wprintf_parse (const wchar_t *format, wchar_t_directives *d, arguments *a); 
     73int wprintf_parse (const wchar_t * format, wchar_t_directives * d, 
     74                   arguments * a); 
    7475 
    7576#endif /* _WPRINTF_PARSE_H */ 
  • sweep/branches/display-cache/intl/xsize.h

    r183 r471  
    5353static inline size_t 
    5454#if __GNUC__ >= 3 
    55 __attribute__ ((__pure__)) 
     55  __attribute__ ((__pure__)) 
    5656#endif 
    57 xsum (size_t size1, size_t size2) 
     57  xsum (size_t size1, size_t size2) 
    5858{ 
    5959  size_t sum = size1 + size2; 
     
    6464static inline size_t 
    6565#if __GNUC__ >= 3 
    66 __attribute__ ((__pure__)) 
     66  __attribute__ ((__pure__)) 
    6767#endif 
    68 xsum3 (size_t size1, size_t size2, size_t size3) 
     68  xsum3 (size_t size1, size_t size2, size_t size3) 
    6969{ 
    7070  return xsum (xsum (size1, size2), size3); 
     
    7474static inline size_t 
    7575#if __GNUC__ >= 3 
    76 __attribute__ ((__pure__)) 
     76  __attribute__ ((__pure__)) 
    7777#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) 
    7979{ 
    8080  return xsum (xsum (xsum (size1, size2), size3), size4); 
     
    8484static inline size_t 
    8585#if __GNUC__ >= 3 
    86 __attribute__ ((__pure__)) 
     86  __attribute__ ((__pure__)) 
    8787#endif 
    88 xmax (size_t size1, size_t size2) 
     88  xmax (size_t size1, size_t size2) 
    8989{ 
    9090  /* No explicit check is needed here, because for any n: 
  • sweep/branches/display-cache/plugins/byenergy/byenergy.c

    r124 r471  
    3030 
    3131static 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, 
     33lower: {f:0.001}, 
     34step: {f:0.001} 
    3535}; 
    3636 
    3737static sw_param_range threshold_range = { 
    3838  SW_RANGE_ALL_VALID, 
    39   lower: {f: 0.0}, 
    40   upper: {f: 1.0}, 
    41   step:  {f: 0.01} 
     39lower: {f:0.0}, 
     40upper: {f:1.0}, 
     41step: {f:0.01} 
    4242}; 
    4343 
    4444static 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, 
     46lower: {f:0.0}, 
     47step: {f:0.01} 
    4848}; 
    4949 
    5050static 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, 
     52lower: {f:0.0}, 
     53step: {f:0.01} 
    5454}; 
    5555 
    5656static sw_param_spec param_specs[] = { 
    5757  { 
    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 
    9393}; 
    9494 
    9595static void 
    96 by_energy_suggest (sw_sample * sample, sw_param_set pset, gpointer custom_data) 
     96by_energy_suggest (sw_sample * sample, sw_param_set pset, 
     97                   gpointer custom_data) 
    9798{ 
    9899  pset[0].b = FALSE; 
     
    112113  gfloat max_interruption_f = pset[4].f; 
    113114 
    114   sw_sounddata * sounddata; 
    115   sw_audio_t * d; 
     115  sw_sounddata *sounddata; 
     116  sw_audio_t *d; 
    116117  glong window, win_s; 
    117118  gint i, doff; 
    118119  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; 
    122123 
    123124  sounddata = sample_get_sounddata (s); 
    124125 
    125   window = (glong)(resolution * (gfloat)sounddata->format->rate); 
     126  window = (glong) (resolution * (gfloat) sounddata->format->rate); 
    126127  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); 
    128129 
    129130  /* 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; 
    134136 
    135137  sounddata_lock_selection (sounddata); 
     
    141143  length = sounddata->nr_frames; 
    142144  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; 
    152165    } 
    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   } 
    162166 
    163167  factor = SW_AUDIO_T_MAX / max_energy; 
     
    167171#endif 
    168172 
    169   threshold *= (gfloat)max_energy; 
     173  threshold *= (gfloat) max_energy; 
    170174 
    171175  length = sounddata->nr_frames; 
    172176  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; 
    182226    } 
    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        } 
    208234    } 
    209235 
    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  
    220236  sounddata_unlock_selection (sounddata); 
    221237} 
    222238 
    223239static sw_op_instance * 
    224 apply_by_energy(sw_sample * sample, sw_param_set pset, gpointer custom_data) 
     240apply_by_energy (sw_sample * sample, sw_param_set pset, gpointer custom_data) 
    225241{ 
    226242  return 
    227243    perform_selection_op (sample, _("Select by energy"), 
    228                           (SweepFilter)select_by_energy, pset, NULL); 
     244                          (SweepFilter) select_by_energy, pset, NULL); 
    229245} 
    230246 
     
    235251  "Copyright (C) 2000 CSIRO Australia", 
    236252  "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() */ 
    243259  apply_by_energy, 
    244   NULL, /* custom data */ 
     260  NULL,                                /* custom data */ 
    245261}; 
    246262 
     
    248264by_energy_init (void) 
    249265{ 
    250   return g_list_append ((GList *)NULL, &proc_by_energy); 
     266  return g_list_append ((GList *) NULL, &proc_by_energy); 
    251267} 
    252268 
    253269 
    254270sw_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  
    3636 
    3737static 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, 
     39lower: {f:0.0}, 
     40step: {f:0.001} 
    4141}; 
    4242 
    4343static sw_param_range gain_range = { 
    4444  SW_RANGE_ALL_VALID, 
    45   lower: {f: 0.0}, 
    46   upper: {f: 1.0}, 
    47   step: {f: 0.01} 
     45lower: {f:0.0}, 
     46upper: {f:1.0}, 
     47step: {f:0.01} 
    4848}; 
    4949 
     
    5151static sw_param_spec param_specs[] = { 
    5252  { 
    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}, 
    6059  { 
    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}, 
    6866}; 
    6967 
     
    8381 
    8482  sw_framecount_t i, delay_f, dlen_s; 
    85   sw_audio_t * d, * e; 
     83  sw_audio_t *d, *e; 
    8684  gpointer ep; 
    8785 
    8886  delay_f = time_to_frames (format, delay); 
    8987 
    90   d = (sw_audio_t *)data; 
     88  d = (sw_audio_t *) data; 
    9189  ep = data + frames_to_bytes (format, delay_f); 
    92   e = (sw_audio_t *)ep; 
     90  e = (sw_audio_t *) ep; 
    9391 
    94   if (delay > nr_frames) return; 
     92  if (delay > nr_frames) 
     93    return; 
    9594 
    9695  dlen_s = frames_to_samples (format, nr_frames - delay_f); 
    9796 
    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    } 
    101101} 
    102102 
     
    106106  return 
    107107    perform_filter_region_op (sample, _("Echo"), 
    108                               (SweepFilterRegion)region_echo, pset, NULL); 
     108                              (SweepFilterRegion) region_echo, pset, NULL); 
    109109} 
    110110 
     
    116116  "Copyright (C) 2000", 
    117117  "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() */ 
    124124  echo_apply, 
    125   NULL, /* custom_data */ 
     125  NULL,                                /* custom_data */ 
    126126}; 
    127127 
     
    129129echo_init (void) 
    130130{ 
    131   return g_list_append ((GList *)NULL, &proc_echo); 
     131  return g_list_append ((GList *) NULL, &proc_echo); 
    132132} 
    133133 
    134134 
    135135sw_plugin plugin = { 
    136   echo_init, /* plugin_init */ 
    137   NULL, /* plugin_cleanup */ 
     136  echo_init,                   /* plugin_init */ 
     137  NULL,                                /* plugin_cleanup */ 
    138138}; 
  • sweep/branches/display-cache/plugins/example/example.c

    r75 r471  
    3434 
    3535static 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")} 
    4141}; 
    4242 
    4343static 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} 
    5252}; 
    5353 
    5454static sw_param_spec example_filter_region_param_specs[] = { 
    5555  { 
    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}, 
    6362  { 
    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}, 
    7169  { 
    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} 
    7976}; 
    8077 
     
    9390{ 
    9491  gboolean flim = pset[0].b; 
    95   gchar * beans = pset[1].s; 
     92  gchar *beans = pset[1].s; 
    9693  gint nr_pants = pset[2].i; 
    9794 
    98   if (flim) { 
    99     /* manage flim */ 
    100   } 
     95  if (flim) 
     96    { 
     97      /* manage flim */ 
     98    } 
    10199 
    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    } 
    107108 
    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    } 
    112114 
    113115  /* Do filtering stuff */ 
     
    121123  return 
    122124    perform_filter_region_op (sample, _("Example Filter Region"), 
    123                               (SweepFilterRegion)example_filter_region_func, 
     125                              (SweepFilterRegion) example_filter_region_func, 
    124126                              pset, NULL); 
    125127} 
     
    132134  "Copyright (C) 2000", 
    133135  "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() */ 
    140142  example_filter_region_apply, 
    141   NULL, /* custom_data */ 
     143  NULL,                                /* custom_data */ 
    142144}; 
    143145 
     
    145147example_init (void) 
    146148{ 
    147   return g_list_append ((GList *)NULL, &proc_example_filter_region); 
     149  return g_list_append ((GList *) NULL, &proc_example_filter_region); 
    148150} 
    149151 
    150152 
    151153sw_plugin plugin = { 
    152   example_init, /* plugin_init */ 
    153   NULL, /* plugin_cleanup */ 
     154  example_init,                        /* plugin_init */ 
     155  NULL,                                /* plugin_cleanup */ 
    154156}; 
  • sweep/branches/display-cache/plugins/fade/fade.c

    r124 r471  
    2626#include <sweep/sweep.h> 
    2727 
    28 #include <../src/sweep_app.h> /* XXX */ 
     28#include <../src/sweep_app.h>  /* XXX */ 
    2929 
    3030static sw_sample * 
    3131fade (sw_sample * sample, gfloat start, gfloat end) 
    3232{ 
    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; 
    3838  gfloat factor = start; 
    3939  sw_framecount_t op_total, run_total; 
     
    4747 
    4848  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; 
    5051  run_total = 0; 
    5152 
    5253#if 0 
    5354  /* 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); 
    7495        } 
    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); 
    8496    } 
    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; 
    88100#endif 
    89101 
    90102  /* 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); 
    112143        } 
    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); 
    122144    } 
    123   } 
    124145 
    125146  return sample; 
     
    142163{ 
    143164  return 
    144     perform_filter_op (sample, _("Fade in"), (SweepFilter)fade_in, 
     165    perform_filter_op (sample, _("Fade in"), (SweepFilter) fade_in, 
    145166                       pset, NULL); 
    146167} 
     
    150171{ 
    151172  return 
    152     perform_filter_op (sample, _("Fade out"), (SweepFilter)fade_out, 
     173    perform_filter_op (sample, _("Fade out"), (SweepFilter) fade_out, 
    153174                       pset, NULL); 
    154175} 
     
    160181  "Copyright (C) 2002", 
    161182  "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() */ 
    168189  apply_fade_in, 
    169   NULL, /* custom_data */ 
     190  NULL,                                /* custom_data */ 
    170191}; 
    171192 
     
    176197  "Copyright (C) 2002", 
    177198  "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() */ 
    184205  apply_fade_out, 
    185   NULL, /* custom_data */ 
     206  NULL,                                /* custom_data */ 
    186207}; 
    187    
     208 
    188209static GList * 
    189210fade_init (void) 
    190211{ 
    191   GList * gl = NULL; 
     212  GList *gl = NULL; 
    192213 
    193214  gl = g_list_append (gl, &proc_fade_in); 
     
    199220 
    200221sw_plugin plugin = { 
    201   fade_init, /* plugin_init */ 
    202   NULL, /* plugin_cleanup */ 
     222  fade_init,                   /* plugin_init */ 
     223  NULL,                                /* plugin_cleanup */ 
    203224}; 
  • sweep/branches/display-cache/plugins/ladspa/ladspa.h

    r124 r471  
    2424 
    2525#ifdef __cplusplus 
    26 extern "C" { 
     26extern "C" 
     27
    2728#endif 
    2829 
     
    7879   amplitude and is a `normal' signal level. */ 
    7980 
    80 typedef float LADSPA_Data; 
     81  typedef float LADSPA_Data; 
    8182 
    8283/*****************************************************************************/ 
     
    8889   properties together. */ 
    8990 
    90 typedef int LADSPA_Properties; 
     91  typedef int LADSPA_Properties; 
    9192 
    9293/* Property LADSPA_PROPERTY_REALTIME indicates that the plugin has a 
     
    146147   and that a port must be a control or audio port but not both. */ 
    147148 
    148 typedef int LADSPA_PortDescriptor; 
     149  typedef int LADSPA_PortDescriptor; 
    149150 
    150151/* Property LADSPA_PORT_INPUT indicates that the port is an input. */ 
     
    194195   LADSPA_PortRangeHint structure. */ 
    195196 
    196 typedef int LADSPA_PortRangeHintDescriptor; 
     197  typedef int LADSPA_PortRangeHintDescriptor; 
    197198 
    198199/* Hint LADSPA_HINT_BOUNDED_BELOW indicates that the LowerBound field 
     
    331332                                         == LADSPA_HINT_DEFAULT_440) 
    332333 
    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; 
    349351 
    350352/*****************************************************************************/ 
     
    357359   may use it to reference internal instance data. */ 
    358360 
    359 typedef void * LADSPA_Handle; 
     361  typedef void *LADSPA_Handle; 
    360362 
    361363/*****************************************************************************/ 
     
    367369   buffers and workspaces and to run it. */ 
    368370 
    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; 
    557556 
    558557/**********************************************************************/ 
     
    583582   for the least index that results in NULL being returned. */ 
    584583 
    585 const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index); 
     584  const LADSPA_Descriptor *ladspa_descriptor (unsigned long Index); 
    586585 
    587586/* 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); 
    590589 
    591590/**********************************************************************/ 
     
    595594#endif 
    596595 
    597 #endif /* LADSPA_INCLUDED */ 
     596#endif                         /* LADSPA_INCLUDED */ 
    598597 
    599598/* EOF */ 
  • sweep/branches/display-cache/plugins/ladspa/ladspameta.c

    r130 r471  
    3030#include <dirent.h> 
    3131#include <string.h> 
    32 #include <math.h> /* for ceil() */ 
     32#include <math.h>              /* for ceil() */ 
    3333 
    3434#include <glib.h> 
     
    5959#define LADSPA_frames_to_bytes(f) (f * sizeof(LADSPA_Data)) 
    6060 
    61 static char * default_ladspa_path = "/usr/lib/ladspa:/usr/local/lib/ladspa:/opt/ladspa/lib"; 
    62  
    63 static GList * modules_list = NULL; 
     61static char *default_ladspa_path = 
     62  "/usr/lib/ladspa:/usr/local/lib/ladspa:/opt/ladspa/lib"; 
     63 
     64static GList *modules_list = NULL; 
    6465static gboolean ladspa_meta_initialised = FALSE; 
    6566 
     
    7374 */ 
    7475static gboolean 
    75 is_usable(const LADSPA_Descriptor * d) 
     76is_usable (const LADSPA_Descriptor * d) 
    7677{ 
    7778  LADSPA_PortDescriptor pd; 
    7879  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; 
    9294 
    9395  /* 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 */ 
    97102 
    98103  return (nr_ai == nr_ao); 
     
    102107convert_type (const LADSPA_PortRangeHintDescriptor prhd) 
    103108{ 
    104   if (LADSPA_IS_HINT_TOGGLED(prhd)) 
     109  if (LADSPA_IS_HINT_TOGGLED (prhd)) 
    105110    return SWEEP_TYPE_BOOL; 
    106   else if (LADSPA_IS_HINT_INTEGER(prhd)) 
     111  else if (LADSPA_IS_HINT_INTEGER (prhd)) 
    107112    return SWEEP_TYPE_INT; 
    108113  else 
     
    113118get_valid_mask (const LADSPA_PortRangeHintDescriptor prhd) 
    114119{ 
    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)) 
    118123    ret |= SW_RANGE_LOWER_BOUND_VALID; 
    119   if (LADSPA_IS_HINT_BOUNDED_ABOVE(prhd)) 
     124  if (LADSPA_IS_HINT_BOUNDED_ABOVE (prhd)) 
    120125    ret |= SW_RANGE_UPPER_BOUND_VALID; 
    121126 
     
    124129 
    125130static sw_param_range * 
    126 convert_constraint ( /* sw_format * format, */ 
    127                     const LADSPA_PortRangeHint * prh) 
    128 { 
    129   sw_param_range * pr; 
     131convert_constraint (           /* sw_format * format, */ 
     132                    const LADSPA_PortRangeHint * prh) 
     133{ 
     134  sw_param_range *pr; 
    130135  LADSPA_PortRangeHintDescriptor prhd = prh->HintDescriptor; 
    131136  LADSPA_Data lower, upper; 
    132137 
    133   if (LADSPA_IS_HINT_TOGGLED(prhd)) 
     138  if (LADSPA_IS_HINT_TOGGLED (prhd)) 
    134139    return NULL; 
    135140 
     
    141146  upper = prh->UpperBound; 
    142147 
    143   if LADSPA_IS_HINT_SAMPLE_RATE (prhd) { 
     148  if LADSPA_IS_HINT_SAMPLE_RATE 
     149    (prhd) 
     150    { 
    144151#if 0 
    145     lower *= format->rate; 
    146     upper *= format->rate; 
     152      lower *= format->rate; 
     153      upper *= format->rate; 
    147154#else 
    148     lower *= 44100; 
    149     upper *= 44100; 
     155      lower *= 44100; 
     156      upper *= 44100; 
    150157#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    } 
    164174 
    165175  return pr; 
     
    168178typedef struct _lm_custom lm_custom; 
    169179 
    170 struct _lm_custom { 
    171   const LADSPA_Descriptor * d; 
    172   sw_param_spec * param_specs; 
     180struct _lm_custom 
     181
     182  const LADSPA_Descriptor *d; 
     183  sw_param_spec *param_specs; 
    173184}; 
    174185 
     
    176187lm_custom_new (const LADSPA_Descriptor * d, sw_param_spec * param_specs) 
    177188{ 
    178   lm_custom * lmc; 
     189  lm_custom *lmc; 
    179190 
    180191  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    } 
    185197 
    186198  return lmc; 
     
    203215  upper = prh->UpperBound; 
    204216 
    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    } 
    209223 
    210224  /* Determine default value, as sw_float */ 
    211225 
    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    } 
    247291 
    248292  /* Convert to sw_param type */ 
    249293 
    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    } 
    257306 
    258307  return param; 
     
    263312                     gpointer custom_data) 
    264313{ 
    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; 
    268317 
    269318  LADSPA_PortDescriptor pd; 
     
    272321  sounddata = sample_get_sounddata (sample); 
    273322 
    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    } 
    282333 
    283334} 
     
    289340                          gpointer custom_data) 
    290341{ 
    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; 
    297348  sw_framecount_t op_total, run_total; 
    298349  sw_framecount_t offset, remaining, n; 
    299350 
    300   GList * gl; 
    301   sw_sel * sel; 
     351  GList *gl; 
     352  sw_sel *sel; 
    302353 
    303354  gpointer pcmdata; 
     
    310361  gint nr_handles; 
    311362 
    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; 
    317368  LADSPA_Data dummy_control_output; 
    318369  LADSPA_PortDescriptor pd; 
    319370  glong length_b; 
    320   gulong port_i; /* counter for iterating over ports */ 
     371  gulong port_i;               /* counter for iterating over ports */ 
    321372  gint h, i, j, c; 
    322373 
    323374  /* 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 */ 
    329379 
    330380  /* The number of audio channels to be processed */ 
     
    332382 
    333383  /* 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; 
    335385 
    336386  /* Counters for allocating input and output buffers */ 
    337   gint ibi=0, obi=0; 
     387  gint ibi = 0, obi = 0; 
    338388 
    339389  gboolean active = TRUE; 
     
    346396 
    347397  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; 
    349400  run_total = 0; 
    350401 
    351402  /* 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    } 
    363415 
    364416  /* Basic assumption of this meta plugin, which was 
     
    374426  g_assert (nr_ao > 0); 
    375427 
    376   nr_handles = (gint) ceil(((double)nr_channels) / ((double)nr_ao)); 
     428  nr_handles = (gint) ceil (((double) nr_channels) / ((double) nr_ao)); 
    377429 
    378430  /* Numbers of input and output buffers: ensure 
     
    384436  /* Create all input and output buffers */ 
    385437 
    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. 
    429443       */ 
    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    } 
    439504 
    440505  /* instantiate the ladspa plugin */ 
    441506  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    } 
    445511 
    446512  /* 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    } 
    486558 
    487559  /* 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    } 
    493567 
    494568  /* 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    } 
    583681 
    584682  /* 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    } 
    590690 
    591691  /* 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    } 
    597699 
    598700  /* free the array of handles */ 
    599701  g_free (handles); 
    600    
     702 
    601703  /* 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    } 
    631744 
    632745  return sample; 
     
    637750                   sw_param_set pset, gpointer custom_data) 
    638751{ 
    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; 
    641754 
    642755  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, 
    645758                       pset, custom_data); 
    646759} 
     
    658771#define PATH_LEN 256 
    659772  gchar path[PATH_LEN]; 
    660   void * module; 
     773  void *module; 
    661774  LADSPA_Descriptor_Function desc_func; 
    662   const LADSPA_Descriptor * d; 
     775  const LADSPA_Descriptor *d; 
    663776  LADSPA_PortDescriptor pd; 
    664777  gint i, j, k, nr_params; 
    665778  int valid_mask; 
    666   sw_procedure * proc; 
     779  sw_procedure *proc; 
    667780 
    668781  snprintf (path, PATH_LEN, "%s/%s", dir, name); 
    669782 
    670783  module = dlopen (path, RTLD_NOW); 
    671   if (!module) return; 
     784  if (!module) 
     785    return; 
    672786 
    673787  modules_list = g_list_append (modules_list, module); 
    674788 
    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    } 
    727853} 
    728854 
     
    736862ladspa_meta_init_dir (gchar * dirname, GList ** gl) 
    737863{ 
    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; 
    743870 
    744871  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    } 
    754883} 
    755884 
     
    757886ladspa_meta_init (void) 
    758887{ 
    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; 
    763892 
    764893  /* If this ladspa_meta module has already been initialised, don't 
     
    770899  ladspa_path = getenv ("LADSPA_PATH"); 
    771900  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')); 
    783916 
    784917  ladspa_meta_initialised = TRUE; 
    785918 
    786919  /* 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); 
    788922 
    789923  return gl; 
     
    793927ladspa_meta_cleanup (void) 
    794928{ 
    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    } 
    802938} 
    803939 
    804940sw_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 */ 
    807943}; 
  • sweep/branches/display-cache/plugins/normalise/normalise.c

    r125 r471  
    2626#include <sweep/sweep.h> 
    2727 
    28 #include <../src/sweep_app.h> /* XXX */ 
     28#include <../src/sweep_app.h>  /* XXX */ 
    2929 
    3030static sw_sample * 
    3131normalise (sw_sample * sample, sw_param_set pset, gpointer custom_data) 
    3232{ 
    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; 
    3838  sw_audio_t max = 0; 
    3939  gfloat factor = 1.0; 
     
    4747  f = sounddata->format; 
    4848 
    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; 
    5152  run_total = 0; 
    5253 
    5354  /* 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; 
    5658 
    57     offset = 0; 
    58     remaining = sel->sel_end - sel->sel_start; 
     59      offset = 0; 
     60      remaining = sel->sel_end - sel->sel_start; 
    5961 
    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); 
    6265 
    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            { 
    6672 
    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); 
    6876 
    69         n = MIN(remaining, 1024); 
     77              n = MIN (remaining, 1024); 
    7078 
    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); 
    7495        } 
     96    } 
    7597 
    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; 
    88100 
    89101  /* 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; 
    92105 
    93     offset = 0; 
    94     remaining = sel->sel_end - sel->sel_start; 
     106      offset = 0; 
     107      remaining = sel->sel_end - sel->sel_start; 
    95108 
    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); 
    98112 
    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); 
    103122 
    104         n = MIN(remaining, 1024); 
     123              n = MIN (remaining, 1024); 
    105124 
    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); 
    108139        } 
    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); 
    118140    } 
    119   } 
    120141 
    121142  return sample; 
     
    123144 
    124145static sw_op_instance * 
    125 apply_normalise(sw_sample * sample, sw_param_set pset, gpointer custom_data) 
     146apply_normalise (sw_sample * sample, sw_param_set pset, gpointer custom_data) 
    126147{ 
    127148  return 
    128     perform_filter_op (sample, _("Normalise"), (SweepFilter)normalise, 
     149    perform_filter_op (sample, _("Normalise"), (SweepFilter) normalise, 
    129150                       pset, NULL); 
    130151} 
     
    136157  "Copyright (C) 2000", 
    137158  "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() */ 
    144165  apply_normalise, 
    145   NULL, /* custom_data */ 
     166  NULL,                                /* custom_data */ 
    146167}; 
    147    
     168 
    148169static GList * 
    149170normalise_init (void) 
    150171{ 
    151   return g_list_append ((GList *)NULL, &proc_normalise); 
     172  return g_list_append ((GList *) NULL, &proc_normalise); 
    152173} 
    153174 
    154175 
    155176sw_plugin plugin = { 
    156   normalise_init, /* plugin_init */ 
    157   NULL, /* plugin_cleanup */ 
     177  normalise_init,              /* plugin_init */ 
     178  NULL,                                /* plugin_cleanup */ 
    158179}; 
  • sweep/branches/display-cache/plugins/reverse/reverse.c

    r125 r471  
    2626#include <sweep/sweep.h> 
    2727 
    28 #include "../src/sweep_app.h" /* XXX */ 
     28#include "../src/sweep_app.h"  /* XXX */ 
    2929 
    3030#if 0 
     
    4242  e = d + frames_to_bytes (format, nr_frames); 
    4343 
    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    } 
    5253 
    5354  g_free (t); 
     
    5960                   gpointer custom_data) 
    6061{ 
    61   GList * gl; 
    62   sw_sel * sel; 
     62  GList *gl; 
     63  sw_sel *sel; 
    6364  glong i, sw; 
    64   sw_sounddata * sounddata; 
    65   sw_format * format; 
     65  sw_sounddata *sounddata; 
     66  sw_format *format; 
    6667  sw_framecount_t nr_frames; 
    6768  gpointer d, e, t; 
     
    7677 
    7778  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; 
    7981  run_total = 0; 
    8082 
     
    8284  t = alloca (sw); 
    8385 
    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; 
    8689 
    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; 
    8992 
    90     e = d + frames_to_bytes (format, nr_frames); 
    91      
    92     remaining = nr_frames/2; 
     93      e = d + frames_to_bytes (format, nr_frames); 
    9394 
    94     while (active && remaining > 0) { 
    95       g_mutex_lock (sample->ops_mutex); 
     95      remaining = nr_frames / 2; 
    9696 
    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); 
    101100 
    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); 
    109126        } 
    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); 
    118127    } 
    119   } 
    120128 
    121129  return sample; 
     
    128136  return 
    129137    perform_filter_region_op (sample, _("Reverse"), 
    130                               (SweepFilterRegion)region_reverse, pset, NULL); 
     138                              (SweepFilterRegion) region_reverse, pset, NULL); 
    131139#endif 
    132140 
    133141  return 
    134142    perform_filter_op (sample, _("Reverse"), 
    135                        (SweepFilter)sounddata_reverse, pset, NULL); 
     143                       (SweepFilter) sounddata_reverse, pset, NULL); 
    136144} 
    137145 
     
    143151  "Copyright (C) 2000", 
    144152  "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() */ 
    151159  apply_reverse, 
    152   NULL, /* custom_data */ 
     160  NULL,                                /* custom_data */ 
    153161}; 
    154162 
     
    156164reverse_init (void) 
    157165{ 
    158   return g_list_append ((GList *)NULL, &proc_reverse); 
     166  return g_list_append ((GList *) NULL, &proc_reverse); 
    159167} 
    160168 
    161169 
    162170sw_plugin plugin = { 
    163   reverse_init, /* plugin_init */ 
    164   NULL, /* plugin_cleanup */ 
     171  reverse_init,                        /* plugin_init */ 
     172  NULL,                                /* plugin_cleanup */ 
    165173}; 
  • sweep/branches/display-cache/po/fr.po

    r402 r471  
    44# 
    55#: src/sample-display.c:220 
    6 #, fuzzy 
    76msgid "" 
    87msgstr "" 
  • sweep/branches/display-cache/po/pl.po

    r402 r471  
    26342634c do ciszy" 
    26352635 
    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  
    3636 
    3737 
    38 static void about_dialog_destroy(void); 
    39 static int about_dialog_button(GtkWidget * widget, 
    40                                GdkEventButton * event); 
     38static void about_dialog_destroy (void); 
     39static int about_dialog_button (GtkWidget * widget, GdkEventButton * event); 
    4140 
    4241static GtkWidget *about_dialog = NULL; 
     
    4948 
    5049void 
    51 about_dialog_create() 
     50about_dialog_create () 
    5251{ 
    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  */ 
    5655  GtkWidget *vbox; 
    5756  GtkWidget *label; 
    5857#define BUF_LEN 64 
    5958  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; 
    6362  gchar buf2[1024]; 
    6463 
    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); 
    7779 
    7880 
    7981 
    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); 
    8385 
    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); 
    9294 
    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); 
    103105 
    104106#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); 
    108112#endif 
    109113 
    110  /* FIXME: old style code 
    111   *   gtk_widget_pop_style(); 
    112   */ 
     114      /* FIXME: old style code 
     115       *   gtk_widget_pop_style(); 
     116       */ 
    113117 
    114118#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); 
    118122 
    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); 
    122126#endif 
    123127 
    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    } 
    135142} 
    136143 
    137144static void 
    138 about_dialog_destroy() 
     145about_dialog_destroy () 
    139146{ 
    140147  about_dialog = NULL; 
     
    142149 
    143150static int 
    144 about_dialog_button(GtkWidget * widget, 
    145                     GdkEventButton * event) 
     151about_dialog_button (GtkWidget * widget, GdkEventButton * event) 
    146152{ 
    147   gtk_widget_hide(about_dialog); 
     153  gtk_widget_hide (about_dialog); 
    148154 
    149155  return FALSE; 
  • sweep/branches/display-cache/src/about_dialog.h

    r7 r471  
    2222#define __ABOUT_DIALOG_H__ 
    2323 
    24 void about_dialog_create(void); 
     24void about_dialog_create (void); 
    2525 
    2626#endif /* __ABOUT_DIALOG_H__ */ 
  • sweep/branches/display-cache/src/callbacks.c

    r285 r471  
    7171sample_new_empty_cb (GtkWidget * widget, gpointer data) 
    7272{ 
    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    } 
    8083} 
    8184 
     
    8386sample_new_copy_cb (GtkWidget * widget, gpointer data) 
    8487{ 
    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; 
    8992 
    9093  s = sd->view->sample; 
    9194 
    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    } 
    99104 
    100105  v = view_new_all (ns, 1.0); 
    101106  sample_add_view (ns, v); 
    102107 
    103   sample_bank_add(ns); 
     108  sample_bank_add (ns); 
    104109} 
    105110 
     
    110115{ 
    111116  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, 
    114120                                          (GSourceFunc) function, data); 
    115  
     121   
    116122} 
    117123 
     
    119125repeater_released_cb (GtkWidget * widget, gpointer data) 
    120126{ 
    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    } 
    127134} 
    128135 
     
    132139view_new_all_cb (GtkWidget * widget, gpointer data) 
    133140{ 
    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; 
    137144 
    138145  s = sd->view->sample; 
    139   v = view_new_all(s, 1.0); 
     146  v = view_new_all (s, 1.0); 
    140147 
    141148  sample_add_view (s, v); 
     
    145152view_new_cb (GtkWidget * widget, gpointer data) 
    146153{ 
    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; 
    150157 
    151158  v = sd->view; 
     
    160167view_close_cb (GtkWidget * widget, gpointer data) 
    161168{ 
    162   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    163   sw_view * v; 
     169  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
     170  sw_view *v; 
    164171 
    165172  v = sd->view; 
    166173 
    167   view_close(v); 
     174  view_close (v); 
    168175} 
    169176 
     
    179186{ 
    180187#if 0 
    181   gint tool = (gint)data; 
    182  
    183   /*  current_tool = tool;*/ 
     188  gint tool = (gint) data; 
     189 
     190  /*  current_tool = tool; */ 
    184191#endif 
    185192  g_print ("NOOOOOOOOOOOOOO global current_tool\n"); 
     
    189196view_set_tool_cb (GtkWidget * widget, gpointer data) 
    190197{ 
    191   sw_view * view = (sw_view *)data; 
     198  sw_view *view = (sw_view *) data; 
    192199  sw_tool_t tool; 
    193200 
    194201  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")); 
    196203 
    197204  view->current_tool = tool; 
     
    205212zoom_in_step (gpointer data) 
    206213{ 
    207   sw_view * view = (sw_view *)data; 
     214  sw_view *view = (sw_view *) data; 
    208215 
    209216  view_zoom_in (view, DEFAULT_ZOOM); 
     
    215222zoom_in_cb (GtkWidget * widget, gpointer data) 
    216223{ 
    217   sw_view * view = (sw_view *)data; 
     224  sw_view *view = (sw_view *) data; 
    218225  view_zoom_in (view, DEFAULT_ZOOM); 
    219226} 
     
    222229zoom_out_step (gpointer data) 
    223230{ 
    224   sw_view * view = (sw_view *)data; 
     231  sw_view *view = (sw_view *) data; 
    225232 
    226233  view_zoom_out (view, DEFAULT_ZOOM); 
     
    232239zoom_out_cb (GtkWidget * widget, gpointer data) 
    233240{ 
    234   sw_view * view = (sw_view *)data; 
     241  sw_view *view = (sw_view *) data; 
    235242  view_zoom_out (view, DEFAULT_ZOOM); 
    236243} 
     
    240247zoom_in_pressed_cb (GtkWidget * widget, gpointer data) 
    241248{ 
    242   sw_view * view = (sw_view *)data; 
     249  sw_view *view = (sw_view *) data; 
    243250 
    244251  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); 
    246253} 
    247254 
     
    249256zoom_out_pressed_cb (GtkWidget * widget, gpointer data) 
    250257{ 
    251   sw_view * view = (sw_view *)data; 
     258  sw_view *view = (sw_view *) data; 
    252259 
    253260  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); 
    255262} 
    256263 
     
    258265zoom_to_sel_cb (GtkWidget * widget, gpointer data) 
    259266{ 
    260   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    261   sw_view * v = sd->view; 
     267  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
     268  sw_view *v = sd->view; 
    262269 
    263270  view_zoom_to_sel (v); 
     
    267274zoom_left_cb (GtkWidget * widget, gpointer data) 
    268275{ 
    269   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    270   sw_view * v = sd->view; 
     276  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
     277  sw_view *v = sd->view; 
    271278 
    272279  view_zoom_left (v); 
     
    276283zoom_right_cb (GtkWidget * widget, gpointer data) 
    277284{ 
    278   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    279   sw_view * v = sd->view; 
     285  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
     286  sw_view *v = sd->view; 
    280287 
    281288  view_zoom_right (v); 
     
    285292zoom_all_cb (GtkWidget * widget, gpointer data) 
    286293{ 
    287   sw_view * v = (sw_view *)data; 
     294  sw_view *v = (sw_view *) data; 
    288295 
    289296  view_zoom_all (v); 
     
    294301zoom_2_1_cb (GtkWidget * widget, gpointer data) 
    295302{ 
    296   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    297   sw_sample * s; 
     303  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
     304  sw_sample *s; 
    298305 
    299306  s = sd->view->sample; 
    300307 
    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); 
    304311} 
    305312 
     
    307314zoom_norm_cb (GtkWidget * widget, gpointer data) 
    308315{ 
    309   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
    310   sw_view * view = sd->view; 
     316  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
     317  sw_view *view = sd->view; 
    311318 
    312319  view_zoom_normal (view); 
     
    316323zoom_1to1_cb (GtkWidget * widget, gpointer data) 
    317324{ 
    318   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     325  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    319326 
    320327  view_zoom_length (sd->view, sd->width); 
     
    325332zoom_center_cb (GtkWidget * widget, gpointer data) 
    326333{ 
    327   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     334  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    328335 
    329336  view_center_on (sd->view, sd->view->sample->user_offset); 
     
    333340zoom_combo_changed_cb (GtkWidget * widget, gpointer data) 
    334341{ 
    335   sw_view * view = (sw_view *)data; 
    336   gchar * text; 
     342  sw_view *view = (sw_view *) data; 
     343  gchar *text; 
    337344  sw_time_t zoom_time; 
    338345  sw_framecount_t zoom_length; 
    339346 
    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    } 
    357368} 
    358369 
     
    370381sample_set_color_cb (GtkWidget * widget, gpointer data) 
    371382{ 
    372   sw_view * view = (sw_view *) data; 
     383  sw_view *view = (sw_view *) data; 
    373384  gint color; 
    374385 
    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")); 
    376387  sample_set_color (view->sample, color); 
    377388} 
     
    382393follow_toggled_cb (GtkWidget * widget, gpointer data) 
    383394{ 
    384   sw_view * view = (sw_view *) data; 
     395  sw_view *view = (sw_view *) data; 
    385396  gboolean active; 
    386397 
    387   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     398  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 
    388399  view_set_following (view, active); 
    389400} 
     
    392403follow_toggle_cb (GtkWidget * widget, gpointer data) 
    393404{ 
    394   sw_view * view = (sw_view *)data; 
     405  sw_view *view = (sw_view *) data; 
    395406  view_set_following (view, !view->following); 
    396407} 
     
    399410loop_toggled_cb (GtkWidget * widget, gpointer data) 
    400411{ 
    401   sw_view * view = (sw_view *) data; 
     412  sw_view *view = (sw_view *) data; 
    402413  gboolean active; 
    403414 
    404   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     415  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 
    405416  sample_set_looping (view->sample, active); 
    406417} 
     
    409420loop_toggle_cb (GtkWidget * widget, gpointer data) 
    410421{ 
    411   sw_view * view = (sw_view *)data; 
     422  sw_view *view = (sw_view *) data; 
    412423  sample_set_looping (view->sample, !view->sample->play_head->looping); 
    413424} 
     
    416427playrev_toggled_cb (GtkWidget * widget, gpointer data) 
    417428{ 
    418   sw_view * view = (sw_view *) data; 
     429  sw_view *view = (sw_view *) data; 
    419430  gboolean active; 
    420431 
    421   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     432  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 
    422433  sample_set_playrev (view->sample, active); 
    423434} 
     
    426437playrev_toggle_cb (GtkWidget * widget, gpointer data) 
    427438{ 
    428   sw_view * view = (sw_view *)data; 
     439  sw_view *view = (sw_view *) data; 
    429440  sample_set_playrev (view->sample, !view->sample->play_head->reverse); 
    430441} 
     
    433444mute_toggled_cb (GtkWidget * widget, gpointer data) 
    434445{ 
    435   sw_view * view = (sw_view *) data; 
     446  sw_view *view = (sw_view *) data; 
    436447  gboolean active; 
    437448 
    438   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     449  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 
    439450  sample_set_mute (view->sample, active); 
    440451} 
     
    443454mute_toggle_cb (GtkWidget * widget, gpointer data) 
    444455{ 
    445   sw_view * view = (sw_view *)data; 
     456  sw_view *view = (sw_view *) data; 
    446457  sample_set_mute (view->sample, !view->sample->play_head->mute); 
    447458} 
     
    450461monitor_toggled_cb (GtkWidget * widget, gpointer data) 
    451462{ 
    452   sw_view * view = (sw_view *) data; 
     463  sw_view *view = (sw_view *) data; 
    453464  gboolean active; 
    454465 
    455   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     466  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 
    456467  sample_set_monitor (view->sample, active); 
    457468} 
     
    460471monitor_toggle_cb (GtkWidget * widget, gpointer data) 
    461472{ 
    462   sw_view * view = (sw_view *)data; 
     473  sw_view *view = (sw_view *) data; 
    463474  sample_set_monitor (view->sample, !view->sample->play_head->monitor); 
    464475} 
     
    467478play_view_button_cb (GtkWidget * widget, gpointer data) 
    468479{ 
    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; 
    471482  gboolean was_restricted = head->restricted; 
    472483 
    473484  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    } 
    481495} 
    482496 
     
    484498play_view_cb (GtkWidget * widget, gpointer data) 
    485499{ 
    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; 
    488502 
    489503  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    } 
    497514} 
    498515 
     
    500517play_view_sel_button_cb (GtkWidget * widget, gpointer data) 
    501518{ 
    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; 
    504521  gboolean was_restricted = head->restricted; 
    505522 
    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    } 
    510528 
    511529  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    } 
    519540} 
    520541 
     
    522543play_view_sel_cb (GtkWidget * widget, gpointer data) 
    523544{ 
    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    } 
    531553 
    532554  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    } 
    540565} 
    541566 
     
    543568pause_playback_cb (GtkWidget * widget, gpointer data) 
    544569{ 
    545   sw_view * view = (sw_view *)data; 
     570  sw_view *view = (sw_view *) data; 
    546571 
    547572  pause_playback (view->sample); 
     
    551576stop_playback_cb (GtkWidget * widget, gpointer data) 
    552577{ 
    553   sw_view * view = (sw_view *)data; 
     578  sw_view *view = (sw_view *) data; 
    554579 
    555580  stop_playback (view->sample); 
     
    559584preview_cut_cb (GtkWidget * widget, gpointer data) 
    560585{ 
    561   sw_view * view = (sw_view *) data; 
     586  sw_view *view = (sw_view *) data; 
    562587 
    563588  sample_refresh_playmode (view->sample); 
    564589 
    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    } 
    570598} 
    571599 
     
    573601preroll_cb (GtkWidget * widget, gpointer data) 
    574602{ 
    575   sw_view * view = (sw_view *) data; 
     603  sw_view *view = (sw_view *) data; 
    576604 
    577605  sample_refresh_playmode (view->sample); 
    578    
     606 
    579607  play_preroll (view); 
    580608} 
     
    585613show_rec_dialog_cb (GtkWidget * widget, gpointer data) 
    586614{ 
    587   sw_view * view = (sw_view *)data; 
     615  sw_view *view = (sw_view *) data; 
    588616 
    589617  rec_dialog_create (view->sample); 
     
    595623rewind_step (gpointer data) 
    596624{ 
    597   sw_sample * sample = (sw_sample *)data; 
     625  sw_sample *sample = (sw_sample *) data; 
    598626  gint step; 
    599627 
    600   step = sample->sounddata->format->rate; /* 1 second */ 
     628  step = sample->sounddata->format->rate;      /* 1 second */ 
    601629  sample_set_playmarker (sample, sample->user_offset - step, TRUE); 
    602630 
     
    607635ffwd_step (gpointer data) 
    608636{ 
    609   sw_sample * sample = (sw_sample *)data; 
     637  sw_sample *sample = (sw_sample *) data; 
    610638  gint step; 
    611639 
    612   step = sample->sounddata->format->rate; /* 1 second */ 
     640  step = sample->sounddata->format->rate;      /* 1 second */ 
    613641  sample_set_playmarker (sample, sample->user_offset + step, TRUE); 
    614642 
     
    619647page_back_cb (GtkWidget * widget, gpointer data) 
    620648{ 
    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; 
    623651  gint step; 
    624652 
    625   step = MIN(sample->sounddata->format->rate, (view->end - view->start)); 
     653  step = MIN (sample->sounddata->format->rate, (view->end - view->start)); 
    626654  sample_set_playmarker (sample, sample->user_offset - step, TRUE); 
    627655} 
     
    630658page_fwd_cb (GtkWidget * widget, gpointer data) 
    631659{ 
    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; 
    634662  gint step; 
    635663 
    636   step = MIN(sample->sounddata->format->rate, (view->end - view->start)); 
     664  step = MIN (sample->sounddata->format->rate, (view->end - view->start)); 
    637665  sample_set_playmarker (sample, sample->user_offset + step, TRUE); 
    638666} 
     
    641669rewind_pressed_cb (GtkWidget * widget, gpointer data) 
    642670{ 
    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); 
    647675} 
    648676 
     
    650678ffwd_pressed_cb (GtkWidget * widget, gpointer data) 
    651679{ 
    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); 
    656684} 
    657685 
     
    659687goto_start_cb (GtkWidget * widget, gpointer data) 
    660688{ 
    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; 
    663691 
    664692  sample_set_scrubbing (sample, FALSE); 
     
    669697goto_start_of_view_cb (GtkWidget * widget, gpointer data) 
    670698{ 
    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; 
    673701 
    674702  sample_set_scrubbing (sample, FALSE); 
     
    679707goto_end_of_view_cb (GtkWidget * widget, gpointer data) 
    680708{ 
    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; 
    683711 
    684712  sample_set_scrubbing (sample, FALSE); 
     
    689717goto_end_cb (GtkWidget * widget, gpointer data) 
    690718{ 
    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; 
    693721 
    694722  sample_set_scrubbing (sample, FALSE); 
     
    701729sd_sel_changed_cb (GtkWidget * widget) 
    702730{ 
    703   SampleDisplay * sd = SAMPLE_DISPLAY(widget); 
     731  SampleDisplay *sd = SAMPLE_DISPLAY (widget); 
    704732 
    705733  sample_refresh_views (sd->view->sample); 
     
    709737sd_win_changed_cb (GtkWidget * widget) 
    710738{ 
    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); 
    716744  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); 
    720748  view_refresh_hruler (v); 
    721749} 
     
    724752adj_changed_cb (GtkWidget * widget, gpointer data) 
    725753{ 
    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); 
    738765  view_refresh_hruler (v); 
    739766} 
     
    742769adj_value_changed_cb (GtkWidget * widget, gpointer data) 
    743770{ 
    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); 
    766795} 
    767796 
     
    771800select_invert_cb (GtkWidget * widget, gpointer data) 
    772801{ 
    773   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     802  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    774803 
    775804  sample_selection_invert (sd->view->sample); 
     
    779808select_all_cb (GtkWidget * widget, gpointer data) 
    780809{ 
    781   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     810  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    782811 
    783812  sample_selection_select_all (sd->view->sample); 
     
    787816select_none_cb (GtkWidget * widget, gpointer data) 
    788817{ 
    789   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     818  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    790819 
    791820  sample_selection_select_none (sd->view->sample); 
     
    795824selection_halve_cb (GtkWidget * widget, gpointer data) 
    796825{ 
    797   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     826  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    798827 
    799828  sample_selection_halve (sd->view->sample); 
     
    803832selection_double_cb (GtkWidget * widget, gpointer data) 
    804833{ 
    805   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     834  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    806835 
    807836  sample_selection_double (sd->view->sample); 
     
    811840select_shift_left_cb (GtkWidget * widget, gpointer data) 
    812841{ 
    813   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     842  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    814843 
    815844  sample_selection_shift_left (sd->view->sample); 
     
    819848select_shift_right_cb (GtkWidget * widget, gpointer data) 
    820849{ 
    821   SampleDisplay * sd = SAMPLE_DISPLAY(data); 
     850  SampleDisplay *sd = SAMPLE_DISPLAY (data); 
    822851 
    823852  sample_selection_shift_right (sd->view->sample); 
     
    829858show_undo_dialog_cb (GtkWidget * widget, gpointer data) 
    830859{ 
    831   sw_view * view = (sw_view *)data; 
     860  sw_view *view = (sw_view *) data; 
    832861 
    833862  undo_dialog_create (view->sample); 
     
    837866undo_cb (GtkWidget * widget, gpointer data) 
    838867{ 
    839   sw_view * view = (sw_view *)data; 
     868  sw_view *view = (sw_view *) data; 
    840869 
    841870  undo_current (view->sample); 
     
    845874redo_cb (GtkWidget * widget, gpointer data) 
    846875{ 
    847   sw_view * view = (sw_view *)data; 
     876  sw_view *view = (sw_view *) data; 
    848877 
    849878  redo_current (view->sample); 
     
    853882cancel_cb (GtkWidget * widget, gpointer data) 
    854883{ 
    855   sw_view * view = (sw_view *)data; 
     884  sw_view *view = (sw_view *) data; 
    856885 
    857886  cancel_active_op (view->sample); 
     
    863892copy_cb (GtkWidget * widget, gpointer data) 
    864893{ 
    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; 
    867896 
    868897  do_copy (s); 
     
    872901cut_cb (GtkWidget * widget, gpointer data) 
    873902{ 
    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; 
    876905 
    877906  do_cut (s); 
     
    881910clear_cb (GtkWidget * widget, gpointer data) 
    882911{ 
    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; 
    885914 
    886915  do_clear (s); 
     
    890919delete_cb (GtkWidget * widget, gpointer data) 
    891920{ 
    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; 
    894923 
    895924  do_delete (s); 
     
    899928crop_cb (GtkWidget * widget, gpointer data) 
    900929{ 
    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; 
    903932 
    904933  do_crop (s); 
     
    908937paste_cb (GtkWidget * widget, gpointer data) 
    909938{ 
    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; 
    912941 
    913942  do_paste_insert (s); 
     
    917946paste_mix_cb (GtkWidget * widget, gpointer data) 
    918947{ 
    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    } 
    927959} 
    928960 
     
    930962paste_xfade_cb (GtkWidget * widget, gpointer data) 
    931963{ 
    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    } 
    940975} 
    941976 
     
    943978paste_as_new_cb (GtkWidget * widget, gpointer data) 
    944979{ 
    945   sw_sample * s; 
    946   sw_view * v; 
     980  sw_sample *s; 
     981  sw_view *v; 
    947982 
    948983  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    } 
    955991} 
    956992 
     
    958994show_info_dialog_cb (GtkWidget * widget, gpointer data) 
    959995{ 
    960   sw_view * view = (sw_view *)data; 
     996  sw_view *view = (sw_view *) data; 
    961997 
    962998  sample_show_info_dialog (view->sample); 
     
    9641000 
    9651001void 
    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   
     1002hide_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 
     1010void 
     1011close_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 
    9851019/* 
    9861020 * Prime the label with the largest string then fetch the width. 
     
    9901024 * don't try this at home kids, karma will get you. (oh well.. it works.)  
    9911025 */ 
    992 void   
    993 hack_max_label_width_cb (GtkWidget *widget, 
    994                                                         GtkStyle *previous_style, 
    995                             gpointer user_data) 
     1026void 
     1027hack_max_label_width_cb (GtkWidget * widget, 
     1028                         GtkStyle * previous_style, gpointer user_data) 
    9961029{ 
    9971030  PangoRectangle logical_rect, ink_rect; 
    9981031  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 
     1047void 
     1048hack_max_combo_width_cb (GtkWidget * widget, 
     1049                         GtkStyle * previous_style, gpointer user_data) 
    10161050{ 
    10171051  PangoRectangle logical_rect, ink_rect; 
    10181052  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  
    2424#include <gtk/gtk.h> 
    2525 
    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); 
     26void sample_new_empty_cb (GtkWidget * widget, gpointer data); 
     27 
     28void sample_new_copy_cb (GtkWidget * widget, gpointer data); 
     29 
     30void view_new_all_cb (GtkWidget * widget, gpointer data); 
     31 
     32void view_new_cb (GtkWidget * widget, gpointer data); 
     33 
     34void view_close_cb (GtkWidget * widget, gpointer data); 
     35 
     36void exit_cb (GtkWidget * widget, gpointer data); 
     37 
     38void set_tool_cb (GtkWidget * widget, gpointer data); 
     39 
     40void view_set_tool_cb (GtkWidget * widget, gpointer data); 
     41 
     42void repeater_released_cb (GtkWidget * widget, gpointer data); 
     43 
     44void zoom_in_cb (GtkWidget * widget, gpointer data); 
     45 
     46void zoom_out_cb (GtkWidget * widget, gpointer data); 
     47 
     48void zoom_in_pressed_cb (GtkWidget * widget, gpointer data); 
     49 
     50void zoom_out_pressed_cb (GtkWidget * widget, gpointer data); 
     51 
     52void zoom_to_sel_cb (GtkWidget * widget, gpointer data); 
     53 
     54void zoom_left_cb (GtkWidget * widget, gpointer data); 
     55 
     56void zoom_right_cb (GtkWidget * widget, gpointer data); 
     57 
     58void zoom_all_cb (GtkWidget * widget, gpointer data); 
     59 
     60void zoom_2_1_cb (GtkWidget * widget, gpointer data); 
     61 
     62void zoom_norm_cb (GtkWidget * widget, gpointer data); 
     63 
     64void zoom_1to1_cb (GtkWidget * widget, gpointer data); 
     65 
     66void zoom_center_cb (GtkWidget * widget, gpointer data); 
     67 
     68void zoom_combo_changed_cb (GtkWidget * widget, gpointer data); 
     69 
     70void sample_set_color_cb (GtkWidget * widget, gpointer data); 
     71 
     72void device_config_cb (GtkWidget * widget, gpointer data); 
     73 
     74void follow_toggled_cb (GtkWidget * widget, gpointer data); 
     75 
     76void follow_toggle_cb (GtkWidget * widget, gpointer data); 
     77 
     78void loop_toggled_cb (GtkWidget * widget, gpointer data); 
     79 
     80void loop_toggle_cb (GtkWidget * widget, gpointer data); 
     81 
     82void playrev_toggled_cb (GtkWidget * widget, gpointer data); 
     83 
     84void playrev_toggle_cb (GtkWidget * widget, gpointer data); 
     85 
     86void mute_toggled_cb (GtkWidget * widget, gpointer data); 
     87 
     88void mute_toggle_cb (GtkWidget * widget, gpointer data); 
     89 
     90void monitor_toggled_cb (GtkWidget * widget, gpointer data); 
     91 
     92void monitor_toggle_cb (GtkWidget * widget, gpointer data); 
     93 
     94void play_view_button_cb (GtkWidget * widget, gpointer data); 
     95 
     96void play_view_sel_button_cb (GtkWidget * widget, gpointer data); 
     97 
     98void play_view_cb (GtkWidget * widget, gpointer data); 
     99 
     100void play_view_all_once_cb (GtkWidget * widget, gpointer data); 
     101 
     102void play_view_all_loop_cb (GtkWidget * widget, gpointer data); 
     103 
     104void play_view_sel_cb (GtkWidget * widget, gpointer data); 
     105 
     106void play_view_sel_once_cb (GtkWidget * widget, gpointer data); 
     107 
     108void play_view_sel_loop_cb (GtkWidget * widget, gpointer data); 
     109 
     110void pause_playback_cb (GtkWidget * widget, gpointer data); 
     111 
     112void stop_playback_cb (GtkWidget * widget, gpointer data); 
     113 
     114void preview_cut_cb (GtkWidget * widget, gpointer data); 
     115 
     116void preroll_cb (GtkWidget * widget, gpointer data); 
     117 
     118void show_rec_dialog_cb (GtkWidget * widget, gpointer data); 
     119 
     120void page_back_cb (GtkWidget * widget, gpointer data); 
     121 
     122void page_fwd_cb (GtkWidget * widget, gpointer data); 
     123 
     124void rewind_pressed_cb (GtkWidget * widget, gpointer data); 
     125 
     126void ffwd_pressed_cb (GtkWidget * widget, gpointer data); 
     127 
     128void goto_start_cb (GtkWidget * widget, gpointer data); 
     129 
     130void goto_start_of_view_cb (GtkWidget * widget, gpointer data); 
     131 
     132void goto_end_of_view_cb (GtkWidget * widget, gpointer data); 
     133 
     134void goto_end_cb (GtkWidget * widget, gpointer data); 
     135 
     136void sd_sel_changed_cb (GtkWidget * widget); 
     137 
     138void sd_win_changed_cb (GtkWidget * widget); 
     139 
     140void adj_changed_cb (GtkWidget * widget, gpointer data); 
     141 
     142void adj_value_changed_cb (GtkWidget * widget, gpointer data); 
     143 
     144void select_invert_cb (GtkWidget * widget, gpointer data); 
     145 
     146void select_all_cb (GtkWidget * widget, gpointer data); 
     147 
     148void select_none_cb (GtkWidget * widget, gpointer data); 
     149 
     150void selection_halve_cb (GtkWidget * widget, gpointer data); 
     151 
     152void selection_double_cb (GtkWidget * widget, gpointer data); 
     153 
     154void select_shift_left_cb (GtkWidget * widget, gpointer data); 
     155 
     156void select_shift_right_cb (GtkWidget * widget, gpointer data); 
     157 
     158void show_undo_dialog_cb (GtkWidget * widget, gpointer data); 
     159 
     160void undo_cb (GtkWidget * widget, gpointer data); 
     161 
     162void redo_cb (GtkWidget * widget, gpointer data); 
     163 
     164void cancel_cb (GtkWidget * widget, gpointer data); 
     165 
     166void copy_cb (GtkWidget * widget, gpointer data); 
     167 
     168void cut_cb (GtkWidget * widget, gpointer data); 
     169 
     170void clear_cb (GtkWidget * widget, gpointer data); 
     171 
     172void delete_cb (GtkWidget * widget, gpointer data); 
     173 
     174void crop_cb (GtkWidget * widget, gpointer data); 
     175 
     176void paste_cb (GtkWidget * widget, gpointer data); 
     177 
     178void paste_mix_cb (GtkWidget * widget, gpointer data); 
     179 
     180void paste_xfade_cb (GtkWidget * widget, gpointer data); 
     181 
     182void paste_as_new_cb (GtkWidget * widget, gpointer data); 
     183 
     184void reverse_cb (GtkWidget * widget, gpointer data); 
     185 
     186void normalise_cb (GtkWidget * widget, gpointer data); 
     187 
     188void show_info_dialog_cb (GtkWidget * widget, gpointer data); 
     189 
     190void 
     191close_window_cb (GtkAccelGroup * accel_group, 
     192                 GObject * acceleratable, 
     193                 guint keyval, GdkModifierType modifier); 
     194 
     195void 
     196hide_window_cb (GtkAccelGroup * accel_group, 
     197                GObject * acceleratable, 
     198                guint keyval, GdkModifierType modifier); 
     199 
     200void 
     201hack_max_label_width_cb (GtkWidget * widget, 
     202                         GtkStyle * previous_style, gpointer user_data); 
     203 
     204void 
     205hack_max_combo_width_cb (GtkWidget * widget, 
     206                         GtkStyle * previous_style, gpointer user_data); 
    293207 
    294208#endif /* __CALLBACKS_H__ */ 
  • sweep/branches/display-cache/src/channelops.c

    r211 r471  
    4747do_dup_channels_thread (sw_op_instance * inst) 
    4848{ 
    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); 
    5151  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; 
    5454  sw_framecount_t nr_frames; 
    5555 
    56   sw_audio_t * old_d, * new_d; 
     56  sw_audio_t *old_d, *new_d; 
    5757 
    5858  sw_framecount_t remaining, n, run_total, ctotal; 
     
    7272  remaining = nr_frames; 
    7373  ctotal = remaining / 100; 
    74   if (ctotal == 0) ctotal = 1; 
     74  if (ctotal == 0) 
     75    ctotal = 1; 
    7576  run_total = 0; 
    7677 
    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; 
    7980 
    8081  /* Create selections */ 
     
    8485 
    8586  /* 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    } 
    126137} 
    127138 
    128139static sw_operation dup_channels_op = { 
    129140  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_destroy 
     141  (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 
    136147}; 
    137148 
     
    143154  char buf[BUF_LEN]; 
    144155 
    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 
    152166  schedule_operation (sample, buf, &dup_channels_op, 
    153                       GINT_TO_POINTER(new_channels)); 
     167                      GINT_TO_POINTER (new_channels)); 
    154168} 
    155169 
     
    157171dup_stereo_cb (GtkWidget * widget, gpointer data) 
    158172{ 
    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; 
    161175 
    162176  dup_channels (sample, 2); 
     
    166180dup_channels_dialog_ok_cb (GtkWidget * widget, gpointer data) 
    167181{ 
    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; 
    171185 
    172186  int new_channels; 
     
    174188  dialog = gtk_widget_get_toplevel (widget); 
    175189 
    176   chooser = g_object_get_data (G_OBJECT(dialog), "default"); 
     190  chooser = g_object_get_data (G_OBJECT (dialog), "default"); 
    177191  new_channels = channelcount_chooser_get_count (chooser); 
    178192 
     
    185199dup_channels_dialog_cancel_cb (GtkWidget * widget, gpointer data) 
    186200{ 
    187   GtkWidget * dialog; 
     201  GtkWidget *dialog; 
    188202 
    189203  dialog = gtk_widget_get_toplevel (widget); 
     
    194208dup_channels_dialog_new_cb (GtkWidget * widget, gpointer data) 
    195209{ 
    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; */ 
    205219 
    206220  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")); 
    208222  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; 
    212226 
    213227#if 0 
     
    215229                             sample->sounddata->format->channels); 
    216230  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); 
    218232  gtk_widget_show (label); 
    219233#endif 
    220234 
    221235  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); 
    223237  channelcount_chooser_set_count (chooser, 
    224238                                  sample->sounddata->format->channels); 
    225239  gtk_widget_show (chooser); 
    226240 
    227   g_object_set_data (G_OBJECT(dialog), "default", chooser); 
     241  g_object_set_data (G_OBJECT (dialog), "default", chooser); 
    228242 
    229243  /* OK */ 
     
    231245  ok_button = gtk_button_new_with_label (_("OK")); 
    232246  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, 
    234248                      TRUE, TRUE, 0); 
    235249  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); 
    239252 
    240253  /* Cancel */ 
     
    242255  button = gtk_button_new_with_label (_("Cancel")); 
    243256  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, 
    245258                      TRUE, TRUE, 0); 
    246259  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); 
    250262 
    251263  gtk_widget_grab_default (ok_button); 
     
    257269do_mono_mixdown_thread (sw_op_instance * inst) 
    258270{ 
    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; 
    263275  sw_framecount_t nr_frames; 
    264276 
    265   sw_audio_t * old_d, * new_d; 
     277  sw_audio_t *old_d, *new_d; 
    266278 
    267279  sw_framecount_t remaining, n, run_total, ctotal; 
     
    278290  remaining = nr_frames; 
    279291  ctotal = remaining / 100; 
    280   if (ctotal == 0) ctotal = 1; 
     292  if (ctotal == 0) 
     293    ctotal = 1; 
    281294  run_total = 0; 
    282295 
    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; 
    285298 
    286299  /* Create selections */ 
     
    290303 
    291304  /* 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    } 
    329351} 
    330352 
    331353static sw_operation mono_mixdown_op = { 
    332354  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_destroy 
     355  (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 
    339361}; 
    340362 
     
    342364mono_mixdown_cb (GtkWidget * widget, gpointer data) 
    343365{ 
    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; 
    346368 
    347369  schedule_operation (sample, _("Mix down to mono"), &mono_mixdown_op, NULL); 
     
    351373do_remove_channel_thread (sw_op_instance * inst) 
    352374{ 
    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; 
    358380  sw_framecount_t nr_frames; 
    359381 
    360   sw_audio_t * old_d, * new_d; 
     382  sw_audio_t *old_d, *new_d; 
    361383 
    362384  sw_framecount_t remaining, n, run_total, ctotal; 
     
    374396  remaining = nr_frames; 
    375397  ctotal = remaining / 100; 
    376   if (ctotal == 0) ctotal = 1; 
     398  if (ctotal == 0) 
     399    ctotal = 1; 
    377400  run_total = 0; 
    378401 
    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; 
    381404 
    382405  /* Create selections */ 
     
    386409 
    387410  /* 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    } 
    427460} 
    428461 
    429462static sw_operation remove_channel_op = { 
    430463  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_destroy 
     464  (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 
    437470}; 
    438471 
     
    440473remove_left_cb (GtkWidget * widget, gpointer data) 
    441474{ 
    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; 
    444477 
    445478  schedule_operation (sample, _("Remove left channel"), &remove_channel_op, 
    446                       GINT_TO_POINTER(0)); 
     479                      GINT_TO_POINTER (0)); 
    447480} 
    448481 
     
    450483remove_right_cb (GtkWidget * widget, gpointer data) 
    451484{ 
    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; 
    454487 
    455488  schedule_operation (sample, _("Remove right channel"), &remove_channel_op, 
    456                       GINT_TO_POINTER(1)); 
     489                      GINT_TO_POINTER (1)); 
    457490} 
    458491 
     
    461494{ 
    462495  sw_framecount_t nr_frames; 
    463   sw_audio_t * dl, * dr, t; 
     496  sw_audio_t *dl, *dr, t; 
    464497 
    465498  sw_framecount_t remaining, n, run_total, ctotal; 
     
    473506  remaining = nr_frames; 
    474507  ctotal = remaining / 100; 
    475   if (ctotal == 0) ctotal = 1; 
     508  if (ctotal == 0) 
     509    ctotal = 1; 
    476510  run_total = 0; 
    477511 
    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++; 
    480515 
    481516  /* 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    } 
    508548} 
    509549 
     
    511551do_stereo_swap_thread (sw_op_instance * inst) 
    512552{ 
    513   sw_sample * sample = inst->sample; 
     553  sw_sample *sample = inst->sample; 
    514554 
    515555  do_stereo_swap (sample, NULL); 
    516556 
    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    } 
    520561} 
    521562 
    522563static sw_operation stereo_swap_op = { 
    523564  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)NULL 
     565  (SweepCallback) do_stereo_swap_thread, 
     566  (SweepFunction) NULL, 
     567  (SweepCallback) do_stereo_swap, 
     568  (SweepFunction) NULL, 
     569  (SweepCallback) do_stereo_swap, 
     570  (SweepFunction) NULL 
    530571}; 
    531572 
     
    533574stereo_swap_cb (GtkWidget * widget, gpointer data) 
    534575{ 
    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; 
    537578 
    538579  if (sample->sounddata->format->channels == 2) 
     
    548589do_change_channels_thread (sw_op_instance * inst) 
    549590{ 
    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); 
    552593  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; 
    555596  sw_framecount_t nr_frames; 
    556597 
    557   sw_audio_t * old_d, * new_d; 
     598  sw_audio_t *old_d, *new_d; 
    558599 
    559600  sw_framecount_t remaining, n, run_total, ctotal; 
     
    573614  remaining = nr_frames; 
    574615  ctotal = remaining / 100; 
    575   if (ctotal == 0) ctotal = 1; 
     616  if (ctotal == 0) 
     617    ctotal = 1; 
    576618  run_total = 0; 
    577619 
    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; 
    580622 
    581623  /* Create selections */ 
     
    585627 
    586628  /* 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    } 
    624675} 
    625676 
    626677static sw_operation change_channels_op = { 
    627678  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_destroy 
     679  (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 
    634685}; 
    635686 
     
    643694  g_snprintf (buf, BUF_LEN, _("Convert from %d to %d channels"), 
    644695              sample->sounddata->format->channels, new_channels); 
    645   
     696 
    646697  schedule_operation (sample, buf, &change_channels_op, 
    647                       GINT_TO_POINTER(new_channels)); 
     698                      GINT_TO_POINTER (new_channels)); 
    648699} 
    649700 
     
    651702channels_dialog_ok_cb (GtkWidget * widget, gpointer data) 
    652703{ 
    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; 
    656707 
    657708  int new_channels; 
     
    659710  dialog = gtk_widget_get_toplevel (widget); 
    660711 
    661   chooser = g_object_get_data (G_OBJECT(dialog), "default"); 
     712  chooser = g_object_get_data (G_OBJECT (dialog), "default"); 
    662713  new_channels = channelcount_chooser_get_count (chooser); 
    663714 
     
    670721channels_dialog_cancel_cb (GtkWidget * widget, gpointer data) 
    671722{ 
    672   GtkWidget * dialog; 
     723  GtkWidget *dialog; 
    673724 
    674725  dialog = gtk_widget_get_toplevel (widget); 
     
    679730channels_dialog_new_cb (GtkWidget * widget, gpointer data) 
    680731{ 
    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; 
    690741 
    691742  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")); 
    693744  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; 
    697748 
    698749  current = g_strdup_printf (_("Currently: %d channels"), 
    699750                             sample->sounddata->format->channels); 
    700751  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); 
    702753  gtk_widget_show (label); 
    703754 
    704755  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); 
    706757  channelcount_chooser_set_count (chooser, 
    707758                                  sample->sounddata->format->channels); 
    708759  gtk_widget_show (chooser); 
    709760 
    710   g_object_set_data (G_OBJECT(dialog), "default", chooser); 
     761  g_object_set_data (G_OBJECT (dialog), "default", chooser); 
    711762 
    712763  /* OK */ 
     
    714765  ok_button = gtk_button_new_with_label (_("OK")); 
    715766  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, 
    717768                      TRUE, TRUE, 0); 
    718769  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); 
    722772 
    723773  /* Cancel */ 
     
    725775  button = gtk_button_new_with_label (_("Cancel")); 
    726776  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, 
    728778                      TRUE, TRUE, 0); 
    729779  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); 
    733782 
    734783  gtk_widget_grab_default (ok_button); 
  • sweep/branches/display-cache/src/channelops.h

    r124 r471  
    2323#define __CHANNELOPS_H__ 
    2424 
    25 void 
    26 dup_stereo_cb (GtkWidget * widget, gpointer data); 
     25void dup_stereo_cb (GtkWidget * widget, gpointer data); 
    2726 
    28 void 
    29 dup_channels_dialog_new_cb (GtkWidget * widget, gpointer data); 
     27void dup_channels_dialog_new_cb (GtkWidget * widget, gpointer data); 
    3028 
    31 void 
    32 mono_mixdown_cb (GtkWidget * widget, gpointer data); 
     29void mono_mixdown_cb (GtkWidget * widget, gpointer data); 
    3330 
    34 void 
    35 remove_left_cb (GtkWidget * widget, gpointer data); 
     31void remove_left_cb (GtkWidget * widget, gpointer data); 
    3632 
    37 void 
    38 remove_right_cb (GtkWidget * widget, gpointer data); 
     33void remove_right_cb (GtkWidget * widget, gpointer data); 
    3934 
    40 void 
    41 stereo_swap_cb (GtkWidget * widget, gpointer data); 
     35void stereo_swap_cb (GtkWidget * widget, gpointer data); 
    4236 
    43 void 
    44 channels_dialog_new_cb (GtkWidget * widget, gpointer data); 
     37void channels_dialog_new_cb (GtkWidget * widget, gpointer data); 
    4538 
    4639#endif /* __CHANNELOPS_H__ */ 
  • sweep/branches/display-cache/src/cursors.c

    r387 r471  
    4242#include "../pixmaps/zoom_out_mask.xbm" 
    4343 
    44 GdkCursor * sweep_cursors[SWEEP_CURSOR_MAX]; 
     44GdkCursor *sweep_cursors[SWEEP_CURSOR_MAX]; 
    4545 
    4646 
    4747void 
    4848create_bitmap_and_mask_from_xpm (GdkBitmap ** bitmap, 
    49                                  GdkBitmap ** mask, 
    50                                  gchar ** xpm) 
     49                                 GdkBitmap ** mask, gchar ** xpm) 
    5150{ 
    5251  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]; 
    5554  int x, y, pix; 
    5655  int transparent_color, black_color; 
    5756 
    58   sscanf (xpm [0], "%d %d %d %d", &height, &width, &colors, &pix); 
     57  sscanf (xpm[0], "%d %d %d %d", &height, &width, &colors, &pix); 
    5958 
    6059  g_assert (height == 32); 
     
    6564  black_color = '.'; 
    6665 
    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; 
    7071 
    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; 
    7477 
    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; 
    7887        } 
    79       } 
    80  
    81       pixmap_buffer [(y * 4 + x/8) - 1] = value; 
    82       mask_buffer [(y * 4 + x/8) - 1] = maskv; 
    8388    } 
    84   } 
    8589 
    8690  *bitmap = gdk_bitmap_create_from_data (NULL, pixmap_buffer, 32, 32); 
     
    9195init_cursors (void) 
    9296{ 
    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 }; 
    97101 
    98102  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); */ 
    100104  sweep_cursors[SWEEP_CURSOR_PENCIL] = gdk_cursor_new (GDK_PENCIL); 
    101105  sweep_cursors[SWEEP_CURSOR_NOISE] = gdk_cursor_new (GDK_SPRAYCAN); 
     106  sweep_cursors[SWEEP_CURSOR_HAND] = gdk_cursor_new (GDK_HAND1); 
    102107 
    103108  create_bitmap_and_mask_from_xpm (&bitmap, &mask, horiz_xpm); 
    104    
     109 
    105110  sweep_cursors[SWEEP_CURSOR_HORIZ] = 
    106111    gdk_cursor_new_from_pixmap (bitmap, mask, &white, &black, 8, 8); 
    107112 
    108113  create_bitmap_and_mask_from_xpm (&bitmap, &mask, horiz_plus_xpm); 
    109    
     114 
    110115  sweep_cursors[SWEEP_CURSOR_HORIZ_PLUS] = 
    111116    gdk_cursor_new_from_pixmap (bitmap, mask, &white, &black, 8, 8); 
    112117 
    113118  create_bitmap_and_mask_from_xpm (&bitmap, &mask, horiz_minus_xpm); 
    114    
     119 
    115120  sweep_cursors[SWEEP_CURSOR_HORIZ_MINUS] = 
    116121    gdk_cursor_new_from_pixmap (bitmap, mask, &white, &black, 8, 8); 
  • sweep/branches/display-cache/src/cursors.h

    r124 r471  
    2222#define __CURSORS_H__ 
    2323 
    24 enum { 
     24enum 
     25
    2526  SWEEP_CURSOR_CROSSHAIR, 
    2627  SWEEP_CURSOR_MOVE, 
     
    3334  SWEEP_CURSOR_PENCIL, 
    3435  SWEEP_CURSOR_NOISE, 
     36  SWEEP_CURSOR_HAND, 
    3537  SWEEP_CURSOR_MAX 
    3638}; 
     
    3840void 
    3941create_bitmap_and_mask_from_xpm (GdkBitmap ** bitmap, 
    40                                  GdkBitmap ** mask, 
    41                                  gchar ** xpm); 
     42                                 GdkBitmap ** mask, gchar ** xpm); 
    4243 
    43 void 
    44 init_cursors (void); 
     44void init_cursors (void); 
    4545 
    4646#endif 
  • sweep/branches/display-cache/src/db_ruler.c

    r340 r471  
    5555 
    5656 
    57 static void db_ruler_class_init    (DbRulerClass *klass); 
    58 static void db_ruler_init          (DbRuler      *db_ruler); 
     57static void db_ruler_class_init (DbRulerClass * klass); 
     58static void db_ruler_init (DbRuler * db_ruler); 
    5959static 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); 
     60static gint 
     61db_ruler_button_press (GtkWidget * widget, GdkEventButton * event); 
     62static gint 
     63db_ruler_button_release (GtkWidget * widget, GdkEventButton * event); 
     64static gint 
     65db_ruler_motion_notify (GtkWidget * widget, GdkEventMotion * event); 
    6666static gint 
    6767db_ruler_leave_notify (GtkWidget * widget, GdkEventCrossing * event); 
    6868 
    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 { 
     69static gboolean db_ruler_scroll_event (GtkWidget * widget, 
     70                                       GdkEventScroll * event); 
     71 
     72static void db_ruler_draw_ticks (GtkRuler * ruler); 
     73static void db_ruler_draw_pos (GtkRuler * ruler); 
     74 
     75static GtkWidgetClass *parent_class = NULL; 
     76 
     77enum 
     78
    7779  CHANGED_SIGNAL, 
    7880  LAST_SIGNAL 
     
    8890  if (!db_ruler_type) 
    8991    { 
    90       static const GTypeInfo db_ruler_info = 
    91       { 
    92                    
     92      static const GTypeInfo db_ruler_info = { 
     93 
    9394        sizeof (DbRulerClass), 
    94         NULL, /* base_init */ 
    95         NULL, /* base_finalize */ 
     95        NULL,                  /* base_init */ 
     96        NULL,                  /* base_finalize */ 
    9697        (GClassInitFunc) db_ruler_class_init, 
    97         NULL, /* class_finalize */ 
    98         NULL, /* class_data */ 
     98        NULL,                  /* class_finalize */ 
     99        NULL,                  /* class_data */ 
    99100        sizeof (DbRuler), 
    100         0,    /* n_preallocs */ 
    101         (GInstanceInitFunc) db_ruler_init,        
     101        0,                     /* n_preallocs */ 
     102        (GInstanceInitFunc) db_ruler_init, 
    102103 
    103104      }; 
    104105 
    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); 
    106108    } 
    107109 
     
    110112 
    111113static void 
    112 db_ruler_class_init (DbRulerClass *klass) 
     114db_ruler_class_init (DbRulerClass * klass) 
    113115{ 
    114116  GtkObjectClass *object_class; 
     
    117119 
    118120  object_class = (GtkObjectClass *) klass; 
    119   widget_class = (GtkWidgetClass*) klass; 
    120   ruler_class = (GtkRulerClass*) klass; 
     121  widget_class = (GtkWidgetClass *) klass; 
     122  ruler_class = (GtkRulerClass *) klass; 
    121123 
    122124  widget_class->realize = db_ruler_realize; 
     
    133135 
    134136  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); 
    142144  klass->changed = NULL; 
    143145} 
    144146 
    145147static 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}; 
    148151 
    149152static gint subdivide[MAXIMUM_SUBDIVIDE] = { 1, 5, 20 }; 
    150153 
    151154static void 
    152 db_ruler_init (DbRuler *db_ruler) 
     155db_ruler_init (DbRuler * db_ruler) 
    153156{ 
    154157  GtkWidget *widget; 
     
    158161  widget->requisition.height = widget->style->ythickness * 2 + 1; 
    159162 
    160   DB_RULER(db_ruler)->dragging = FALSE; 
     163  DB_RULER (db_ruler)->dragging = FALSE; 
    161164} 
    162165 
     
    164167db_ruler_realize (GtkWidget * widget) 
    165168{ 
    166   GtkRuler * ruler; 
     169  GtkRuler *ruler; 
    167170  GdkWindowAttr attributes; 
    168171  gint attributes_mask; 
    169   GdkVisual * visual; 
     172  GdkVisual *visual; 
    170173 
    171174  g_return_if_fail (widget != NULL); 
     
    174177  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); 
    175178 
    176   ruler = GTK_RULER(widget); 
     179  ruler = GTK_RULER (widget); 
    177180 
    178181  attributes.x = widget->allocation.x; 
     
    196199  widget->style = gtk_style_attach (widget->style, widget->window); 
    197200 
    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); 
    201204 
    202205  visual = gdk_window_get_visual (widget->window); 
    203206 
    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    } 
    207211 
    208212  ruler->backing_store = gdk_pixmap_new (widget->window, 
     
    215219} 
    216220 
    217 GtkWidget
     221GtkWidget
    218222db_ruler_new (void) 
    219223{ 
     
    222226 
    223227static gint 
    224 db_ruler_motion_notify (GtkWidget *widget, GdkEventMotion *event) 
     228db_ruler_motion_notify (GtkWidget * widget, GdkEventMotion * event) 
    225229{ 
    226230  GtkRuler *ruler; 
     
    240244    y = event->y; 
    241245 
    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; 
    256263 
    257264  ruler->position = 
     
    264271 
    265272#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))); 
    267275#endif 
    268276 
     
    273281db_ruler_button_press (GtkWidget * widget, GdkEventButton * event) 
    274282{ 
    275   int y; 
     283  int y; 
    276284 
    277285  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    } 
    287296 
    288297  return TRUE; 
     
    292301db_ruler_button_release (GtkWidget * widget, GdkEventButton * event) 
    293302{ 
    294   DB_RULER(widget)->dragging = FALSE; 
     303  DB_RULER (widget)->dragging = FALSE; 
    295304 
    296305  return TRUE; 
     
    298307 
    299308static gboolean 
    300 db_ruler_scroll_event (GtkWidget *widget, GdkEventScroll *event) 
    301 { 
    302   GtkRuler * ruler = GTK_RULER(widget); 
     309db_ruler_scroll_event (GtkWidget * widget, GdkEventScroll * event) 
     310{ 
     311  GtkRuler *ruler = GTK_RULER (widget); 
    303312  float delta; 
    304313 
    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? */ 
    322336} 
    323337 
     
    325339db_ruler_leave_notify (GtkWidget * widget, GdkEventCrossing * event) 
    326340{ 
    327   DB_RULER(widget)->dragging = FALSE; 
     341  DB_RULER (widget)->dragging = FALSE; 
    328342 
    329343  return TRUE; 
     
    331345 
    332346static void 
    333 db_ruler_draw_ticks (GtkRuler *ruler) 
     347db_ruler_draw_ticks (GtkRuler * ruler) 
    334348{ 
    335349  GtkWidget *widget; 
     
    341355  gint length, ideal_length; 
    342356  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 */ 
    344358  gint scale;                   /* Number of units per major unit */ 
    345359  gfloat subd_incr; 
     
    357371  g_return_if_fail (GTK_IS_DB_RULER (ruler)); 
    358372 
    359   if (!GTK_WIDGET_DRAWABLE (ruler))  
     373  if (!GTK_WIDGET_DRAWABLE (ruler)) 
    360374    return; 
    361375 
     
    368382  ythickness = widget->style->ythickness; 
    369383 
    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; */ 
    372386  height = widget->allocation.height; 
    373387 
    374388  layout = gtk_widget_create_pango_layout (widget, "012456789dBinf-"); 
    375389  pango_layout_get_extents (layout, &ink_rect, &logical_rect); 
    376    
     390 
    377391  digit_height = PANGO_PIXELS (ink_rect.height) + 2; 
    378392  digit_offset = ink_rect.y; 
    379393 
    380394  gtk_paint_box (widget->style, ruler->backing_store, 
    381                  GTK_STATE_NORMAL, GTK_SHADOW_OUT,  
     395                 GTK_STATE_NORMAL, GTK_SHADOW_OUT, 
    382396                 NULL, widget, "db_ruler", 
    383                  0, 0,  
    384                  widget->allocation.width, widget->allocation.height); 
     397                 0, 0, widget->allocation.width, widget->allocation.height); 
    385398 
    386399  gdk_draw_line (ruler->backing_store, gc, 
    387400                 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; 
    394405 
    395406//   upper = ruler->upper; 
    396407//   lower = ruler->lower; 
    397408 
    398   if ((upper - lower) == 0)  
     409  if ((upper - lower) == 0) 
    399410    return; 
    400411 
    401412  increment = (gfloat) height / (upper - lower); 
    402   abs_increment = (gfloat) fabs((double)increment); 
     413  abs_increment = (gfloat) fabs ((double) increment); 
    403414 
    404415// * strlen (unit_str) 
    405 text_height = digit_height + 1; 
     416  text_height = digit_height + 1; 
    406417 
    407418  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) 
    411422      break; 
    412423  if (scale == MAXIMUM_SCALES) 
     
    419430 
    420431  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); 
    430436 
    431437  length = 0; 
    432438  for (i = MAXIMUM_SUBDIVIDE - 1; i >= 0; i--) 
    433439    { 
    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) 
    437442        continue; 
    438443 
     
    447452        { 
    448453          start = floor (lower / subd_incr) * subd_incr; 
    449           end   = ceil (upper / subd_incr) * subd_incr; 
     454          end = ceil (upper / subd_incr) * subd_incr; 
    450455        } 
    451456      else 
    452457        { 
    453458          start = floor (upper / subd_incr) * subd_incr; 
    454           end   = ceil (lower / subd_incr) * subd_incr; 
     459          end = ceil (lower / subd_incr) * subd_incr; 
    455460        } 
    456461 
     
    464469 
    465470          /* 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); 
    491498            } 
    492499        } 
    493          
    494     } 
    495          
     500 
     501    } 
     502 
    496503} 
    497504 
    498505static void 
    499 db_ruler_draw_pos (GtkRuler *ruler) 
     506db_ruler_draw_pos (GtkRuler * ruler) 
    500507{ 
    501508  GtkWidget *widget; 
     
    530537          if (ruler->backing_store && ruler->non_gr_exp_gc) 
    531538            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); 
    537543 
    538544          increment = (gfloat) height / (ruler->upper - ruler->lower); 
    539545 
    540546          x = (width - bs_width) + xthickness - 2; 
    541           y = DB_RULER(ruler)->y; 
     547          y = DB_RULER (ruler)->y; 
    542548 
    543549          for (i = 0; i < bs_width; i++) 
    544550            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); 
    547552 
    548553          ruler->xsrc = x; 
  • sweep/branches/display-cache/src/db_ruler.h

    r213 r471  
    4343 
    4444#ifdef __cplusplus 
    45 extern "C" { 
    46 #endif /* __cplusplus */ 
     45extern "C" 
     46
     47#endif                          /* __cplusplus */ 
    4748 
    4849 
     
    5253 
    5354 
    54 typedef struct _DbRuler      DbRuler; 
    55 typedef struct _DbRulerClass DbRulerClass; 
     55  typedef struct _DbRuler DbRuler; 
     56  typedef struct _DbRulerClass DbRulerClass; 
    5657 
    57 struct _DbRuler 
    58 
    59   GtkRuler ruler; 
     58  struct _DbRuler 
     59 
     60    GtkRuler ruler; 
    6061 
    61   gfloat y; 
    62   gboolean dragging; 
    63 }; 
     62    gfloat y; 
     63    gboolean dragging; 
     64  }; 
    6465 
    65 struct _DbRulerClass 
    66 
    67   GtkRulerClass parent_class; 
     66  struct _DbRulerClass 
     67 
     68    GtkRulerClass parent_class; 
    6869 
    69   void (*changed) (DbRuler * ruler); 
    70 }; 
     70    void (*changed) (DbRuler * ruler); 
     71  }; 
    7172 
    7273 
    73 GType      db_ruler_get_type (void); 
    74 GtkWidget* db_ruler_new      (void); 
     74  GType db_ruler_get_type (void); 
     75  GtkWidget *db_ruler_new (void); 
    7576 
    7677#ifdef __cplusplus 
    7778} 
    78 #endif /* __cplusplus */ 
     79#endif                         /* __cplusplus */ 
    7980 
    8081 
    81 #endif /* __DB_RULER_H__ */ 
     82#endif                         /* __DB_RULER_H__ */ 
  • sweep/branches/display-cache/src/db_slider.c

    r298 r471  
    4242#include "db_slider.h" 
    4343 
    44 enum { 
     44enum 
     45
    4546  VALUE_CHANGED_SIGNAL, 
    4647  LAST_SIGNAL 
     
    5051 
    5152static void 
    52 db_slider_class_init(DbSliderClass * klass) 
     53db_slider_class_init (DbSliderClass * klass) 
    5354{ 
    5455  GtkObjectClass *object_class; 
     
    5758 
    5859  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); 
    6670  klass->value_changed = NULL; 
    6771} 
     
    7377 
    7478GType 
    75 db_slider_get_type() 
     79db_slider_get_type () 
    7680{ 
    7781  static GType db_slider_type = 0; 
    7882 
    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    } 
    97103 
    98104  return db_slider_type; 
     
    103109slider_get_value (GtkWidget * slider) 
    104110{ 
    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")); 
    107112} 
    108113 
     
    110115slider_set_value (GtkWidget * slider, int value) 
    111116{ 
    112   GtkWidget * combo_entry; 
     117  GtkWidget *combo_entry; 
    113118  int i; 
    114119 
    115120  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    } 
    124131 
    125132  /* 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); 
    127134 
    128135  return slider_set_value_direct (slider, value);; 
     
    141148db_slider_get_value (DbSlider * slider) 
    142149{ 
    143   return ADJ_TO_VALUE(GTK_ADJUSTMENT(slider->adj)->value); 
     150  return ADJ_TO_VALUE (GTK_ADJUSTMENT (slider->adj)->value); 
    144151} 
    145152 
     
    147154db_slider_set_value (DbSlider * slider, gfloat value) 
    148155{ 
    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)); 
    151158} 
    152159 
     
    154161db_slider_value_changed_cb (GtkWidget * widget, gpointer data) 
    155162{ 
    156   GtkWidget * slider = (GtkWidget *)data; 
     163  GtkWidget *slider = (GtkWidget *) data; 
    157164  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)); 
    161168  db_value = VALUE_TO_DB (value); 
    162169 
    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); 
    170180 
    171181  g_free (db_text); 
    172182 
    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); 
    175184} 
    176185 
     
    178187db_slider_build (GtkWidget * slider, gchar * title, gfloat value) 
    179188{ 
    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; 
    187196 
    188197  vbox = gtk_vbox_new (FALSE, 0); 
    189   gtk_container_add (GTK_CONTAINER(slider), vbox); 
     198  gtk_container_add (GTK_CONTAINER (slider), vbox); 
    190199  gtk_widget_show (vbox); 
    191200 
    192201  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); 
    194203  gtk_widget_show (label); 
    195204 
    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); 
    211220  gtk_widget_show (vscale); 
    212221 
    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; 
    217226 
    218227  db_slider_value_changed_cb (NULL, slider); 
     
    220229  range_text = g_strdup_printf ("%s\n[%2.0f to %2.0f dB]", 
    221230                                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)); 
    224233 
    225234  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); 
    228237} 
    229238 
     
    232241db_slider_new (gchar * title, gfloat value, gfloat lower, gfloat upper) 
    233242{ 
    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)); 
    235244 
    236245  slider->lower = lower; 
  • sweep/branches/display-cache/src/db_slider.h

    r215 r471  
    3232typedef struct _DbSliderClass DbSliderClass; 
    3333 
    34 struct _DbSlider { 
     34struct _DbSlider 
     35
    3536  GtkEventBox ebox; 
    3637 
    37   GtkObject * adj; 
    38   GtkWidget * db_label; 
     38  GtkObject *adj; 
     39  GtkWidget *db_label; 
    3940 
    4041  gfloat lower; 
     
    4243}; 
    4344 
    44 struct _DbSliderClass { 
     45struct _DbSliderClass 
     46
    4547  GtkVBoxClass parent_class; 
    46    
     48 
    4749  void (*value_changed) (DbSlider * slider, gfloat value); 
    4850}; 
    4951 
    5052GType db_slider_get_type (void); 
    51 GtkWidget * db_slider_new (gchar * title, gfloat value, gfloat lower, 
    52                           gfloat upper); 
     53GtkWidget *db_slider_new (gchar * title, gfloat value, gfloat lower, 
     54                          gfloat upper); 
    5355gfloat db_slider_get_value (DbSlider * slider); 
    5456void db_slider_set_value (DbSlider * slider, gfloat value); 
  • sweep/branches/display-cache/src/display-cache.c

    r425 r471  
    3232 
    3333#ifdef HAVE_LIBSAMPLERATE 
    34        #include <samplerate.h> 
     34#include <samplerate.h> 
    3535#endif 
    3636 
    3737#include "display-cache.h" 
    3838#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 */ 
    3947 
    4048#define STEP_MAX  256 
     
    4654//#define DEBUG_VERY_VERBOSE_CUST 
    4755 
    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; 
     56static void 
     57display_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; 
    5362} 
    5463 
    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; 
     64static void 
     65display_cache_remove_sample (DisplayCache * dc) 
     66
     67  dc->sample->dispcaches = g_list_remove (dc->sample->dispcaches, dc); 
     68  dc->sample = NULL; 
    5969} 
    6070 
    6171// 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; 
     72static void 
     73display_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; 
    7586}; 
    7687 
    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; 
     88static void 
     89display_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; 
    109122} 
    110123 
    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; 
     124void 
     125display_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; 
    143157} 
    144158 
    145159// 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; 
     160DisplayCache * 
     161display_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; 
    167182}; 
    168183 
    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); 
     184void 
     185display_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); 
    182198}; 
    183199 
    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"); 
     200void 
     201display_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"); 
    210227#endif 
    211228}; 
    212229 
    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         } 
     230void 
     231display_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    } 
    233251}; 
    234252 
    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         } 
     253void 
     254display_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    } 
    253272} 
    254273 
    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++) 
     274void 
     275display_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) 
    267311                { 
    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; 
    304313                } 
    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    } 
    306339} 
    307340 
    308341#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         } 
     342void 
     343display_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    } 
    358400} 
    359401#endif 
     
    364406// end: last sample frame on view 
    365407// 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 
     408void 
     409display_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 
    430481 
    431482#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    { 
    449502 
    450503#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 
    459513 
    460514#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 
    483536 
    484537#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 left 
    509                        // TODO: make valid parameters for sinc interpolation 
     538          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 
    510563 
    511564#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 
    533589 
    534590#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); 
    579639#endif 
    580640 
    581641#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 
    594656#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); 
    607672 
    608673}; 
    609674 
    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"); 
     675void 
     676display_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"); 
    639707#endif 
    640708}; 
    641709 
    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"); 
     710void 
     711display_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"); 
    676747#endif 
    677748}; 
  • sweep/branches/display-cache/src/display-cache.h

    r425 r471  
    3030// DC_OPS_INPROGRESS - operation which invalidate cache is in progress -> always invalidate cache 
    3131// DC_OPS_DONE - operation which invalidated cache is done - we can make cache valid and set  
    32 //                                                     flag to DC_OPS_NONE 
     32//                                                      flag to DC_OPS_NONE 
    3333//  
    34 enum { 
    35         DC_OPS_NONE, 
    36         DC_OPS_INVALID, 
    37         DC_OPS_INPROGRESS, 
    38         DC_OPS_DONE 
     34enum 
     35
     36  DC_OPS_NONE, 
     37  DC_OPS_INVALID, 
     38  DC_OPS_INPROGRESS, 
     39  DC_OPS_DONE 
    3940}; 
    4041 
    41 typedef struct _DisplayCache           DisplayCache; 
     42typedef struct _DisplayCache DisplayCache; 
    4243 
    4344struct _DisplayCache 
    4445{ 
    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 channels 
    49        sw_framecount_t psoff;         // start offset in prepare 
    50        sw_framecount_t peoff;         // end offset in prepare 
     46  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 
    5152 
    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 general 
    54        gint    ops;                                                           // indicate working or done operation which invalidate cache 
    55        sw_sample       *sample;                               // cached sample 
    56          
    57        sw_audio_t      *min;                                  // min data 
    58        sw_audio_t      *max;                                  // max data 
    59        sw_audio_t      *rms;                                  // rms data (average) 
    60        gboolean          *points;                     // display sample points 
     53  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 
    6162}; 
    6263 
    6364// 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); 
     65DisplayCache *display_cache_new (sw_framecount_t len); 
     66void display_cache_delete (DisplayCache * dc); 
     67void display_cache_invalidate_start (sw_sample * sample); 
     68void display_cache_invalidate_end (sw_sample * sample); 
    6869 
    6970// *dc: pointer to DisplayCache structure 
     
    7273// end: last sample frame on view 
    7374// 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); 
     75void display_cache_prepare (DisplayCache * dc, sw_sample * sample, 
     76                            sw_framecount_t start, sw_framecount_t end, 
     77                            sw_framecount_t length); 
    7578 
    7679// *dc: pointer to DisplayCache structure 
     
    7982// **points: pointer to array for sample points indications 
    8083// 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); 
     84void display_cache_get_minmax (DisplayCache * dc, sw_audio_t ** min, 
     85                               sw_audio_t ** max, gboolean ** points, 
     86                               gint offset, sw_framecount_t length); 
    8387 
    8488// *dc: pointer to DisplayCache structure 
     
    8993// length: length of prepared arrays 
    9094// 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); 
     95void 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); 
    9399 
    94100#endif /* _DISPLAY_CACHE_H */ 
  • sweep/branches/display-cache/src/driver.c

    r272 r471  
    4343#include "driver.h" 
    4444 
    45 extern sw_driver * driver_alsa; 
    46 extern sw_driver * driver_oss; 
    47 extern sw_driver * driver_solaris; 
    48  
    49 extern GMutex * play_mutex; 
     45extern sw_driver *driver_alsa; 
     46extern sw_driver *driver_oss; 
     47extern sw_driver *driver_solaris; 
     48 
     49extern GMutex *play_mutex; 
    5050 
    5151/* preferred driver */ 
     
    5454}; 
    5555 
    56 static sw_driver * pref = &_driver_null; 
     56static sw_driver *pref = &_driver_null; 
    5757 
    5858#include "preferences.h" 
     
    6262pcmio_get_default_main_dev (void) 
    6363{ 
    64   GList * names = NULL, * gl; 
     64  GList *names = NULL, *gl; 
    6565 
    6666  if (pref->get_names) 
    6767    names = pref->get_names (); 
    6868 
    69   if ((gl = names) != NULL) { 
    70     return (char *)gl->data; 
    71   } 
     69  if ((gl = names) != NULL) 
     70    { 
     71      return (char *) gl->data; 
     72    } 
    7273 
    7374  return NULL; 
     
    7778pcmio_get_default_monitor_dev (void) 
    7879{ 
    79   GList * names = NULL, * gl; 
     80  GList *names = NULL, *gl; 
    8081 
    8182  if (pref->get_names) 
    8283    names = pref->get_names (); 
    8384 
    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    } 
    8992 
    9093  return NULL; 
     
    9497pcmio_get_main_dev (void) 
    9598{ 
    96   char * main_dev; 
     99  char *main_dev; 
    97100 
    98101  main_dev = prefs_get_string (DEV_KEY); 
    99102 
    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 
    102106  return main_dev; 
    103107} 
     
    106110pcmio_get_monitor_dev (void) 
    107111{ 
    108   char * monitor_dev; 
     112  char *monitor_dev; 
    109113 
    110114  monitor_dev = prefs_get_string (MONITOR_DEV_KEY); 
    111115 
    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 
    114119  return monitor_dev; 
    115120} 
     
    118123pcmio_get_use_monitor (void) 
    119124{ 
    120   int * use_monitor; 
     125  int *use_monitor; 
    121126 
    122127  use_monitor = prefs_get_int (USE_MONITOR_KEY); 
    123128 
    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); 
    126133} 
    127134 
     
    129136pcmio_get_log_frags (void) 
    130137{ 
    131   int * log_frags; 
     138  int *log_frags; 
    132139 
    133140  log_frags = prefs_get_int (LOG_FRAGS_KEY); 
    134141 
    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 
     148extern GtkStyle *style_bw; 
     149static GtkWidget *dialog = NULL; 
     150static GtkWidget *main_combo; 
     151static GtkWidget *monitor_combo; 
     152static GtkObject *adj; 
    144153 
    145154 
     
    147156monitor_checked (GtkWidget * dialog) 
    148157{ 
    149   GtkWidget * monitor_chb; 
     158  GtkWidget *monitor_chb; 
    150159 
    151160  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")); 
    153162 
    154163  return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (monitor_chb)); 
     
    158167config_dev_dsp_dialog_ok_cb (GtkWidget * widget, gpointer data) 
    159168{ 
    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"); 
    165174 
    166175  prefs_set_int (LOG_FRAGS_KEY, adj->value); 
    167176 
    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    } 
    182193 
    183194  gtk_widget_hide (dialog); 
     
    187198config_dev_dsp_dialog_cancel_cb (GtkWidget * widget, gpointer data) 
    188199{ 
    189   GtkWidget * dialog; 
     200  GtkWidget *dialog; 
    190201 
    191202  dialog = gtk_widget_get_toplevel (widget); 
     
    196207update_ok_button (GtkWidget * widget, gpointer data) 
    197208{ 
    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; 
    201212  gboolean ok = FALSE; 
    202213 
    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    } 
    216229 
    217230  gtk_widget_set_sensitive (ok_button, ok); 
     
    221234set_monitor_widgets (GtkWidget * dialog, gboolean use_monitor) 
    222235{ 
    223   GtkWidget * monitor_chb, * monitor_widget, * swap; 
     236  GtkWidget *monitor_chb, *monitor_widget, *swap; 
    224237 
    225238  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"); 
    230243  gtk_widget_set_sensitive (monitor_widget, use_monitor); 
    231244 
    232   swap = g_object_get_data (G_OBJECT(dialog), "swap"); 
     245  swap = g_object_get_data (G_OBJECT (dialog), "swap"); 
    233246  gtk_widget_set_sensitive (swap, use_monitor); 
    234247 
     
    238251set_buff_adj (GtkWidget * dialog, gint logfrags) 
    239252{ 
    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"); 
    243256  gtk_adjustment_set_value (adj, logfrags); 
    244257} 
     
    247260pcmio_devname_swap_cb (GtkWidget * widget, gpointer data) 
    248261{ 
    249   GtkWidget * dialog = GTK_WIDGET (data); 
    250   gchar * main_dev, * monitor_dev; 
     262  GtkWidget *dialog = GTK_WIDGET (data); 
     263  gchar *main_dev, *monitor_dev; 
    251264 
    252265  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); 
    258273 
    259274  g_free (main_dev); 
    260275 
    261   set_monitor_widgets (dialog, pcmio_get_use_monitor()); 
     276  set_monitor_widgets (dialog, pcmio_get_use_monitor ()); 
    262277 
    263278  update_ok_button (widget, data); 
     
    267282pcmio_devname_reset_cb (GtkWidget * widget, gpointer data) 
    268283{ 
    269   GtkWidget * dialog = GTK_WIDGET (data); 
    270   char * main_dev, * monitor_dev; 
     284  GtkWidget *dialog = GTK_WIDGET (data); 
     285  char *main_dev, *monitor_dev; 
    271286 
    272287  main_dev = pcmio_get_main_dev (); 
    273288  monitor_dev = pcmio_get_monitor_dev (); 
    274289 
    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 ()); 
    279295 
    280296  update_ok_button (widget, data); 
     
    284300pcmio_devname_default_cb (GtkWidget * widget, gpointer data) 
    285301{ 
    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    } 
    296314 
    297315  set_monitor_widgets (dialog, DEFAULT_USE_MONITOR); 
     
    303321monitor_enable_cb (GtkWidget * widget, gpointer data) 
    304322{ 
    305   GtkWidget * dialog = GTK_WIDGET (data); 
     323  GtkWidget *dialog = GTK_WIDGET (data); 
    306324  gboolean active; 
    307325 
    308   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)); 
     326  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); 
    309327 
    310328  set_monitor_widgets (dialog, active); 
     
    314332pcmio_buffering_reset_cb (GtkWidget * widget, gpointer data) 
    315333{ 
    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 ()); 
    319337} 
    320338 
     
    322340pcmio_buffering_default_cb (GtkWidget * widget, gpointer data) 
    323341{ 
    324   GtkWidget * dialog = GTK_WIDGET (data); 
     342  GtkWidget *dialog = GTK_WIDGET (data); 
    325343 
    326344  set_buff_adj (dialog, DEFAULT_LOG_FRAGS); 
     
    330348create_devices_combo (void) 
    331349{ 
    332   GtkWidget * combo; 
    333   GList * cbitems = NULL; 
     350  GtkWidget *combo; 
     351  GList *cbitems = NULL; 
    334352 
    335353  if (pref->get_names) 
    336     cbitems = pref->get_names(); 
    337    
     354    cbitems = pref->get_names (); 
     355 
    338356  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); 
    341359 
    342360  return combo; 
     
    346364device_config (void) 
    347365{ 
    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); 
    447468 
    448469#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); 
    454475#endif 
    455476 
    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); 
    601621 
    602622#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); 
    611631#endif 
    612632 
    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), 
    644664                      pcmio_get_main_dev ()); 
    645665 
    646   gtk_entry_set_text (GTK_ENTRY(GTK_COMBO(monitor_combo)->entry), 
     666  gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (monitor_combo)->entry), 
    647667                      pcmio_get_monitor_dev ()); 
    648668 
    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    } 
    656679} 
    657680 
  • sweep/branches/display-cache/src/driver.h

    r124 r471  
    3131typedef struct _sw_driver sw_driver; 
    3232 
    33 struct _sw_handle { 
     33struct _sw_handle 
     34
    3435  int driver_flags; 
    3536  int driver_fd; 
    3637  int driver_channels; 
    3738  int driver_rate; 
    38   void * custom_data; 
     39  void *custom_data; 
    3940}; 
    4041 
    41 struct _sw_driver { 
    42   GList * (*get_names) (void); 
    43   sw_handle * (*open) (int cueing, int flags); 
     42struct _sw_driver 
     43
     44  GList *(*get_names) (void); 
     45  sw_handle *(*open) (int cueing, int flags); 
    4446  void (*setup) (sw_handle * handle, sw_format * format); 
    4547  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); 
    5052  void (*reset) (sw_handle * handle); 
    5153  void (*flush) (sw_handle * handle); 
     
    5456}; 
    5557 
    56 void 
    57 device_config (void); 
     58void device_config (void); 
    5859 
    59 sw_handle * 
    60 device_open (int cueing, int flags); 
     60sw_handle *device_open (int cueing, int flags); 
    6161 
    62 void 
    63 device_setup (sw_handle * handle, sw_format * format); 
     62void device_setup (sw_handle * handle, sw_format * format); 
    6463 
    65 int 
    66 device_wait (sw_handle * handle); 
     64int device_wait (sw_handle * handle); 
    6765 
    6866/* 
    6967 * For recording, ie. reading pcm data from the device. 
    7068 */ 
    71 ssize_t 
    72 device_read (sw_handle * handle, sw_audio_t * buf, size_t count); 
     69ssize_t device_read (sw_handle * handle, sw_audio_t * buf, size_t count); 
    7370 
    7471ssize_t 
     
    9390 * PortAudio. So for now, just return -1. 
    9491 */ 
    95 sw_framecount_t 
    96 device_offset (sw_handle * handle); 
     92sw_framecount_t device_offset (sw_handle * handle); 
    9793 
    9894/* 
     
    10298 * it can accept new parameters, but sweep's not actually making use of that. 
    10399 */ 
    104 void 
    105 device_reset (sw_handle * handle); 
     100void device_reset (sw_handle * handle); 
    106101 
    107 void 
    108 device_flush (sw_handle * handle); 
     102void device_flush (sw_handle * handle); 
    109103 
    110104/* 
     
    112106 * (otherwise you often lose the last bit of sound when closing the device). 
    113107 */ 
    114 void 
    115 device_drain (sw_handle * handle); 
     108void device_drain (sw_handle * handle); 
    116109 
    117 void 
    118 device_close (sw_handle * handle); 
     110void device_close (sw_handle * handle); 
    119111 
    120 void 
    121 init_devices (void); 
     112void init_devices (void); 
    122113 
    123 void 
    124 stop_playback (sw_sample * s) ; 
     114void stop_playback (sw_sample * s); 
    125115 
    126116#endif /* __DRIVER_H__ */ 
  • sweep/branches/display-cache/src/driver_alsa.c

    r198 r471  
    6565#endif 
    6666 
    67 void print_pcm_state (snd_pcm_t * pcm) 
    68 
    69   switch (snd_pcm_state(pcm)) { 
     67void 
     68print_pcm_state (snd_pcm_t * pcm) 
     69
     70  switch (snd_pcm_state (pcm)) 
     71    { 
    7072    case SND_PCM_STATE_OPEN: 
    7173      fprintf (stderr, "sweep: print_pcm_state: state is OPEN\n"); 
     
    9395      break; 
    9496    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    } 
    97100} 
    98101 
     
    100103alsa_get_names (void) 
    101104{ 
    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    } 
    108112 
    109113  /* The standard command line options for this are -D or --device. 
     
    122126{ 
    123127  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; 
    127131  snd_pcm_stream_t stream; 
    128132 
    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    { 
    133155      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    } 
    152165 
    153166  handle = g_malloc0 (sizeof (sw_handle)); 
     
    165178{ 
    166179  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; 
    169182  int dir; 
    170183  unsigned int rate = format->rate; 
    171184  unsigned int channels = format->channels; 
    172185  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; 
    174187 
    175188#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    } 
    183201#else 
    184202  dir = 0; 
     
    187205  snd_pcm_hw_params_alloca (&hwparams); 
    188206 
    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    } 
    195214 
    196215  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    } 
    203223 
    204224  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   
    212232 
    213233  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   
    221241 
    222242  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   
    230250 
    231251  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 ()); 
    240261 
    241262  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    } 
    249271 
    250272  // see alsa-lib html docs (may have to build them) for methods doco 
     
    257279  // params.buffer_size = 3 * params.frag_size; 
    258280 
    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    } 
    265288  //printf ("sweep: alsa_setup 9\n"); 
    266289 
     
    269292    int dir = 0; 
    270293 
    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      } 
    282307 
    283308#ifdef DEBUG 
     
    289314  } 
    290315 
    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    } 
    295322} 
    296323 
     
    298325alsa_device_wait (sw_handle * handle) 
    299326{ 
    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    } 
    305333 
    306334  return 0; 
     
    312340alsa_device_read (sw_handle * handle, sw_audio_t * buf, size_t count) 
    313341{ 
    314   snd_pcm_t * pcm_handle = (snd_pcm_t *)handle->custom_data; 
     342  snd_pcm_t *pcm_handle = (snd_pcm_t *) handle->custom_data; 
    315343  snd_pcm_uframes_t uframes; 
    316344  int err; 
     
    325353static ssize_t 
    326354alsa_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; 
    330358  snd_pcm_uframes_t uframes; 
    331   snd_pcm_status_t * status; 
     359  snd_pcm_status_t *status; 
    332360  int err; 
    333361 
    334362#if 0 
    335   gint16 * bbuf; 
     363  gint16 *bbuf; 
    336364  size_t byte_count; 
    337365  ssize_t bytes_written; 
     
    339367  int i; 
    340368 
    341   if (handle == NULL) { 
     369  if (handle == NULL) 
     370    { 
    342371#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   
    347376 
    348377  byte_count = count * sizeof (gint16); 
    349378  bbuf = alloca (byte_count); 
    350379 
    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); 
    356386#else 
    357   /*printf ("sweep: alsa_write \n");*/ 
     387  /*printf ("sweep: alsa_write \n"); */ 
    358388 
    359389  uframes = count / handle->driver_channels; 
     
    361391 
    362392  // 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    } 
    392436 
    393437  return 1; 
     
    397441alsa_device_offset (sw_handle * handle) 
    398442{ 
    399   /*printf ("sweep: alsa_offset\n");*/ 
     443  /*printf ("sweep: alsa_offset\n"); */ 
    400444  return -1; 
    401445} 
     
    404448alsa_device_reset (sw_handle * handle) 
    405449{ 
    406   /*printf ("sweep: alsa_reset\n");*/ 
     450  /*printf ("sweep: alsa_reset\n"); */ 
    407451} 
    408452 
     
    410454alsa_device_flush (sw_handle * handle) 
    411455{ 
    412   /*printf ("sweep: alsa_flush\n");*/ 
     456  /*printf ("sweep: alsa_flush\n"); */ 
    413457} 
    414458 
     
    421465alsa_device_drain (sw_handle * handle) 
    422466{ 
    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    } 
    433479} 
    434480 
     
    436482alsa_device_close (sw_handle * handle) 
    437483{ 
    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 
    440486  snd_pcm_close (pcm_handle); 
    441487} 
     
    463509#endif 
    464510 
    465 sw_driver * driver_alsa = &_driver_alsa; 
     511sw_driver *driver_alsa = &_driver_alsa; 
  • sweep/branches/display-cache/src/driver_oss.c

    r124 r471  
    6060typedef struct _oss_play_offset oss_play_offset; 
    6161 
    62 struct _oss_play_offset { 
     62struct _oss_play_offset 
     63
    6364  int framenr; 
    6465  sw_framecount_t offset; 
     
    6667 
    6768 
    68 static oss_play_offset offsets[1<<LOG_FRAGS_MAX]; 
     69static oss_play_offset offsets[1 << LOG_FRAGS_MAX]; 
    6970 
    7071static int nfrags = 0; 
     
    8485oss_get_names (void) 
    8586{ 
    86   GList * names = NULL; 
     87  GList *names = NULL; 
    8788 
    8889  names = g_list_append (names, "/dev/dsp"); 
     
    9697open_dev_dsp (int monitoring, int flags) 
    9798{ 
    98   char * dev_name; 
     99  char *dev_name; 
    99100  int dev_dsp; 
    100   sw_handle * handle; 
     101  sw_handle *handle; 
    101102  int i; 
    102103 
    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); 
    107121      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    } 
    118123 
    119124  handle = g_malloc0 (sizeof (sw_handle)); 
     
    123128  oindex = 0; 
    124129  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    } 
    129135  frame = 0; 
    130136 
     
    136142{ 
    137143  int dev_dsp; 
    138   /*  int mask, format, stereo, frequency;*/ 
     144  /*  int mask, format, stereo, frequency; */ 
    139145 
    140146  int stereo = 0; 
     
    146152  int fmt; 
    147153 
    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    } 
    154161 
    155162  dev_dsp = handle->driver_fd; 
    156163 
    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 ()); 
    169178  fragsize = 8; 
    170179  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    } 
    174184 
    175185  fragsize = (frag & 0xffff); 
    176   nfrags = (frag & 0x7fff000)>>16; 
     186  nfrags = (frag & 0x7fff000) >> 16; 
    177187#ifdef DEBUG 
    178188  g_print ("Got %d frags of size 2^%d\n", nfrags, fragsize); 
    179189#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    } 
    198213 
    199214  handle->driver_channels = channels; 
     
    201216  srate = format->rate; 
    202217 
    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    } 
    207223 
    208224  handle->driver_rate = srate; 
    209225 
    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    } 
    214231 
    215232  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); 
    222240 
    223241#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    } 
    227246#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    } 
    231251#endif 
    232252 
     
    235255    int caps; 
    236256 
    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      } 
    240261    /* CAP_REALTIME tells whether or not this device can give exact 
    241262     * DMA pointers via GETOSPACE/GETISPACE. If this is true, then 
     
    261282read_dev_dsp (sw_handle * handle, sw_audio_t * buf, size_t count) 
    262283{ 
    263   gint16 * bbuf; 
     284  gint16 *bbuf; 
    264285  size_t byte_count; 
    265286  ssize_t bytes_read; 
     
    271292  bytes_read = read (handle->driver_fd, bbuf, byte_count); 
    272293 
    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    } 
    294319 
    295320  return (bytes_read / sizeof (gint16)); 
     
    302327               sw_framecount_t play_offset) 
    303328{ 
    304   gint16 * bbuf; 
     329  gint16 *bbuf; 
    305330  size_t byte_count; 
    306331  ssize_t bytes_written; 
     
    308333  int i; 
    309334 
    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    } 
    316342 
    317343  current_frame += count; 
    318344  offsets[oindex].framenr = current_frame; 
    319345  offsets[oindex].offset = play_offset; 
    320   oindex++; oindex %= nfrags; 
     346  oindex++; 
     347  oindex %= nfrags; 
    321348 
    322349  byte_count = count * sizeof (gint16); 
    323350  bbuf = alloca (byte_count); 
    324351 
    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    } 
    341371 
    342372  bytes_written = write (handle->driver_fd, bbuf, byte_count); 
    343373 
    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    } 
    350383} 
    351384 
     
    356389  int i, o; 
    357390 
    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    { 
    366401#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   
    371406 
    372407  frame = info.bytes; 
     
    375410#endif 
    376411 
    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; 
    380416#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    } 
    388425 
    389426  return -1; 
     
    393430reset_dev_dsp (sw_handle * handle) 
    394431{ 
    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    } 
    405444} 
    406445 
     
    413452drain_dev_dsp (sw_handle * handle) 
    414453{ 
    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    } 
    427469} 
    428470 
     
    455497#endif 
    456498 
    457 sw_driver * driver_oss = &_driver_oss; 
     499sw_driver *driver_oss = &_driver_oss; 
  • sweep/branches/display-cache/src/driver_solaris.c

    r124 r471  
    5252{ 
    5353  int dev_audio; 
    54   sw_handle * handle; 
     54  sw_handle *handle; 
    5555 
    56   if (cueing) return NULL; 
     56  if (cueing) 
     57    return NULL; 
    5758 
    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    } 
    6264 
    6365  handle = g_malloc0 (sizeof (sw_handle)); 
     
    7375  audio_info_t info; 
    7476 
    75   AUDIO_INITINFO(&info); 
     77  AUDIO_INITINFO (&info); 
    7678  info.play.precision = 16;     /* cs4231 doesn't handle 16-bit linear PCM */ 
    7779  info.play.encoding = AUDIO_ENCODING_LINEAR; 
    7880  info.play.channels = format->channels; 
    7981  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"); 
    8284 
    8385  handle->driver_channels = info.play.channels; 
     
    8587 
    8688static ssize_t 
    87 write_dev_audio (sw_handle * handle, void * buf, size_t count) 
     89write_dev_audio (sw_handle * handle, void *buf, size_t count) 
    8890{ 
    8991  return write (handle->driver_fd, buf, count); 
     
    98100flush_dev_audio (sw_handle * handle) 
    99101{ 
    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"); 
    102104} 
    103105 
     
    105107drain_dev_audio (sw_handle * handle) 
    106108{ 
    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"); 
    109111} 
    110112 
     
    116118 
    117119static sw_driver _driver_solaris = { 
    118   NULL, /* config */ 
     120  NULL,                                /* config */ 
    119121  open_dev_audio, 
    120122  setup_dev_audio, 
     
    135137#endif 
    136138 
    137 sw_driver * driver_solaris = &_driver_solaris; 
     139sw_driver *driver_solaris = &_driver_solaris; 
  • sweep/branches/display-cache/src/edit.c

    r124 r471  
    4545 
    4646 
    47 sw_edit_buffer * ebuf = NULL; 
     47sw_edit_buffer *ebuf = NULL; 
    4848 
    4949void * 
    50 sweep_large_alloc_data (size_t len, void * data, int prot) 
    51 { 
    52   void * ptr; 
     50sweep_large_alloc_data (size_t len, void *data, int prot) 
     51{ 
     52  void *ptr; 
    5353 
    5454#if HAVE_MMAP 
    55   FILE * f; 
     55  FILE *f; 
    5656  int fd; 
    5757 
    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    } 
    8287#else 
    8388  ptr = g_malloc (len); 
     
    9297sweep_large_alloc_zero (size_t len, int prot) 
    9398{ 
    94   void * ptr; 
     99  void *ptr; 
    95100 
    96101#if HAVE_MMAP 
    97102  int fd; 
    98103 
    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    } 
    123133#else 
    124134  ptr = g_malloc0 (len); 
     
    129139 
    130140void 
    131 sweep_large_free (void * ptr, size_t len) 
     141sweep_large_free (void *ptr, size_t len) 
    132142{ 
    133143#if HAVE_MMAP 
     
    143153                 sw_framecount_t end, gpointer data) 
    144154{ 
    145   sw_edit_region * er; 
     155  sw_edit_region *er; 
    146156  sw_framecount_t len; 
    147157 
    148   er = g_malloc (sizeof(sw_edit_region)); 
     158  er = g_malloc (sizeof (sw_edit_region)); 
    149159 
    150160  er->start = start; 
    151161  er->end = end; 
    152162 
    153   len = frames_to_bytes (format, end-start); 
     163  len = frames_to_bytes (format, end - start); 
    154164  er->data = sweep_large_alloc_data (len, data, PROT_READ); 
    155165 
     
    165175 
    166176  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); 
    170180} 
    171181 
     
    173183edit_region_copy (sw_format * format, sw_edit_region * oer) 
    174184{ 
    175   sw_edit_region * er; 
     185  sw_edit_region *er; 
    176186 
    177187  er = edit_region_new (format, oer->start, oer->end, oer->data); 
     
    183193edit_buffer_new (sw_format * format) 
    184194{ 
    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)); 
    188198  eb->format = format_copy (format); 
    189199  eb->regions = NULL; 
     
    196206edit_buffer_copy (sw_edit_buffer * oeb) 
    197207{ 
    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; 
    201211 
    202212  eb = edit_buffer_new (oeb->format); 
    203213 
    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    } 
    211222 
    212223  return eb; 
     
    223234edit_buffer_clear (sw_edit_buffer * eb) 
    224235{ 
    225   GList * gl; 
    226   sw_edit_region * er; 
     236  GList *gl; 
     237  sw_edit_region *er; 
    227238  size_t len; 
    228239 
    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    } 
    238252  g_list_free (eb->regions); 
    239253 
     
    249263{ 
    250264  eb->refcount--; 
    251   if (eb->refcount > 0) return; 
     265  if (eb->refcount > 0) 
     266    return; 
    252267 
    253268  edit_buffer_clear (eb); 
     
    258273ebuf_clear (void) 
    259274{ 
    260   if (!ebuf) return; 
     275  if (!ebuf) 
     276    return; 
    261277 
    262278  edit_buffer_destroy (ebuf); 
     
    268284edit_buffer_length (sw_edit_buffer * eb) 
    269285{ 
    270   GList * gl; 
    271   sw_edit_region * er; 
     286  GList *gl; 
     287  sw_edit_region *er; 
    272288  sw_framecount_t length = 0; 
    273289 
    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    } 
    279296 
    280297  return length; 
     
    284301edit_buffer_width (sw_edit_buffer * eb) 
    285302{ 
    286   GList * gl; 
    287   sw_edit_region * er; 
     303  GList *gl; 
     304  sw_edit_region *er; 
    288305  sw_framecount_t start, end; 
    289306 
    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; 
    294313  start = er->start; 
    295314 
    296315  gl = g_list_last (eb->regions); 
    297   er = (sw_edit_region *)gl->data; 
     316  er = (sw_edit_region *) gl->data; 
    298317  end = er->end; 
    299    
     318 
    300319  return (end - start); 
    301320} 
     
    310329edit_buffer_from_sounddata_sels (sw_sounddata * sounddata, GList * sels) 
    311330{ 
    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; 
    316335 
    317336  eb = edit_buffer_new (sounddata->format); 
    318337 
    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); 
    325344 
    326345#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); 
    328347#endif 
    329348 
    330     eb->regions = g_list_append (eb->regions, er); 
    331  
     349      eb->regions = g_list_append (eb->regions, er); 
     350   
    332351 
    333352  return eb; 
     
    349368sels_from_edit_buffer_offset (sw_edit_buffer * eb, sw_framecount_t offset) 
    350369{ 
    351   GList * gl, * sels = NULL; 
    352   sw_edit_region * er; 
     370  GList *gl, *sels = NULL; 
     371  sw_edit_region *er; 
    353372  sw_framecount_t start; 
    354373 
    355374  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; 
    359379  start = er->start; 
    360380 
    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    } 
    367388 
    368389  return sels; 
     
    372393sample_from_edit_buffer (sw_edit_buffer * eb) 
    373394{ 
    374   sw_sample * s; 
    375   GList * gl; 
    376   sw_edit_region * er; 
     395  sw_sample *s; 
     396  GList *gl; 
     397  sw_edit_region *er; 
    377398  sw_framecount_t offset0 = 0, start, length; 
    378399  sw_framecount_t offset, len; 
     
    381402  gl = eb->regions; 
    382403 
    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; 
    386408  start = er->start; 
    387    
     409 
    388410  for (; gl->next; gl = gl->next); 
    389   er = (sw_edit_region *)gl->data; 
     411  er = (sw_edit_region *) gl->data; 
    390412  length = er->end - start; 
    391413 
    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); 
    396415 
    397416  offset0 = frames_to_bytes (eb->format, start); 
    398417 
    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); 
    408428 
    409429#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); 
    411431#endif 
    412  
     432   
    413433 
    414434  return s; 
     
    419439                    sw_framecount_t upper, sw_framecount_t amount) 
    420440{ 
    421   if (head == NULL) return; 
     441  if (head == NULL) 
     442    return; 
    422443 
    423444  g_mutex_lock (head->head_mutex); 
     
    435456head_inc_if_gt (sw_head * head, sw_framecount_t lower, sw_framecount_t amount) 
    436457{ 
    437   if (head == NULL) return; 
     458  if (head == NULL) 
     459    return; 
    438460 
    439461  g_mutex_lock (head->head_mutex); 
     
    452474                    sw_framecount_t upper, sw_framecount_t value) 
    453475{ 
    454   if (head == NULL) return; 
     476  if (head == NULL) 
     477    return; 
    455478 
    456479  g_mutex_lock (head->head_mutex); 
     
    458481  if (head->stop_offset >= lower && head->stop_offset <= upper) 
    459482    head->stop_offset = value; 
    460    
     483 
    461484  if (head->offset >= lower && head->offset <= upper) 
    462485    head->offset = value; 
     
    469492splice_out_sel (sw_sample * sample) 
    470493{ 
    471   sw_sounddata * sounddata = sample->sounddata; 
    472   sw_format * f = sounddata->format; 
     494  sw_sounddata *sounddata = sample->sounddata; 
     495  sw_format *f = sounddata->format; 
    473496  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; */ 
    477500  gpointer d; 
    478501  sw_framecount_t offset, len, sel_length = 0; 
    479502  sw_framecount_t move_length, run_length; 
    480503 
    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    } 
    485509 
    486510  length = sounddata->nr_frames - sounddata_selection_nr_frames (sounddata); 
     
    488512 
    489513#ifdef DEBUG 
    490   printf("Splice out: remaining length %d\n", length); 
     514  printf ("Splice out: remaining length %d\n", length); 
    491515#endif 
    492516 
     
    502526 
    503527  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    { 
    534599      sample->user_offset -= sel_length; 
    535600    } 
    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   } 
    571601 
    572602  head_dec_if_within (sample->play_head, sel->sel_end, FRAMECOUNT_MAX, 
     
    576606                      sel_length); 
    577607 
    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)); 
    591622  sounddata->data = d; 
    592623  sounddata->nr_frames = length; 
     
    604635sounddata_set_sel_from_eb (sw_sounddata * sounddata, sw_edit_buffer * eb) 
    605636{ 
    606   GList * gl; 
    607   sw_edit_region * er; 
     637  GList *gl; 
     638  sw_edit_region *er; 
    608639 
    609640  if (sounddata->sels) 
    610641    sounddata_clear_selection (sounddata); 
    611642 
    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    } 
    621656} 
    622657 
     
    625660splice_in_eb_data (sw_sample * sample, sw_edit_buffer * eb) 
    626661{ 
    627   sw_sounddata * sounddata = sample->sounddata; 
    628   sw_format * f = sounddata->format; 
     662  sw_sounddata *sounddata = sample->sounddata; 
     663  sw_format *f = sounddata->format; 
    629664  gint length; 
    630   GList * gl; 
    631   sw_edit_region * er; 
     665  GList *gl; 
     666  sw_edit_region *er; 
    632667  sw_framecount_t prev_start = 0; 
    633668  sw_framecount_t er_width; 
     
    635670  sw_framecount_t len; 
    636671 
    637   if (!eb) { 
    638     return sample; 
    639   } 
     672  if (!eb) 
     673    { 
     674      return sample; 
     675    } 
    640676 
    641677  g_mutex_lock (sample->ops_mutex); 
     
    657693 
    658694  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    } 
    683721 
    684722  /* The head of the sounddata remains intact */ 
     
    686724  /* Move offset markers */ 
    687725 
    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    } 
    699738 
    700739  sounddata->nr_frames = length; 
     
    719758crop_in_eb_data (sw_sounddata * sounddata, sw_edit_buffer * eb) 
    720759{ 
    721   sw_format * f = sounddata->format; 
     760  sw_format *f = sounddata->format; 
    722761  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; 
    725764  sw_framecount_t len1 = 0, len2 = 0; 
    726765  sw_framecount_t byte_len1, byte_len2; 
    727766  gpointer d; 
    728767 
    729   if (!eb) { 
    730     return sounddata; 
    731   } 
     768  if (!eb) 
     769    { 
     770      return sounddata; 
     771    } 
    732772 
    733773  o_byte_length = frames_to_bytes (f, sounddata->nr_frames); 
    734774 
    735775  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    } 
    740781  byte_len1 = frames_to_bytes (f, len1); 
    741782 
    742783  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    } 
    747789  byte_len2 = frames_to_bytes (f, len2); 
    748790 
    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 */ 
    765818      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    } 
    797851 
    798852  return sounddata; 
     
    802856crop_in (sw_sample * sample, sw_edit_buffer * eb) 
    803857{ 
    804   sw_sounddata * sounddata; 
    805   GList * gl; 
    806   sw_edit_region * er; 
     858  sw_sounddata *sounddata; 
     859  GList *gl; 
     860  sw_edit_region *er; 
    807861  sw_framecount_t delta; 
    808862 
     
    811865 
    812866  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    } 
    837893 
    838894  return sample; 
     
    843899edit_clear_sel (sw_sample * sample) 
    844900{ 
    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; 
    849905  sw_framecount_t offset, len; 
    850906  sw_framecount_t sel_total, run_total; 
     
    853909 
    854910  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; 
    856913  run_total = 0; 
    857914 
    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    } 
    877938} 
    878939 
     
    881942crop_out (sw_sample * sample) 
    882943{ 
    883   sw_sounddata * sounddata = sample->sounddata; 
    884   sw_format * f = sounddata->format; 
     944  sw_sounddata *sounddata = sample->sounddata; 
     945  sw_format *f = sounddata->format; 
    885946  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; */ 
    889950  gpointer d; 
    890951  sw_framecount_t offset, len; 
    891952  sw_framecount_t byte_length; 
    892953 
    893   if (!sounddata->sels) { 
    894     return sample; 
    895   } 
     954  if (!sounddata->sels) 
     955    { 
     956      return sample; 
     957    } 
    896958 
    897959 
    898960#ifdef DEBUG 
    899   printf("Splice out: remaining length %d\n", length); 
     961  printf ("Splice out: remaining length %d\n", length); 
    900962#endif 
    901963 
     
    910972 
    911973  gl = sounddata->sels; 
    912   sel1 = (sw_sel *)gl->data; 
     974  sel1 = (sw_sel *) gl->data; 
    913975 
    914976  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    } 
    921984 
    922985  sample_set_progress_percent (sample, 13); 
     
    928991  d = sounddata->data; 
    929992 
    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    } 
    935999 
    9361000  sample_set_progress_percent (sample, 37); 
     
    9431007  /* Fix offsets */ 
    9441008  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); 
    9461010 
    9471011  g_mutex_lock (sample->play_head->head_mutex); 
    9481012 
    9491013  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); 
    9521015 
    9531016  sample->play_head->stop_offset -= sel1->sel_start; 
    9541017  sample->play_head->stop_offset = 
    955     CLAMP(sample->play_head->stop_offset, 0, length); 
     1018    CLAMP (sample->play_head->stop_offset, 0, length); 
    9561019 
    9571020  g_mutex_unlock (sample->play_head->head_mutex); 
    9581021 
    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   
    9721035 
    9731036  /* Fix selection */ 
    9741037  sounddata_selection_translate (sounddata, -(sel1->sel_start)); 
    9751038 
    976  zero_out: 
     1039zero_out: 
    9771040  /* Zero out data between selections */ 
    9781041  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    } 
    9901054 
    9911055  sample_set_progress_percent (sample, 100); 
     
    10011065              sw_framecount_t paste_offset) 
    10021066{ 
    1003   sw_sounddata * sounddata = sample->sounddata; 
    1004   sw_format * f = sounddata->format; 
     1067  sw_sounddata *sounddata = sample->sounddata; 
     1068  sw_format *f = sounddata->format; 
    10051069  sw_framecount_t paste_delta = 0, len; 
    10061070  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; 
    10091073  gpointer d; 
    10101074 
     
    10121076 
    10131077  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; 
    10151079 
    10161080  d = g_realloc (sounddata->data, frames_to_bytes (f, length)); 
    10171081  sounddata->data = d; 
    10181082 
    1019   d = (gpointer)(sounddata->data + frames_to_bytes(f, length)); 
     1083  d = (gpointer) (sounddata->data + frames_to_bytes (f, length)); 
    10201084 
    10211085  /* 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    } 
    10271092 
    10281093  /* 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    } 
    10381104 
    10391105  /* If paste point is beyond the previous sounddata length, 
    10401106     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    } 
    10461113 
    10471114  /* The head of the sounddata remains intact */ 
     
    10611128    sample->play_head->stop_offset += sel_length; 
    10621129 
    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    } 
    10691137 
    10701138  sounddata->nr_frames = length; 
     
    10771145paste_over (sw_sample * sample, sw_edit_buffer * eb) 
    10781146{ 
    1079   sw_format * f = sample->sounddata->format; 
     1147  sw_format *f = sample->sounddata->format; 
    10801148  sw_framecount_t offset, len; 
    10811149  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; 
    10861155 
    10871156  length = sample->sounddata->nr_frames; 
    10881157 
    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    } 
    10981169 
    10991170  return sample; 
     
    11051176           sw_framecount_t paste_offset, gdouble src_gain, gdouble dest_gain) 
    11061177{ 
    1107   sw_format * f = sample->sounddata->format; 
     1178  sw_format *f = sample->sounddata->format; 
    11081179  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; 
    11121183  sw_framecount_t offset, remaining, n, i; 
    11131184  sw_framecount_t run_total, eb_total; 
     
    11201191#endif 
    11211192 
    1122   if (eb == NULL || eb->regions == NULL) return sample; 
     1193  if (eb == NULL || eb->regions == NULL) 
     1194    return sample; 
    11231195 
    11241196  length = sample->sounddata->nr_frames; 
     
    11271199  eb_total = edit_buffer_length (eb); 
    11281200 
    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