From 99f5fef0ea5671d41fb7b737fbc3e4236542a757 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 10 Jun 2014 23:56:05 +0200 Subject: Add more const While I'm not very fond of "const", it's important for declarations (it decides whether a symbol is emitted in a read-only or read/write section). Fix all these cases, so we have writeable global data only when we really need. --- audio/chmap.c | 6 ++-- audio/chmap_sel.c | 4 +-- audio/filter/af.c | 62 ++++++++++++++++++------------------- audio/filter/af_bs2b.c | 2 +- audio/filter/af_center.c | 2 +- audio/filter/af_channels.c | 2 +- audio/filter/af_convert24.c | 2 +- audio/filter/af_convertsignendian.c | 2 +- audio/filter/af_delay.c | 2 +- audio/filter/af_drc.c | 2 +- audio/filter/af_dummy.c | 2 +- audio/filter/af_equalizer.c | 2 +- audio/filter/af_export.c | 2 +- audio/filter/af_extrastereo.c | 2 +- audio/filter/af_format.c | 2 +- audio/filter/af_hrtf.c | 2 +- audio/filter/af_karaoke.c | 2 +- audio/filter/af_ladspa.c | 2 +- audio/filter/af_lavcac3enc.c | 2 +- audio/filter/af_lavfi.c | 2 +- audio/filter/af_lavrresample.c | 2 +- audio/filter/af_pan.c | 2 +- audio/filter/af_scaletempo.c | 2 +- audio/filter/af_sinesuppress.c | 2 +- audio/filter/af_sub.c | 6 ++-- audio/filter/af_surround.c | 6 ++-- audio/filter/af_sweep.c | 2 +- audio/filter/af_volume.c | 2 +- audio/out/ao_alsa.c | 2 +- audio/out/ao_oss.c | 4 +-- common/msg.c | 2 +- common/msg_control.h | 2 +- common/version.c | 4 +-- demux/demux_lavf.c | 6 ++-- demux/demux_mkv.c | 6 ++-- demux/demux_playlist.c | 6 ++-- options/m_config.c | 4 +-- player/client.c | 6 ++-- player/client.h | 2 +- player/command.c | 10 +++--- player/configfiles.c | 2 +- player/loadfile.c | 4 +-- player/lua.c | 4 +-- player/scripting.c | 2 +- stream/stream.c | 2 +- stream/stream.h | 4 +-- stream/stream_avdevice.c | 2 +- stream/stream_cdda.c | 6 ++-- stream/stream_dvb.c | 4 +-- stream/stream_dvd.c | 6 ++-- stream/stream_dvd_common.c | 2 +- stream/stream_dvdnav.c | 10 +++--- stream/stream_edl.c | 2 +- stream/stream_file.c | 2 +- stream/stream_lavf.c | 2 +- stream/stream_memory.c | 2 +- stream/stream_mf.c | 2 +- stream/stream_null.c | 2 +- stream/stream_pvr.c | 2 +- stream/stream_rar.c | 2 +- stream/stream_smb.c | 2 +- stream/stream_tv.c | 4 +-- stream/tv.c | 4 +-- sub/ass_mp.c | 2 +- sub/dec_sub.c | 2 +- sub/find_subfiles.c | 6 ++-- sub/osd.c | 2 +- sub/sd_microdvd.c | 2 +- sub/sd_srt.c | 2 +- video/decode/vd_lavc.c | 2 +- video/filter/vf_noise.c | 2 +- video/filter/vf_rotate.c | 2 +- video/filter/vf_scale.c | 2 +- video/image_writer.c | 14 ++++----- video/out/gl_common.c | 50 +++++++++++++++--------------- video/out/gl_common.h | 2 +- video/out/gl_lcms.c | 4 +-- video/out/gl_video.c | 16 +++++----- video/out/vo.c | 36 ++++++++++----------- video/out/vo.h | 3 -- video/out/wayland_common.c | 3 +- video/out/x11_common.c | 2 +- 82 files changed, 204 insertions(+), 208 deletions(-) diff --git a/audio/chmap.c b/audio/chmap.c index 9a18512e21..316ca35c94 100644 --- a/audio/chmap.c +++ b/audio/chmap.c @@ -23,7 +23,7 @@ // Names taken from libavutil/channel_layout.c (Not accessible by API.) // Use of these names is hard-coded in some places (e.g. ao_alsa.c) -static const char *speaker_names[MP_SPEAKER_ID_COUNT][2] = { +static const char *const speaker_names[MP_SPEAKER_ID_COUNT][2] = { [MP_SPEAKER_ID_FL] = {"fl", "front left"}, [MP_SPEAKER_ID_FR] = {"fr", "front right"}, [MP_SPEAKER_ID_FC] = {"fc", "front center"}, @@ -53,7 +53,7 @@ static const char *speaker_names[MP_SPEAKER_ID_COUNT][2] = { // Names taken from libavutil/channel_layout.c (Not accessible by API.) // Channel order corresponds to lavc/waveex, except for the alsa entries. -static const char *std_layout_names[][2] = { +static const char *const std_layout_names[][2] = { {"empty", ""}, // not in lavc {"mono", "fc"}, {"stereo", "fl-fr"}, @@ -105,7 +105,7 @@ static const struct mp_chmap default_layouts[MP_NUM_CHANNELS + 1] = { // channels. 3 and 7 channels were likely undefined (no ALSA support). // I'm not sure about the 4 channel case: ALSA uses "quad", while the ffmpeg // default layout is "4.0". -static const char *mplayer_layouts[MP_NUM_CHANNELS + 1] = { +static const char *const mplayer_layouts[MP_NUM_CHANNELS + 1] = { [1] = "mono", [2] = "stereo", [4] = "quad", diff --git a/audio/chmap_sel.c b/audio/chmap_sel.c index f71a868674..160f1ce5fa 100644 --- a/audio/chmap_sel.c +++ b/audio/chmap_sel.c @@ -21,7 +21,7 @@ #include "common/common.h" #include "chmap_sel.h" -static struct mp_chmap speaker_replacements[][2] = { +static const struct mp_chmap speaker_replacements[][2] = { // 5.1 <-> 5.1 (side) { MP_CHMAP2(SL, SR), MP_CHMAP2(BL, BR) }, // 7.1 <-> 7.1 (rear ext) @@ -170,7 +170,7 @@ bool mp_chmap_sel_adjust(const struct mp_chmap_sel *s, struct mp_chmap *map) } for (int i = 0; i < MP_ARRAY_SIZE(speaker_replacements); i++) { struct mp_chmap t = *map; - struct mp_chmap *r = speaker_replacements[i]; + struct mp_chmap *r = (struct mp_chmap *)speaker_replacements[i]; if (replace_speakers(&t, r) && test_layout(s, &t)) { *map = t; return true; diff --git a/audio/filter/af.c b/audio/filter/af.c index d2c4bae40e..c69077e93f 100644 --- a/audio/filter/af.c +++ b/audio/filter/af.c @@ -31,34 +31,34 @@ #include "af.h" // Static list of filters -extern struct af_info af_info_dummy; -extern struct af_info af_info_delay; -extern struct af_info af_info_channels; -extern struct af_info af_info_format; -extern struct af_info af_info_force; -extern struct af_info af_info_volume; -extern struct af_info af_info_equalizer; -extern struct af_info af_info_pan; -extern struct af_info af_info_surround; -extern struct af_info af_info_sub; -extern struct af_info af_info_export; -extern struct af_info af_info_drc; -extern struct af_info af_info_extrastereo; -extern struct af_info af_info_lavcac3enc; -extern struct af_info af_info_lavrresample; -extern struct af_info af_info_sweep; -extern struct af_info af_info_hrtf; -extern struct af_info af_info_ladspa; -extern struct af_info af_info_center; -extern struct af_info af_info_sinesuppress; -extern struct af_info af_info_karaoke; -extern struct af_info af_info_scaletempo; -extern struct af_info af_info_bs2b; -extern struct af_info af_info_lavfi; -extern struct af_info af_info_convert24; -extern struct af_info af_info_convertsignendian; - -static struct af_info* filter_list[] = { +extern const struct af_info af_info_dummy; +extern const struct af_info af_info_delay; +extern const struct af_info af_info_channels; +extern const struct af_info af_info_format; +extern const struct af_info af_info_force; +extern const struct af_info af_info_volume; +extern const struct af_info af_info_equalizer; +extern const struct af_info af_info_pan; +extern const struct af_info af_info_surround; +extern const struct af_info af_info_sub; +extern const struct af_info af_info_export; +extern const struct af_info af_info_drc; +extern const struct af_info af_info_extrastereo; +extern const struct af_info af_info_lavcac3enc; +extern const struct af_info af_info_lavrresample; +extern const struct af_info af_info_sweep; +extern const struct af_info af_info_hrtf; +extern const struct af_info af_info_ladspa; +extern const struct af_info af_info_center; +extern const struct af_info af_info_sinesuppress; +extern const struct af_info af_info_karaoke; +extern const struct af_info af_info_scaletempo; +extern const struct af_info af_info_bs2b; +extern const struct af_info af_info_lavfi; +extern const struct af_info af_info_convert24; +extern const struct af_info af_info_convertsignendian; + +static const struct af_info *const filter_list[] = { &af_info_dummy, &af_info_delay, &af_info_channels, @@ -389,7 +389,7 @@ static char *af_find_conversion_filter(int srcfmt, int *dstfmt) } for (int n = 0; filter_list[n]; n++) { - struct af_info *af = filter_list[n]; + const struct af_info *af = filter_list[n]; if (!af->test_conversion) continue; for (int i = 0; af_fmtstr_table[i].format; i++) { @@ -589,7 +589,7 @@ void af_uninit(struct af_stream *s) struct af_stream *af_new(struct mpv_global *global) { struct af_stream *s = talloc_zero(NULL, struct af_stream); - static struct af_info in = { .name = "in" }; + static const struct af_info in = { .name = "in" }; s->first = talloc(s, struct af_instance); *s->first = (struct af_instance) { .info = &in, @@ -599,7 +599,7 @@ struct af_stream *af_new(struct mpv_global *global) .data = &s->input, .mul = 1.0, }; - static struct af_info out = { .name = "out" }; + static const struct af_info out = { .name = "out" }; s->last = talloc(s, struct af_instance); *s->last = (struct af_instance) { .info = &out, diff --git a/audio/filter/af_bs2b.c b/audio/filter/af_bs2b.c index 08d037bf4e..0a2bd8e552 100644 --- a/audio/filter/af_bs2b.c +++ b/audio/filter/af_bs2b.c @@ -189,7 +189,7 @@ static int af_open(struct af_instance *af) #define OPT_BASE_STRUCT struct af_bs2b /// Description of this filter -struct af_info af_info_bs2b = { +const struct af_info af_info_bs2b = { .info = "Bauer stereophonic-to-binaural audio filter", .name = "bs2b", .open = af_open, diff --git a/audio/filter/af_center.c b/audio/filter/af_center.c index 106e08412e..3039e50302 100644 --- a/audio/filter/af_center.c +++ b/audio/filter/af_center.c @@ -86,7 +86,7 @@ static int af_open(struct af_instance* af){ } #define OPT_BASE_STRUCT af_center_t -struct af_info af_info_center = { +const struct af_info af_info_center = { .info = "Audio filter for adding a center channel", .name = "center", .flags = AF_FLAGS_NOT_REENTRANT, diff --git a/audio/filter/af_channels.c b/audio/filter/af_channels.c index 118607b66f..83be68263e 100644 --- a/audio/filter/af_channels.c +++ b/audio/filter/af_channels.c @@ -238,7 +238,7 @@ static int af_open(struct af_instance* af){ } #define OPT_BASE_STRUCT af_channels_t -struct af_info af_info_channels = { +const struct af_info af_info_channels = { .info = "Insert or remove channels", .name = "channels", .open = af_open, diff --git a/audio/filter/af_convert24.c b/audio/filter/af_convert24.c index 6990fbd421..38799bd8fc 100644 --- a/audio/filter/af_convert24.c +++ b/audio/filter/af_convert24.c @@ -108,7 +108,7 @@ static int af_open(struct af_instance *af) return AF_OK; } -struct af_info af_info_convert24 = { +const struct af_info af_info_convert24 = { .info = "Convert between 24 and 32 bit sample format", .name = "convert24", .open = af_open, diff --git a/audio/filter/af_convertsignendian.c b/audio/filter/af_convertsignendian.c index 7bfaf0f978..45b365efd8 100644 --- a/audio/filter/af_convertsignendian.c +++ b/audio/filter/af_convertsignendian.c @@ -123,7 +123,7 @@ static int af_open(struct af_instance *af) return AF_OK; } -struct af_info af_info_convertsignendian = { +const struct af_info af_info_convertsignendian = { .info = "Convert between sample format sign/endian", .name = "convertsignendian", .open = af_open, diff --git a/audio/filter/af_delay.c b/audio/filter/af_delay.c index b16cdc1f63..56013b3270 100644 --- a/audio/filter/af_delay.c +++ b/audio/filter/af_delay.c @@ -178,7 +178,7 @@ static int af_open(struct af_instance* af){ } #define OPT_BASE_STRUCT af_delay_t -struct af_info af_info_delay = { +const struct af_info af_info_delay = { .info = "Delay audio filter", .name = "delay", .open = af_open, diff --git a/audio/filter/af_drc.c b/audio/filter/af_drc.c index 3bcd368d4d..94e161130f 100644 --- a/audio/filter/af_drc.c +++ b/audio/filter/af_drc.c @@ -313,7 +313,7 @@ static int af_open(struct af_instance* af){ } #define OPT_BASE_STRUCT af_drc_t -struct af_info af_info_drc = { +const struct af_info af_info_drc = { .info = "Dynamic range compression filter", .name = "drc", .flags = AF_FLAGS_NOT_REENTRANT, diff --git a/audio/filter/af_dummy.c b/audio/filter/af_dummy.c index d920480e01..61f2207d84 100644 --- a/audio/filter/af_dummy.c +++ b/audio/filter/af_dummy.c @@ -54,7 +54,7 @@ static int af_open(struct af_instance* af){ } // Description of this filter -struct af_info af_info_dummy = { +const struct af_info af_info_dummy = { .info = "dummy", .name = "dummy", .open = af_open, diff --git a/audio/filter/af_equalizer.c b/audio/filter/af_equalizer.c index 83fa80f2b3..4e96223ee7 100644 --- a/audio/filter/af_equalizer.c +++ b/audio/filter/af_equalizer.c @@ -194,7 +194,7 @@ static int af_open(struct af_instance* af){ } #define OPT_BASE_STRUCT af_equalizer_t -struct af_info af_info_equalizer = { +const struct af_info af_info_equalizer = { .info = "Equalizer audio filter", .name = "equalizer", .flags = AF_FLAGS_NOT_REENTRANT, diff --git a/audio/filter/af_export.c b/audio/filter/af_export.c index faa09bf927..9c3bab671a 100644 --- a/audio/filter/af_export.c +++ b/audio/filter/af_export.c @@ -222,7 +222,7 @@ static int af_open( struct af_instance* af ) } #define OPT_BASE_STRUCT af_export_t -struct af_info af_info_export = { +const struct af_info af_info_export = { .info = "Sound export filter", .name = "export", .open = af_open, diff --git a/audio/filter/af_extrastereo.c b/audio/filter/af_extrastereo.c index 05a1ac8e36..4ebe03a228 100644 --- a/audio/filter/af_extrastereo.c +++ b/audio/filter/af_extrastereo.c @@ -118,7 +118,7 @@ static int af_open(struct af_instance* af){ } #define OPT_BASE_STRUCT af_extrastereo_t -struct af_info af_info_extrastereo = { +const struct af_info af_info_extrastereo = { .info = "Increase difference between audio channels", .name = "extrastereo", .flags = AF_FLAGS_NOT_REENTRANT, diff --git a/audio/filter/af_format.c b/audio/filter/af_format.c index a51c543406..9183259bd9 100644 --- a/audio/filter/af_format.c +++ b/audio/filter/af_format.c @@ -114,7 +114,7 @@ static int af_open(struct af_instance *af) #define OPT_BASE_STRUCT struct priv -struct af_info af_info_format = { +const struct af_info af_info_format = { .info = "Force audio format", .name = "format", .open = af_open, diff --git a/audio/filter/af_hrtf.c b/audio/filter/af_hrtf.c index e8ab5fc72d..e01f659772 100644 --- a/audio/filter/af_hrtf.c +++ b/audio/filter/af_hrtf.c @@ -631,7 +631,7 @@ static int af_open(struct af_instance* af) } #define OPT_BASE_STRUCT af_hrtf_t -struct af_info af_info_hrtf = { +const struct af_info af_info_hrtf = { .info = "HRTF Headphone", .name = "hrtf", .open = af_open, diff --git a/audio/filter/af_karaoke.c b/audio/filter/af_karaoke.c index 00c4d16dca..3187a41f2f 100644 --- a/audio/filter/af_karaoke.c +++ b/audio/filter/af_karaoke.c @@ -73,7 +73,7 @@ static int af_open(struct af_instance* af){ } // Description of this filter -struct af_info af_info_karaoke = { +const struct af_info af_info_karaoke = { .info = "Simple karaoke/voice-removal audio filter", .name = "karaoke", .flags = AF_FLAGS_NOT_REENTRANT, diff --git a/audio/filter/af_ladspa.c b/audio/filter/af_ladspa.c index 7beaded3d3..ab76c35fe9 100644 --- a/audio/filter/af_ladspa.c +++ b/audio/filter/af_ladspa.c @@ -104,7 +104,7 @@ static int af_ladspa_malloc_failed(char*); /* ------------------------------------------------------------------------- */ #define OPT_BASE_STRUCT af_ladspa_t -struct af_info af_info_ladspa = { +const struct af_info af_info_ladspa = { .info = "LADSPA plugin loader", .name = "ladspa", .open = af_open, diff --git a/audio/filter/af_lavcac3enc.c b/audio/filter/af_lavcac3enc.c index 705431ca7d..3b3b33b98a 100644 --- a/audio/filter/af_lavcac3enc.c +++ b/audio/filter/af_lavcac3enc.c @@ -305,7 +305,7 @@ static int af_open(struct af_instance* af){ #define OPT_BASE_STRUCT struct af_ac3enc_s -struct af_info af_info_lavcac3enc = { +const struct af_info af_info_lavcac3enc = { .info = "runtime encode to ac3 using libavcodec", .name = "lavcac3enc", .open = af_open, diff --git a/audio/filter/af_lavfi.c b/audio/filter/af_lavfi.c index 5bca39d6dd..a565e202f4 100644 --- a/audio/filter/af_lavfi.c +++ b/audio/filter/af_lavfi.c @@ -299,7 +299,7 @@ static int af_open(struct af_instance *af) #define OPT_BASE_STRUCT struct priv -struct af_info af_info_lavfi = { +const struct af_info af_info_lavfi = { .info = "libavfilter bridge", .name = "lavfi", .open = af_open, diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c index 692297bb38..8e33f3b23c 100644 --- a/audio/filter/af_lavrresample.c +++ b/audio/filter/af_lavrresample.c @@ -382,7 +382,7 @@ static int af_open(struct af_instance *af) #define OPT_BASE_STRUCT struct af_resample -struct af_info af_info_lavrresample = { +const struct af_info af_info_lavrresample = { .info = "Sample frequency conversion using libavresample", .name = "lavrresample", .open = af_open, diff --git a/audio/filter/af_pan.c b/audio/filter/af_pan.c index b966deb9b3..65269a86e1 100644 --- a/audio/filter/af_pan.c +++ b/audio/filter/af_pan.c @@ -177,7 +177,7 @@ static int af_open(struct af_instance* af){ } #define OPT_BASE_STRUCT af_pan_t -struct af_info af_info_pan = { +const struct af_info af_info_pan = { .info = "Panning audio filter", .name = "pan", .open = af_open, diff --git a/audio/filter/af_scaletempo.c b/audio/filter/af_scaletempo.c index cd288e9d12..82aa17c802 100644 --- a/audio/filter/af_scaletempo.c +++ b/audio/filter/af_scaletempo.c @@ -467,7 +467,7 @@ static int af_open(struct af_instance *af) #define OPT_BASE_STRUCT af_scaletempo_t -struct af_info af_info_scaletempo = { +const struct af_info af_info_scaletempo = { .info = "Scale audio tempo while maintaining pitch", .name = "scaletempo", .open = af_open, diff --git a/audio/filter/af_sinesuppress.c b/audio/filter/af_sinesuppress.c index 6b1d5da50d..95d2478b7e 100644 --- a/audio/filter/af_sinesuppress.c +++ b/audio/filter/af_sinesuppress.c @@ -136,7 +136,7 @@ static int af_open(struct af_instance* af){ } #define OPT_BASE_STRUCT af_sinesuppress_t -struct af_info af_info_sinesuppress = { +const struct af_info af_info_sinesuppress = { .info = "Sine Suppress", .name = "sinesuppress", .open = af_open, diff --git a/audio/filter/af_sub.c b/audio/filter/af_sub.c index 742d2e7413..5642c4573d 100644 --- a/audio/filter/af_sub.c +++ b/audio/filter/af_sub.c @@ -46,8 +46,8 @@ typedef struct{ } biquad_t; // S-parameters for designing 4th order Butterworth filter -static biquad_t sp[2] = {{{1.0,0.0,0.0},{1.0,0.765367,1.0}}, - {{1.0,0.0,0.0},{1.0,1.847759,1.0}}}; +static const biquad_t sp[2] = {{{1.0,0.0,0.0},{1.0,0.765367,1.0}}, + {{1.0,0.0,0.0},{1.0,1.847759,1.0}}}; // Data for specific instances of this filter typedef struct af_sub_s @@ -128,7 +128,7 @@ static int af_open(struct af_instance* af){ } #define OPT_BASE_STRUCT af_sub_t -struct af_info af_info_sub = { +const struct af_info af_info_sub = { .info = "Audio filter for adding a sub-base channel", .name = "sub", .flags = AF_FLAGS_NOT_REENTRANT, diff --git a/audio/filter/af_surround.c b/audio/filter/af_surround.c index 06a8c4a761..7e04a79ed8 100644 --- a/audio/filter/af_surround.c +++ b/audio/filter/af_surround.c @@ -131,7 +131,7 @@ static int control(struct af_instance* af, int cmd, void* arg) } // The beginnings of an active matrix... -static float steering_matrix[][12] = { +static const float steering_matrix[][12] = { // LL RL LR RR LS RS // LLs RLs LRs RRs LC RC {.707, .0, .0, .707, .5, -.5, @@ -144,7 +144,7 @@ static float steering_matrix[][12] = { // Filter data through filter static int filter(struct af_instance* af, struct mp_audio* data, int flags){ af_surround_t* s = (af_surround_t*)af->priv; - float* m = steering_matrix[0]; + const float* m = steering_matrix[0]; float* in = data->planes[0]; // Input audio data float* out = NULL; // Output audio data float* end = in + data->samples * data->nch; @@ -229,7 +229,7 @@ static int af_open(struct af_instance* af){ } #define OPT_BASE_STRUCT af_surround_t -struct af_info af_info_surround = +const struct af_info af_info_surround = { .info = "Surround decoder filter", .name = "surround", diff --git a/audio/filter/af_sweep.c b/audio/filter/af_sweep.c index af5fc71b78..982cb6210c 100644 --- a/audio/filter/af_sweep.c +++ b/audio/filter/af_sweep.c @@ -74,7 +74,7 @@ static int af_open(struct af_instance* af){ } #define OPT_BASE_STRUCT af_sweept -struct af_info af_info_sweep = { +const struct af_info af_info_sweep = { .info = "sine sweep", .name = "sweep", .open = af_open, diff --git a/audio/filter/af_volume.c b/audio/filter/af_volume.c index 837ce12c86..f07914313b 100644 --- a/audio/filter/af_volume.c +++ b/audio/filter/af_volume.c @@ -140,7 +140,7 @@ static int af_open(struct af_instance *af) #define OPT_BASE_STRUCT struct priv // Description of this filter -struct af_info af_info_volume = { +const struct af_info af_info_volume = { .info = "Volume control audio filter", .name = "volume", .flags = AF_FLAGS_NOT_REENTRANT, diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 8bdf5e635c..25a051fee8 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -244,7 +244,7 @@ static int find_alsa_format(int af_format) // The second item must be resolvable with mp_chmap_from_str(). // Source: http://www.alsa-project.org/main/index.php/DeviceNames // (Speaker names are slightly different from mpv's.) -static const char *device_channel_layouts[][2] = { +static const char *const device_channel_layouts[][2] = { {"default", "fc"}, {"default", "fl-fr"}, {"rear", "bl-br"}, diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c index 545ddca3f8..7698af4e0c 100644 --- a/audio/out/ao_oss.c +++ b/audio/out/ao_oss.c @@ -65,7 +65,7 @@ struct priv { char *cfg_oss_mixer_channel; }; -static const char *mixer_channels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES; +static const char *const mixer_channels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES; /* like alsa except for 6.1 and 7.1, from pcm/matrix_map.h */ static const struct mp_chmap oss_layouts[MP_NUM_CHANNELS + 1] = { @@ -80,7 +80,7 @@ static const struct mp_chmap oss_layouts[MP_NUM_CHANNELS + 1] = { MP_CHMAP8(FL, FR, BL, BR, FC, LFE, SL, SR), // 7.1 }; -static int format_table[][2] = { +static const int format_table[][2] = { {AFMT_U8, AF_FORMAT_U8}, {AFMT_S8, AF_FORMAT_S8}, {AFMT_U16_LE, AF_FORMAT_U16_LE}, diff --git a/common/msg.c b/common/msg.c index fa8b235243..9b05e55660 100644 --- a/common/msg.c +++ b/common/msg.c @@ -563,7 +563,7 @@ void mp_msg(struct mp_log *log, int lev, const char *format, ...) va_end(va); } -char *mp_log_levels[MSGL_MAX + 1] = { +const char *const mp_log_levels[MSGL_MAX + 1] = { [MSGL_FATAL] = "fatal", [MSGL_ERR] = "error", [MSGL_WARN] = "warn", diff --git a/common/msg_control.h b/common/msg_control.h index 755cd10e57..f659d180b2 100644 --- a/common/msg_control.h +++ b/common/msg_control.h @@ -31,6 +31,6 @@ int mp_msg_open_stats_file(struct mpv_global *global, const char *path); struct bstr; int mp_msg_split_msglevel(struct bstr *s, struct bstr *out_mod, int *out_level); -extern char *mp_log_levels[MSGL_MAX + 1]; +extern const char *const mp_log_levels[MSGL_MAX + 1]; #endif diff --git a/common/version.c b/common/version.c index 83177a5fc7..196b2ff807 100644 --- a/common/version.c +++ b/common/version.c @@ -22,5 +22,5 @@ #define BUILDDATE "UNKNOWN" #endif -const char *mpv_version = "mpv " VERSION; -const char *mpv_builddate = BUILDDATE; +const char *const mpv_version = "mpv " VERSION; +const char *const mpv_builddate = BUILDDATE; diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 23a89386b7..4fb1ee3cb3 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -111,7 +111,7 @@ static const struct format_hack format_hacks[] = { {0} }; -static const char *format_blacklist[] = { +static const char *const format_blacklist[] = { "tty", // Useless non-sense, sometimes breaks MLP2 subreader.c fallback 0 }; @@ -184,7 +184,7 @@ static void list_formats(struct demuxer *demuxer) MP_INFO(demuxer, "%15s : %s\n", fmt->name, fmt->long_name); } -static char *remove_prefix(char *s, const char **prefixes) +static char *remove_prefix(char *s, const char *const *prefixes) { for (int n = 0; prefixes[n]; n++) { int len = strlen(prefixes[n]); @@ -194,7 +194,7 @@ static char *remove_prefix(char *s, const char **prefixes) return s; } -static const char *prefixes[] = +static const char *const prefixes[] = {"ffmpeg://", "lavf://", "avdevice://", "av://", NULL}; static int lavf_check_file(demuxer_t *demuxer, enum demux_check check) diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index 4b08ce2a13..462a93aaa8 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -1289,7 +1289,7 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track) return 0; } -static struct mkv_audio_tag { +static const struct mkv_audio_tag { char *id; bool prefix; uint32_t formattag; bool parse; } mkv_audio_tags[] = { @@ -1376,7 +1376,7 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track) } else { sh_a->wf = talloc_zero(sh_a, MP_WAVEFORMATEX); for (int i = 0; ; i++) { - struct mkv_audio_tag *t = mkv_audio_tags + i; + const struct mkv_audio_tag *t = mkv_audio_tags + i; if (t->id == NULL) goto error; if (t->prefix) { @@ -1606,7 +1606,7 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track) return 1; } -static const char *mkv_sub_tag[][2] = { +static const char *const mkv_sub_tag[][2] = { { MKV_S_VOBSUB, "dvd_subtitle" }, { MKV_S_TEXTSSA, "ass"}, { MKV_S_TEXTASS, "ass"}, diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c index af24d4906f..b2344b5583 100644 --- a/demux/demux_playlist.c +++ b/demux/demux_playlist.c @@ -154,11 +154,11 @@ static int parse_txt(struct pl_parser *p) struct pl_format { const char *name; int (*parse)(struct pl_parser *p); - const char **mime_types; + const char *const *mime_types; }; #define MIME_TYPES(...) \ - .mime_types = (const char*[]){__VA_ARGS__, NULL} + .mime_types = (const char*const[]){__VA_ARGS__, NULL} static const struct pl_format formats[] = { {"m3u", parse_m3u, @@ -170,7 +170,7 @@ static const struct pl_format formats[] = { {"txt", parse_txt}, }; -static bool check_mimetype(struct stream *s, const char **list) +static bool check_mimetype(struct stream *s, const char *const *list) { if (s->mime_type) { for (int n = 0; list && list[n]; n++) { diff --git a/options/m_config.c b/options/m_config.c index b0b06bc271..2ebf17bb70 100644 --- a/options/m_config.c +++ b/options/m_config.c @@ -38,7 +38,7 @@ static const union m_option_value default_value; -static const char *replaced_opts; +static const char *const replaced_opts; // Profiles allow to predefine some sets of options that can then // be applied later on with the internal -profile option. @@ -912,7 +912,7 @@ void *m_sub_options_copy(void *talloc_ctx, const struct m_sub_options *opts, } // This is used for printing error messages on unknown options. -static const char *replaced_opts = +static const char *const replaced_opts = "|a52drc#--ad-lavc-ac3drc=level" "|afm#--ad" "|aspect#--video-aspect" diff --git a/player/client.c b/player/client.c index ed99f6f34e..ececec37f6 100644 --- a/player/client.c +++ b/player/client.c @@ -1169,7 +1169,7 @@ static bool match_property(const char *a, const char *b) } // Broadcast that properties have changed. -void mp_client_property_change(struct MPContext *mpctx, const char **list) +void mp_client_property_change(struct MPContext *mpctx, const char *const *list) { struct mp_client_api *clients = mpctx->clients; @@ -1340,7 +1340,7 @@ unsigned long mpv_client_api_version(void) return MPV_CLIENT_API_VERSION; } -static const char *err_table[] = { +static const char *const err_table[] = { [-MPV_ERROR_SUCCESS] = "success", [-MPV_ERROR_EVENT_QUEUE_FULL] = "event queue full", [-MPV_ERROR_NOMEM] = "memory allocation failed", @@ -1367,7 +1367,7 @@ const char *mpv_error_string(int error) return name ? name : "unknown error"; } -static const char *event_table[] = { +static const char *const event_table[] = { [MPV_EVENT_NONE] = "none", [MPV_EVENT_SHUTDOWN] = "shutdown", [MPV_EVENT_LOG_MESSAGE] = "log-message", diff --git a/player/client.h b/player/client.h index e9d41d8c09..af94778a55 100644 --- a/player/client.h +++ b/player/client.h @@ -17,7 +17,7 @@ int mp_clients_num(struct MPContext *mpctx); void mp_client_broadcast_event(struct MPContext *mpctx, int event, void *data); int mp_client_send_event(struct MPContext *mpctx, const char *client_name, int event, void *data); -void mp_client_property_change(struct MPContext *mpctx, const char **list); +void mp_client_property_change(struct MPContext *mpctx, const char *const *list); struct mpv_handle *mp_new_client(struct mp_client_api *clients, const char *name); struct mp_log *mp_client_get_log(struct mpv_handle *ctx); diff --git a/player/command.c b/player/command.c index 315013b0e8..87c91f295e 100644 --- a/player/command.c +++ b/player/command.c @@ -2597,8 +2597,8 @@ static const m_option_t mp_properties[] = { }; // Each entry describes which properties an event (possibly) changes. -#define E(x, ...) [x] = (const char*[]){__VA_ARGS__, NULL} -const char **mp_event_property_change[] = { +#define E(x, ...) [x] = (const char*const[]){__VA_ARGS__, NULL} +static const char *const *const mp_event_property_change[] = { E(MPV_EVENT_START_FILE, "*"), E(MPV_EVENT_END_FILE, "*"), E(MPV_EVENT_FILE_LOADED, "*"), @@ -2690,7 +2690,7 @@ void property_print_help(struct mp_log *log) * terminal output if there is no video; it'll be a label shown together with * percentage. */ -static struct property_osd_display { +static const struct property_osd_display { // property name const char *name; // name used on OSD @@ -2763,7 +2763,7 @@ static void show_property_osd(MPContext *mpctx, const char *pname, int osd_mode) { struct MPOpts *opts = mpctx->opts; struct m_option prop = {0}; - struct property_osd_display *p; + const struct property_osd_display *p; const char *name = pname; if (mp_property_do(pname, M_PROPERTY_GET_TYPE, &prop, mpctx) <= 0) @@ -2875,7 +2875,7 @@ static bool reinit_filters(MPContext *mpctx, enum stream_type mediatype) return false; } -static const char *filter_opt[STREAM_TYPE_COUNT] = { +static const char *const filter_opt[STREAM_TYPE_COUNT] = { [STREAM_VIDEO] = "vf", [STREAM_AUDIO] = "af", }; diff --git a/player/configfiles.c b/player/configfiles.c index 94b8e33f85..9b20f5af71 100644 --- a/player/configfiles.c +++ b/player/configfiles.c @@ -207,7 +207,7 @@ exit: return res; } -static const char *backup_properties[] = { +static const char *const backup_properties[] = { "options/osd-level", //"loop", "options/speed", diff --git a/player/loadfile.c b/player/loadfile.c index 712ba58f02..43cb127e5a 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -826,7 +826,7 @@ static void open_subtitles_from_resolve(struct MPContext *mpctx) } } -static const char *font_mimetypes[] = { +static const char *const font_mimetypes[] = { "application/x-truetype-font", "application/vnd.ms-opentype", "application/x-font-ttf", @@ -834,7 +834,7 @@ static const char *font_mimetypes[] = { NULL }; -static const char *font_exts[] = {".ttf", ".ttc", ".otf", NULL}; +static const char *const font_exts[] = {".ttf", ".ttc", ".otf", NULL}; static bool attachment_is_font(struct mp_log *log, struct demux_attachment *att) { diff --git a/player/lua.c b/player/lua.c index 689be1896b..1da26f9f2b 100644 --- a/player/lua.c +++ b/player/lua.c @@ -49,7 +49,7 @@ // List of builtin modules and their contents as strings. // All these are generated from player/lua/*.lua -static const char *builtin_lua_scripts[][2] = { +static const char * const builtin_lua_scripts[][2] = { {"mp.defaults", # include "player/lua/defaults.inc" }, @@ -1106,7 +1106,7 @@ static const struct fn_entry main_fns[] = { {0} }; -static struct fn_entry utils_fns[] = { +static const struct fn_entry utils_fns[] = { FN_ENTRY(readdir), FN_ENTRY(split_path), FN_ENTRY(join_path), diff --git a/player/scripting.c b/player/scripting.c index 5f072be1ca..7b3d408030 100644 --- a/player/scripting.c +++ b/player/scripting.c @@ -36,7 +36,7 @@ extern const struct mp_scripting mp_scripting_lua; -static const struct mp_scripting *scripting_backends[] = { +static const struct mp_scripting *const scripting_backends[] = { #if HAVE_LUA &mp_scripting_lua, #endif diff --git a/stream/stream.c b/stream/stream.c index 171d6781a1..2a6136f036 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -893,7 +893,7 @@ unsigned char *stream_read_line(stream_t *s, unsigned char *mem, int max, return mem; } -static const char *bom[3] = {"\xEF\xBB\xBF", "\xFF\xFE", "\xFE\xFF"}; +static const char *const bom[3] = {"\xEF\xBB\xBF", "\xFF\xFE", "\xFE\xFF"}; // Return utf16 argument for stream_read_line int stream_skip_bom(struct stream *s) diff --git a/stream/stream.h b/stream/stream.h index cd81e7daeb..fc8969d649 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -129,12 +129,12 @@ typedef struct stream_info_st { const char *name; // opts is set from ->opts int (*open)(struct stream *st); - const char **protocols; + const char *const *protocols; int priv_size; const void *priv_defaults; void *(*get_defaults)(struct stream *st); const struct m_option *options; - const char **url_options; + const char *const *url_options; bool stream_filter; bool can_write; } stream_info_t; diff --git a/stream/stream_avdevice.c b/stream/stream_avdevice.c index b4983b507a..cd6fd1a572 100644 --- a/stream/stream_avdevice.c +++ b/stream/stream_avdevice.c @@ -31,5 +31,5 @@ static int open_f(stream_t *stream) const stream_info_t stream_info_avdevice = { .name = "avdevice", .open = open_f, - .protocols = (const char*[]){ "avdevice", "av", NULL }, + .protocols = (const char*const[]){ "avdevice", "av", NULL }, }; diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index b11671333a..8ad7608604 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -97,7 +97,7 @@ const struct m_sub_options stream_cdda_conf = { }, }; -static const char *cdtext_name[] = { +static const char *const cdtext_name[] = { #ifdef OLD_API [CDTEXT_ARRANGER] = "Arranger", [CDTEXT_COMPOSER] = "Composer", @@ -411,11 +411,11 @@ static void *get_defaults(stream_t *st) const stream_info_t stream_info_cdda = { .name = "cdda", .open = open_cdda, - .protocols = (const char*[]){"cdda", NULL }, + .protocols = (const char*const[]){"cdda", NULL }, .priv_size = sizeof(cdda_priv), .get_defaults = get_defaults, .options = cdda_params_fields, - .url_options = (const char*[]){ + .url_options = (const char*const[]){ "hostname=span", "port=speed", "filename=device", diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index e71a41e960..1462d568e7 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -823,11 +823,11 @@ static void *get_defaults(stream_t *st) const stream_info_t stream_info_dvb = { .name = "dvbin", .open = dvb_open, - .protocols = (const char*[]){ "dvb", NULL }, + .protocols = (const char*const[]){ "dvb", NULL }, .priv_size = sizeof(dvb_priv_t), .get_defaults = get_defaults, .options = stream_params, - .url_options = (const char*[]){ + .url_options = (const char*const[]){ "hostname=prog", "username=card", NULL diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index 3ab7149a46..d67f14a5c1 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -947,11 +947,11 @@ static int ifo_stream_open (stream_t *stream) const stream_info_t stream_info_dvd = { .name = "dvd", .open = open_s, - .protocols = (const char*[]){ "dvd", NULL }, + .protocols = (const char*const[]){ "dvd", NULL }, .priv_size = sizeof(dvd_priv_t), .priv_defaults = &stream_priv_dflts, .options = stream_opts_fields, - .url_options = (const char*[]){ + .url_options = (const char*const[]){ "hostname=title", "filename=device", NULL @@ -961,5 +961,5 @@ const stream_info_t stream_info_dvd = { const stream_info_t stream_info_ifo = { .name = "ifo", .open = ifo_stream_open, - .protocols = (const char*[]){ "file", "", NULL }, + .protocols = (const char*const[]){ "file", "", NULL }, }; diff --git a/stream/stream_dvd_common.c b/stream/stream_dvd_common.c index 677b70a1bc..a9a6895384 100644 --- a/stream/stream_dvd_common.c +++ b/stream/stream_dvd_common.c @@ -125,7 +125,7 @@ void dvd_set_speed(stream_t *stream, char *device, unsigned speed) */ int mp_dvdtimetomsec(dvd_time_t *dt) { - static int framerates[4] = {0, 2500, 0, 2997}; + int framerates[4] = {0, 2500, 0, 2997}; int framerate = framerates[(dt->frame_u & 0xc0) >> 6]; int msec = (((dt->hour & 0xf0) >> 3) * 5 + (dt->hour & 0x0f)) * 3600000; msec += (((dt->minute & 0xf0) >> 3) * 5 + (dt->minute & 0x0f)) * 60000; diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index 20382a14e4..b2b10d5bf4 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -77,7 +77,7 @@ static const m_option_t stream_opts_fields[] = { }; #define DNE(e) [e] = # e -static char *mp_dvdnav_events[] = { +static const char *const mp_dvdnav_events[] = { DNE(DVDNAV_BLOCK_OK), DNE(DVDNAV_NOP), DNE(DVDNAV_STILL_FRAME), @@ -93,7 +93,7 @@ static char *mp_dvdnav_events[] = { DNE(DVDNAV_WAIT), }; -static char *mp_nav_cmd_types[] = { +static const char *const mp_nav_cmd_types[] = { DNE(MP_NAV_CMD_NONE), DNE(MP_NAV_CMD_ENABLE), DNE(MP_NAV_CMD_DRAIN_OK), @@ -103,7 +103,7 @@ static char *mp_nav_cmd_types[] = { DNE(MP_NAV_CMD_MOUSE_POS), }; -static char *mp_nav_event_types[] = { +static const char *const mp_nav_event_types[] = { DNE(MP_NAV_EVENT_NONE), DNE(MP_NAV_EVENT_RESET), DNE(MP_NAV_EVENT_RESET_CLUT), @@ -737,11 +737,11 @@ static int open_s(stream_t *stream) const stream_info_t stream_info_dvdnav = { .name = "dvdnav", .open = open_s, - .protocols = (const char*[]){ "dvdnav", NULL }, + .protocols = (const char*const[]){ "dvdnav", NULL }, .priv_size = sizeof(struct priv), .priv_defaults = &stream_priv_dflts, .options = stream_opts_fields, - .url_options = (const char*[]){ + .url_options = (const char*const[]){ "hostname=title", "filename=device", NULL diff --git a/stream/stream_edl.c b/stream/stream_edl.c index ac1e1f9406..4873047cc2 100644 --- a/stream/stream_edl.c +++ b/stream/stream_edl.c @@ -14,5 +14,5 @@ static int s_open (struct stream *stream) const stream_info_t stream_info_edl = { .name = "edl", .open = s_open, - .protocols = (const char*[]){"edl", NULL}, + .protocols = (const char*const[]){"edl", NULL}, }; diff --git a/stream/stream_file.c b/stream/stream_file.c index 6b9c6d5471..12bea3554c 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -279,6 +279,6 @@ static int open_f(stream_t *stream) const stream_info_t stream_info_file = { .name = "file", .open = open_f, - .protocols = (const char*[]){ "file", "", NULL }, + .protocols = (const char*const[]){ "file", "", NULL }, .can_write = true, }; diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c index b8f90cc9b1..82aa4ab820 100644 --- a/stream/stream_lavf.c +++ b/stream/stream_lavf.c @@ -315,7 +315,7 @@ done: const stream_info_t stream_info_ffmpeg = { .name = "ffmpeg", .open = open_f, - .protocols = (const char*[]){ + .protocols = (const char *const[]){ "lavf", "ffmpeg", "rtmp", "rtsp", "http", "https", "mms", "mmst", "mmsh", "mmshttp", "udp", "ftp", "rtp", "httpproxy", "hls", "rtmpe", "rtmps", "rtmpt", "rtmpte", "rtmpts", "srtp", "tcp", "udp", "tls", "unix", "sftp", diff --git a/stream/stream_memory.c b/stream/stream_memory.c index b748c9264c..a451e0f722 100644 --- a/stream/stream_memory.c +++ b/stream/stream_memory.c @@ -77,5 +77,5 @@ static int open_f(stream_t *stream) const stream_info_t stream_info_memory = { .name = "memory", .open = open_f, - .protocols = (const char*[]){ "memory", NULL }, + .protocols = (const char*const[]){ "memory", NULL }, }; diff --git a/stream/stream_mf.c b/stream/stream_mf.c index 05c5bb60bd..ac2751b031 100644 --- a/stream/stream_mf.c +++ b/stream/stream_mf.c @@ -41,5 +41,5 @@ mf_stream_open (stream_t *stream) const stream_info_t stream_info_mf = { .name = "mf", .open = mf_stream_open, - .protocols = (const char*[]){ "mf", NULL }, + .protocols = (const char*const[]){ "mf", NULL }, }; diff --git a/stream/stream_null.c b/stream/stream_null.c index 8fca1282a5..8bd0fb7c51 100644 --- a/stream/stream_null.c +++ b/stream/stream_null.c @@ -33,6 +33,6 @@ static int open_s(stream_t *stream) const stream_info_t stream_info_null = { .name = "null", .open = open_s, - .protocols = (const char*[]){ "null", NULL }, + .protocols = (const char*const[]){ "null", NULL }, .can_write = true, }; diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c index 5ba42c4048..7fc521fa28 100644 --- a/stream/stream_pvr.c +++ b/stream/stream_pvr.c @@ -1722,5 +1722,5 @@ static int pvr_stream_control(struct stream *s, int cmd, void *arg) const stream_info_t stream_info_pvr = { .name = "pvr", .open = pvr_stream_open, - .protocols = (const char*[]){ "pvr", NULL }, + .protocols = (const char*const[]){ "pvr", NULL }, }; diff --git a/stream/stream_rar.c b/stream/stream_rar.c index d40a8ca545..ee76d62909 100644 --- a/stream/stream_rar.c +++ b/stream/stream_rar.c @@ -199,7 +199,7 @@ static int rar_filter_open(stream_t *stream) const stream_info_t stream_info_rar_entry = { .name = "rar_entry", .open = rar_entry_open, - .protocols = (const char*[]){ "rar", NULL }, + .protocols = (const char*const[]){ "rar", NULL }, }; const stream_info_t stream_info_rar_filter = { diff --git a/stream/stream_smb.c b/stream/stream_smb.c index f2fb2fd01a..96f8ec69bd 100644 --- a/stream/stream_smb.c +++ b/stream/stream_smb.c @@ -140,6 +140,6 @@ static int open_f (stream_t *stream) const stream_info_t stream_info_smb = { .name = "smb", .open = open_f, - .protocols = (const char*[]){"smb", NULL}, + .protocols = (const char*const[]){"smb", NULL}, .can_write = true, //who's gonna do that? }; diff --git a/stream/stream_tv.c b/stream/stream_tv.c index 3ca4973d1e..b4181ac286 100644 --- a/stream/stream_tv.c +++ b/stream/stream_tv.c @@ -58,13 +58,13 @@ tv_stream_open (stream_t *stream) const stream_info_t stream_info_tv = { .name = "tv", .open = tv_stream_open, - .protocols = (const char*[]){ "tv", NULL }, + .protocols = (const char*const[]){ "tv", NULL }, .priv_size = sizeof(tv_param_t), .priv_defaults = &(const struct tv_stream_params){ .input = -1, }, .options = stream_opts_fields, - .url_options = (const char*[]){ + .url_options = (const char*const[]){ "hostname=channel", "filename=input", NULL diff --git a/stream/tv.c b/stream/tv.c index c9791a2b50..17b1f9ecb9 100644 --- a/stream/tv.c +++ b/stream/tv.c @@ -60,7 +60,7 @@ extern const tvi_info_t tvi_info_dummy; extern const tvi_info_t tvi_info_v4l2; /** List of drivers in autodetection order */ -static const tvi_info_t* tvi_driver_list[]={ +static const tvi_info_t *const tvi_driver_list[]={ #if HAVE_TV_V4L2 &tvi_info_v4l2, #endif @@ -1225,7 +1225,7 @@ static int demux_tv_control(demuxer_t *demuxer, int cmd, void *arg) return DEMUXER_CTRL_OK; } -demuxer_desc_t demuxer_desc_tv = { +const demuxer_desc_t demuxer_desc_tv = { .name = "tv", .desc = "TV card demuxer", .type = DEMUXER_TYPE_TV, diff --git a/sub/ass_mp.c b/sub/ass_mp.c index d417912826..a4a22b61a6 100644 --- a/sub/ass_mp.c +++ b/sub/ass_mp.c @@ -222,7 +222,7 @@ void mp_ass_render_frame(ASS_Renderer *renderer, ASS_Track *track, double time, *parts = res->parts; } -static int map_ass_level[] = { +static const int map_ass_level[] = { MSGL_ERR, // 0 "FATAL errors" MSGL_WARN, MSGL_INFO, diff --git a/sub/dec_sub.c b/sub/dec_sub.c index ccaf64b471..9fc3997af1 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -41,7 +41,7 @@ extern const struct sd_functions sd_microdvd; extern const struct sd_functions sd_lavf_srt; extern const struct sd_functions sd_lavc_conv; -static const struct sd_functions *sd_list[] = { +static const struct sd_functions *const sd_list[] = { #if HAVE_LIBASS &sd_ass, #endif diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c index 2d03300eaf..a8d6348fe9 100644 --- a/sub/find_subfiles.c +++ b/sub/find_subfiles.c @@ -13,9 +13,9 @@ #include "common/common.h" #include "sub/find_subfiles.h" -static const char *sub_exts[] = {"utf", "utf8", "utf-8", "idx", "sub", "srt", - "smi", "rt", "txt", "ssa", "aqt", "jss", - "js", "ass", NULL}; +static const char *const sub_exts[] = {"utf", "utf8", "utf-8", "idx", "sub", "srt", + "smi", "rt", "txt", "ssa", "aqt", "jss", + "js", "ass", NULL}; static bool is_sub_ext(bstr ext) { diff --git a/sub/osd.c b/sub/osd.c index 8da9fd0756..8b19428e5d 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -55,7 +55,7 @@ static const struct osd_style_opts osd_style_opts_def = { #define OPT_BASE_STRUCT struct osd_style_opts const struct m_sub_options osd_style_conf = { - .opts = (m_option_t[]) { + .opts = (const m_option_t[]) { OPT_STRING("font", font, 0), OPT_FLOATRANGE("font-size", font_size, 0, 1, 9000), OPT_COLOR("color", color, 0), diff --git a/sub/sd_microdvd.c b/sub/sd_microdvd.c index e9c7a788bc..6e6a9c31a8 100644 --- a/sub/sd_microdvd.c +++ b/sub/sd_microdvd.c @@ -309,7 +309,7 @@ static void convert_microdvd(const char *orig, char *dest, int dest_buffer_size) new_line.buf[new_line.len] = 0; } -static const char *microdvd_ass_extradata = +static const char *const microdvd_ass_extradata = "[Script Info]\n" "ScriptType: v4.00+\n" "PlayResX: 384\n" diff --git a/sub/sd_srt.c b/sub/sd_srt.c index 18ef0cce8f..733a27d0f4 100644 --- a/sub/sd_srt.c +++ b/sub/sd_srt.c @@ -439,7 +439,7 @@ static void convert_subrip(struct sd *sd, const char *orig, new_line.buf[new_line.len] = 0; } -static const char *srt_ass_extradata = +static const char *const srt_ass_extradata = "[Script Info]\n" "ScriptType: v4.00+\n" "PlayResX: 384\n" diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 1d04b5cd3d..5b8cdc3e50 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -88,7 +88,7 @@ const struct vd_lavc_hwdec mp_vd_lavc_vda; const struct vd_lavc_hwdec mp_vd_lavc_vaapi; const struct vd_lavc_hwdec mp_vd_lavc_vaapi_copy; -static const struct vd_lavc_hwdec *hwdec_list[] = { +static const struct vd_lavc_hwdec *const hwdec_list[] = { #if HAVE_VDPAU_HWACCEL &mp_vd_lavc_vdpau, #endif diff --git a/video/filter/vf_noise.c b/video/filter/vf_noise.c index 3046315219..acf8f4f0fd 100644 --- a/video/filter/vf_noise.c +++ b/video/filter/vf_noise.c @@ -73,7 +73,7 @@ struct vf_priv_s { static int nonTempRandShift_init; static int nonTempRandShift[MAX_RES]; -static int patt[4] = { +static const int patt[4] = { -1,0,1,0 }; diff --git a/video/filter/vf_rotate.c b/video/filter/vf_rotate.c index ad691a544e..6328e75722 100644 --- a/video/filter/vf_rotate.c +++ b/video/filter/vf_rotate.c @@ -36,7 +36,7 @@ static int vf_open(vf_instance_t *vf) { struct vf_priv_s *p = vf->priv; - static const char *rot[] = { + static const char *const rot[] = { "null", "transpose=clock", "vflip,hflip", diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c index 730994c12c..f11fd58a65 100644 --- a/video/filter/vf_scale.c +++ b/video/filter/vf_scale.c @@ -137,7 +137,7 @@ static const unsigned int outfmt_list[] = { * or to stop vf_scale from choosing a conversion that has no * fast assembler implementation. */ -static int preferred_conversions[][2] = { +static const int preferred_conversions[][2] = { {IMGFMT_YUYV, IMGFMT_UYVY}, {IMGFMT_YUYV, IMGFMT_422P}, {IMGFMT_UYVY, IMGFMT_YUYV}, diff --git a/video/image_writer.c b/video/image_writer.c index af1dab294c..f1318512b3 100644 --- a/video/image_writer.c +++ b/video/image_writer.c @@ -57,7 +57,7 @@ const struct image_writer_opts image_writer_opts_defaults = { #define OPT_BASE_STRUCT struct image_writer_opts const struct m_sub_options image_writer_conf = { - .opts = (m_option_t[]) { + .opts = (const m_option_t[]) { OPT_INTRANGE("jpeg-quality", jpeg_quality, 0, 0, 100), OPT_INTRANGE("jpeg-optimize", jpeg_optimize, 0, 0, 100), OPT_INTRANGE("jpeg-smooth", jpeg_smooth, 0, 0, 100), @@ -82,7 +82,7 @@ struct image_writer_ctx { struct img_writer { const char *file_ext; int (*write)(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp); - int *pixfmts; + const int *pixfmts; int lavc_codec; }; @@ -219,16 +219,16 @@ static const struct img_writer img_writers[] = { { "ppm", write_lavc, .lavc_codec = AV_CODEC_ID_PPM }, { "pgm", write_lavc, .lavc_codec = AV_CODEC_ID_PGM, - .pixfmts = (int[]) { IMGFMT_Y8, 0 }, + .pixfmts = (const int[]) { IMGFMT_Y8, 0 }, }, { "pgmyuv", write_lavc, .lavc_codec = AV_CODEC_ID_PGMYUV, - .pixfmts = (int[]) { IMGFMT_420P, 0 }, + .pixfmts = (const int[]) { IMGFMT_420P, 0 }, }, { "tga", write_lavc, .lavc_codec = AV_CODEC_ID_TARGA, - .pixfmts = (int[]) { IMGFMT_BGR24, IMGFMT_BGRA, IMGFMT_BGR15_LE, - IMGFMT_Y8, 0}, + .pixfmts = (const int[]) { IMGFMT_BGR24, IMGFMT_BGRA, IMGFMT_BGR15_LE, + IMGFMT_Y8, 0}, }, #if HAVE_JPEG { "jpg", write_jpeg }, @@ -277,7 +277,7 @@ int write_image(struct mp_image *image, const struct image_writer_opts *opts, if (writer->pixfmts) { destfmt = writer->pixfmts[0]; // default to first pixel format - for (int *fmt = writer->pixfmts; *fmt; fmt++) { + for (const int *fmt = writer->pixfmts; *fmt; fmt++) { if (*fmt == image->imgfmt) { destfmt = *fmt; break; diff --git a/video/out/gl_common.c b/video/out/gl_common.c index 4ed76caeeb..243f442b4d 100644 --- a/video/out/gl_common.c +++ b/video/out/gl_common.c @@ -156,17 +156,17 @@ struct gl_functions { int ver_core; // introduced as required function int ver_removed; // removed as required function (no replacement) bool partial_ok; // loading only some functions is ok - struct gl_function *functions; + const struct gl_function *functions; }; #define MAX_FN_COUNT 50 // max functions per gl_functions section -struct gl_functions gl_functions[] = { +static const struct gl_functions gl_functions[] = { // GL functions which are always available anywhere at least since 1.1 { .ver_core = MPGL_VER(1, 1), .provides = MPGL_CAP_GL, - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { DEF_FN(Viewport), DEF_FN(Clear), DEF_FN(GenTextures), @@ -204,7 +204,7 @@ struct gl_functions gl_functions[] = { { .ver_core = MPGL_VER(2, 0), .provides = MPGL_CAP_GL2, - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { DEF_FN(GenBuffers), DEF_FN(DeleteBuffers), DEF_FN(BindBuffer), @@ -248,7 +248,7 @@ struct gl_functions gl_functions[] = { { .ver_core = MPGL_VER(2, 1), .provides = MPGL_CAP_GL21, - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { DEF_FN(UniformMatrix4x3fv), {0} }, @@ -257,7 +257,7 @@ struct gl_functions gl_functions[] = { { .ver_core = MPGL_VER(3, 0), .provides = MPGL_CAP_GL3 | MPGL_CAP_SRGB_TEX | MPGL_CAP_SRGB_FB, - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { DEF_FN(GetStringi), {0} }, @@ -267,7 +267,7 @@ struct gl_functions gl_functions[] = { .ver_core = MPGL_VER(3, 0), .extension = "GL_ARB_framebuffer_object", .provides = MPGL_CAP_FB, - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { DEF_FN(BindFramebuffer), DEF_FN(GenFramebuffers), DEF_FN(DeleteFramebuffers), @@ -281,7 +281,7 @@ struct gl_functions gl_functions[] = { .ver_removed = MPGL_VER(3, 0), // don't touch these fn names in 3.x .extension = "GL_EXT_framebuffer_object", .provides = MPGL_CAP_FB, - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { DEF_FN_NAMES(BindFramebuffer, "glBindFramebufferEXT"), DEF_FN_NAMES(GenFramebuffers, "glGenFramebuffersEXT"), DEF_FN_NAMES(DeleteFramebuffers, "glDeleteFramebuffersEXT"), @@ -295,7 +295,7 @@ struct gl_functions gl_functions[] = { .ver_core = MPGL_VER(3, 0), .extension = "GL_ARB_vertex_array_object", .provides = MPGL_CAP_VAO, - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { DEF_FN(GenVertexArrays), DEF_FN(BindVertexArray), DEF_FN(DeleteVertexArrays), @@ -307,33 +307,33 @@ struct gl_functions gl_functions[] = { .ver_core = MPGL_VER(3, 0), .extension = "GL_EXT_texture_sRGB", .provides = MPGL_CAP_SRGB_TEX, - .functions = (struct gl_function[]) {{0}}, + .functions = (const struct gl_function[]) {{0}}, }, // sRGB framebuffers, extension in GL 2.x, core in GL 3.x core. { .ver_core = MPGL_VER(3, 0), .extension = "GL_EXT_framebuffer_sRGB", .provides = MPGL_CAP_SRGB_FB, - .functions = (struct gl_function[]) {{0}}, + .functions = (const struct gl_function[]) {{0}}, }, // Float textures, extension in GL 2.x, core in GL 3.x core. { .ver_core = MPGL_VER(3, 0), .extension = "GL_ARB_texture_float", .provides = MPGL_CAP_FLOAT_TEX, - .functions = (struct gl_function[]) {{0}}, + .functions = (const struct gl_function[]) {{0}}, }, // GL_RED / GL_RG textures, extension in GL 2.x, core in GL 3.x core. { .ver_core = MPGL_VER(3, 0), .extension = "GL_ARB_texture_rg", .provides = MPGL_CAP_TEX_RG, - .functions = (struct gl_function[]) {{0}}, + .functions = (const struct gl_function[]) {{0}}, }, // Swap control, always an OS specific extension { .extension = "_swap_control", - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { DEF_FN_NAMES(SwapInterval, "glXSwapIntervalSGI", "glXSwapInterval", "wglSwapIntervalSGI", "wglSwapInterval", "wglSwapIntervalEXT"), @@ -345,7 +345,7 @@ struct gl_functions gl_functions[] = { .ver_core = MPGL_VER(1, 1), .ver_removed = MPGL_VER(3, 0), .provides = MPGL_CAP_GL_LEGACY, - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { DEF_FN(Begin), DEF_FN(End), DEF_FN(MatrixMode), @@ -381,7 +381,7 @@ struct gl_functions gl_functions[] = { { .ver_removed = MPGL_VER(2, 1), .partial_ok = true, - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { DEF_FN_NAMES(GenBuffers, "glGenBuffers", "glGenBuffersARB"), DEF_FN_NAMES(DeleteBuffers, "glDeleteBuffers", "glDeleteBuffersARB"), DEF_FN_NAMES(BindBuffer, "glBindBuffer", "glBindBufferARB"), @@ -399,7 +399,7 @@ struct gl_functions gl_functions[] = { { .extension = "_program", .ver_removed = MPGL_VER(3, 0), - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { DEF_FN_NAMES(GenPrograms, "glGenProgramsARB"), DEF_FN_NAMES(DeletePrograms, "glDeleteProgramsARB"), DEF_FN_NAMES(BindProgram, "glBindProgramARB"), @@ -413,7 +413,7 @@ struct gl_functions gl_functions[] = { { .extension = "ATI_fragment_shader", .ver_removed = MPGL_VER(3, 0), - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { DEF_FN_NAMES(BeginFragmentShader, "glBeginFragmentShaderATI"), DEF_FN_NAMES(EndFragmentShader, "glEndFragmentShaderATI"), DEF_FN_NAMES(SampleMap, "glSampleMapATI"), @@ -428,7 +428,7 @@ struct gl_functions gl_functions[] = { { .extension = "GL_NV_vdpau_interop", .provides = MPGL_CAP_VDPAU, - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { // (only functions needed by us) DEF_FN(VDPAUInitNV), DEF_FN(VDPAUFiniNV), @@ -446,7 +446,7 @@ struct gl_functions gl_functions[] = { { .extension = "GL_APPLE_rgb_422", .provides = MPGL_CAP_APPLE_RGB_422, - .functions = (struct gl_function[]) { + .functions = (const struct gl_function[]) { {0} }, }, @@ -529,7 +529,7 @@ void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *), mp_dbg(log, "Combined OpenGL extensions string:\n%s\n", gl->extensions); for (int n = 0; n < sizeof(gl_functions) / sizeof(gl_functions[0]); n++) { - struct gl_functions *section = &gl_functions[n]; + const struct gl_functions *section = &gl_functions[n]; // With has_legacy, the legacy functions are still available, and // functions are never actually removed. (E.g. the context could be at @@ -558,7 +558,7 @@ void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *), bool all_loaded = true; for (int i = 0; section->functions[i].funcnames[0]; i++) { - struct gl_function *fn = §ion->functions[i]; + const struct gl_function *fn = §ion->functions[i]; void *ptr = NULL; for (int x = 0; fn->funcnames[x]; x++) { ptr = getProcAddress((const GLubyte *)fn->funcnames[x]); @@ -583,7 +583,7 @@ void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *), if (all_loaded || section->partial_ok) { gl->mpgl_caps |= section->provides; for (int i = 0; section->functions[i].funcnames[0]; i++) { - struct gl_function *fn = §ion->functions[i]; + const struct gl_function *fn = §ion->functions[i]; void **funcptr = (void**)(((char*)gl) + fn->offset); if (loaded[i]) *funcptr = loaded[i]; @@ -853,7 +853,7 @@ struct backend { MPGLSetBackendFn init; }; -static struct backend backends[] = { +static const struct backend backends[] = { #if HAVE_GL_COCOA {"cocoa", mpgl_set_backend_cocoa}, #endif @@ -1014,7 +1014,7 @@ extern const struct gl_hwdec_driver gl_hwdec_vaglx; extern const struct gl_hwdec_driver gl_hwdec_vda; extern const struct gl_hwdec_driver gl_hwdec_vdpau; -const struct gl_hwdec_driver *mpgl_hwdec_drivers[] = { +const struct gl_hwdec_driver *const mpgl_hwdec_drivers[] = { #if HAVE_VAAPI_GLX &gl_hwdec_vaglx, #endif diff --git a/video/out/gl_common.h b/video/out/gl_common.h index 622f1f2659..75ff0d5dfd 100644 --- a/video/out/gl_common.h +++ b/video/out/gl_common.h @@ -206,7 +206,7 @@ struct gl_hwdec_driver { void (*destroy)(struct gl_hwdec *hw); }; -extern const struct gl_hwdec_driver *mpgl_hwdec_drivers[]; +extern const struct gl_hwdec_driver *const mpgl_hwdec_drivers[]; void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *), const char *ext2, struct mp_log *log); diff --git a/video/out/gl_lcms.c b/video/out/gl_lcms.c index ad1bd1bb96..adda52b145 100644 --- a/video/out/gl_lcms.c +++ b/video/out/gl_lcms.c @@ -69,7 +69,7 @@ static int validate_3dlut_size_opt(struct mp_log *log, const m_option_t *opt, #define OPT_BASE_STRUCT struct mp_icc_opts const struct m_sub_options mp_icc_conf = { - .opts = (m_option_t[]) { + .opts = (const m_option_t[]) { OPT_STRING("icc-profile", profile, 0), OPT_FLAG("icc-profile-auto", profile_auto, 0), OPT_STRING("icc-cache", cache, 0), @@ -250,7 +250,7 @@ error_exit: #else /* HAVE_LCMS2 */ const struct m_sub_options mp_icc_conf = { - .opts = (m_option_t[]) { {0} }, + .opts = (const m_option_t[]) { {0} }, .size = sizeof(struct mp_icc_opts), .defaults = &(const struct mp_icc_opts) {0}, }; diff --git a/video/out/gl_video.c b/video/out/gl_video.c index ab56ca51a8..1b83d416ce 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -55,7 +55,7 @@ static const char vo_opengl_shaders[] = // lscale/cscale arguments that map directly to shader filter routines. // Note that the convolution filters are not included in this list. -static const char *fixed_scale_filters[] = { +static const char *const fixed_scale_filters[] = { "bilinear", "bicubic_fast", "sharpen3", @@ -73,7 +73,7 @@ struct lut_tex_format { // This must match the weightsN functions in the shader. // Each entry uses (size+3)/4 pixels per LUT entry, and size/pixels components // per pixel. -struct lut_tex_format lut_tex_formats[] = { +const struct lut_tex_format lut_tex_formats[] = { [2] = {1, GL_RG16F, GL_RG}, [4] = {1, GL_RGBA16F, GL_RGBA}, [6] = {2, GL_RGB16F, GL_RGB}, @@ -271,7 +271,7 @@ static const struct packed_fmt_entry mp_packed_formats[] = { {0}, }; -static const char *osd_shaders[SUBBITMAP_COUNT] = { +static const char *const osd_shaders[SUBBITMAP_COUNT] = { [SUBBITMAP_LIBASS] = "frag_osd_libass", [SUBBITMAP_RGBA] = "frag_osd_rgba", }; @@ -303,7 +303,7 @@ static int validate_scaler_opt(struct mp_log *log, const m_option_t *opt, #define OPT_BASE_STRUCT struct gl_video_opts const struct m_su