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.
This commit is contained in:
wm4
2014-06-10 23:56:05 +02:00
parent ad4b7a8c96
commit 99f5fef0ea
82 changed files with 202 additions and 206 deletions

View File

@@ -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",

View File

@@ -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;

View File

@@ -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;
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 struct af_info* filter_list[] = {
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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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",

View File

@@ -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,

View File

@@ -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,

View File

@@ -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"},

View File

@@ -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},

View File

@@ -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",

View File

@@ -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

View File

@@ -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;

View File

@@ -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)

View File

@@ -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"},

View File

@@ -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++) {

View File

@@ -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"

View File

@@ -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",

View File

@@ -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);

View File

@@ -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",
};

View File

@@ -207,7 +207,7 @@ exit:
return res;
}
static const char *backup_properties[] = {
static const char *const backup_properties[] = {
"options/osd-level",
//"loop",
"options/speed",

View File

@@ -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)
{

View File

@@ -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),

View File

@@ -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

View File

@@ -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)

View File

@@ -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;

View File

@@ -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 },
};

View File

@@ -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",

View File

@@ -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

View File

@@ -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 },
};

View File

@@ -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;

View File

@@ -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

View File

@@ -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},
};

View File

@@ -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,
};

View File

@@ -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",

View File

@@ -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 },
};

View File

@@ -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 },
};

View File

@@ -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,
};

View File

@@ -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 },
};

View File

@@ -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 = {

View File

@@ -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?
};

View File

@@ -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

View File

@@ -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,

View File

@@ -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,

View File

@@ -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

View File

@@ -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)
{

View File

@@ -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),

View File

@@ -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"

View File

@@ -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"

View File

@@ -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

View File

@@ -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
};

View File

@@ -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",

View File

@@ -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},

View File

@@ -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;

View File

@@ -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 = &section->functions[i];
const struct gl_function *fn = &section->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 = &section->functions[i];
const struct gl_function *fn = &section->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

View File

@@ -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);

View File

@@ -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},
};

View File

@@ -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_sub_options gl_video_conf = {
.opts = (m_option_t[]) {
.opts = (const m_option_t[]) {
OPT_FLOATRANGE("gamma", gamma, 0, 0.0, 10.0),
OPT_FLAG("srgb", srgb, 0),
OPT_FLAG("approx-gamma", approx_gamma, 0),
@@ -1046,7 +1046,7 @@ static void init_scaler(struct gl_video *p, struct scaler *scaler)
int size = scaler->kernel->size;
assert(size < FF_ARRAY_ELEMS(lut_tex_formats));
struct lut_tex_format *fmt = &lut_tex_formats[size];
const struct lut_tex_format *fmt = &lut_tex_formats[size];
bool use_2d = fmt->pixels > 1;
bool is_luma = scaler->index == 0;
scaler->lut_name = use_2d
@@ -1854,7 +1854,7 @@ static bool test_fbo(struct gl_video *p, GLenum format)
0xFFFFFF / (float)(1 << 25), // float mantissa
2, // out of range value
};
static const char *val_names[] = {
static const char *const val_names[] = {
"8-bit precision",
"16-bit precision",
"full float",
@@ -2237,7 +2237,7 @@ static const char* handle_scaler_opt(const char *name)
if (can_use_filter_kernel(kernel))
return kernel->name;
for (const char **filter = fixed_scale_filters; *filter; filter++) {
for (const char *const *filter = fixed_scale_filters; *filter; filter++) {
if (strcmp(*filter, name) == 0)
return *filter;
}
@@ -2289,7 +2289,7 @@ static int validate_scaler_opt(struct mp_log *log, const m_option_t *opt,
{
if (bstr_equals0(param, "help")) {
mp_info(log, "Available scalers:\n");
for (const char **filter = fixed_scale_filters; *filter; filter++)
for (const char *const *filter = fixed_scale_filters; *filter; filter++)
mp_info(log, " %s\n", *filter);
for (int n = 0; mp_filter_kernels[n].name; n++)
mp_info(log, " %s\n", mp_filter_kernels[n].name);

View File

@@ -47,24 +47,24 @@
//
// Externally visible list of all vo drivers
//
extern struct vo_driver video_out_x11;
extern struct vo_driver video_out_vdpau;
extern struct vo_driver video_out_xv;
extern struct vo_driver video_out_opengl;
extern struct vo_driver video_out_opengl_hq;
extern struct vo_driver video_out_opengl_old;
extern struct vo_driver video_out_null;
extern struct vo_driver video_out_image;
extern struct vo_driver video_out_lavc;
extern struct vo_driver video_out_caca;
extern struct vo_driver video_out_direct3d;
extern struct vo_driver video_out_direct3d_shaders;
extern struct vo_driver video_out_sdl;
extern struct vo_driver video_out_corevideo;
extern struct vo_driver video_out_vaapi;
extern struct vo_driver video_out_wayland;
extern const struct vo_driver video_out_x11;
extern const struct vo_driver video_out_vdpau;
extern const struct vo_driver video_out_xv;
extern const struct vo_driver video_out_opengl;
extern const struct vo_driver video_out_opengl_hq;
extern const struct vo_driver video_out_opengl_old;
extern const struct vo_driver video_out_null;
extern const struct vo_driver video_out_image;
extern const struct vo_driver video_out_lavc;
extern const struct vo_driver video_out_caca;
extern const struct vo_driver video_out_direct3d;
extern const struct vo_driver video_out_direct3d_shaders;
extern const struct vo_driver video_out_sdl;
extern const struct vo_driver video_out_corevideo;
extern const struct vo_driver video_out_vaapi;
extern const struct vo_driver video_out_wayland;
const struct vo_driver *video_out_drivers[] =
const struct vo_driver *const video_out_drivers[] =
{
#if HAVE_VDPAU
&video_out_vdpau,

View File

@@ -288,9 +288,6 @@ void vo_destroy(struct vo *vo);
const char *vo_get_window_title(struct vo *vo);
// NULL terminated array of all drivers
extern const struct vo_driver *video_out_drivers[];
struct mp_keymap {
int from;
int to;

View File

@@ -596,8 +596,7 @@ static const struct wl_registry_listener registry_listener = {
static int lookupkey(int key)
{
static const char *passthrough_keys
= " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]";
const char *passthrough_keys = " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]";
int mpkey = 0;
if ((key >= 'a' && key <= 'z') ||

View File

@@ -513,7 +513,7 @@ static const struct mp_keymap keymap[] = {
static int vo_x11_lookupkey(int key)
{
static const char *passthrough_keys = " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]";
const char *passthrough_keys = " -+*/<>`~!@#$%^&()_{}:;\"\',.?\\|=[]";
int mpkey = 0;
if ((key >= 'a' && key <= 'z') ||
(key >= 'A' && key <= 'Z') ||