From 1c49cfdb97983b6a4cdb19587962da59866a03a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sat, 1 Mar 2025 10:36:15 +0100 Subject: [PATCH] various: use mp_assert macro --- audio/aframe.c | 2 +- audio/chmap.c | 6 +- audio/chmap_sel.c | 4 +- audio/decode/ad_spdif.c | 4 +- audio/filter/af_rubberband.c | 10 +- audio/filter/af_scaletempo.c | 2 +- audio/filter/af_scaletempo2.c | 10 +- audio/filter/af_scaletempo2_internals.c | 16 +-- audio/out/ao.c | 2 +- audio/out/ao_alsa.c | 2 +- audio/out/ao_audiotrack.c | 4 +- audio/out/ao_coreaudio_chmap.c | 2 +- audio/out/ao_wasapi.c | 2 +- audio/out/ao_wasapi_utils.c | 2 +- audio/out/buffer.c | 16 +-- common/common.c | 4 +- common/common.h | 2 +- common/encode_lavc.c | 6 +- common/msg.c | 18 +-- common/playlist.c | 26 ++--- common/stats.c | 10 +- demux/cache.c | 14 +-- demux/demux.c | 148 ++++++++++++------------ demux/demux_disc.c | 4 +- demux/demux_edl.c | 4 +- demux/demux_lavf.c | 6 +- demux/demux_mkv.c | 6 +- demux/demux_timeline.c | 4 +- demux/ebml.c | 10 +- demux/packet.c | 6 +- demux/packet_pool.c | 6 +- filters/f_async_queue.c | 18 +-- filters/f_auto_filters.c | 4 +- filters/f_decoder_wrapper.c | 20 ++-- filters/f_hwtransfer.c | 2 +- filters/f_lavfi.c | 14 +-- filters/f_output_chain.c | 10 +- filters/f_swresample.c | 8 +- filters/f_utils.c | 4 +- filters/filter.c | 98 ++++++++-------- filters/frame.c | 2 +- filters/user_filters.c | 2 +- input/cmd.c | 6 +- input/input.c | 12 +- input/ipc.c | 2 +- misc/bstr.c | 2 +- misc/codepoint_width.c | 2 +- misc/dispatch.c | 32 ++--- misc/io_utils.c | 2 +- misc/json.c | 2 +- misc/node.c | 16 +-- misc/path_utils.c | 2 +- misc/thread_pool.c | 12 +- misc/thread_tools.c | 4 +- options/m_config_core.c | 60 +++++----- options/m_config_frontend.c | 6 +- options/m_option.c | 18 +-- options/m_option.h | 1 + options/m_property.c | 6 +- options/parse_commandline.c | 6 +- options/path.c | 4 +- osdep/compiler.h | 2 + osdep/io.c | 4 +- osdep/subprocess-posix.c | 4 +- osdep/terminal-unix.c | 6 +- osdep/threads-posix.h | 14 +-- osdep/timer.c | 4 +- osdep/win32/smtc.cpp | 2 +- player/audio.c | 16 +-- player/client.c | 18 +-- player/command.c | 24 ++-- player/loadfile.c | 48 ++++---- player/lua.c | 16 +-- player/main.c | 4 +- player/osd.c | 2 +- player/screenshot.c | 2 +- player/scripting.c | 2 +- player/sub.c | 4 +- player/video.c | 22 ++-- stream/stream.c | 54 ++++----- stream/stream_dvb.c | 4 +- stream/stream_dvdnav.c | 2 +- stream/stream_libarchive.c | 2 +- stream/stream_memory.c | 2 +- sub/dec_sub.c | 2 +- sub/draw_bmp.c | 54 ++++----- sub/osd.c | 4 +- sub/osd_libass.c | 2 +- sub/sd_lavc.c | 6 +- test/img_format.c | 22 ++-- test/img_utils.c | 4 +- test/repack.c | 32 ++--- test/scale_test.c | 26 ++--- test/test_utils.c | 2 +- test/test_utils.h | 4 +- video/csputils.c | 4 +- video/decode/vd_lavc.c | 14 +-- video/filter/refqueue.c | 14 +-- video/filter/vf_gpu.c | 2 +- video/filter/vf_vapoursynth.c | 10 +- video/hwdec.c | 4 +- video/img_format.c | 2 +- video/mp_image.c | 50 ++++---- video/mp_image_pool.c | 14 +-- video/out/bitmap_packer.c | 4 +- video/out/d3d11/context.c | 2 +- video/out/d3d11/ra_d3d11.c | 4 +- video/out/dither.c | 5 +- video/out/dr_helper.c | 16 +-- video/out/filter_kernels.c | 4 +- video/out/gpu/error_diffusion.c | 4 +- video/out/gpu/hwdec.c | 4 +- video/out/gpu/osd.c | 6 +- video/out/gpu/ra.c | 6 +- video/out/gpu/shader_cache.c | 20 ++-- video/out/gpu/user_shaders.c | 2 +- video/out/gpu/utils.c | 8 +- video/out/gpu/video.c | 40 +++---- video/out/hwdec/dmabuf_interop_gl.c | 2 +- video/out/hwdec/hwdec_aimagereader.c | 10 +- video/out/hwdec/hwdec_ios_gl.m | 2 +- video/out/hwdec/hwdec_mac_gl.c | 2 +- video/out/hwdec/hwdec_vt_pl.m | 2 +- video/out/libmpv_sw.c | 2 +- video/out/opengl/common.c | 4 +- video/out/opengl/hwdec_vdpau.c | 2 +- video/out/opengl/ra_gl.c | 36 +++--- video/out/opengl/utils.c | 10 +- video/out/placebo/ra_pl.c | 2 +- video/out/vo.c | 10 +- video/out/vo_direct3d.c | 2 +- video/out/vo_dmabuf_wayland.c | 2 +- video/out/vo_gpu.c | 4 +- video/out/vo_gpu_next.c | 12 +- video/out/vo_libmpv.c | 8 +- video/out/vo_mediacodec_embed.c | 2 +- video/out/vo_tct.c | 4 +- video/out/vo_vaapi.c | 2 +- video/out/vo_vdpau.c | 4 +- video/out/vulkan/context.c | 4 +- video/out/vulkan/utils.c | 2 +- video/out/w32_common.c | 6 +- video/out/wayland_common.c | 2 +- video/out/x11_common.c | 12 +- video/repack.c | 50 ++++---- video/sws_utils.c | 2 +- video/vdpau.c | 20 ++-- video/vdpau_mixer.c | 2 +- video/zimg.c | 16 +-- 149 files changed, 817 insertions(+), 813 deletions(-) diff --git a/audio/aframe.c b/audio/aframe.c index e22a98edac..fbba7a3b10 100644 --- a/audio/aframe.c +++ b/audio/aframe.c @@ -418,7 +418,7 @@ char *mp_aframe_format_str_buf(char *buf, size_t buf_size, struct mp_aframe *fmt // Set data to the audio after the given number of samples (i.e. slice it). void mp_aframe_skip_samples(struct mp_aframe *f, int samples) { - assert(samples >= 0 && samples <= mp_aframe_get_size(f)); + mp_assert(samples >= 0 && samples <= mp_aframe_get_size(f)); if (av_frame_make_writable(f->av_frame) < 0) return; // go complain to ffmpeg diff --git a/audio/chmap.c b/audio/chmap.c index a56d78dfe2..79ae2d74d6 100644 --- a/audio/chmap.c +++ b/audio/chmap.c @@ -206,7 +206,7 @@ void mp_chmap_remove_na(struct mp_chmap *map) // Add silent (NA) channels to map until map->num >= num. void mp_chmap_fill_na(struct mp_chmap *map, int num) { - assert(num <= MP_NUM_CHANNELS); + mp_assert(num <= MP_NUM_CHANNELS); while (map->num < num) map->speaker[map->num++] = MP_SPEAKER_ID_NA; } @@ -298,7 +298,7 @@ bool mp_chmap_is_lavc(const struct mp_chmap *src) return true; // lavc's channel layout is a bit mask, and channels are always ordered // from LSB to MSB speaker bits, so speaker IDs have to increase. - assert(src->num > 0); + mp_assert(src->num > 0); for (int n = 1; n < src->num; n++) { if (src->speaker[n - 1] >= src->speaker[n]) return false; @@ -350,7 +350,7 @@ void mp_chmap_get_reorder(int src[MP_NUM_CHANNELS], const struct mp_chmap *from, } for (int n = 0; n < to->num; n++) - assert(src[n] < 0 || (to->speaker[n] == from->speaker[src[n]])); + mp_assert(src[n] < 0 || (to->speaker[n] == from->speaker[src[n]])); } // Return the number of channels only in a. diff --git a/audio/chmap_sel.c b/audio/chmap_sel.c index 4fb7544f20..f92f65c2b8 100644 --- a/audio/chmap_sel.c +++ b/audio/chmap_sel.c @@ -34,7 +34,7 @@ static const struct mp_chmap speaker_replacements[][2] = { // right, or the other way around. static bool replace_speakers(struct mp_chmap *map, struct mp_chmap list[2]) { - assert(list[0].num == list[1].num); + mp_assert(list[0].num == list[1].num); if (!mp_chmap_is_valid(map)) return false; for (int dir = 0; dir < 2; dir++) { @@ -126,7 +126,7 @@ void mp_chmap_sel_add_waveext_def(struct mp_chmap_sel *s) // speakers are allowed. void mp_chmap_sel_add_speaker(struct mp_chmap_sel *s, int id) { - assert(id >= 0 && id < MP_SPEAKER_ID_COUNT); + mp_assert(id >= 0 && id < MP_SPEAKER_ID_COUNT); s->speakers[id] = true; } diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c index 45fef43165..2c0c8d2966 100644 --- a/audio/decode/ad_spdif.c +++ b/audio/decode/ad_spdif.c @@ -328,8 +328,8 @@ static void ad_spdif_process(struct mp_filter *da) if (!spdif_ctx->lavf_ctx) { if (init_filter(da) < 0) goto done; - assert(spdif_ctx->avpkt); - assert(spdif_ctx->lavf_ctx); + mp_assert(spdif_ctx->avpkt); + mp_assert(spdif_ctx->lavf_ctx); } spdif_ctx->out_buffer_len = 0; diff --git a/audio/filter/af_rubberband.c b/audio/filter/af_rubberband.c index e71937fcb2..4027c12922 100644 --- a/audio/filter/af_rubberband.c +++ b/audio/filter/af_rubberband.c @@ -75,8 +75,8 @@ static bool init_rubberband(struct mp_filter *f) { struct priv *p = f->priv; - assert(!p->rubber); - assert(p->pending); + mp_assert(!p->rubber); + mp_assert(p->pending); int opts = p->opts->transients | p->opts->detector | p->opts->phase | p->opts->window | p->opts->smoothing | p->opts->formant | @@ -132,7 +132,7 @@ static void af_rubberband_process(struct mp_filter *f) return; // no new data yet } } - assert(p->pending || eof); + mp_assert(p->pending || eof); if (!p->rubber) { if (!p->pending) { @@ -185,7 +185,7 @@ static void af_rubberband_process(struct mp_filter *f) } } - assert(p->pending); + mp_assert(p->pending); int out_samples = rubberband_available(p->rubber); if (out_samples > 0) { @@ -199,7 +199,7 @@ static void af_rubberband_process(struct mp_filter *f) float *out_data[MP_NUM_CHANNELS] = {0}; uint8_t **planes = mp_aframe_get_data_rw(out); - assert(planes); + mp_assert(planes); int num_planes = mp_aframe_get_planes(out); for (int n = 0; n < num_planes; n++) out_data[n] = (void *)planes[n]; diff --git a/audio/filter/af_scaletempo.c b/audio/filter/af_scaletempo.c index bc0b372404..b31879a3c6 100644 --- a/audio/filter/af_scaletempo.c +++ b/audio/filter/af_scaletempo.c @@ -117,7 +117,7 @@ static bool fill_queue(struct priv *s) } int bytes_needed = s->bytes_queue - s->bytes_queued; - assert(bytes_needed >= 0); + mp_assert(bytes_needed >= 0); int bytes_copy = MPMIN(bytes_needed, bytes_in); if (bytes_copy > 0) { diff --git a/audio/filter/af_scaletempo2.c b/audio/filter/af_scaletempo2.c index 749e219454..65e7440e09 100644 --- a/audio/filter/af_scaletempo2.c +++ b/audio/filter/af_scaletempo2.c @@ -46,7 +46,7 @@ static void af_scaletempo2_process(struct mp_filter *f) return; // no new data yet } } - assert(p->pending || eof); + mp_assert(p->pending || eof); if (!p->initialized) { if (!p->pending) { @@ -88,7 +88,7 @@ static void af_scaletempo2_process(struct mp_filter *f) } } - assert(p->pending); + mp_assert(p->pending); if (mp_scaletempo2_frames_available(p->data, p->speed)) { struct mp_aframe *out = mp_aframe_new_ref(p->cur_format); int out_samples = p->data->ola_hop_size; @@ -100,8 +100,8 @@ static void af_scaletempo2_process(struct mp_filter *f) mp_aframe_copy_attributes(out, p->pending); uint8_t **planes = mp_aframe_get_data_rw(out); - assert(planes); - assert(mp_aframe_get_planes(out) == p->data->channels); + mp_assert(planes); + mp_assert(mp_aframe_get_planes(out) == p->data->channels); out_samples = mp_scaletempo2_fill_buffer(p->data, (float**)planes, out_samples, p->speed); @@ -140,7 +140,7 @@ error: static bool init_scaletempo2(struct mp_filter *f) { struct priv *p = f->priv; - assert(p->pending); + mp_assert(p->pending); if (mp_aframe_get_format(p->pending) != AF_FORMAT_FLOATP) return false; diff --git a/audio/filter/af_scaletempo2_internals.c b/audio/filter/af_scaletempo2_internals.c index 7f3a99638f..2b038a06c5 100644 --- a/audio/filter/af_scaletempo2_internals.c +++ b/audio/filter/af_scaletempo2_internals.c @@ -115,8 +115,8 @@ static void multi_channel_dot_product( int channels, int num_frames, float *dot_product) { - assert(frame_offset_a >= 0); - assert(frame_offset_b >= 0); + mp_assert(frame_offset_a >= 0); + mp_assert(frame_offset_b >= 0); for (int k = 0; k < channels; ++k) { const float* ch_a = a[k] + frame_offset_a; @@ -176,8 +176,8 @@ static void multi_channel_dot_product( int channels, int num_frames, float *dot_product) { - assert(frame_offset_a >= 0); - assert(frame_offset_b >= 0); + mp_assert(frame_offset_a >= 0); + mp_assert(frame_offset_b >= 0); for (int k = 0; k < channels; ++k) { const float* ch_a = a[k] + frame_offset_a; @@ -405,7 +405,7 @@ static int compute_optimal_index( static void peek_buffer(struct mp_scaletempo2 *p, int frames, int read_offset, int write_offset, float **dest) { - assert(p->input_buffer_frames >= frames); + mp_assert(p->input_buffer_frames >= frames); for (int i = 0; i < p->channels; ++i) { memcpy(dest[i] + write_offset, p->input_buffer[i] + read_offset, @@ -415,7 +415,7 @@ static void peek_buffer(struct mp_scaletempo2 *p, static void seek_buffer(struct mp_scaletempo2 *p, int frames) { - assert(p->input_buffer_frames >= frames); + mp_assert(p->input_buffer_frames >= frames); p->input_buffer_frames -= frames; if (p->input_buffer_final_frames > 0) { p->input_buffer_final_frames = MPMAX(0, p->input_buffer_final_frames - frames); @@ -533,7 +533,7 @@ static bool target_is_within_search_region(struct mp_scaletempo2 *p) static void peek_audio_with_zero_prepend(struct mp_scaletempo2 *p, int read_offset_frames, float **dest, int dest_frames) { - assert(read_offset_frames + dest_frames <= p->input_buffer_frames); + mp_assert(read_offset_frames + dest_frames <= p->input_buffer_frames); int write_offset = 0; int num_frames_to_read = dest_frames; @@ -638,7 +638,7 @@ static bool run_one_wsola_iteration(struct mp_scaletempo2 *p, double playback_ra set_output_time(p, get_updated_time(p, playback_rate)); remove_old_input_frames(p); - assert(p->search_block_index + p->search_block_size <= p->input_buffer_frames); + mp_assert(p->search_block_index + p->search_block_size <= p->input_buffer_frames); get_optimal_block(p); diff --git a/audio/out/ao.c b/audio/out/ao.c index ee20b736a3..c5d2fb4b94 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -159,7 +159,7 @@ static struct ao *ao_alloc(bool probing, struct mpv_global *global, void (*wakeup_cb)(void *ctx), void *wakeup_ctx, char *name) { - assert(wakeup_cb); + mp_assert(wakeup_cb); struct mp_log *log = mp_log_new(NULL, global->log, "ao"); struct m_obj_desc desc; diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index 1bf6015c78..b5ce81e47b 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -308,7 +308,7 @@ static void replace_submap(struct mp_chmap *dst, struct mp_chmap *a, struct mp_chmap t = *dst; if (!mp_chmap_is_valid(&t) || mp_chmap_diffn(a, &t) != 0) return; - assert(a->num == b->num); + mp_assert(a->num == b->num); for (int n = 0; n < t.num; n++) { for (int i = 0; i < a->num; i++) { if (t.speaker[n] == a->speaker[i]) { diff --git a/audio/out/ao_audiotrack.c b/audio/out/ao_audiotrack.c index 8068a09f9d..7bce2d4263 100644 --- a/audio/out/ao_audiotrack.c +++ b/audio/out/ao_audiotrack.c @@ -719,7 +719,7 @@ static int init(struct ao *ao) if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels)) goto error; p->channel_config = layout_map[ao->channels.num]; - assert(p->channel_config); + mp_assert(p->channel_config); } jint buffer_size = MP_JNI_CALL_STATIC_INT( @@ -743,7 +743,7 @@ static int init(struct ao *ao) max = MP_ALIGN_UP(max, bps); p->size = MPCLAMP(buffer_size * 2, min, max); MP_VERBOSE(ao, "Setting bufferSize = %d (driver=%d, min=%d, max=%d)\n", p->size, buffer_size, min, max); - assert(p->size % bps == 0); + mp_assert(p->size % bps == 0); ao->device_buffer = p->size / bps; p->chunksize = p->size; diff --git a/audio/out/ao_coreaudio_chmap.c b/audio/out/ao_coreaudio_chmap.c index 55e738382a..2c6131f13c 100644 --- a/audio/out/ao_coreaudio_chmap.c +++ b/audio/out/ao_coreaudio_chmap.c @@ -348,7 +348,7 @@ static void replace_submap(struct mp_chmap *dst, struct mp_chmap *a, struct mp_chmap t = *dst; if (!mp_chmap_is_valid(&t) || mp_chmap_diffn(a, &t) != 0) return; - assert(a->num == b->num); + mp_assert(a->num == b->num); for (int n = 0; n < t.num; n++) { for (int i = 0; i < a->num; i++) { if (t.speaker[n] == a->speaker[i]) { diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c index 34c3b6193f..7ad1e6427f 100644 --- a/audio/out/ao_wasapi.c +++ b/audio/out/ao_wasapi.c @@ -447,7 +447,7 @@ static int thread_control(struct ao *ao, enum aocontrol cmd, void *arg) MP_WARN(ao, "Error setting audio session name: %s\n", mp_HRESULT_to_str(hr)); - assert(ao->client_name); + mp_assert(ao->client_name); if (!ao->client_name) return CONTROL_ERROR; diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index f7ea7cfbb4..2f050212e0 100644 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -628,7 +628,7 @@ static void init_session_display(struct wasapi_state *state, const char *name) { mp_HRESULT_to_str(hr)); } - assert(name); + mp_assert(name); if (!name) return; diff --git a/audio/out/buffer.c b/audio/out/buffer.c index 067ab4e073..660a144c86 100644 --- a/audio/out/buffer.c +++ b/audio/out/buffer.c @@ -182,7 +182,7 @@ static int ao_read_data_locked(struct ao *ao, void **data, int samples, int64_t out_time_ns, bool *eof, bool pad_silence) { struct buffer_state *p = ao->buffer_state; - assert(!ao->driver->write); + mp_assert(!ao->driver->write); int pos = read_buffer(ao, data, samples, eof, pad_silence); @@ -241,8 +241,8 @@ int ao_read_data_converted(struct ao *ao, struct ao_convert_fmt *fmt, if (!ao_need_conversion(fmt)) return ao_read_data(ao, data, samples, out_time_ns, NULL, true, true); - assert(ao->format == fmt->src_fmt); - assert(ao->channels.num == fmt->channels); + mp_assert(ao->format == fmt->src_fmt); + mp_assert(ao->channels.num == fmt->channels); bool planar = af_fmt_is_planar(fmt->src_fmt); int planes = planar ? fmt->channels : 1; @@ -554,10 +554,10 @@ bool init_buffer_post(struct ao *ao) { struct buffer_state *p = ao->buffer_state; - assert(ao->driver->start); + mp_assert(ao->driver->start); if (ao->driver->write) { - assert(ao->driver->reset); - assert(ao->driver->get_state); + mp_assert(ao->driver->reset); + mp_assert(ao->driver->get_state); } mp_mutex_init(&p->lock); @@ -642,7 +642,7 @@ static bool ao_play_data(struct ao *ao) int space = state.free_samples; if (!space) return false; - assert(space >= 0); + mp_assert(space >= 0); int samples = 0; bool got_eof = false; @@ -656,7 +656,7 @@ static bool ao_play_data(struct ao *ao) return false; } planes = (void **)mp_aframe_get_data_rw(p->temp_buf); - assert(planes); + mp_assert(planes); if (p->recover_pause) { samples = MPCLAMP(p->prepause_state.delay * ao->samplerate, 0, space); diff --git a/common/common.c b/common/common.c index d9468fba94..4fa70b42ef 100644 --- a/common/common.c +++ b/common/common.c @@ -213,7 +213,7 @@ int mp_rect_subtract(const struct mp_rect *rc1, const struct mp_rect *rc2, int mp_snprintf_cat(char *str, size_t size, const char *format, ...) { size_t len = strnlen(str, size); - assert(!size || len < size); // str with no 0-termination is not allowed + mp_assert(!size || len < size); // str with no 0-termination is not allowed int r; va_list ap; va_start(ap, format); @@ -427,6 +427,6 @@ uint32_t mp_round_next_power_of_2(uint32_t v) int mp_lcm(int x, int y) { - assert(x && y); + mp_assert(x && y); return x * (y / av_gcd(x, y)); } diff --git a/common/common.h b/common/common.h index f20d94292b..80fb5bfb0f 100644 --- a/common/common.h +++ b/common/common.h @@ -18,7 +18,6 @@ #ifndef MPLAYER_MPCOMMON_H #define MPLAYER_MPCOMMON_H -#include #include #include #include @@ -31,6 +30,7 @@ #include #endif +#include "misc/mp_assert.h" #include "osdep/compiler.h" #include "mpv_talloc.h" diff --git a/common/encode_lavc.c b/common/encode_lavc.c index 2eb7a63314..cb7cb791e9 100644 --- a/common/encode_lavc.c +++ b/common/encode_lavc.c @@ -393,7 +393,7 @@ static void encode_lavc_add_packet(struct mux_stream *dst, AVPacket *pkt) struct encode_lavc_context *ctx = dst->ctx; struct encode_priv *p = ctx->priv; - assert(dst->st); + mp_assert(dst->st); mp_mutex_lock(&ctx->lock); @@ -407,7 +407,7 @@ static void encode_lavc_add_packet(struct mux_stream *dst, AVPacket *pkt) } pkt->stream_index = dst->st->index; - assert(dst->st == p->muxer->streams[pkt->stream_index]); + mp_assert(dst->st == p->muxer->streams[pkt->stream_index]); av_packet_rescale_ts(pkt, dst->encoder_timebase, dst->st->time_base); @@ -842,7 +842,7 @@ static void encoder_2pass_prepare(struct encoder_context *p) bool encoder_init_codec_and_muxer(struct encoder_context *p, void (*on_ready)(void *ctx), void *ctx) { - assert(!avcodec_is_open(p->encoder)); + mp_assert(!avcodec_is_open(p->encoder)); char **copts = p->type == STREAM_VIDEO ? p->options->vopts diff --git a/common/msg.c b/common/msg.c index b44b63e389..542f76d690 100644 --- a/common/msg.c +++ b/common/msg.c @@ -244,7 +244,7 @@ static void prepare_prefix(struct mp_log_root *root, bstr *out, int lev, int ter bstr up_clear = bstr0("\033[A\033[K"); for (int i = 1; i < root->status_lines; ++i) bstr_xappend(root, out, up_clear); - assert(root->status_lines > 0 && root->blank_lines >= root->status_lines); + mp_assert(root->status_lines > 0 && root->blank_lines >= root->status_lines); line_skip = root->blank_lines - root->status_lines; } @@ -432,7 +432,7 @@ static void append_terminal_line(struct mp_log *log, int lev, static struct mp_log_buffer_entry *log_buffer_read(struct mp_log_buffer *buffer) { - assert(buffer->num_entries); + mp_assert(buffer->num_entries); struct mp_log_buffer_entry *res = buffer->entries[buffer->entry0]; buffer->entry0 = (buffer->entry0 + 1) % buffer->capacity; buffer->num_entries -= 1; @@ -521,7 +521,7 @@ static void write_term_msg(struct mp_log *log, int lev, bstr text, bstr *out) while (str.len) { bstr line = bstr_getline(str, &str); if (line.start[line.len - 1] != '\n') { - assert(str.len == 0); + mp_assert(str.len == 0); str = line; break; } @@ -636,7 +636,7 @@ static void destroy_log(void *ptr) struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent, const char *name) { - assert(parent); + mp_assert(parent); struct mp_log *log = talloc_zero(talloc_ctx, struct mp_log); if (!parent->root) return log; // same as null_log @@ -670,7 +670,7 @@ struct mp_log *mp_log_new(void *talloc_ctx, struct mp_log *parent, void mp_msg_init(struct mpv_global *global) { - assert(!global->log); + mp_assert(!global->log); struct mp_log_root *root = talloc_zero(NULL, struct mp_log_root); *root = (struct mp_log_root){ @@ -897,7 +897,7 @@ void mp_msg_uninit(struct mpv_global *global) terminate_log_file_thread(root); mp_msg_log_buffer_destroy(root->early_buffer); mp_msg_log_buffer_destroy(root->early_filebuffer); - assert(root->num_buffers == 0); + mp_assert(root->num_buffers == 0); if (root->stats_file) fclose(root->stats_file); talloc_free(root->stats_path); @@ -941,7 +941,7 @@ static void mp_msg_set_early_logging_raw(struct mpv_global *global, bool enable, struct mp_log_buffer *buf = mp_msg_log_buffer_new(global, size, level, NULL, NULL); mp_mutex_lock(&root->lock); - assert(!*root_logbuf); // no concurrent calls to this function + mp_assert(!*root_logbuf); // no concurrent calls to this function *root_logbuf = buf; } else { struct mp_log_buffer *buf = *root_logbuf; @@ -992,7 +992,7 @@ struct mp_log_buffer *mp_msg_log_buffer_new(struct mpv_global *global, } } - assert(size > 0); + mp_assert(size > 0); struct mp_log_buffer *buffer = talloc_ptrtype(NULL, buffer); *buffer = (struct mp_log_buffer) { @@ -1018,7 +1018,7 @@ void mp_msg_log_buffer_resize(struct mp_log_buffer *buffer, int size) { mp_mutex_lock(&buffer->lock); - assert(size > 0); + mp_assert(size > 0); if (buffer->capacity < size && buffer->entry0 + buffer->num_entries <= buffer->capacity) { // shortcut if buffer doesn't wrap diff --git a/common/playlist.c b/common/playlist.c index ad2870c022..5bf7735779 100644 --- a/common/playlist.c +++ b/common/playlist.c @@ -65,8 +65,8 @@ static void playlist_update_indexes(struct playlist *pl, int start, int end) void playlist_insert_at(struct playlist *pl, struct playlist_entry *add, struct playlist_entry *at) { - assert(add->filename); - assert(!at || at->pl == pl); + mp_assert(add->filename); + mp_assert(!at || at->pl == pl); int index = at ? at->pl_index : pl->num_entries; MP_TARRAY_INSERT_AT(pl, pl->entries, pl->num_entries, index, add); @@ -84,14 +84,14 @@ void playlist_entry_unref(struct playlist_entry *e) { e->reserved--; if (e->reserved < 0) { - assert(!e->pl); + mp_assert(!e->pl); talloc_free(e); } } void playlist_remove(struct playlist *pl, struct playlist_entry *entry) { - assert(pl && entry->pl == pl); + mp_assert(pl && entry->pl == pl); if (pl->current == entry) { pl->current = playlist_entry_get_rel(entry, 1); @@ -113,7 +113,7 @@ void playlist_clear(struct playlist *pl) { for (int n = pl->num_entries - 1; n >= 0; n--) playlist_remove(pl, pl->entries[n]); - assert(!pl->current); + mp_assert(!pl->current); pl->current_was_replaced = false; pl->playlist_completed = false; pl->playlist_started = false; @@ -137,8 +137,8 @@ void playlist_move(struct playlist *pl, struct playlist_entry *entry, if (entry == at) return; - assert(entry && entry->pl == pl); - assert(!at || at->pl == pl); + mp_assert(entry && entry->pl == pl); + mp_assert(!at || at->pl == pl); int index = at ? at->pl_index : pl->num_entries; MP_TARRAY_INSERT_AT(pl, pl->entries, pl->num_entries, index, entry); @@ -210,7 +210,7 @@ struct playlist_entry *playlist_get_last(struct playlist *pl) struct playlist_entry *playlist_get_next(struct playlist *pl, int direction) { - assert(direction == -1 || direction == +1); + mp_assert(direction == -1 || direction == +1); if (!pl->current && pl->playlist_completed && direction < 0) { return playlist_entry_from_index(pl, pl->num_entries - 1); } else if (!pl->current && !pl->playlist_started && direction > 0) { @@ -218,7 +218,7 @@ struct playlist_entry *playlist_get_next(struct playlist *pl, int direction) } else if (!pl->current) { return NULL; } - assert(pl->current->pl == pl); + mp_assert(pl->current->pl == pl); if (direction < 0) return playlist_entry_get_rel(pl->current, -1); return pl->current_was_replaced ? pl->current : @@ -229,7 +229,7 @@ struct playlist_entry *playlist_get_next(struct playlist *pl, int direction) struct playlist_entry *playlist_entry_get_rel(struct playlist_entry *e, int direction) { - assert(direction == -1 || direction == +1); + mp_assert(direction == -1 || direction == +1); if (!e->pl) return NULL; return playlist_entry_from_index(e->pl, e->pl_index + direction); @@ -326,7 +326,7 @@ void playlist_set_stream_flags(struct playlist *pl, int flags) int64_t playlist_transfer_entries_to(struct playlist *pl, int dst_index, struct playlist *source_pl) { - assert(pl != source_pl); + mp_assert(pl != source_pl); struct playlist_entry *first = playlist_get_first(source_pl); int count = source_pl->num_entries; @@ -365,8 +365,8 @@ int64_t playlist_transfer_entries(struct playlist *pl, struct playlist *source_p if (pl->current_was_replaced) add_at += 1; } - assert(add_at >= 0); - assert(add_at <= pl->num_entries); + mp_assert(add_at >= 0); + mp_assert(add_at <= pl->num_entries); return playlist_transfer_entries_to(pl, add_at, source_pl); } diff --git a/common/stats.c b/common/stats.c index 37d3e262a2..0fe2f655a8 100644 --- a/common/stats.c +++ b/common/stats.c @@ -72,14 +72,14 @@ static void stats_destroy(void *p) struct stats_base *stats = p; // All entries must have been destroyed before this. - assert(!stats->list.head); + mp_assert(!stats->list.head); mp_mutex_destroy(&stats->lock); } void stats_global_init(struct mpv_global *global) { - assert(!global->stats); + mp_assert(!global->stats); struct stats_base *stats = talloc_zero(global, struct stats_base); ta_set_destructor(stats, stats_destroy); mp_mutex_init(&stats->lock); @@ -110,7 +110,7 @@ static int cmp_entry(const void *p1, const void *p2) void stats_global_query(struct mpv_global *global, struct mpv_node *out) { struct stats_base *stats = global->stats; - assert(stats); + mp_assert(stats); mp_mutex_lock(&stats->lock); @@ -223,7 +223,7 @@ struct stats_ctx *stats_ctx_create(void *ta_parent, struct mpv_global *global, const char *prefix) { struct stats_base *base = global->stats; - assert(base); + mp_assert(base); struct stats_ctx *ctx = talloc_zero(ta_parent, struct stats_ctx); ctx->base = base; @@ -247,7 +247,7 @@ static struct stat_entry *find_entry(struct stats_ctx *ctx, const char *name) struct stat_entry *e = talloc_zero(ctx, struct stat_entry); snprintf(e->name, sizeof(e->name), "%s", name); - assert(strcmp(e->name, name) == 0); // make e->name larger and don't complain + mp_assert(strcmp(e->name, name) == 0); // make e->name larger and don't complain e->full_name = talloc_asprintf(e, "%s/%s", ctx->prefix, e->name); diff --git a/demux/cache.c b/demux/cache.c index 278bef0e77..046bff8bfe 100644 --- a/demux/cache.c +++ b/demux/cache.c @@ -205,7 +205,7 @@ static bool read_raw(struct demux_cache *cache, void *ptr, size_t len) // Returns a negative value on errors, i.e. writing the file failed. int64_t demux_cache_write(struct demux_cache *cache, struct demux_packet *dp) { - assert(dp->avpacket); + mp_assert(dp->avpacket); // AV_PKT_FLAG_TRUSTED usually means there are embedded pointers and such // in the packet data. The pointer will become invalid if the packet is @@ -215,10 +215,10 @@ int64_t demux_cache_write(struct demux_cache *cache, struct demux_packet *dp) return -1; } - assert(!dp->is_cached); - assert(dp->len <= INT32_MAX); - assert(dp->avpacket->flags >= 0 && dp->avpacket->flags <= INT32_MAX); - assert(dp->avpacket->side_data_elems >= 0 && + mp_assert(!dp->is_cached); + mp_assert(dp->len <= INT32_MAX); + mp_assert(dp->avpacket->flags >= 0 && dp->avpacket->flags <= INT32_MAX); + mp_assert(dp->avpacket->side_data_elems >= 0 && dp->avpacket->side_data_elems <= INT32_MAX); if (!do_seek(cache, cache->file_size)) @@ -262,8 +262,8 @@ int64_t demux_cache_write(struct demux_cache *cache, struct demux_packet *dp) for (int n = 0; n < dp->avpacket->side_data_elems; n++) { AVPacketSideData *sd = &dp->avpacket->side_data[n]; - assert(sd->size <= INT32_MAX); - assert(sd->type >= 0 && sd->type <= INT32_MAX); + mp_assert(sd->size <= INT32_MAX); + mp_assert(sd->type >= 0 && sd->type <= INT32_MAX); struct sd_header sd_hd = { .av_type = sd->type, diff --git a/demux/demux.c b/demux/demux.c index 5d8987c41c..a35d62bcaf 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -464,19 +464,19 @@ static void check_queue_consistency(struct demux_internal *in) { uint64_t total_bytes = 0; - assert(in->current_range && in->num_ranges > 0); - assert(in->current_range == in->ranges[in->num_ranges - 1]); + mp_assert(in->current_range && in->num_ranges > 0); + mp_assert(in->current_range == in->ranges[in->num_ranges - 1]); for (int n = 0; n < in->num_ranges; n++) { struct demux_cached_range *range = in->ranges[n]; int range_num_packets = 0; - assert(range->num_streams == in->num_streams); + mp_assert(range->num_streams == in->num_streams); for (int i = 0; i < range->num_streams; i++) { struct demux_queue *queue = range->streams[i]; - assert(queue->range == range); + mp_assert(queue->range == range); size_t fw_bytes = 0; bool is_forward = false; @@ -494,45 +494,45 @@ static void check_queue_consistency(struct demux_internal *in) queue_total_bytes += bytes; if (is_forward) { fw_bytes += bytes; - assert(range == in->current_range); - assert(queue->ds->queue == queue); + mp_assert(range == in->current_range); + mp_assert(queue->ds->queue == queue); } range_num_packets += 1; if (!dp->next) - assert(queue->tail == dp); + mp_assert(queue->tail == dp); if (next_index < queue->num_index && QUEUE_INDEX_ENTRY(queue, next_index).pkt == dp) next_index += 1; } if (!queue->head) - assert(!queue->tail); - assert(next_index == queue->num_index); + mp_assert(!queue->tail); + mp_assert(next_index == queue->num_index); uint64_t queue_total_bytes2 = 0; if (queue->head) queue_total_bytes2 = queue->tail_cum_pos - queue->head->cum_pos; - assert(queue_total_bytes == queue_total_bytes2); + mp_assert(queue_total_bytes == queue_total_bytes2); // If the queue is currently used... if (queue->ds->queue == queue) { // ...reader_head and others must be in the queue. - assert(is_forward == !!queue->ds->reader_head); - assert(kf_found == !!queue->keyframe_latest); + mp_assert(is_forward == !!queue->ds->reader_head); + mp_assert(kf_found == !!queue->keyframe_latest); uint64_t fw_bytes2 = get_forward_buffered_bytes(queue->ds); - assert(fw_bytes == fw_bytes2); + mp_assert(fw_bytes == fw_bytes2); } - assert(kf1_found == !!queue->keyframe_first); + mp_assert(kf1_found == !!queue->keyframe_first); if (range != in->current_range) { - assert(fw_bytes == 0); + mp_assert(fw_bytes == 0); } if (queue->keyframe_latest) - assert(queue->keyframe_latest->keyframe); + mp_assert(queue->keyframe_latest->keyframe); total_bytes += queue->index_size * sizeof(struct index_entry); } @@ -540,10 +540,10 @@ static void check_queue_consistency(struct demux_internal *in) // Invariant needed by pruning; violation has worse effects than just // e.g. broken seeking due to incorrect seek ranges. if (range->seek_start != MP_NOPTS_VALUE) - assert(range_num_packets > 0); + mp_assert(range_num_packets > 0); } - assert(in->total_bytes == total_bytes); + mp_assert(in->total_bytes == total_bytes); } #endif @@ -684,7 +684,7 @@ static void remove_head_packet(struct demux_queue *queue) { struct demux_packet *dp = queue->head; - assert(queue->ds->reader_head != dp); + mp_assert(queue->ds->reader_head != dp); if (queue->keyframe_first == dp) queue->keyframe_first = NULL; if (queue->keyframe_latest == dp) @@ -767,8 +767,8 @@ static void free_empty_cached_ranges(struct demux_internal *in) // (Not set during early init or late destruction.) if (in->current_range) { - assert(in->current_range && in->num_ranges > 0); - assert(in->current_range == in->ranges[in->num_ranges - 1]); + mp_assert(in->current_range && in->num_ranges > 0); + mp_assert(in->current_range == in->ranges[in->num_ranges - 1]); end -= 1; } @@ -936,7 +936,7 @@ static void add_missing_streams(struct demux_internal *in, }; clear_queue(queue); MP_TARRAY_APPEND(range, range->streams, range->num_streams, queue); - assert(range->streams[ds->index] == queue); + mp_assert(range->streams[ds->index] == queue); } } @@ -966,7 +966,7 @@ struct sh_stream *demux_alloc_sh_stream(enum stream_type type) static void demux_add_sh_stream_locked(struct demux_internal *in, struct sh_stream *sh) { - assert(!sh->ds); // must not be added yet + mp_assert(!sh->ds); // must not be added yet sh->index = in->num_streams; @@ -989,7 +989,7 @@ static void demux_add_sh_stream_locked(struct demux_internal *in, sh->ff_index = sh->index; MP_TARRAY_APPEND(in, in->streams, in->num_streams, sh); - assert(in->streams[sh->index] == sh); + mp_assert(in->streams[sh->index] == sh); if (in->current_range) { for (int n = 0; n < in->num_ranges; n++) @@ -1033,7 +1033,7 @@ static void demux_add_sh_stream_locked(struct demux_internal *in, void demux_add_sh_stream(struct demuxer *demuxer, struct sh_stream *sh) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_thread); + mp_assert(demuxer == in->d_thread); mp_mutex_lock(&in->lock); demux_add_sh_stream_locked(in, sh); mp_mutex_unlock(&in->lock); @@ -1047,7 +1047,7 @@ struct sh_stream *demux_get_stream(struct demuxer *demuxer, int index) { struct demux_internal *in = demuxer->in; mp_mutex_lock(&in->lock); - assert(index >= 0 && index < in->num_streams); + mp_assert(index >= 0 && index < in->num_streams); struct sh_stream *r = in->streams[index]; mp_mutex_unlock(&in->lock); return r; @@ -1081,7 +1081,7 @@ static void demux_shutdown(struct demux_internal *in) in->d_thread->priv = NULL; demux_flush(demuxer); - assert(in->total_bytes == 0); + mp_assert(in->total_bytes == 0); in->current_range = NULL; free_empty_cached_ranges(in); @@ -1108,7 +1108,7 @@ void demux_free(struct demuxer *demuxer) if (!demuxer) return; struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_user); + mp_assert(demuxer == in->d_user); demux_stop_thread(demuxer); demux_shutdown(in); @@ -1125,7 +1125,7 @@ void demux_free(struct demuxer *demuxer) struct demux_free_async_state *demux_free_async(struct demuxer *demuxer) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_user); + mp_assert(demuxer == in->d_user); if (!in->threading) return NULL; @@ -1185,7 +1185,7 @@ void demux_cancel_and_free(struct demuxer *demuxer) void demux_start_thread(struct demuxer *demuxer) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_user); + mp_assert(demuxer == in->d_user); if (!in->threading) { in->threading = true; @@ -1197,7 +1197,7 @@ void demux_start_thread(struct demuxer *demuxer) void demux_stop_thread(struct demuxer *demuxer) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_user); + mp_assert(demuxer == in->d_user); if (in->threading) { mp_mutex_lock(&in->lock); @@ -1223,7 +1223,7 @@ void demux_set_wakeup_cb(struct demuxer *demuxer, void (*cb)(void *ctx), void *c void demux_start_prefetch(struct demuxer *demuxer) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_user); + mp_assert(demuxer == in->d_user); mp_mutex_lock(&in->lock); in->reading = true; @@ -1393,7 +1393,7 @@ static void find_backward_restart_pos(struct demux_stream *ds) } else if (!first) { return; // no packets yet } else { - assert(last); + mp_assert(last); if ((ds->global_correct_dts && last->dts < ds->back_restart_dts) || (ds->global_correct_pos && last->pos < ds->back_restart_pos)) @@ -1444,7 +1444,7 @@ static void find_backward_restart_pos(struct demux_stream *ds) // Number of keyframes to return to the user in total. int total = batch + ds->back_preroll; - assert(total >= 1); + mp_assert(total >= 1); bool is_bof = ds->queue->is_bof && (first == ds->queue->head || ds->back_seek_pos < ds->queue->seek_start); @@ -1507,7 +1507,7 @@ static void find_backward_restart_pos(struct demux_stream *ds) kf_pos++; } } - assert(restart_pkt); + mp_assert(restart_pkt); ds->back_restart_dts = restart_pkt->dts; ds->back_restart_pos = restart_pkt->pos; @@ -1566,7 +1566,7 @@ static void back_demux_see_packets(struct demux_stream *ds) if (!ds->selected || !in->back_demuxing || !ds->eager) return; - assert(!(ds->back_resuming && ds->back_restarting)); + mp_assert(!(ds->back_resuming && ds->back_restarting)); if (!ds->global_correct_dts && !ds->global_correct_pos) { MP_ERR(in, "Can't demux backward due to demuxer problems.\n"); @@ -1597,7 +1597,7 @@ static void add_index_entry(struct demux_queue *queue, struct demux_packet *dp, { struct demux_internal *in = queue->ds->in; - assert(dp->keyframe && pts != MP_NOPTS_VALUE); + mp_assert(dp->keyframe && pts != MP_NOPTS_VALUE); if (queue->num_index > 0) { struct index_entry *last = &QUEUE_INDEX_ENTRY(queue, queue->num_index - 1); @@ -1608,7 +1608,7 @@ static void add_index_entry(struct demux_queue *queue, struct demux_packet *dp, if (queue->num_index == queue->index_size) { // Needs to honor power-of-2 requirement. size_t new_size = MPMAX(128, queue->index_size * 2); - assert(!(new_size & (new_size - 1))); + mp_assert(!(new_size & (new_size - 1))); MP_DBG(in, "stream %d: resize index to %zu\n", queue->ds->index, new_size); // Note: we could tolerate allocation failure, and just discard the @@ -1622,7 +1622,7 @@ static void add_index_entry(struct demux_queue *queue, struct demux_packet *dp, queue->index_size = new_size; } - assert(queue->num_index < queue->index_size); + mp_assert(queue->num_index < queue->index_size); queue->num_index += 1; @@ -1640,8 +1640,8 @@ static void attempt_range_joining(struct demux_internal *in) struct demux_cached_range *next = NULL; double next_dist = INFINITY; - assert(current && in->num_ranges > 0); - assert(current == in->ranges[in->num_ranges - 1]); + mp_assert(current && in->num_ranges > 0); + mp_assert(current == in->ranges[in->num_ranges - 1]); for (int n = 0; n < in->num_ranges - 1; n++) { struct demux_cached_range *range = in->ranges[n]; @@ -1741,7 +1741,7 @@ static void attempt_range_joining(struct demux_internal *in) struct demux_queue *q2 = next->streams[n]; struct demux_stream *ds = in->streams[n]->ds; - assert(ds->queue == q1); + mp_assert(ds->queue == q1); // First new packet that is appended to the current range. struct demux_packet *join_point = q2->head; @@ -1942,8 +1942,8 @@ static struct mp_recorder *recorder_create(struct demux_internal *in, static void write_dump_packet(struct demux_internal *in, struct demux_packet *dp) { - assert(in->dumper); - assert(in->dumper_status == CONTROL_TRUE); + mp_assert(in->dumper); + mp_assert(in->dumper_status == CONTROL_TRUE); struct mp_recorder_sink *sink = mp_recorder_get_sink(in->dumper, in->streams[dp->stream]); @@ -1989,14 +1989,14 @@ static void record_packet(struct demux_internal *in, struct demux_packet *dp) static void add_packet_locked(struct sh_stream *stream, demux_packet_t *dp) { struct demux_stream *ds = stream ? stream->ds : NULL; - assert(ds && ds->in); + mp_assert(ds && ds->in); if (!dp->len || demux_cancel_test(ds->in->d_thread)) { talloc_free(dp); return; } - assert(dp->stream == stream->index); - assert(!dp->next); + mp_assert(dp->stream == stream->index); + mp_assert(!dp->next); struct demux_internal *in = ds->in; @@ -2265,7 +2265,7 @@ static bool read_packet(struct demux_internal *in) update_cache(in); if (pkt) { - assert(pkt->stream >= 0 && pkt->stream < in->num_streams); + mp_assert(pkt->stream >= 0 && pkt->stream < in->num_streams); add_packet_locked(in->streams[pkt->stream], pkt); } @@ -2289,7 +2289,7 @@ static bool read_packet(struct demux_internal *in) static void prune_old_packets(struct demux_internal *in) { - assert(in->current_range == in->ranges[in->num_ranges - 1]); + mp_assert(in->current_range == in->ranges[in->num_ranges - 1]); // It's not clear what the ideal way to prune old packets is. For now, we // prune the oldest packet runs, as long as the total cache amount is too @@ -2363,7 +2363,7 @@ static void prune_old_packets(struct demux_internal *in) // Need to update the seekable time range. if (kf_was_pruned) { - assert(!queue->keyframe_first); // it was just deleted, supposedly + mp_assert(!queue->keyframe_first); // it was just deleted, supposedly queue->keyframe_first = queue->head; // (May happen if reader_head stopped pruning the range, and there's @@ -2599,7 +2599,7 @@ static struct demux_packet *read_packet_from_cache(struct demux_internal *in, return NULL; if (pkt->is_cached) { - assert(in->cache); + mp_assert(in->cache); struct demux_packet *meta = pkt; pkt = demux_cache_read(in->cache, pkt->cached_data.pos); if (pkt) { @@ -2650,7 +2650,7 @@ static int dequeue_packet(struct demux_stream *ds, double min_pts, ds->force_read_until = min_pts; if (ds->back_resuming || ds->back_restarting) { - assert(in->back_demuxing); + mp_assert(in->back_demuxing); return 0; } @@ -2694,14 +2694,14 @@ static int dequeue_packet(struct demux_stream *ds, double min_pts, } struct demux_packet *pkt = advance_reader_head(ds); - assert(pkt); + mp_assert(pkt); pkt = read_packet_from_cache(in, pkt); if (!pkt) return 0; if (in->back_demuxing) { if (pkt->keyframe) { - assert(ds->back_range_count > 0); + mp_assert(ds->back_range_count > 0); ds->back_range_count -= 1; if (ds->back_range_preroll >= 0) ds->back_range_preroll -= 1; @@ -2802,7 +2802,7 @@ struct demux_packet *demux_read_any_packet(struct demuxer *demuxer) { struct demux_internal *in = demuxer->in; mp_mutex_lock(&in->lock); - assert(!in->threading); // doesn't work with threading + mp_assert(!in->threading); // doesn't work with threading struct demux_packet *out_pkt = NULL; bool read_more = true; while (read_more && !in->blocked) { @@ -3038,9 +3038,9 @@ void demux_stream_tags_changed(struct demuxer *demuxer, struct sh_stream *sh, struct mp_tags *tags, double pts) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_thread); + mp_assert(demuxer == in->d_thread); struct demux_stream *ds = sh ? sh->ds : NULL; - assert(!sh || ds); // stream must have been added + mp_assert(!sh || ds); // stream must have been added mp_mutex_lock(&in->lock); @@ -3058,7 +3058,7 @@ void demux_stream_tags_changed(struct demuxer *demuxer, struct sh_stream *sh, // (It will be propagated to the user as timed metadata.) void demux_metadata_changed(demuxer_t *demuxer) { - assert(demuxer == demuxer->in->d_thread); // call from demuxer impl. only + mp_assert(demuxer == demuxer->in->d_thread); // call from demuxer impl. only struct demux_internal *in = demuxer->in; mp_mutex_lock(&in->lock); @@ -3069,7 +3069,7 @@ void demux_metadata_changed(demuxer_t *demuxer) // Called locked, with user demuxer. static void update_final_metadata(demuxer_t *demuxer, struct timed_metadata *tm) { - assert(demuxer == demuxer->in->d_user); + mp_assert(demuxer == demuxer->in->d_user); struct demux_internal *in = demuxer->in; struct mp_tags *dyn_tags = NULL; @@ -3138,7 +3138,7 @@ static struct timed_metadata *lookup_timed_metadata(struct demux_internal *in, // The pts parameter is the current playback position. void demux_update(demuxer_t *demuxer, double pts) { - assert(demuxer == demuxer->in->d_user); + mp_assert(demuxer == demuxer->in->d_user); struct demux_internal *in = demuxer->in; mp_mutex_lock(&in->lock); @@ -3208,7 +3208,7 @@ static void demux_init_cuesheet(struct demuxer *demuxer) void demux_close_stream(struct demuxer *demuxer) { struct demux_internal *in = demuxer->in; - assert(!in->threading && demuxer == in->d_thread); + mp_assert(!in->threading && demuxer == in->d_thread); if (!demuxer->stream || !in->owns_stream) return; @@ -3456,7 +3456,7 @@ static struct stream *create_webshit_concat_stream(struct mpv_global *global, bstr init, struct stream *real) { struct stream *mem = stream_memory_open(global, init.start, init.len); - assert(mem); + mp_assert(mem); struct stream *streams[2] = {mem, real}; struct stream *concat = stream_concat_open(global, c, streams, 2); @@ -3499,7 +3499,7 @@ struct demuxer *demux_open_url(const char *url, struct demuxer *d = demux_open(s, priv_cancel, params, global); if (d) { talloc_steal(d->in, priv_cancel); - assert(d->cancel); + mp_assert(d->cancel); } else { params->demuxer_failed = true; if (!params->external_stream) @@ -3513,7 +3513,7 @@ struct demuxer *demux_open_url(const char *url, void demux_flush(demuxer_t *demuxer) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_user); + mp_assert(demuxer == in->d_user); mp_mutex_lock(&in->lock); clear_reader_state(in, true); @@ -3535,7 +3535,7 @@ static void switch_current_range(struct demux_internal *in, struct demux_cached_range *range) { struct demux_cached_range *old = in->current_range; - assert(old != range); + mp_assert(old != range); set_current_range(in, range); @@ -3789,7 +3789,7 @@ static void switch_to_fresh_cache_range(struct demux_internal *in) int demux_seek(demuxer_t *demuxer, double seek_pts, int flags) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_user); + mp_assert(demuxer == in->d_user); mp_mutex_lock(&in->lock); @@ -4120,7 +4120,7 @@ int demuxer_add_chapter(demuxer_t *demuxer, char *name, void demux_block_reading(struct demuxer *demuxer, bool block) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_user); + mp_assert(demuxer == in->d_user); mp_mutex_lock(&in->lock); in->blocked = block; @@ -4268,7 +4268,7 @@ static void dump_cache(struct demux_internal *in, double start, double end) if (!dp) continue; - assert(dp->stream == ds->index); + mp_assert(dp->stream == ds->index); double pdts = MP_PTS_OR_DEF(dp->dts, dp->pts); @@ -4338,7 +4338,7 @@ bool demux_cache_dump_set(struct demuxer *demuxer, double start, double end, char *file) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_user); + mp_assert(demuxer == in->d_user); bool res = false; @@ -4387,7 +4387,7 @@ double demux_probe_cache_dump_target(struct demuxer *demuxer, double pts, bool for_end) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_user); + mp_assert(demuxer == in->d_user); double res = MP_NOPTS_VALUE; if (pts == MP_NOPTS_VALUE) @@ -4461,7 +4461,7 @@ double demux_probe_cache_dump_target(struct demuxer *demuxer, double pts, void demux_report_unbuffered_read_bytes(struct demuxer *demuxer, int64_t new) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_thread); + mp_assert(demuxer == in->d_thread); in->slave_unbuffered_read_bytes += new; } @@ -4474,7 +4474,7 @@ int64_t demux_get_bytes_read_hack(struct demuxer *demuxer) // Required because demuxer==in->d_user, and we access in->d_thread. // Locking won't solve this, because we also need to access struct stream. - assert(!in->threading); + mp_assert(!in->threading); update_bytes_read(in); @@ -4486,7 +4486,7 @@ int64_t demux_get_bytes_read_hack(struct demuxer *demuxer) void demux_get_bitrate_stats(struct demuxer *demuxer, double *rates) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_user); + mp_assert(demuxer == in->d_user); mp_mutex_lock(&in->lock); @@ -4504,7 +4504,7 @@ void demux_get_bitrate_stats(struct demuxer *demuxer, double *rates) void demux_get_reader_state(struct demuxer *demuxer, struct demux_reader_state *r) { struct demux_internal *in = demuxer->in; - assert(demuxer == in->d_user); + mp_assert(demuxer == in->d_user); mp_mutex_lock(&in->lock); diff --git a/demux/demux_disc.c b/demux/demux_disc.c index 7fb7e16f87..7881a2c504 100644 --- a/demux/demux_disc.c +++ b/demux/demux_disc.c @@ -131,13 +131,13 @@ static void add_streams(demuxer_t *demuxer) if (src->demuxer_id >= 0x20 && src->demuxer_id <= 0x3F) sub = p->dvd_subs[src->demuxer_id - 0x20]; if (sub) { - assert(p->num_streams == n); // directly mapped + mp_assert(p->num_streams == n); // directly mapped MP_TARRAY_APPEND(p, p->streams, p->num_streams, sub); continue; } } struct sh_stream *sh = demux_alloc_sh_stream(src->type); - assert(p->num_streams == n); // directly mapped + mp_assert(p->num_streams == n); // directly mapped MP_TARRAY_APPEND(p, p->streams, p->num_streams, sh); // Copy all stream fields that might be relevant *sh->codec = *src->codec; diff --git a/demux/demux_edl.c b/demux/demux_edl.c index 96f76c9066..813d26db61 100644 --- a/demux/demux_edl.c +++ b/demux/demux_edl.c @@ -319,7 +319,7 @@ static struct tl_root *parse_edl(bstr str, struct mp_log *log) BSTR_P(ctx.param_names[n])); } } - assert(root->num_pars); + mp_assert(root->num_pars); for (int n = 0; n < root->num_pars; n++) { if (root->pars[n]->num_parts < 1) { mp_err(log, "EDL specifies no segments.'\n"); @@ -557,7 +557,7 @@ static struct timeline_par *build_timeline(struct timeline *root, if (root->meta) mp_tags_merge(root->meta->metadata, edl_root->tags); - assert(tl->num_parts == parts->num_parts); + mp_assert(tl->num_parts == parts->num_parts); return tl; error: diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 78cb469842..038c3e1960 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -649,7 +649,7 @@ static void export_replaygain(demuxer_t *demuxer, struct sh_stream *sh, // This must be run only before the stream was added, otherwise there // will be race conditions with accesses from the user thread. - assert(!sh->ds); + mp_assert(!sh->ds); sh->codec->replaygain_data = rgain; } @@ -814,7 +814,7 @@ static void handle_new_stream(demuxer_t *demuxer, int i) .last_key_pts = MP_NOPTS_VALUE, .highest_pts = MP_NOPTS_VALUE, }; - assert(priv->num_streams == i); // directly mapped + mp_assert(priv->num_streams == i); // directly mapped MP_TARRAY_APPEND(priv, priv->streams, priv->num_streams, info); if (sh) { @@ -1221,7 +1221,7 @@ static bool demux_lavf_read_packet(struct demuxer *demux, add_new_streams(demux); update_metadata(demux); - assert(pkt->stream_index >= 0 && pkt->stream_index < priv->num_streams); + mp_assert(pkt->stream_index >= 0 && pkt->stream_index < priv->num_streams); struct stream_info *info = priv->streams[pkt->stream_index]; struct sh_stream *stream = info->sh; AVStream *st = priv->avfc->streams[pkt->stream_index]; diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index 9e3787b7f9..bc7d91d133 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -2844,7 +2844,7 @@ static void mkv_parse_and_add_packet(demuxer_t *demuxer, mkv_track_t *track, if (track->parse && !track->av_parser) { int id = mp_codec_to_av_codec_id(track->stream->codec->codec); const AVCodec *codec = avcodec_find_decoder(id); - assert(!track->av_parser_codec); + mp_assert(!track->av_parser_codec); if (codec) track->av_parser_codec = avcodec_alloc_context3(codec); if (track->av_parser_codec) @@ -3277,7 +3277,7 @@ static int read_next_block(demuxer_t *demuxer, struct block_info *block) if (res < 1) return res; - assert(mkv_d->num_blocks); + mp_assert(mkv_d->num_blocks); } *block = mkv_d->blocks[0]; @@ -3312,7 +3312,7 @@ static bool demux_mkv_read_packet(struct demuxer *demuxer, static mkv_index_t *get_highest_index_entry(struct demuxer *demuxer) { struct mkv_demuxer *mkv_d = demuxer->priv; - assert(!mkv_d->index_complete); // would require separate code + mp_assert(!mkv_d->index_complete); // would require separate code mkv_index_t *index = NULL; for (int n = 0; n < mkv_d->num_tracks; n++) { diff --git a/demux/demux_timeline.c b/demux/demux_timeline.c index 5572fb53bf..a0490dc886 100644 --- a/demux/demux_timeline.c +++ b/demux/demux_timeline.c @@ -595,7 +595,7 @@ static bool add_tl(struct demuxer *demuxer, struct timeline_par *tl) .sh = new, }; MP_TARRAY_APPEND(p, p->streams, p->num_streams, vs); - assert(demux_get_stream(demuxer, p->num_streams - 1) == new); + mp_assert(demux_get_stream(demuxer, p->num_streams - 1) == new); MP_TARRAY_APPEND(src, src->streams, src->num_streams, vs); } @@ -610,7 +610,7 @@ static bool add_tl(struct demuxer *demuxer, struct timeline_par *tl) } if (!part->source) - assert(tl->dash || tl->delay_open); + mp_assert(tl->dash || tl->delay_open); struct segment *seg = talloc_ptrtype(src, seg); *seg = (struct segment){ diff --git a/demux/ebml.c b/demux/ebml.c index ea980f0f0b..83a8b5fdd1 100644 --- a/demux/ebml.c +++ b/demux/ebml.c @@ -282,7 +282,7 @@ static uint64_t ebml_parse_length(uint8_t *data, size_t data_len, int *length) static uint64_t ebml_parse_uint(uint8_t *data, int length) { - assert(length >= 0 && length <= 8); + mp_assert(length >= 0 && length <= 8); uint64_t r = 0; while (length--) r = (r << 8) + *data++; @@ -291,7 +291,7 @@ static uint64_t ebml_parse_uint(uint8_t *data, int length) static int64_t ebml_parse_sint(uint8_t *data, int length) { - assert(length >= 0 && length <= 8); + mp_assert(length >= 0 && length <= 8); if (!length) return 0; uint64_t r = 0; @@ -304,7 +304,7 @@ static int64_t ebml_parse_sint(uint8_t *data, int length) static double ebml_parse_float(uint8_t *data, int length) { - assert(length == 0 || length == 4 || length == 8); + mp_assert(length == 0 || length == 4 || length == 8); uint64_t i = ebml_parse_uint(data, length); if (length == 4) return av_int2float(i); @@ -318,8 +318,8 @@ static void ebml_parse_element(struct ebml_parse_ctx *ctx, void *target, uint8_t *data, int size, const struct ebml_elem_desc *type, int level) { - assert(type->type == EBML_TYPE_SUBELEMENTS); - assert(level < 8); + mp_assert(type->type == EBML_TYPE_SUBELEMENTS); + mp_assert(level < 8); MP_TRACE(ctx, "%.*sParsing element %s\n", level, " ", type->name); char *s = target; diff --git a/demux/packet.c b/demux/packet.c index ae60847337..76ca36b343 100644 --- a/demux/packet.c +++ b/demux/packet.c @@ -39,7 +39,7 @@ void demux_packet_unref_contents(struct demux_packet *dp) { if (dp->avpacket) { - assert(!dp->is_cached); + mp_assert(!dp->is_cached); av_packet_free(&dp->avpacket); dp->buffer = NULL; dp->len = 0; @@ -148,7 +148,7 @@ struct demux_packet *new_demux_packet(struct demux_packet_pool *pool, size_t len void demux_packet_shorten(struct demux_packet *dp, size_t len) { - assert(len <= dp->len); + mp_assert(len <= dp->len); if (dp->len) { dp->len = len; memset(dp->buffer + dp->len, 0, AV_INPUT_BUFFER_PADDING_SIZE); @@ -207,7 +207,7 @@ size_t demux_packet_estimate_total_size(struct demux_packet *dp) size += 8 * sizeof(void *); // ta overhead size += 10 * sizeof(void *); // additional estimate for ta_ext_header if (dp->avpacket) { - assert(!dp->is_cached); + mp_assert(!dp->is_cached); size += ROUND_ALLOC(dp->len); size += ROUND_ALLOC(sizeof(AVPacket)); size += 8 * sizeof(void *); // ta overhead diff --git a/demux/packet_pool.c b/demux/packet_pool.c index f18b48f699..5bfd80bc66 100644 --- a/demux/packet_pool.c +++ b/demux/packet_pool.c @@ -53,7 +53,7 @@ void demux_packet_pool_init(struct mpv_global *global) mp_mutex_init(&pool->lock); pool->packets = NULL; - assert(!global->packet_pool); + mp_assert(!global->packet_pool); global->packet_pool = pool; } @@ -87,8 +87,8 @@ void demux_packet_pool_prepend(struct demux_packet_pool *pool, { if (!head) return; - assert(tail); - assert(head != tail ? !!head->next : !head->next); + mp_assert(tail); + mp_assert(head != tail ? !!head->next : !head->next); mp_mutex_lock(&pool->lock); tail->next = pool->packets; diff --git a/filters/f_async_queue.c b/filters/f_async_queue.c index 95db385d7f..498ffee27e 100644 --- a/filters/f_async_queue.c +++ b/filters/f_async_queue.c @@ -54,7 +54,7 @@ static void unref_queue(struct async_queue *q) if (!q) return; int count = atomic_fetch_add(&q->refcount, -1) - 1; - assert(count >= 0); + mp_assert(count >= 0); if (count == 0) { reset_queue(q); mp_mutex_destroy(&q->lock); @@ -112,7 +112,7 @@ static bool is_full(struct async_queue *q) static void account_frame(struct async_queue *q, struct mp_frame frame, int dir) { - assert(dir == 1 || dir == -1); + mp_assert(dir == 1 || dir == -1); q->samples_size += dir * frame_get_samples(q, frame); q->byte_size += dir * mp_frame_approx_size(frame); @@ -137,7 +137,7 @@ void mp_async_queue_set_config(struct mp_async_queue *queue, cfg.max_bytes = MPCLAMP(cfg.max_bytes, 1, (size_t)-1 / 2); - assert(cfg.sample_unit == AQUEUE_UNIT_FRAME || + mp_assert(cfg.sample_unit == AQUEUE_UNIT_FRAME || cfg.sample_unit == AQUEUE_UNIT_SAMPLES); cfg.max_samples = MPMAX(cfg.max_samples, 1); @@ -246,7 +246,7 @@ static void process_in(struct mp_filter *f) { struct priv *p = f->priv; struct async_queue *q = p->q; - assert(q->conn[0] == f); + mp_assert(q->conn[0] == f); mp_mutex_lock(&q->lock); if (!q->reading) { @@ -281,7 +281,7 @@ static void process_out(struct mp_filter *f) { struct priv *p = f->priv; struct async_queue *q = p->q; - assert(q->conn[1] == f); + mp_assert(q->conn[1] == f); if (!mp_pin_in_needs_data(f->ppins[0])) return; @@ -295,7 +295,7 @@ static void process_out(struct mp_filter *f) struct mp_frame frame = q->frames[q->num_frames - 1]; q->num_frames -= 1; account_frame(q, frame, -1); - assert(q->samples_size >= 0); + mp_assert(q->samples_size >= 0); mp_pin_in_write(f->ppins[0], frame); // Notify writer that we need new frames. if (q->conn[0]) @@ -336,7 +336,7 @@ static const struct mp_filter_info info_out = { void mp_async_queue_set_notifier(struct mp_filter *f, struct mp_filter *notify) { - assert(mp_filter_get_info(f) == &info_in); + mp_assert(mp_filter_get_info(f) == &info_in); struct priv *p = f->priv; if (p->notify != notify) { p->notify = notify; @@ -350,7 +350,7 @@ struct mp_filter *mp_async_queue_create_filter(struct mp_filter *parent, struct mp_async_queue *queue) { bool is_in = dir == MP_PIN_IN; - assert(queue); + mp_assert(queue); struct mp_filter *f = mp_filter_create(parent, is_in ? &info_in : &info_out); if (!f) @@ -367,7 +367,7 @@ struct mp_filter *mp_async_queue_create_filter(struct mp_filter *parent, mp_mutex_lock(&q->lock); int slot = is_in ? 0 : 1; - assert(!q->conn[slot]); // fails if already connected on this end + mp_assert(!q->conn[slot]); // fails if already connected on this end q->conn[slot] = f; mp_mutex_unlock(&q->lock); diff --git a/filters/f_auto_filters.c b/filters/f_auto_filters.c index 32a20b103f..5b472f8952 100644 --- a/filters/f_auto_filters.c +++ b/filters/f_auto_filters.c @@ -65,7 +65,7 @@ static void deint_process(struct mp_filter *f) if (!mp_subfilter_drain_destroy(&p->sub)) return; - assert(!p->sub.filter); + mp_assert(!p->sub.filter); p->prev_imgfmt = img->imgfmt; p->deinterlace_active = should_deinterlace; @@ -246,7 +246,7 @@ static void rotate_process(struct mp_filter *f) if (!mp_subfilter_drain_destroy(&p->sub)) return; - assert(!p->sub.filter); + mp_assert(!p->sub.filter); int rotate = p->prev_rotate = img->params.rotate; p->target_rotate = rotate; diff --git a/filters/f_decoder_wrapper.c b/filters/f_decoder_wrapper.c index 055328fb9c..dc9433bb0e 100644 --- a/filters/f_decoder_wrapper.c +++ b/filters/f_decoder_wrapper.c @@ -279,14 +279,14 @@ static void thread_lock(struct priv *p) if (p->dec_dispatch) mp_dispatch_lock(p->dec_dispatch); - assert(!p->dec_thread_lock); + mp_assert(!p->dec_thread_lock); p->dec_thread_lock = true; } // Undo thread_lock(). static void thread_unlock(struct priv *p) { - assert(p->dec_thread_lock); + mp_assert(p->dec_thread_lock); p->dec_thread_lock = false; if (p->dec_dispatch) @@ -321,7 +321,7 @@ static void reset_decoder(struct priv *p) static void decf_reset(struct mp_filter *f) { struct priv *p = f->priv; - assert(p->decf == f); + mp_assert(p->decf == f); p->pts = MP_NOPTS_VALUE; p->last_format = p->fixed_format = (struct mp_image_params){0}; @@ -366,7 +366,7 @@ int mp_decoder_wrapper_control(struct mp_decoder_wrapper *d, static void decf_destroy(struct mp_filter *f) { struct priv *p = f->priv; - assert(p->decf == f); + mp_assert(p->decf == f); if (p->decoder) { MP_DBG(f, "Uninit decoder.\n"); @@ -902,12 +902,12 @@ static void feed_packet(struct priv *p) // Flush current data if the packet is a new segment. if (is_new_segment(p, p->packet)) { - assert(!p->new_segment); + mp_assert(!p->new_segment); p->new_segment = p->packet.data; p->packet = MP_EOF_FRAME; } - assert(p->packet.type == MP_FRAME_PACKET || p->packet.type == MP_FRAME_EOF); + mp_assert(p->packet.type == MP_FRAME_PACKET || p->packet.type == MP_FRAME_EOF); struct demux_packet *packet = p->packet.type == MP_FRAME_PACKET ? p->packet.data : NULL; @@ -1107,7 +1107,7 @@ static void update_queue_config(struct priv *p) static void decf_process(struct mp_filter *f) { struct priv *p = f->priv; - assert(p->decf == f); + mp_assert(p->decf == f); if (m_config_cache_update(p->opt_cache)) update_queue_config(p); @@ -1139,7 +1139,7 @@ static MP_THREAD_VOID dec_thread(void *ptr) static void public_f_reset(struct mp_filter *f) { struct priv *p = f->priv; - assert(p->public.f == f); + mp_assert(p->public.f == f); if (p->queue) { mp_async_queue_reset(p->queue); @@ -1154,10 +1154,10 @@ static void public_f_reset(struct mp_filter *f) static void public_f_destroy(struct mp_filter *f) { struct priv *p = f->priv; - assert(p->public.f == f); + mp_assert(p->public.f == f); if (p->dec_thread_valid) { - assert(p->dec_dispatch); + mp_assert(p->dec_dispatch); thread_lock(p); p->request_terminate_dec_thread = 1; mp_dispatch_interrupt(p->dec_dispatch); diff --git a/filters/f_hwtransfer.c b/filters/f_hwtransfer.c index 7d86002f9c..cf8c08ebc4 100644 --- a/filters/f_hwtransfer.c +++ b/filters/f_hwtransfer.c @@ -169,7 +169,7 @@ static bool select_format(struct priv *p, int input_fmt, MP_TARRAY_REMOVE_AT(upload_fmts, num_upload_fmts, i); break; } - assert(hw_input_fmt == IMGFMT_NONE); + mp_assert(hw_input_fmt == IMGFMT_NONE); } if (p->ctx->try_upload) diff --git a/filters/f_lavfi.c b/filters/f_lavfi.c index 9e7a670990..d983b281ad 100644 --- a/filters/f_lavfi.c +++ b/filters/f_lavfi.c @@ -256,7 +256,7 @@ static void add_pads_direct(struct lavfi *c, int dir, AVFilterContext *f, // Parse the user-provided filter graph, and populate the unlinked filter pads. static void precreate_graph(struct lavfi *c, bool first_init) { - assert(!c->graph); + mp_assert(!c->graph); c->failed = false; @@ -358,7 +358,7 @@ static bool is_format_ok(struct mp_frame a, struct mp_frame b) static void read_pad_input(struct lavfi *c, struct lavfi_pad *pad) { - assert(pad->dir == MP_PIN_IN); + mp_assert(pad->dir == MP_PIN_IN); if (pad->pending.type || c->draining_recover) return; @@ -431,7 +431,7 @@ static bool init_pads(struct lavfi *c) return false; if (mp_frame_is_data(pad->pending)) { - assert(pad->pending.type == pad->type); + mp_assert(pad->pending.type == pad->type); pad->in_fmt = mp_frame_ref(pad->pending); if (!pad->in_fmt.type) @@ -544,7 +544,7 @@ static void dump_graph(struct lavfi *c) // initialized, or can't be initialized yet, do nothing. static void init_graph(struct lavfi *c) { - assert(!c->initialized); + mp_assert(!c->initialized); if (!c->graph) precreate_graph(c, false); @@ -600,7 +600,7 @@ static bool feed_input_pads(struct lavfi *c) bool progress = false; bool was_draining = c->draining_recover; - assert(c->initialized); + mp_assert(c->initialized); for (int n = 0; n < c->num_in_pads; n++) { struct lavfi_pad *pad = c->in_pads[n]; @@ -692,7 +692,7 @@ static bool read_output_pads(struct lavfi *c) { bool progress = false; - assert(c->initialized); + mp_assert(c->initialized); for (int n = 0; n < c->num_out_pads; n++) { struct lavfi_pad *pad = c->out_pads[n]; @@ -700,7 +700,7 @@ static bool read_output_pads(struct lavfi *c) if (!mp_pin_in_needs_data(pad->pin)) continue; - assert(pad->buffer); + mp_assert(pad->buffer); int r = AVERROR_EOF; if (!pad->buffer_is_eof) diff --git a/filters/f_output_chain.c b/filters/f_output_chain.c index cbccb3a8d9..0bdea90f99 100644 --- a/filters/f_output_chain.c +++ b/filters/f_output_chain.c @@ -152,7 +152,7 @@ static void user_wrapper_process(struct mp_filter *f) mp_filter_set_error_handler(u->f, f); const char *name = u->label ? u->label : u->name; - assert(u->name); + mp_assert(u->name); if (!u->failed && mp_filter_has_failed(u->f)) { if (u == p->convert_wrapper) { @@ -268,7 +268,7 @@ static void relink_filter_list(struct chain *p) MP_TARRAY_APPEND(p, p->all_filters, p->num_all_filters, filters[i]); } - assert(p->num_all_filters > 0); + mp_assert(p->num_all_filters > 0); p->filters_in = NULL; p->filters_out = NULL; @@ -386,8 +386,8 @@ void mp_output_chain_set_ao(struct mp_output_chain *c, struct ao *ao) { struct chain *p = c->f->priv; - assert(p->public.ao_needs_update); // can't just call it any time - assert(!p->ao); + mp_assert(p->public.ao_needs_update); // can't just call it any time + mp_assert(!p->ao); p->public.ao_needs_update = false; @@ -470,7 +470,7 @@ static void set_speed_any(struct mp_user_filter **filters, int num_filters, int command, double *speed) { for (int n = num_filters - 1; n >= 0; n--) { - assert(*speed); + mp_assert(*speed); struct mp_filter_command cmd = { .type = command, .speed = *speed, diff --git a/filters/f_swresample.c b/filters/f_swresample.c index ee0835b896..ac0a715a4e 100644 --- a/filters/f_swresample.c +++ b/filters/f_swresample.c @@ -336,7 +336,7 @@ static bool reorder_planes(struct mp_aframe *mpa, int *reorder, if (num_planes && !planes) return false; uint8_t *old_planes[MP_NUM_CHANNELS]; - assert(num_planes <= MP_NUM_CHANNELS); + mp_assert(num_planes <= MP_NUM_CHANNELS); for (int n = 0; n < num_planes; n++) old_planes[n] = planes[n]; @@ -346,11 +346,11 @@ static bool reorder_planes(struct mp_aframe *mpa, int *reorder, for (int n = 0; n < num_planes; n++) { int src = reorder[n]; - assert(src >= -1 && src < num_planes); + mp_assert(src >= -1 && src < num_planes); if (src >= 0) { planes[n] = old_planes[src]; } else { - assert(next_na < num_planes); + mp_assert(next_na < num_planes); planes[n] = old_planes[next_na++]; // The NA planes were never written by avrctx, so clear them. af_fill_silence(planes[n], @@ -488,7 +488,7 @@ static void swresample_process(struct mp_filter *f) } if (input) { - assert(!p->input); + mp_assert(!p->input); struct mp_swresample *s = &p->public; diff --git a/filters/f_utils.c b/filters/f_utils.c index 86ef106031..992e81c93b 100644 --- a/filters/f_utils.c +++ b/filters/f_utils.c @@ -74,7 +74,7 @@ void mp_chain_filters(struct mp_pin *in, struct mp_pin *out, for (int n = 0; n < num_filters; n++) { if (!filters[n]) continue; - assert(filters[n]->num_pins == 2); + mp_assert(filters[n]->num_pins == 2); mp_pin_connect(filters[n]->pins[0], in); in = filters[n]->pins[1]; } @@ -258,7 +258,7 @@ static void fixed_aframe_size_process(struct mp_filter *f) // p->in not set means draining for EOF or format change if ((!p->in && p->out_written) || p->out_written == p->samples) { int missing = p->samples - p->out_written; - assert(missing >= 0); + mp_assert(missing >= 0); if (missing) { mp_aframe_set_silence(p->out, p->out_written, missing); if (!p->pad_silence) diff --git a/filters/filter.c b/filters/filter.c index 2664b1ec4d..13753e6d2f 100644 --- a/filters/filter.c +++ b/filters/filter.c @@ -147,7 +147,7 @@ static void add_pending(struct mp_filter *f) static void add_pending_pin(struct mp_pin *p) { struct mp_filter *f = p->manual_connection; - assert(f); + mp_assert(f); if (f->in->pending) return; @@ -168,28 +168,28 @@ static void add_pending_pin(struct mp_pin *p) static void filter_recursive(struct mp_pin *p) { struct mp_filter *f = p->conn->manual_connection; - assert(f); + mp_assert(f); struct filter_runner *r = f->in->runner; // Never do internal filtering recursively. if (r->filtering) return; - assert(!r->recursive); + mp_assert(!r->recursive); r->recursive = p; // Also don't lose the pending state, which the user may or may not // care about. r->external_pending |= mp_filter_graph_run(r->root_filter); - assert(r->recursive == p); + mp_assert(r->recursive == p); r->recursive = NULL; } void mp_filter_internal_mark_progress(struct mp_filter *f) { struct filter_runner *r = f->in->runner; - assert(r->filtering); // only call from f's process() + mp_assert(r->filtering); // only call from f's process() add_pending(f); } @@ -211,7 +211,7 @@ static void flush_async_notifications(struct filter_runner *r) bool mp_filter_graph_run(struct mp_filter *filter) { struct filter_runner *r = filter->in->runner; - assert(filter == r->root_filter); // user is supposed to call this on root only + mp_assert(filter == r->root_filter); // user is supposed to call this on root only int64_t end_time = 0; if (isfinite(r->max_run_time)) @@ -219,7 +219,7 @@ bool mp_filter_graph_run(struct mp_filter *filter) // (could happen with separate filter graphs calling each other, for now // ignore this issue as we don't use such a setup anywhere) - assert(!r->filtering); + mp_assert(!r->filtering); r->filtering = true; @@ -288,8 +288,8 @@ bool mp_pin_transfer_data(struct mp_pin *dst, struct mp_pin *src) bool mp_pin_in_needs_data(struct mp_pin *p) { - assert(p->dir == MP_PIN_IN); - assert(!p->within_conn); + mp_assert(p->dir == MP_PIN_IN); + mp_assert(!p->within_conn); return p->conn && p->conn->manual_connection && p->conn->data_requested; } @@ -301,7 +301,7 @@ bool mp_pin_in_write(struct mp_pin *p, struct mp_frame frame) mp_frame_unref(&frame); return false; } - assert(p->conn->data.type == MP_FRAME_NONE); + mp_assert(p->conn->data.type == MP_FRAME_NONE); p->conn->data = frame; p->conn->data_requested = false; add_pending_pin(p->conn); @@ -311,8 +311,8 @@ bool mp_pin_in_write(struct mp_pin *p, struct mp_frame frame) bool mp_pin_out_has_data(struct mp_pin *p) { - assert(p->dir == MP_PIN_OUT); - assert(!p->within_conn); + mp_assert(p->dir == MP_PIN_OUT); + mp_assert(!p->within_conn); return p->conn && p->conn->manual_connection && p->data.type != MP_FRAME_NONE; } @@ -347,13 +347,13 @@ struct mp_frame mp_pin_out_read(struct mp_pin *p) void mp_pin_out_unread(struct mp_pin *p, struct mp_frame frame) { - assert(p->dir == MP_PIN_OUT); - assert(!p->within_conn); - assert(p->conn && p->conn->manual_connection); + mp_assert(p->dir == MP_PIN_OUT); + mp_assert(!p->within_conn); + mp_assert(p->conn && p->conn->manual_connection); // Unread is allowed strictly only if you didn't do anything else with // the pin since the time you read it. - assert(!mp_pin_out_has_data(p)); - assert(!p->data_requested); + mp_assert(!mp_pin_out_has_data(p)); + mp_assert(!p->data_requested); p->data = frame; } @@ -392,14 +392,14 @@ static void init_connection(struct mp_pin *p) struct mp_pin *out = find_connected_end(p->other); // These are the "outer" pins by definition, they have no user connections. - assert(!in->user_conn); - assert(!out->user_conn); + mp_assert(!in->user_conn); + mp_assert(!out->user_conn); // This and similar checks enforce the same root filter requirement. if (in->manual_connection) - assert(in->manual_connection->in->runner == runner); + mp_assert(in->manual_connection->in->runner == runner); if (out->manual_connection) - assert(out->manual_connection->in->runner == runner); + mp_assert(out->manual_connection->in->runner == runner); // Logically, the ends are always manual connections. A pin chain without // manual connections at the ends is still disconnected (or if this @@ -408,18 +408,18 @@ static void init_connection(struct mp_pin *p) if (!in->manual_connection || !out->manual_connection) return; - assert(in->dir == MP_PIN_IN); - assert(out->dir == MP_PIN_OUT); + mp_assert(in->dir == MP_PIN_IN); + mp_assert(out->dir == MP_PIN_OUT); struct mp_pin *cur = in; while (cur) { - assert(!cur->within_conn && !cur->other->within_conn); - assert(!cur->conn && !cur->other->conn); - assert(!cur->data_requested); // unused for in pins - assert(!cur->data.type); // unused for in pins - assert(!cur->other->data_requested); // unset for unconnected out pins - assert(!cur->other->data.type); // unset for unconnected out pins - assert(cur->owner->in->runner == runner); + mp_assert(!cur->within_conn && !cur->other->within_conn); + mp_assert(!cur->conn && !cur->other->conn); + mp_assert(!cur->data_requested); // unused for in pins + mp_assert(!cur->data.type); // unused for in pins + mp_assert(!cur->other->data_requested); // unset for unconnected out pins + mp_assert(!cur->other->data.type); // unset for unconnected out pins + mp_assert(cur->owner->in->runner == runner); cur->within_conn = cur->other->within_conn = true; cur = cur->other->user_conn; } @@ -436,11 +436,11 @@ static void init_connection(struct mp_pin *p) void mp_pin_connect(struct mp_pin *dst, struct mp_pin *src) { - assert(src->dir == MP_PIN_OUT); - assert(dst->dir == MP_PIN_IN); + mp_assert(src->dir == MP_PIN_OUT); + mp_assert(dst->dir == MP_PIN_IN); if (dst->user_conn == src) { - assert(src->user_conn == dst); + mp_assert(src->user_conn == dst); return; } @@ -483,8 +483,8 @@ static void deinit_connection(struct mp_pin *p) while (p) { p->conn = p->other->conn = NULL; p->within_conn = p->other->within_conn = false; - assert(!p->other->data_requested); // unused for in pins - assert(!p->other->data.type); // unused for in pins + mp_assert(!p->other->data_requested); // unused for in pins + mp_assert(!p->other->data.type); // unused for in pins p->data_requested = false; if (p->data.type) MP_VERBOSE(p->owner, "dropping frame due to pin disconnect\n"); @@ -584,8 +584,8 @@ bool mp_filter_has_failed(struct mp_filter *filter) static void reset_pin(struct mp_pin *p) { if (!p->conn || p->dir != MP_PIN_OUT) { - assert(!p->data.type); - assert(!p->data_requested); + mp_assert(!p->data.type); + mp_assert(!p->data_requested); } mp_frame_unref(&p->data); p->data_requested = false; @@ -612,9 +612,9 @@ void mp_filter_reset(struct mp_filter *filter) struct mp_pin *mp_filter_add_pin(struct mp_filter *f, enum mp_pin_dir dir, const char *name) { - assert(dir == MP_PIN_IN || dir == MP_PIN_OUT); - assert(name && name[0]); - assert(!mp_filter_get_named_pin(f, name)); + mp_assert(dir == MP_PIN_IN || dir == MP_PIN_OUT); + mp_assert(name && name[0]); + mp_assert(!mp_filter_get_named_pin(f, name)); // "Public" pin struct mp_pin *p = talloc_ptrtype(NULL, p); @@ -651,7 +651,7 @@ void mp_filter_remove_pin(struct mp_filter *f, struct mp_pin *p) if (!p) return; - assert(p->owner == f); + mp_assert(p->owner == f); mp_pin_disconnect(p); mp_pin_disconnect(p->other); @@ -662,7 +662,7 @@ void mp_filter_remove_pin(struct mp_filter *f, struct mp_pin *p) break; } } - assert(index >= 0); + mp_assert(index >= 0); talloc_free(f->pins[index]); talloc_free(f->ppins[index]); @@ -735,14 +735,14 @@ void mp_filter_mark_async_progress(struct mp_filter *f) void mp_filter_graph_set_max_run_time(struct mp_filter *f, double seconds) { struct filter_runner *r = f->in->runner; - assert(f == r->root_filter); // user is supposed to call this on root only + mp_assert(f == r->root_filter); // user is supposed to call this on root only r->max_run_time = seconds; } void mp_filter_graph_interrupt(struct mp_filter *f) { struct filter_runner *r = f->in->runner; - assert(f == r->root_filter); // user is supposed to call this on root only + mp_assert(f == r->root_filter); // user is supposed to call this on root only atomic_store(&r->interrupt_flag, true); } @@ -788,7 +788,7 @@ static void filter_destructor(void *p) } if (r->root_filter == f) { - assert(!f->in->parent); + mp_assert(!f->in->parent); mp_mutex_destroy(&r->async_lock); talloc_free(r->async_pending); talloc_free(r); @@ -814,7 +814,7 @@ struct mp_filter *mp_filter_create_with_params(struct mp_filter_params *params) }; if (!f->in->runner) { - assert(params->global); + mp_assert(params->global); f->in->runner = talloc(NULL, struct filter_runner); *f->in->runner = (struct filter_runner){ @@ -849,8 +849,8 @@ struct mp_filter *mp_filter_create_with_params(struct mp_filter_params *params) struct mp_filter *mp_filter_create(struct mp_filter *parent, const struct mp_filter_info *info) { - assert(parent); - assert(info); + mp_assert(parent); + mp_assert(info); struct mp_filter_params params = { .info = info, .parent = parent, @@ -877,7 +877,7 @@ void mp_filter_graph_set_wakeup_cb(struct mp_filter *root, void (*wakeup_cb)(void *ctx), void *ctx) { struct filter_runner *r = root->in->runner; - assert(root == r->root_filter); // user is supposed to call this on root only + mp_assert(root == r->root_filter); // user is supposed to call this on root only mp_mutex_lock(&r->async_lock); r->wakeup_cb = wakeup_cb; r->wakeup_ctx = ctx; diff --git a/filters/frame.c b/filters/frame.c index 077386e654..4d97e3ef5f 100644 --- a/filters/frame.c +++ b/filters/frame.c @@ -152,7 +152,7 @@ void mp_frame_unref(struct mp_frame *frame) struct mp_frame mp_frame_ref(struct mp_frame frame) { if (frame_handlers[frame.type].new_ref) { - assert(frame.data); + mp_assert(frame.data); frame.data = frame_handlers[frame.type].new_ref(frame.data); if (!frame.data) frame.type = MP_FRAME_NONE; diff --git a/filters/user_filters.c b/filters/user_filters.c index 73b6e3ccfd..68c7016371 100644 --- a/filters/user_filters.c +++ b/filters/user_filters.c @@ -154,7 +154,7 @@ struct mp_filter *mp_create_user_filter(struct mp_filter *parent, frame_type = MP_FRAME_AUDIO; obj_list = &af_obj_list; } - assert(frame_type && obj_list); + mp_assert(frame_type && obj_list); struct mp_filter *f = NULL; diff --git a/input/cmd.c b/input/cmd.c index 498c767b6d..de43a7db3f 100644 --- a/input/cmd.c +++ b/input/cmd.c @@ -142,7 +142,7 @@ static bool finish_cmd(struct mp_log *log, struct mp_cmd *cmd) struct mp_cmd_arg arg = {.type = opt}; if (opt->defval) m_option_copy(opt, &arg.v, opt->defval); - assert(i <= cmd->nargs); + mp_assert(i <= cmd->nargs); if (i == cmd->nargs) { MP_TARRAY_APPEND(cmd, cmd->args, cmd->nargs, arg); } else { @@ -203,7 +203,7 @@ static bool set_node_arg(struct mp_log *log, struct mp_cmd *cmd, int i, static bool cmd_node_array(struct mp_log *log, struct mp_cmd *cmd, mpv_node *node) { - assert(node->format == MPV_FORMAT_NODE_ARRAY); + mp_assert(node->format == MPV_FORMAT_NODE_ARRAY); mpv_node_list *args = node->u.list; int cur = 0; @@ -232,7 +232,7 @@ static bool cmd_node_array(struct mp_log *log, struct mp_cmd *cmd, mpv_node *nod static bool cmd_node_map(struct mp_log *log, struct mp_cmd *cmd, mpv_node *node) { - assert(node->format == MPV_FORMAT_NODE_MAP); + mp_assert(node->format == MPV_FORMAT_NODE_MAP); mpv_node_list *args = node->u.list; mpv_node *name = node_map_get(node, "name"); diff --git a/input/input.c b/input/input.c index de00931756..cffe8ccca8 100644 --- a/input/input.c +++ b/input/input.c @@ -271,7 +271,7 @@ static void queue_remove(struct cmd_queue *queue, struct mp_cmd *cmd) p_prev = &(*p_prev)->queue_next; } // if this fails, cmd was not in the queue - assert(*p_prev == cmd); + mp_assert(*p_prev == cmd); *p_prev = cmd->queue_next; } @@ -1291,7 +1291,7 @@ static void remove_binds(struct cmd_bind_section *bs, bool builtin) for (int n = bs->num_binds - 1; n >= 0; n--) { if (bs->binds[n].is_builtin == builtin) { bind_dealloc(&bs->binds[n]); - assert(bs->num_binds >= 1); + mp_assert(bs->num_binds >= 1); bs->binds[n] = bs->binds[bs->num_binds - 1]; bs->num_binds--; } @@ -1355,7 +1355,7 @@ static void bind_keys(struct input_ctx *ictx, bool builtin, bstr section, struct cmd_bind_section *bs = get_bind_section(ictx, section); struct cmd_bind *bind = NULL; - assert(num_keys <= MP_MAX_KEY_DOWN); + mp_assert(num_keys <= MP_MAX_KEY_DOWN); for (int n = 0; n < bs->num_binds; n++) { struct cmd_bind *b = &bs->binds[n]; @@ -1792,9 +1792,9 @@ static void input_src_kill(struct mp_input_src *src) void mp_input_src_init_done(struct mp_input_src *src) { - assert(!src->in->init_done); - assert(src->in->thread_running); - assert(mp_thread_id_equal(mp_thread_get_id(src->in->thread), mp_thread_current_id())); + mp_assert(!src->in->init_done); + mp_assert(src->in->thread_running); + mp_assert(mp_thread_id_equal(mp_thread_get_id(src->in->thread), mp_thread_current_id())); src->in->init_done = true; mp_rendezvous(&src->in->init_done, 0); } diff --git a/input/ipc.c b/input/ipc.c index 9a3633a17a..1d28f12537 100644 --- a/input/ipc.c +++ b/input/ipc.c @@ -78,7 +78,7 @@ static void mpv_node_map_add_string(void *ta_parent, mpv_node *src, const char * static void mpv_format_command_reply(void *ta_parent, mpv_event *event, mpv_node *dst) { - assert(event->event_id == MPV_EVENT_COMMAND_REPLY); + mp_assert(event->event_id == MPV_EVENT_COMMAND_REPLY); mpv_event_command *cmd = event->data; mpv_node_map_add_int64(ta_parent, dst, "request_id", event->reply_userdata); diff --git a/misc/bstr.c b/misc/bstr.c index 0b82244bca..b08762c7b9 100644 --- a/misc/bstr.c +++ b/misc/bstr.c @@ -351,7 +351,7 @@ struct bstr bstr_sanitize_utf8_latin1(void *talloc_ctx, struct bstr s) static void resize_append(void *talloc_ctx, bstr *s, size_t append_min) { size_t size = talloc_get_size(s->start); - assert(s->len <= size); + mp_assert(s->len <= size); if (append_min > size - s->len) { if (append_min < size) append_min = size; // preallocate in power of 2s diff --git a/misc/codepoint_width.c b/misc/codepoint_width.c index 3e048f4d66..74843414a3 100644 --- a/misc/codepoint_width.c +++ b/misc/codepoint_width.c @@ -739,7 +739,7 @@ int term_disp_width(bstr str, int max_width, const unsigned char **cut_pos) current_width = MPMIN(current_width, 2); next: if (width + current_width > max_width) { - assert(prev_pos < str.start + str.len); + mp_assert(prev_pos < str.start + str.len); *cut_pos = prev_pos; break; } diff --git a/misc/dispatch.c b/misc/dispatch.c index 8b6d69bfff..5467b7e6f0 100644 --- a/misc/dispatch.c +++ b/misc/dispatch.c @@ -63,10 +63,10 @@ struct mp_dispatch_item { static void queue_dtor(void *p) { struct mp_dispatch_queue *queue = p; - assert(!queue->head); - assert(!queue->in_process); - assert(!queue->lock_requests); - assert(!queue->locked); + mp_assert(!queue->head); + mp_assert(!queue->in_process); + mp_assert(!queue->lock_requests); + mp_assert(!queue->locked); mp_cond_destroy(&queue->cond); mp_mutex_destroy(&queue->lock); } @@ -273,7 +273,7 @@ void mp_dispatch_queue_process(struct mp_dispatch_queue *queue, double timeout) { mp_mutex_lock(&queue->lock); queue->wait = timeout > 0 ? mp_time_ns_add(mp_time_ns(), timeout) : 0; - assert(!queue->in_process); // recursion not allowed + mp_assert(!queue->in_process); // recursion not allowed queue->in_process = true; queue->in_process_thread_id = mp_thread_current_id(); // Wake up thread which called mp_dispatch_lock(). @@ -293,14 +293,14 @@ void mp_dispatch_queue_process(struct mp_dispatch_queue *queue, double timeout) // while the dispatch item is processed. // At the same time, we must prevent other threads from returning // from mp_dispatch_lock(), which is done by locked=true. - assert(!queue->locked); + mp_assert(!queue->locked); queue->locked = true; mp_mutex_unlock(&queue->lock); item->fn(item->fn_data); mp_mutex_lock(&queue->lock); - assert(queue->locked); + mp_assert(queue->locked); queue->locked = false; // Wakeup mp_dispatch_run(), also mp_dispatch_lock(). mp_cond_broadcast(&queue->cond); @@ -316,7 +316,7 @@ void mp_dispatch_queue_process(struct mp_dispatch_queue *queue, double timeout) break; } } - assert(!queue->locked); + mp_assert(!queue->locked); queue->in_process = false; queue->interrupted = false; mp_mutex_unlock(&queue->lock); @@ -366,10 +366,10 @@ void mp_dispatch_lock(struct mp_dispatch_queue *queue) mp_mutex_lock(&queue->lock); // Must not be called recursively from dispatched callbacks. if (queue->in_process) - assert(!mp_thread_id_equal(queue->in_process_thread_id, mp_thread_current_id())); + mp_assert(!mp_thread_id_equal(queue->in_process_thread_id, mp_thread_current_id())); // Must not be called recursively at all. if (queue->locked_explicit) - assert(!mp_thread_id_equal(queue->locked_explicit_thread_id, mp_thread_current_id())); + mp_assert(!mp_thread_id_equal(queue->locked_explicit_thread_id, mp_thread_current_id())); queue->lock_requests += 1; // And now wait until the target thread gets "trapped" within the // mp_dispatch_queue_process() call, which will mean we get exclusive @@ -389,9 +389,9 @@ void mp_dispatch_lock(struct mp_dispatch_queue *queue) while (!queue->in_process || queue->locked) mp_cond_wait(&queue->cond, &queue->lock); // "Lock". - assert(queue->lock_requests); - assert(!queue->locked); - assert(!queue->locked_explicit); + mp_assert(queue->lock_requests); + mp_assert(!queue->locked); + mp_assert(!queue->locked_explicit); queue->locked = true; queue->locked_explicit = true; queue->locked_explicit_thread_id = mp_thread_current_id(); @@ -402,10 +402,10 @@ void mp_dispatch_lock(struct mp_dispatch_queue *queue) void mp_dispatch_unlock(struct mp_dispatch_queue *queue) { mp_mutex_lock(&queue->lock); - assert(queue->locked); + mp_assert(queue->locked); // Must be called after a mp_dispatch_lock(), from the same thread. - assert(queue->locked_explicit); - assert(mp_thread_id_equal(queue->locked_explicit_thread_id, mp_thread_current_id())); + mp_assert(queue->locked_explicit); + mp_assert(mp_thread_id_equal(queue->locked_explicit_thread_id, mp_thread_current_id())); // "Unlock". queue->locked = false; queue->locked_explicit = false; diff --git a/misc/io_utils.c b/misc/io_utils.c index 777e1c780c..bc82ccbd18 100644 --- a/misc/io_utils.c +++ b/misc/io_utils.c @@ -59,7 +59,7 @@ int mp_mkostemps(char *template, int suffixlen, int flags) bool mp_save_to_file(const char *filepath, const void *data, size_t size) { - assert(filepath && data && size); + mp_assert(filepath && data && size); bool result = false; char *tmp = talloc_asprintf(NULL, "%sXXXXXX", filepath); diff --git a/misc/json.c b/misc/json.c index 9e7894c7e3..3890d87ba4 100644 --- a/misc/json.c +++ b/misc/json.c @@ -257,7 +257,7 @@ static const char special_escape[] = { static void write_json_str(bstr *b, unsigned char *str) { - assert(str); + mp_assert(str); APPEND(b, "\""); while (1) { diff --git a/misc/node.c b/misc/node.c index 8915e2038a..f24e82d3ef 100644 --- a/misc/node.c +++ b/misc/node.c @@ -12,14 +12,14 @@ void node_init(struct mpv_node *dst, int format, struct mpv_node *parent) { // Other formats need to be initialized manually. - assert(format == MPV_FORMAT_NODE_MAP || format == MPV_FORMAT_NODE_ARRAY || + mp_assert(format == MPV_FORMAT_NODE_MAP || format == MPV_FORMAT_NODE_ARRAY || format == MPV_FORMAT_FLAG || format == MPV_FORMAT_INT64 || format == MPV_FORMAT_DOUBLE || format == MPV_FORMAT_BYTE_ARRAY || format == MPV_FORMAT_NONE); void *ta_parent = NULL; if (parent) { - assert(parent->format == MPV_FORMAT_NODE_MAP || + mp_assert(parent->format == MPV_FORMAT_NODE_MAP || parent->format == MPV_FORMAT_NODE_ARRAY); ta_parent = parent->u.list; } @@ -36,7 +36,7 @@ void node_init(struct mpv_node *dst, int format, struct mpv_node *parent) struct mpv_node *node_array_add(struct mpv_node *dst, int format) { struct mpv_node_list *list = dst->u.list; - assert(dst->format == MPV_FORMAT_NODE_ARRAY && dst->u.list); + mp_assert(dst->format == MPV_FORMAT_NODE_ARRAY && dst->u.list); MP_TARRAY_GROW(list, list->values, list->num); node_init(&list->values[list->num], format, dst); return &list->values[list->num++]; @@ -47,16 +47,16 @@ struct mpv_node *node_array_add(struct mpv_node *dst, int format) // m_option_type_node memory management rules apply. struct mpv_node *node_map_add(struct mpv_node *dst, const char *key, int format) { - assert(key); + mp_assert(key); return node_map_badd(dst, bstr0(key), format); } struct mpv_node *node_map_badd(struct mpv_node *dst, struct bstr key, int format) { - assert(key.start); + mp_assert(key.start); struct mpv_node_list *list = dst->u.list; - assert(dst->format == MPV_FORMAT_NODE_MAP && dst->u.list); + mp_assert(dst->format == MPV_FORMAT_NODE_MAP && dst->u.list); MP_TARRAY_GROW(list, list->values, list->num); MP_TARRAY_GROW(list, list->keys, list->num); list->keys[list->num] = bstrdup0(list, key); @@ -69,7 +69,7 @@ struct mpv_node *node_map_badd(struct mpv_node *dst, struct bstr key, int format // m_option_type_node memory management rules apply. void node_map_add_string(struct mpv_node *dst, const char *key, const char *val) { - assert(val); + mp_assert(val); struct mpv_node *entry = node_map_add(dst, key, MPV_FORMAT_NONE); entry->format = MPV_FORMAT_STRING; @@ -78,7 +78,7 @@ void node_map_add_string(struct mpv_node *dst, const char *key, const char *val) void node_map_add_bstr(struct mpv_node *dst, const char *key, bstr val) { - assert(val.start); + mp_assert(val.start); struct mpv_node *entry = node_map_add(dst, key, MPV_FORMAT_NONE); entry->format = MPV_FORMAT_STRING; diff --git a/misc/path_utils.c b/misc/path_utils.c index 044802f9c0..8e4ac6c22a 100644 --- a/misc/path_utils.c +++ b/misc/path_utils.c @@ -84,7 +84,7 @@ void mp_path_strip_trailing_separator(char *path) char *mp_splitext(const char *path, bstr *root) { - assert(path); + mp_assert(path); int skip = (*path == '.'); // skip leading dot for "hidden" unix files const char *split = strrchr(path + skip, '.'); if (!split || !split[1] || strchr(split, '/')) diff --git a/misc/thread_pool.c b/misc/thread_pool.c index e20d9d07e6..85e5492e0c 100644 --- a/misc/thread_pool.c +++ b/misc/thread_pool.c @@ -133,8 +133,8 @@ static void thread_pool_dtor(void *ctx) for (int n = 0; n < num_threads; n++) mp_thread_join(threads[n]); - assert(pool->num_work == 0); - assert(pool->num_threads == 0); + mp_assert(pool->num_work == 0); + mp_assert(pool->num_threads == 0); mp_cond_destroy(&pool->wakeup); mp_mutex_destroy(&pool->lock); } @@ -153,9 +153,9 @@ static bool add_thread(struct mp_thread_pool *pool) struct mp_thread_pool *mp_thread_pool_create(void *ta_parent, int init_threads, int min_threads, int max_threads) { - assert(min_threads >= 0); - assert(init_threads <= min_threads); - assert(max_threads > 0 && max_threads >= min_threads); + mp_assert(min_threads >= 0); + mp_assert(init_threads <= min_threads); + mp_assert(max_threads > 0 && max_threads >= min_threads); struct mp_thread_pool *pool = talloc_zero(ta_parent, struct mp_thread_pool); talloc_set_destructor(pool, thread_pool_dtor); @@ -183,7 +183,7 @@ static bool thread_pool_add(struct mp_thread_pool *pool, void (*fn)(void *ctx), { bool ok = true; - assert(fn); + mp_assert(fn); mp_mutex_lock(&pool->lock); struct work work = {fn, fn_ctx}; diff --git a/misc/thread_tools.c b/misc/thread_tools.c index ddc354be06..40e1dae38f 100644 --- a/misc/thread_tools.c +++ b/misc/thread_tools.c @@ -60,7 +60,7 @@ uintptr_t mp_waiter_wait(struct mp_waiter *waiter) void mp_waiter_wakeup(struct mp_waiter *waiter, uintptr_t value) { mp_mutex_lock(&waiter->lock); - assert(!waiter->done); + mp_assert(!waiter->done); waiter->done = true; waiter->value = value; mp_cond_signal(&waiter->wakeup); @@ -102,7 +102,7 @@ static void cancel_destroy(void *p) { struct mp_cancel *c = p; - assert(!c->slaves.head); // API user error + mp_assert(!c->slaves.head); // API user error mp_cancel_set_parent(c, NULL); diff --git a/options/m_config_core.c b/options/m_config_core.c index ae9e94f3a3..069d8e9853 100644 --- a/options/m_config_core.c +++ b/options/m_config_core.c @@ -130,8 +130,8 @@ static struct m_group_data *m_config_gdata(struct m_config_data *data, static const char *concat_name_buf(char *buf, size_t buf_size, const char *a, const char *b) { - assert(a); - assert(b); + mp_assert(a); + mp_assert(b); if (!a[0]) return b; if (!b[0]) @@ -156,7 +156,7 @@ static bool iter_next(struct m_config_shadow *shadow, int group_start, int group_index = id == -1 ? group_start : id >> 16; int opt_index = id == -1 ? -1 : id & 0xFFFF; - assert(group_index >= group_start && group_index <= group_end); + mp_assert(group_index >= group_start && group_index <= group_end); while (1) { if (group_index >= group_end) @@ -165,7 +165,7 @@ static bool iter_next(struct m_config_shadow *shadow, int group_start, struct m_config_group *g = &shadow->groups[group_index]; const struct m_option *opts = g->group->opts; - assert(opt_index >= -1 && opt_index < g->opt_count); + mp_assert(opt_index >= -1 && opt_index < g->opt_count); opt_index += 1; @@ -200,8 +200,8 @@ static void get_opt_from_id(struct m_config_shadow *shadow, int32_t id, int group_index = id >> 16; int opt_index = id & 0xFFFF; - assert(group_index >= 0 && group_index < shadow->num_groups); - assert(opt_index >= 0 && opt_index < shadow->groups[group_index].opt_count); + mp_assert(group_index >= 0 && group_index < shadow->num_groups); + mp_assert(opt_index >= 0 && opt_index < shadow->groups[group_index].opt_count); *out_group_index = group_index; *out_opt_index = opt_index; @@ -266,7 +266,7 @@ void *m_config_cache_get_opt_data(struct m_config_cache *cache, int32_t id) int group_index, opt_index; get_opt_from_id(cache->shadow, id, &group_index, &opt_index); - assert(group_index >= cache->internal->group_start && + mp_assert(group_index >= cache->internal->group_start && group_index < cache->internal->group_end); struct m_group_data *gd = m_config_gdata(cache->internal->data, group_index); @@ -295,7 +295,7 @@ uint64_t m_config_cache_get_option_change_mask(struct m_config_cache *cache, int group_index, opt_index; get_opt_from_id(shadow, id, &group_index, &opt_index); - assert(group_index >= cache->internal->group_start && + mp_assert(group_index >= cache->internal->group_start && group_index < cache->internal->group_end); return get_opt_change_mask(cache->shadow, group_index, @@ -308,13 +308,13 @@ uint64_t m_config_cache_get_option_change_mask(struct m_config_cache *cache, // actually casted from struct some_type* ). The dummy struct type is in // theory needed, because void* and struct pointers could have different // representations, while pointers to different struct types don't. -static void *substruct_read_ptr(const void *ptr) +MP_UNUSED static inline void *substruct_read_ptr(const void *ptr) { struct mp_dummy_ *res; memcpy(&res, ptr, sizeof(res)); return res; } -static void substruct_write_ptr(void *ptr, void *val) +static inline void substruct_write_ptr(void *ptr, void *val) { struct mp_dummy_ *src = val; memcpy(ptr, &src, sizeof(src)); @@ -339,8 +339,8 @@ static void init_opt_inplace(const struct m_option *opt, void *dst, static void alloc_group(struct m_config_data *data, int group_index, struct m_config_data *copy) { - assert(group_index == data->group_index + data->num_gdata); - assert(group_index < data->shadow->num_groups); + mp_assert(group_index == data->group_index + data->num_gdata); + mp_assert(group_index < data->shadow->num_groups); struct m_config_group *group = &data->shadow->groups[group_index]; const struct m_sub_options *opts = group->group; @@ -378,7 +378,7 @@ static void alloc_group(struct m_config_data *data, int group_index, if (group->parent_group >= data->group_index && group->parent_ptr >= 0) { struct m_group_data *parent_gdata = m_config_gdata(data, group->parent_group); - assert(parent_gdata); + mp_assert(parent_gdata); substruct_write_ptr(parent_gdata->udata + group->parent_ptr, gdata->udata); } @@ -412,7 +412,7 @@ static struct m_config_data *allocate_option_data(void *ta_parent, int group_index, struct m_config_data *copy) { - assert(group_index >= 0 && group_index < shadow->num_groups); + mp_assert(group_index >= 0 && group_index < shadow->num_groups); struct m_config_data *data = talloc_zero(ta_parent, struct m_config_data); talloc_set_destructor(data, free_option_data); @@ -420,7 +420,7 @@ static struct m_config_data *allocate_option_data(void *ta_parent, data->group_index = group_index; struct m_config_group *root_group = &shadow->groups[group_index]; - assert(root_group->group_count > 0); + mp_assert(root_group->group_count > 0); for (int n = group_index; n < group_index + root_group->group_count; n++) alloc_group(data, n, copy); @@ -433,7 +433,7 @@ static void shadow_destroy(void *p) struct m_config_shadow *shadow = p; // must all have been unregistered - assert(shadow->num_listeners == 0); + mp_assert(shadow->num_listeners == 0); talloc_free(shadow->data); mp_mutex_destroy(&shadow->lock); @@ -486,19 +486,19 @@ static void add_sub_group(struct m_config_shadow *shadow, const char *name_prefi { // Can't be used multiple times. for (int n = 0; n < shadow->num_groups; n++) - assert(shadow->groups[n].group != subopts); + mp_assert(shadow->groups[n].group != subopts); if (!name_prefix) name_prefix = ""; if (subopts->prefix && subopts->prefix[0]) { - assert(!name_prefix[0]); + mp_assert(!name_prefix[0]); name_prefix = subopts->prefix; } // You can only use UPDATE_ flags here. - assert(!(subopts->change_flags & ~UPDATE_OPTS_MASK)); + mp_assert(!(subopts->change_flags & ~UPDATE_OPTS_MASK)); - assert(parent_group_index >= -1 && parent_group_index < shadow->num_groups); + mp_assert(parent_group_index >= -1 && parent_group_index < shadow->num_groups); int group_index = shadow->num_groups++; MP_TARRAY_GROW(shadow, shadow->groups, group_index); @@ -518,7 +518,7 @@ static void add_sub_group(struct m_config_shadow *shadow, const char *name_prefi // Providing default structs in-place is not allowed. if (opt->offset >= 0 && subopts->defaults) { void *ptr = (char *)subopts->defaults + opt->offset; - assert(!substruct_read_ptr(ptr)); + mp_assert(!substruct_read_ptr(ptr)); } const char *prefix = concat_name(shadow, name_prefix, opt->name); @@ -568,14 +568,14 @@ struct m_config_cache *m_config_cache_from_shadow(void *ta_parent, } } - assert(group_index >= 0); // invalid group (or not in option tree) + mp_assert(group_index >= 0); // invalid group (or not in option tree) struct cache_alloc { struct m_config_cache a; struct config_cache b; }; struct cache_alloc *alloc = talloc_zero(ta_parent, struct cache_alloc); - assert((void *)&alloc->a == (void *)alloc); + mp_assert((void *)&alloc->a == (void *)alloc); struct m_config_cache *cache = &alloc->a; talloc_set_destructor(cache, cache_destroy); cache->internal = &alloc->b; @@ -593,7 +593,7 @@ struct m_config_cache *m_config_cache_from_shadow(void *ta_parent, in->group_start = in->data->group_index; in->group_end = in->group_start + in->data->num_gdata; - assert(shadow->groups[in->group_start].group_count == in->data->num_gdata); + mp_assert(shadow->groups[in->group_start].group_count == in->data->num_gdata); in->upd_group = -1; @@ -641,14 +641,14 @@ static void update_next_option(struct m_config_cache *cache, void **p_opt) struct m_config_data *dst = in->data; struct m_config_data *src = in->src; - assert(src->group_index == 0); // must be the option root currently + mp_assert(src->group_index == 0); // must be the option root currently *p_opt = NULL; while (in->upd_group < dst->group_index + dst->num_gdata) { struct m_group_data *gsrc = m_config_gdata(src, in->upd_group); struct m_group_data *gdst = m_config_gdata(dst, in->upd_group); - assert(gsrc && gdst); + mp_assert(gsrc && gdst); if (gdst->ts < gsrc->ts) { struct m_config_group *g = &dst->shadow->groups[in->upd_group]; @@ -788,7 +788,7 @@ bool m_config_cache_write_opt(struct m_config_cache *cache, void *ptr) find_opt(shadow, in->data, ptr, &group_idx, &opt_idx); // ptr was not in cache->opts, or no option declaration matching it. - assert(group_idx >= 0); + mp_assert(group_idx >= 0); struct m_config_group *g = &shadow->groups[group_idx]; const struct m_option *opt = &g->group->opts[opt_idx]; @@ -797,7 +797,7 @@ bool m_config_cache_write_opt(struct m_config_cache *cache, void *ptr) struct m_group_data *gdst = m_config_gdata(in->data, group_idx); struct m_group_data *gsrc = m_config_gdata(in->src, group_idx); - assert(gdst && gsrc); + mp_assert(gdst && gsrc); bool changed = !m_option_equal(opt, gsrc->udata + opt->offset, ptr) || opt->force_update; @@ -836,7 +836,7 @@ void m_config_cache_set_wakeup_cb(struct m_config_cache *cache, } } for (int n = 0; n < shadow->num_listeners; n++) - assert(shadow->listeners[n] != in); // only 1 wakeup_cb per cache + mp_assert(shadow->listeners[n] != in); // only 1 wakeup_cb per cache // (The deinitialization path relies on this to free all memory.) if (!shadow->num_listeners) { talloc_free(shadow->listeners); @@ -856,7 +856,7 @@ static void dispatch_notify(void *p) { struct config_cache *in = p; - assert(in->wakeup_dispatch_queue); + mp_assert(in->wakeup_dispatch_queue); mp_dispatch_enqueue_notify(in->wakeup_dispatch_queue, in->wakeup_dispatch_cb, in->wakeup_dispatch_cb_ctx); diff --git a/options/m_config_frontend.c b/options/m_config_frontend.c index 8505b4e4ef..91e5eec910 100644 --- a/options/m_config_frontend.c +++ b/options/m_config_frontend.c @@ -595,7 +595,7 @@ static void notify_opt(struct m_config *config, void *ptr, bool self_notificatio } // ptr doesn't point to any config->optstruct field declared in the // option list? - assert(false); + mp_assert(false); } void m_config_notify_change_opt_ptr(struct m_config *config, void *ptr) @@ -717,7 +717,7 @@ int m_config_set_option_cli(struct m_config *config, struct bstr name, struct bstr param, int flags) { int r; - assert(config != NULL); + mp_assert(config != NULL); bool negate; struct m_config_option *co = @@ -738,7 +738,7 @@ int m_config_set_option_cli(struct m_config *config, struct bstr name, } // This is the only mandatory function - assert(co->opt->type->parse); + mp_assert(co->opt->type->parse); r = handle_set_opt_flags(config, co, flags); if (r <= 0) diff --git a/options/m_option.c b/options/m_option.c index 04c8b4afe4..7b394bfece 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -674,7 +674,7 @@ static int parse_choice(struct mp_log *log, const struct m_option *opt, static void choice_get_min_max(const struct m_option *opt, int *min, int *max) { - assert(opt->type == &m_option_type_choice); + mp_assert(opt->type == &m_option_type_choice); *min = INT_MAX; *max = INT_MIN; for (const struct m_opt_choice_alternatives *alt = opt->priv; alt->name; alt++) { @@ -699,7 +699,7 @@ static void check_choice(int dir, int val, bool *found, int *best, int choice) static void add_choice(const m_option_t *opt, void *val, double add, bool wrap) { - assert(opt->type == &m_option_type_choice); + mp_assert(opt->type == &m_option_type_choice); int dir = add > 0 ? +1 : -1; bool found = false; int ival = *(int *)val; @@ -1687,7 +1687,7 @@ static void keyvalue_list_del_key(char **lst, int index) int count = 0; for (int n = 0; lst && lst[n]; n++) count++; - assert(index * 2 + 1 < count); + mp_assert(index * 2 + 1 < count); count += 1; // terminating item talloc_free(lst[index * 2 + 0]); talloc_free(lst[index * 2 + 1]); @@ -2986,7 +2986,7 @@ static void obj_settings_list_del_at(m_obj_settings_t **p_obj_list, int idx) m_obj_settings_t *obj_list = *p_obj_list; int num = obj_settings_list_num_items(obj_list); - assert(idx >= 0 && idx < num); + mp_assert(idx >= 0 && idx < num); obj_setting_free(&obj_list[idx]); @@ -3014,7 +3014,7 @@ static bool obj_settings_list_insert_at(struct mp_log *log, } if (idx < 0) idx = num + idx + 1; - assert(idx >= 0 && idx <= num); + mp_assert(idx >= 0 && idx <= num); *p_obj_list = talloc_realloc(NULL, *p_obj_list, struct m_obj_settings, num + 2); memmove(*p_obj_list + idx + 1, *p_obj_list + idx, @@ -3403,7 +3403,7 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, const struct m_obj_list *ol = opt->priv; int ret = 1; - assert(opt->priv); + mp_assert(opt->priv); if (bstr_endswith0(name, "-add")) { op = OP_ADD; @@ -3600,7 +3600,7 @@ static int parse_obj_settings_list(struct mp_log *log, const m_option_t *opt, } free_obj_settings_list(&res); } else { - assert(op == OP_NONE); + mp_assert(op == OP_NONE); free_obj_settings_list(&list); list = res; } @@ -3706,7 +3706,7 @@ error: static struct mpv_node *add_array_entry(struct mpv_node *dst) { struct mpv_node_list *list = dst->u.list; - assert(dst->format == MPV_FORMAT_NODE_ARRAY&& dst->u.list); + mp_assert(dst->format == MPV_FORMAT_NODE_ARRAY&& dst->u.list); MP_TARRAY_GROW(list, list->values, list->num); return &list->values[list->num++]; } @@ -3714,7 +3714,7 @@ static struct mpv_node *add_array_entry(struct mpv_node *dst) static struct mpv_node *add_map_entry(struct mpv_node *dst, const char *key) { struct mpv_node_list *list = dst->u.list; - assert(dst->format == MPV_FORMAT_NODE_MAP && dst->u.list); + mp_assert(dst->format == MPV_FORMAT_NODE_MAP && dst->u.list); MP_TARRAY_GROW(list, list->values, list->num); MP_TARRAY_GROW(list, list->keys, list->num); list->keys[list->num] = talloc_strdup(list, key); diff --git a/options/m_option.h b/options/m_option.h index b6309f79f8..ecb665bed8 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -18,6 +18,7 @@ #ifndef MPLAYER_M_OPTION_H #define MPLAYER_M_OPTION_H +#include #include #include #include diff --git a/options/m_property.c b/options/m_property.c index 85686d8d0a..49681560b7 100644 --- a/options/m_property.c +++ b/options/m_property.c @@ -46,7 +46,7 @@ static int m_property_multiply(struct mp_log *log, &opt, ctx); if (r != M_PROPERTY_OK) return r; - assert(opt.type); + mp_assert(opt.type); if (!opt.type->multiply) return M_PROPERTY_NOT_IMPLEMENTED; @@ -105,7 +105,7 @@ int m_property_do(struct mp_log *log, const struct m_property *prop_list, r = do_action(prop_list, name, M_PROPERTY_GET_TYPE, &opt, ctx); if (r <= 0) return r; - assert(opt.type); + mp_assert(opt.type); switch (action) { case M_PROPERTY_FIXED_LEN_PRINT: @@ -147,7 +147,7 @@ int m_property_do(struct mp_log *log, const struct m_property *prop_list, &opt, ctx); if (r <= 0) return r; - assert(opt.type); + mp_assert(opt.type); if (!opt.type->add) return M_PROPERTY_NOT_IMPLEMENTED; if ((r = do_action(prop_list, name, M_PROPERTY_GET, &val, ctx)) <= 0) diff --git a/options/parse_commandline.c b/options/parse_commandline.c index b07d8e66db..529dc0a877 100644 --- a/options/parse_commandline.c +++ b/options/parse_commandline.c @@ -50,7 +50,7 @@ struct parse_state { // Returns true if more args, false if all parsed or an error occurred. static bool split_opt(struct parse_state *p) { - assert(!p->error); + mp_assert(!p->error); if (!p->argv || !p->argv[0]) return false; @@ -128,7 +128,7 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, int local_params_count = 0; struct playlist_param *local_params = 0; - assert(config != NULL); + mp_assert(config != NULL); mode = GLOBAL; @@ -156,7 +156,7 @@ int m_config_parse_mp_command_line(m_config_t *config, struct playlist *files, goto err_out; } mode = LOCAL; - assert(!local_start); + mp_assert(!local_start); local_start = playlist_get_last(files); continue; } diff --git a/options/path.c b/options/path.c index f09115775c..8be6303b3b 100644 --- a/options/path.c +++ b/options/path.c @@ -72,7 +72,7 @@ static const char *mp_get_platform_path(void *talloc_ctx, struct mpv_global *global, const char *type) { - assert(talloc_ctx); + mp_assert(talloc_ctx); if (global->configdir) { // Return NULL for all platform paths if --no-config is passed @@ -99,7 +99,7 @@ static const char *mp_get_platform_path(void *talloc_ctx, } if (fallback_type) { - assert(strcmp(fallback_type, type) != 0); + mp_assert(strcmp(fallback_type, type) != 0); return mp_get_platform_path(talloc_ctx, global, fallback_type); } return NULL; diff --git a/osdep/compiler.h b/osdep/compiler.h index 9c5b18e696..cb04fed81f 100644 --- a/osdep/compiler.h +++ b/osdep/compiler.h @@ -1,6 +1,8 @@ #ifndef MPV_COMPILER_H #define MPV_COMPILER_H +#include + #define MP_EXPAND_ARGS(...) __VA_ARGS__ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L diff --git a/osdep/io.c b/osdep/io.c index 483da8a1d1..f7e24ba29a 100644 --- a/osdep/io.c +++ b/osdep/io.c @@ -811,8 +811,8 @@ int msync(void *addr, size_t length, int flags) void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { - assert(addr == NULL); // not implemented - assert(flags == MAP_SHARED); // not implemented + mp_assert(addr == NULL); // not implemented + mp_assert(flags == MAP_SHARED); // not implemented HANDLE osf = (HANDLE)_get_osfhandle(fd); if (!osf) { diff --git a/osdep/subprocess-posix.c b/osdep/subprocess-posix.c index 071068dd52..d583ab07d0 100644 --- a/osdep/subprocess-posix.c +++ b/osdep/subprocess-posix.c @@ -185,13 +185,13 @@ void mp_subprocess2(struct mp_subprocess_opts *opts, } for (int n = 0; n < opts->num_fds; n++) { - assert(!(opts->fds[n].on_read && opts->fds[n].on_write)); + mp_assert(!(opts->fds[n].on_read && opts->fds[n].on_write)); if (opts->fds[n].on_read && mp_make_cloexec_pipe(comm_pipe[n]) < 0) goto done; if (opts->fds[n].on_write || opts->fds[n].write_buf) { - assert(opts->fds[n].on_write && opts->fds[n].write_buf); + mp_assert(opts->fds[n].on_write && opts->fds[n].write_buf); if (mp_make_cloexec_pipe(comm_pipe[n]) < 0) goto done; MPSWAP(int, comm_pipe[n][0], comm_pipe[n][1]); diff --git a/osdep/terminal-unix.c b/osdep/terminal-unix.c index 49ddf8f163..7cc00f0ea3 100644 --- a/osdep/terminal-unix.c +++ b/osdep/terminal-unix.c @@ -195,7 +195,7 @@ struct termbuf { static void skip_buf(struct termbuf *b, unsigned int count) { - assert(count <= b->len); + mp_assert(count <= b->len); memmove(&b->b[0], &b->b[count], b->len - count); b->len -= count; @@ -285,7 +285,7 @@ static void process_input(struct input_ctx *input_ctx, bool timeout) if (match->replace) { int rep = strlen(match->replace); - assert(rep <= seq_len); + mp_assert(rep <= seq_len); memcpy(buf.b, match->replace, rep); memmove(buf.b + rep, buf.b + seq_len, buf.len - seq_len); buf.len = rep + buf.len - seq_len; @@ -597,7 +597,7 @@ void terminal_set_mouse_input(bool enable) void terminal_init(void) { - assert(!getch2_enabled); + mp_assert(!getch2_enabled); getch2_enabled = 1; if (mp_make_wakeup_pipe(stop_cont_pipe) < 0) { diff --git a/osdep/threads-posix.h b/osdep/threads-posix.h index 6b0409494c..469bbc02e6 100644 --- a/osdep/threads-posix.h +++ b/osdep/threads-posix.h @@ -132,7 +132,7 @@ static inline int mp_mutex_init_type_internal(mp_mutex *mutex, enum mp_mutex_typ pthread_mutexattr_settype(&attr, mutex_type); ret = pthread_mutex_init(mutex, &attr); pthread_mutexattr_destroy(&attr); - assert(!ret); + mp_assert(!ret); return ret; } @@ -143,7 +143,7 @@ static inline int mp_mutex_init_type_internal(mp_mutex *mutex, enum mp_mutex_typ static inline int mp_cond_init(mp_cond *cond) { - assert(cond); + mp_assert(cond); int ret = 0; pthread_condattr_t attr; @@ -164,31 +164,31 @@ static inline int mp_cond_init(mp_cond *cond) static inline int mp_cond_destroy(mp_cond *cond) { - assert(cond); + mp_assert(cond); return pthread_cond_destroy(&cond->cond); } static inline int mp_cond_broadcast(mp_cond *cond) { - assert(cond); + mp_assert(cond); return pthread_cond_broadcast(&cond->cond); } static inline int mp_cond_signal(mp_cond *cond) { - assert(cond); + mp_assert(cond); return pthread_cond_signal(&cond->cond); } static inline int mp_cond_wait(mp_cond *cond, mp_mutex *mutex) { - assert(cond); + mp_assert(cond); return pthread_cond_wait(&cond->cond, mutex); } static inline int mp_cond_timedwait(mp_cond *cond, mp_mutex *mutex, int64_t timeout) { - assert(cond); + mp_assert(cond); timeout = MPMAX(0, timeout); // consider anything above 1000 days as infinity diff --git a/osdep/timer.c b/osdep/timer.c index c0aac8972b..48e07ad6a6 100644 --- a/osdep/timer.c +++ b/osdep/timer.c @@ -32,7 +32,7 @@ static void do_timer_init(void) { mp_raw_time_init(); raw_time_offset = mp_raw_time_ns(); - assert(raw_time_offset > 0); + mp_assert(raw_time_offset > 0); } void mp_time_init(void) @@ -57,7 +57,7 @@ double mp_time_sec(void) int64_t mp_time_ns_add(int64_t time_ns, double timeout_sec) { - assert(time_ns > 0); // mp_time_ns() returns strictly positive values + mp_assert(time_ns > 0); // mp_time_ns() returns strictly positive values double t = MPCLAMP(timeout_sec * 1e9, -0x1p63, 0x1p63); int64_t ti = t == 0x1p63 ? INT64_MAX : (int64_t)t; if (ti > INT64_MAX - time_ns) diff --git a/osdep/win32/smtc.cpp b/osdep/win32/smtc.cpp index 4e5365e46b..27faac13aa 100644 --- a/osdep/win32/smtc.cpp +++ b/osdep/win32/smtc.cpp @@ -174,7 +174,7 @@ static void update_thumbnail(SystemMediaTransportControls &smtc, smtc_ctx &ctx) auto track_list = mp_get_property(ctx.mpv, "track-list"); if (!track_list) return; - assert(track_list->format == MPV_FORMAT_NODE_ARRAY); + mp_assert(track_list->format == MPV_FORMAT_NODE_ARRAY); auto list = track_list->u.list; const char *thumbnail = nullptr; mp_string filepath{ mpv_get_property_string(ctx.mpv, "path") }; diff --git a/player/audio.c b/player/audio.c index 9d91c25f5a..ec0f5abce4 100644 --- a/player/audio.c +++ b/player/audio.c @@ -88,7 +88,7 @@ static void update_speed_filters(struct MPContext *mpctx) static int recreate_audio_filters(struct MPContext *mpctx) { struct ao_chain *ao_c = mpctx->ao_chain; - assert(ao_c); + mp_assert(ao_c); if (!mp_output_chain_update_filters(ao_c->filter, mpctx->opts->af_settings)) goto fail; @@ -268,10 +268,10 @@ static void ao_chain_uninit(struct ao_chain *ao_c) { struct track *track = ao_c->track; if (track) { - assert(track->ao_c == ao_c); + mp_assert(track->ao_c == ao_c); track->ao_c = NULL; if (ao_c->dec_src) - assert(track->dec->f->pins[0] == ao_c->dec_src); + mp_assert(track->dec->f->pins[0] == ao_c->dec_src); talloc_free(track->dec->f); track->dec = NULL; } @@ -338,7 +338,7 @@ done: static void ao_chain_set_ao(struct ao_chain *ao_c, struct ao *ao) { if (ao_c->ao != ao) { - assert(!ao_c->ao); + mp_assert(!ao_c->ao); ao_c->ao = ao; ao_c->ao_queue = ao_get_queue(ao_c->ao); ao_c->queue_filter = mp_async_queue_create_filter(ao_c->ao_filter, @@ -359,10 +359,10 @@ static int reinit_audio_filters_and_output(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; struct ao_chain *ao_c = mpctx->ao_chain; - assert(ao_c); + mp_assert(ao_c); struct track *track = ao_c->track; - assert(ao_c->filter->ao_needs_update); + mp_assert(ao_c->filter->ao_needs_update); // The "ideal" filter output format struct mp_aframe *out_fmt = mp_aframe_new_ref(ao_c->filter->output_aformat); @@ -519,7 +519,7 @@ init_error: int init_audio_decoder(struct MPContext *mpctx, struct track *track) { - assert(!track->dec); + mp_assert(!track->dec); if (!track->stream) goto init_error; @@ -564,7 +564,7 @@ static const struct mp_filter_info ao_filter = { // (track=NULL creates a blank chain, used for lavfi-complex) void reinit_audio_chain_src(struct MPContext *mpctx, struct track *track) { - assert(!mpctx->ao_chain); + mp_assert(!mpctx->ao_chain); mp_notify(mpctx, MPV_EVENT_AUDIO_RECONFIG, NULL); diff --git a/player/client.c b/player/client.c index b5112d1490..ca64dda3c2 100644 --- a/player/client.c +++ b/player/client.c @@ -170,7 +170,7 @@ static void prop_unref(struct observe_property *prop) if (!prop) return; - assert(prop->refcount > 0); + mp_assert(prop->refcount > 0); prop->refcount -= 1; if (!prop->refcount) talloc_free(prop); @@ -190,7 +190,7 @@ void mp_clients_destroy(struct MPContext *mpctx) { if (!mpctx->clients) return; - assert(mpctx->clients->num_clients == 0); + mp_assert(mpctx->clients->num_clients == 0); // The API user is supposed to call mpv_render_context_free(). It's simply // not allowed not to do this. @@ -482,7 +482,7 @@ static void mp_destroy_client(mpv_handle *ctx, bool terminate) break; } } - assert(!ctx); + mp_assert(!ctx); if (mpctx->is_cli) { terminate = false; @@ -757,7 +757,7 @@ static void send_reply(struct mpv_handle *ctx, uint64_t userdata, event->reply_userdata = userdata; mp_mutex_lock(&ctx->lock); // If this fails, reserve_reply() probably wasn't called. - assert(ctx->reserved_events > 0); + mp_assert(ctx->reserved_events > 0); ctx->reserved_events--; if (append_event(ctx, *event, false) < 0) MP_ASSERT_UNREACHABLE(); @@ -854,7 +854,7 @@ int mpv_request_event(mpv_handle *ctx, mpv_event_id event, int enable) return MPV_ERROR_INVALID_PARAMETER; if (event == MPV_EVENT_SHUTDOWN && !enable) return MPV_ERROR_INVALID_PARAMETER; - assert(event < (int)INTERNAL_EVENT_BASE); // excluded above; they have no name + mp_assert(event < (int)INTERNAL_EVENT_BASE); // excluded above; they have no name mp_mutex_lock(&ctx->lock); uint64_t bit = 1ULL << event; ctx->event_mask = enable ? ctx->event_mask | bit : ctx->event_mask & ~bit; @@ -1525,7 +1525,7 @@ static void property_free(void *p) { struct observe_property *prop = p; - assert(prop->refcount == 0); + mp_assert(prop->refcount == 0); if (prop->type) { m_option_free(prop->type, &prop->value); @@ -1544,7 +1544,7 @@ int mpv_observe_property(mpv_handle *ctx, uint64_t userdata, return MPV_ERROR_PROPERTY_FORMAT; mp_mutex_lock(&ctx->lock); - assert(!ctx->destroying); + mp_assert(!ctx->destroying); struct observe_property *prop = talloc_ptrtype(ctx, prop); talloc_set_destructor(prop, property_free); *prop = (struct observe_property){ @@ -1709,7 +1709,7 @@ static void send_client_property_changes(struct mpv_handle *ctx) ctx->has_pending_properties = true; break; } - assert(prop->refcount > 0); + mp_assert(prop->refcount > 0); bool val_valid = req.status >= 0; changed = prop->value_valid != val_valid; @@ -2163,7 +2163,7 @@ void kill_video_async(struct mp_client_api *client_api) bool mp_set_main_render_context(struct mp_client_api *client_api, struct mpv_render_context *ctx, bool active) { - assert(ctx); + mp_assert(ctx); mp_mutex_lock(&client_api->lock); bool is_set = !!client_api->render_context; diff --git a/player/command.c b/player/command.c index 62cbea4c5c..45d55bbde8 100644 --- a/player/command.c +++ b/player/command.c @@ -1918,7 +1918,7 @@ static int mp_property_audio_out_params(void *ctx, struct m_property *prop, static struct track* track_next(struct MPContext *mpctx, enum stream_type type, int direction, struct track *track) { - assert(direction == -1 || direction == +1); + mp_assert(direction == -1 || direction == +1); struct track *prev = NULL, *next = NULL; bool seen = track == NULL; for (int n = 0; n < mpctx->num_tracks; n++) { @@ -2286,7 +2286,7 @@ static int mp_property_current_tracks(void *ctx, struct m_property *prop, break; } } - assert(index >= 0); + mp_assert(index >= 0); char *name = mp_tprintf(80, "track-list/%d%s%s", index, *rem ? "/" : "", rem); return mp_property_do(name, ka->action, ka->arg, ctx); @@ -3970,7 +3970,7 @@ static int do_op_udata(struct udata_ctx* ctx, int action, void *arg) return M_PROPERTY_OK; case M_PROPERTY_GET: case M_PROPERTY_GET_NODE: // same as GET, because type==mpv_node - assert(node); + mp_assert(node); m_option_copy(&udata_type, arg, node); return M_PROPERTY_OK; case M_PROPERTY_FIXED_LEN_PRINT: @@ -3981,13 +3981,13 @@ static int do_op_udata(struct udata_ctx* ctx, int action, void *arg) } case M_PROPERTY_SET: case M_PROPERTY_SET_NODE: - assert(node); + mp_assert(node); m_option_copy(&udata_type, node, arg); talloc_steal(ctx->ta_parent, node_get_alloc(node)); mp_notify_property(mpctx, ctx->path); return M_PROPERTY_OK; case M_PROPERTY_KEY_ACTION: { - assert(node); + mp_assert(node); // If we're operating on an array, sub-object access is handled by m_property_read_list if (node->format == MPV_FORMAT_NODE_ARRAY) @@ -4999,7 +4999,7 @@ done: static void replace_overlay(struct MPContext *mpctx, int id, struct overlay *new) { struct command_ctx *cmd = mpctx->command_ctx; - assert(id >= 0); + mp_assert(id >= 0); if (id >= cmd->num_overlays) { MP_TARRAY_GROW(cmd, cmd->overlays, id); while (cmd->num_overlays <= id) @@ -5441,7 +5441,7 @@ void run_command(struct MPContext *mpctx, struct mp_cmd *cmd, if (!ctx->abort && cmd->def->can_abort) ctx->abort = talloc_zero(ctx, struct mp_abort_entry); - assert(cmd->def->can_abort == !!ctx->abort); + mp_assert(cmd->def->can_abort == !!ctx->abort); if (ctx->abort) { ctx->abort->coupled_to_playback |= cmd->def->abort_on_playback_end; @@ -6868,13 +6868,13 @@ static void cache_dump_poll(struct MPContext *mpctx) return; // Can't close demuxer without stopping dumping. - assert(mpctx->demuxer); + mp_assert(mpctx->demuxer); if (mp_cancel_test(cmd->abort->cancel)) { // Synchronous abort. In particular, the dump command shall not report // completion to the user before the dump target file was closed. demux_cache_dump_set(mpctx->demuxer, 0, 0, NULL); - assert(demux_cache_dump_get_status(mpctx->demuxer) <= 0); + mp_assert(demux_cache_dump_get_status(mpctx->demuxer) <= 0); } int status = demux_cache_dump_get_status(mpctx->demuxer); @@ -6898,7 +6898,7 @@ void mp_abort_cache_dumping(struct MPContext *mpctx) if (ctx->cache_dump_cmd) mp_cancel_trigger(ctx->cache_dump_cmd->abort->cancel); cache_dump_poll(mpctx); - assert(!ctx->cache_dump_cmd); // synchronous abort, must have worked + mp_assert(!ctx->cache_dump_cmd); // synchronous abort, must have worked } static void run_dump_cmd(struct mp_cmd_ctx *cmd, double start, double end, @@ -7501,7 +7501,7 @@ void command_uninit(struct MPContext *mpctx) { struct command_ctx *ctx = mpctx->command_ctx; - assert(!ctx->cache_dump_cmd); // closing the demuxer must have aborted it + mp_assert(!ctx->cache_dump_cmd); // closing the demuxer must have aborted it overlay_uninit(mpctx); ao_hotplug_destroy(ctx->hotplug); @@ -7539,7 +7539,7 @@ void command_init(struct MPContext *mpctx) int count = num_base; for (int n = 0; n < num_opts; n++) { struct m_config_option *co = m_config_get_co_index(mpctx->mconfig, n); - assert(co->name[0]); + mp_assert(co->name[0]); if (co->opt->flags & M_OPT_NOPROP) continue; diff --git a/player/loadfile.c b/player/loadfile.c index 1525bff86a..0377ddbb41 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -88,7 +88,7 @@ void mp_abort_playback_async(struct MPContext *mpctx) void mp_abort_add(struct MPContext *mpctx, struct mp_abort_entry *abort) { mp_mutex_lock(&mpctx->abort_lock); - assert(!abort->cancel); + mp_assert(!abort->cancel); abort->cancel = mp_cancel_new(NULL); MP_TARRAY_APPEND(NULL, mpctx->abort_list, mpctx->num_abort_list, abort); mp_abort_recheck_locked(mpctx, abort); @@ -108,7 +108,7 @@ void mp_abort_remove(struct MPContext *mpctx, struct mp_abort_entry *abort) break; } } - assert(!abort); // should have been in the list + mp_assert(!abort); // should have been in the list mp_mutex_unlock(&mpctx->abort_lock); } @@ -212,9 +212,9 @@ static void uninit_demuxer(struct MPContext *mpctx) for (int i = 0; i < mpctx->num_tracks; i++) { struct track *track = mpctx->tracks[i]; - assert(!track->dec && !track->d_sub); - assert(!track->vo_c && !track->ao_c); - assert(!track->sink); + mp_assert(!track->dec && !track->d_sub); + mp_assert(!track->vo_c && !track->ao_c); + mp_assert(!track->sink); // Demuxers can be added in any order (if they appear mid-stream), and // we can't know which tracks uses which, so here's some O(n^2) trash. @@ -668,7 +668,7 @@ static void check_previous_track_selection(struct MPContext *mpctx) void mark_track_selection(struct MPContext *mpctx, int order, enum stream_type type, int value) { - assert(order >= 0 && order < num_ptracks[type]); + mp_assert(order >= 0 && order < num_ptracks[type]); mpctx->opts->stream_id[order][type] = value; m_config_notify_change_opt_ptr(mpctx->mconfig, &mpctx->opts->stream_id[order][type]); @@ -677,9 +677,9 @@ void mark_track_selection(struct MPContext *mpctx, int order, void mp_switch_track_n(struct MPContext *mpctx, int order, enum stream_type type, struct track *track, int flags) { - assert(!track || track->type == type); - assert(type >= 0 && type < STREAM_TYPE_COUNT); - assert(order >= 0 && order < num_ptracks[type]); + mp_assert(!track || track->type == type); + mp_assert(type >= 0 && type < STREAM_TYPE_COUNT); + mp_assert(order >= 0 && order < num_ptracks[type]); // Mark the current track selection as explicitly user-requested. (This is // different from auto-selection or disabling a track due to errors.) @@ -1185,10 +1185,10 @@ static void start_open(struct MPContext *mpctx, char *url, int url_flags, { cancel_open(mpctx); - assert(!mpctx->open_active); - assert(!mpctx->open_cancel); - assert(!mpctx->open_res_demuxer); - assert(!atomic_load(&mpctx->open_done)); + mp_assert(!mpctx->open_active); + mp_assert(!mpctx->open_cancel); + mp_assert(!mpctx->open_res_demuxer); + mp_assert(!atomic_load(&mpctx->open_done)); mpctx->open_cancel = mp_cancel_new(NULL); mpctx->open_url = talloc_strdup(NULL, url); @@ -1348,7 +1348,7 @@ static void kill_outputs(struct MPContext *mpctx, struct track *track) track->user_tid); mp_switch_track(mpctx, track->type, NULL, 0); } - assert(!(track->vo_c || track->ao_c)); + mp_assert(!(track->vo_c || track->ao_c)); } // >0: changed, 0: no change, -1: error @@ -1398,7 +1398,7 @@ static int reinit_complex_filters(struct MPContext *mpctx, bool force_uninit) goto done; } struct vo_chain *vo_c = mpctx->vo_chain; - assert(!vo_c->track); + mp_assert(!vo_c->track); vo_c->filter_src = pad; mp_pin_connect(vo_c->filter->f->pins[0], vo_c->filter_src); } @@ -1413,7 +1413,7 @@ static int reinit_complex_filters(struct MPContext *mpctx, bool force_uninit) goto done; } struct ao_chain *ao_c = mpctx->ao_chain; - assert(!ao_c->track); + mp_assert(!ao_c->track); ao_c->filter_src = pad; mp_pin_connect(ao_c->filter->f->pins[0], ao_c->filter_src); } @@ -1435,9 +1435,9 @@ static int reinit_complex_filters(struct MPContext *mpctx, bool force_uninit) continue; if (mp_pin_get_dir(pad) != MP_PIN_IN) continue; - assert(!mp_pin_is_connected(pad)); + mp_assert(!mp_pin_is_connected(pad)); - assert(!track->sink); + mp_assert(!track->sink); kill_outputs(mpctx, track); @@ -1623,7 +1623,7 @@ static void play_current_file(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; - assert(mpctx->stop_play); + mp_assert(mpctx->stop_play); mpctx->stop_play = 0; process_hooks(mpctx, "on_before_start_file"); @@ -1670,8 +1670,8 @@ static void play_current_file(struct MPContext *mpctx) #endif mpctx->playing = mpctx->playlist->current; - assert(mpctx->playing); - assert(mpctx->playing->filename); + mp_assert(mpctx->playing); + mp_assert(mpctx->playing->filename); mpctx->playing->reserved += 1; mpctx->filename = talloc_strdup(NULL, mpctx->playing->filename); @@ -1712,7 +1712,7 @@ static void play_current_file(struct MPContext *mpctx) mpctx->playing->playlist_path) MP_INFO(mpctx, "Playing: %s\n", mpctx->filename); - assert(mpctx->demuxer == NULL); + mp_assert(mpctx->demuxer == NULL); process_hooks(mpctx, "on_load"); if (mpctx->stop_play) @@ -2011,7 +2011,7 @@ terminate_playback: mpctx->files_played++; } - assert(mpctx->stop_play); + mp_assert(mpctx->stop_play); process_hooks(mpctx, "on_after_end_file"); @@ -2136,7 +2136,7 @@ void mp_play_files(struct MPContext *mpctx) // e must be on the mpctx->playlist. void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e) { - assert(!e || playlist_entry_to_index(mpctx->playlist, e) >= 0); + mp_assert(!e || playlist_entry_to_index(mpctx->playlist, e) >= 0); mpctx->playlist->current = e; mpctx->playlist->current_was_replaced = false; mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL); diff --git a/player/lua.c b/player/lua.c index 8d88be5c82..960cde7feb 100644 --- a/player/lua.c +++ b/player/lua.c @@ -212,7 +212,7 @@ static struct script_ctx *get_ctx(lua_State *L) lua_getfield(L, LUA_REGISTRYINDEX, "ctx"); struct script_ctx *ctx = lua_touserdata(L, -1); lua_pop(L, 1); - assert(ctx); + mp_assert(ctx); return ctx; } @@ -411,24 +411,24 @@ static int run_lua(lua_State *L) lua_pop(L, 1); // - - assert(lua_gettop(L) == 0); + mp_assert(lua_gettop(L) == 0); // Add a preloader for each builtin Lua module lua_getglobal(L, "package"); // package - assert(lua_type(L, -1) == LUA_TTABLE); + mp_assert(lua_type(L, -1) == LUA_TTABLE); lua_getfield(L, -1, "preload"); // package preload - assert(lua_type(L, -1) == LUA_TTABLE); + mp_assert(lua_type(L, -1) == LUA_TTABLE); for (int n = 0; builtin_lua_scripts[n][0]; n++) { lua_pushcfunction(L, load_builtin); // package preload load_builtin lua_setfield(L, -2, builtin_lua_scripts[n][0]); } lua_pop(L, 2); // - - assert(lua_gettop(L) == 0); + mp_assert(lua_gettop(L) == 0); fuck_lua(L, "path", ctx->path); fuck_lua(L, "cpath", NULL); - assert(lua_gettop(L) == 0); + mp_assert(lua_gettop(L) == 0); // run this under an error handler that can do backtraces lua_pushcfunction(L, error_handler); // errf @@ -1274,7 +1274,7 @@ static int script_autofree_call(lua_State *L) // n*args &data autofree_data *data = lua_touserdata(L, -1); lua_pop(L, 1); // n*args - assert(data && data->target && data->ctx); + mp_assert(data && data->target && data->ctx); return data->target(L, data->ctx); } @@ -1285,7 +1285,7 @@ static int script_autofree_trampoline(lua_State *L) .target = lua_touserdata(L, lua_upvalueindex(2)), // fn .ctx = NULL, }; - assert(data.target); + mp_assert(data.target); lua_pushvalue(L, lua_upvalueindex(1)); // n*args autofree_call (closure) lua_insert(L, 1); // autofree_call n*args diff --git a/player/main.c b/player/main.c index 6263f3a90f..8898ed0305 100644 --- a/player/main.c +++ b/player/main.c @@ -203,7 +203,7 @@ void mp_destroy(struct MPContext *mpctx) uninit_libav(mpctx->global); mp_msg_uninit(mpctx->global); - assert(!mpctx->num_abort_list); + mp_assert(!mpctx->num_abort_list); talloc_free(mpctx->abort_list); mp_mutex_destroy(&mpctx->abort_lock); talloc_free(mpctx->mconfig); // destroy before dispatch @@ -333,7 +333,7 @@ int mp_initialize(struct MPContext *mpctx, char **options) { struct MPOpts *opts = mpctx->opts; - assert(!mpctx->initialized); + mp_assert(!mpctx->initialized); // Preparse the command line, so we can init the terminal early. if (options) { diff --git a/player/osd.c b/player/osd.c index 840dff88cc..4a2952f3fa 100644 --- a/player/osd.c +++ b/player/osd.c @@ -434,7 +434,7 @@ void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size) static void sadd_osd_status(char **buffer, struct MPContext *mpctx, int level) { - assert(level >= 0 && level <= 3); + mp_assert(level >= 0 && level <= 3); if (level == 0) return; char *msg = mpctx->opts->osd_msg[level - 1]; diff --git a/player/screenshot.c b/player/screenshot.c index 4211b67289..8943c155c5 100644 --- a/player/screenshot.c +++ b/player/screenshot.c @@ -563,7 +563,7 @@ void cmd_screenshot_raw(void *p) const enum mp_imgfmt formats[] = {IMGFMT_BGR0, IMGFMT_BGRA, IMGFMT_RGBA, IMGFMT_RGBA64}; const char *format_names[] = {"bgr0", "bgra", "rgba", "rgba64"}; int idx = cmd->args[1].v.i; - assert(idx >= 0 && idx <= 3); + mp_assert(idx >= 0 && idx <= 3); bool high_depth = formats[idx] == IMGFMT_RGBA64; struct mp_image *img = screenshot_get_rgb(mpctx, cmd->args[0].v.i, diff --git a/player/scripting.c b/player/scripting.c index b8325dc000..d15c6d2107 100644 --- a/player/scripting.c +++ b/player/scripting.c @@ -240,7 +240,7 @@ static char **list_script_files(void *talloc_ctx, char *path) static void load_builtin_script(struct MPContext *mpctx, int slot, bool enable, const char *fname) { - assert(slot < MP_ARRAY_SIZE(mpctx->builtin_script_ids)); + mp_assert(slot < MP_ARRAY_SIZE(mpctx->builtin_script_ids)); int64_t *pid = &mpctx->builtin_script_ids[slot]; if (*pid > 0 && !mp_client_id_exists(mpctx, *pid)) *pid = 0; // died diff --git a/player/sub.c b/player/sub.c index 8ae737b88b..f15d68c304 100644 --- a/player/sub.c +++ b/player/sub.c @@ -191,7 +191,7 @@ static struct attachment_list *get_all_attachments(struct MPContext *mpctx) static bool init_subdec(struct MPContext *mpctx, struct track *track) { - assert(!track->d_sub); + mp_assert(!track->d_sub); if (!track->demuxer || !track->stream) return false; @@ -216,7 +216,7 @@ void reinit_sub(struct MPContext *mpctx, struct track *track) if (!track || !track->stream || track->stream->type != STREAM_SUB) return; - assert(!track->d_sub); + mp_assert(!track->d_sub); if (!init_subdec(mpctx, track)) { error_on_track(mpctx, track); diff --git a/player/video.c b/player/video.c index a47c6dc359..ff086db272 100644 --- a/player/video.c +++ b/player/video.c @@ -66,7 +66,7 @@ static bool recreate_video_filters(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; struct vo_chain *vo_c = mpctx->vo_chain; - assert(vo_c); + mp_assert(vo_c); return mp_output_chain_update_filters(vo_c->filter, opts->vf_settings); } @@ -139,10 +139,10 @@ static void vo_chain_uninit(struct vo_chain *vo_c) { struct track *track = vo_c->track; if (track) { - assert(track->vo_c == vo_c); + mp_assert(track->vo_c == vo_c); track->vo_c = NULL; if (vo_c->dec_src) - assert(track->dec->f->pins[0] == vo_c->dec_src); + mp_assert(track->dec->f->pins[0] == vo_c->dec_src); talloc_free(track->dec->f); track->dec = NULL; } @@ -170,7 +170,7 @@ void uninit_video_chain(struct MPContext *mpctx) int init_video_decoder(struct MPContext *mpctx, struct track *track) { - assert(!track->dec); + mp_assert(!track->dec); if (!track->stream) goto err_out; @@ -222,7 +222,7 @@ static void filter_update_subtitles(void *ctx, double pts) // (track=NULL creates a blank chain, used for lavfi-complex) void reinit_video_chain_src(struct MPContext *mpctx, struct track *track) { - assert(!mpctx->vo_chain); + mp_assert(!mpctx->vo_chain); if (!mpctx->video_out) { struct vo_extra ex = { @@ -370,7 +370,7 @@ static void adjust_sync(struct MPContext *mpctx, double v_pts, double frame_time // Generally, if position 0 gets a new frame, this must be called. static void handle_new_frame(struct MPContext *mpctx) { - assert(mpctx->num_next_frames >= 1); + mp_assert(mpctx->num_next_frames >= 1); double frame_time = 0; double pts = mpctx->next_frames[0]->pts; @@ -446,8 +446,8 @@ static bool needs_new_frame(struct MPContext *mpctx) // Queue a frame to mpctx->next_frames[]. Call only if needs_new_frame() signals ok. static void add_new_frame(struct MPContext *mpctx, struct mp_image *frame) { - assert(mpctx->num_next_frames < MP_ARRAY_SIZE(mpctx->next_frames)); - assert(frame); + mp_assert(mpctx->num_next_frames < MP_ARRAY_SIZE(mpctx->next_frames)); + mp_assert(frame); mpctx->next_frames[mpctx->num_next_frames++] = frame; if (mpctx->num_next_frames == 1) handle_new_frame(mpctx); @@ -967,7 +967,7 @@ static void schedule_frame(struct MPContext *mpctx, struct vo_frame *frame) static void calculate_frame_duration(struct MPContext *mpctx) { struct vo_chain *vo_c = mpctx->vo_chain; - assert(mpctx->num_past_frames >= 1 && mpctx->num_next_frames >= 1); + mp_assert(mpctx->num_past_frames >= 1 && mpctx->num_next_frames >= 1); double demux_duration = vo_c->filter->container_fps > 0 ? 1.0 / vo_c->filter->container_fps : -1; @@ -1220,7 +1220,7 @@ void write_video(struct MPContext *mpctx) if (!vo_is_ready_for_frame(vo, mpctx->display_sync_active ? -1 : pts)) return; - assert(mpctx->num_next_frames >= 1); + mp_assert(mpctx->num_next_frames >= 1); if (mpctx->num_past_frames >= MAX_NUM_VO_PTS) mpctx->num_past_frames--; @@ -1233,7 +1233,7 @@ void write_video(struct MPContext *mpctx) calculate_frame_duration(mpctx); int req = vo_get_num_req_frames(mpctx->video_out); - assert(req >= 1 && req <= VO_MAX_REQ_FRAMES); + mp_assert(req >= 1 && req <= VO_MAX_REQ_FRAMES); struct vo_frame dummy = { .pts = pts, .duration = -1, diff --git a/stream/stream.c b/stream/stream.c index 1414564a42..1ab23630aa 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -244,7 +244,7 @@ static int check_origin(int src, int new) // returns: bytes copied to dst (limited by len and available buffered data) static int ring_copy(struct stream *s, void *dst, int len, int pos) { - assert(len >= 0); + mp_assert(len >= 0); if (pos < s->buf_start || pos > s->buf_end) return 0; @@ -272,19 +272,19 @@ static int ring_copy(struct stream *s, void *dst, int len, int pos) // Does nothing if the size is adequate. Calling this with 0 ensures it uses the // default buffer size if possible. // The caller must check whether enough data was really allocated. -// keep: keep at least [buf_end-keep, buf_end] (used for assert()s only) +// keep: keep at least [buf_end-keep, buf_end] (used for mp_assert()s only) // new: new total size of buffer // returns: false if buffer allocation failed, true if reallocated or size ok static bool stream_resize_buffer(struct stream *s, int keep, int new) { - assert(keep >= s->buf_end - s->buf_cur); - assert(keep <= new); + mp_assert(keep >= s->buf_end - s->buf_cur); + mp_assert(keep <= new); new = MPMAX(new, s->requested_buffer_size); new = MPMIN(new, STREAM_MAX_BUFFER_SIZE); new = mp_round_next_power_of_2(new); - assert(keep <= new); // can't fail (if old buffer size was valid) + mp_assert(keep <= new); // can't fail (if old buffer size was valid) if (new == s->buffer_mask + 1) return true; @@ -302,9 +302,9 @@ static bool stream_resize_buffer(struct stream *s, int keep, int new) int new_len = 0; if (s->buffer) new_len = ring_copy(s, nbuf, new, s->buf_start + skip); - assert(new_len == old_used_len - skip); - assert(old_pos >= skip); // "keep" too low - assert(old_pos - skip <= new_len); + mp_assert(new_len == old_used_len - skip); + mp_assert(old_pos >= skip); // "keep" too low + mp_assert(old_pos - skip <= new_len); s->buf_start = 0; s->buf_cur = old_pos - skip; s->buf_end = new_len; @@ -412,7 +412,7 @@ static int stream_create_instance(const stream_info_t *sinfo, return STREAM_ERROR; } - assert(s->seekable == !!s->seek); + mp_assert(s->seekable == !!s->seek); if (s->mime_type) MP_VERBOSE(s, "Mime-type: '%s'\n", s->mime_type); @@ -425,7 +425,7 @@ static int stream_create_instance(const stream_info_t *sinfo, int stream_create_with_args(struct stream_open_args *args, struct stream **ret) { - assert(args->url); + mp_assert(args->url); int r = STREAM_NO_MATCH; *ret = NULL; @@ -498,7 +498,7 @@ stream_t *open_output_stream(const char *filename, struct mpv_global *global) // Partial reads are possible, even if EOF is not reached. static int stream_read_unbuffered(stream_t *s, void *buf, int len) { - assert(len >= 0); + mp_assert(len >= 0); if (len <= 0) return 0; @@ -510,7 +510,7 @@ static int stream_read_unbuffered(stream_t *s, void *buf, int len) s->eof = 1; return 0; } - assert(res <= len); + mp_assert(res <= len); // When reading succeeded we are obviously not at eof. s->eof = 0; s->pos += res; @@ -524,7 +524,7 @@ static int stream_read_unbuffered(stream_t *s, void *buf, int len) // returns: progress (false on EOF or on OOM or if enough data was available) static bool stream_read_more(struct stream *s, int forward) { - assert(forward >= 0); + mp_assert(forward >= 0); int forward_avail = s->buf_end - s->buf_cur; if (forward_avail >= forward) @@ -532,7 +532,7 @@ static bool stream_read_more(struct stream *s, int forward) // Avoid that many small reads will lead to many low-level read calls. forward = MPMAX(forward, s->requested_buffer_size / 2); - assert(forward_avail < forward); + mp_assert(forward_avail < forward); // Keep guaranteed seek-back. int buf_old = MPMIN(s->buf_cur - s->buf_start, s->requested_buffer_size / 2); @@ -542,11 +542,11 @@ static bool stream_read_more(struct stream *s, int forward) int buf_alloc = s->buffer_mask + 1; - assert(s->buf_start <= s->buf_cur); - assert(s->buf_cur <= s->buf_end); - assert(s->buf_cur < buf_alloc * 2); - assert(s->buf_end < buf_alloc * 2); - assert(s->buf_start < buf_alloc); + mp_assert(s->buf_start <= s->buf_cur); + mp_assert(s->buf_cur <= s->buf_end); + mp_assert(s->buf_cur < buf_alloc * 2); + mp_assert(s->buf_end < buf_alloc * 2); + mp_assert(s->buf_start < buf_alloc); // Note: read as much as possible, even if forward is much smaller. Do // this because the stream buffer is supposed to set an approx. minimum @@ -565,12 +565,12 @@ static bool stream_read_more(struct stream *s, int forward) // May have overwritten old data. if (s->buf_end - s->buf_start >= buf_alloc) { - assert(s->buf_end >= buf_alloc); + mp_assert(s->buf_end >= buf_alloc); s->buf_start = s->buf_end - buf_alloc; - assert(s->buf_start <= s->buf_cur); - assert(s->buf_cur <= s->buf_end); + mp_assert(s->buf_start <= s->buf_cur); + mp_assert(s->buf_cur <= s->buf_end); if (s->buf_start >= buf_alloc) { s->buf_start -= buf_alloc; @@ -580,7 +580,7 @@ static bool stream_read_more(struct stream *s, int forward) } // Must not have overwritten guaranteed old data. - assert(s->buf_cur - s->buf_start >= buf_old); + mp_assert(s->buf_cur - s->buf_start >= buf_old); if (s->buf_cur < s->buf_end) s->eof = 0; @@ -592,8 +592,8 @@ static bool stream_read_more(struct stream *s, int forward) // Return 0 on EOF, error, or if buf_size was 0. int stream_read_partial(stream_t *s, void *buf, int buf_size) { - assert(s->buf_cur <= s->buf_end); - assert(buf_size >= 0); + mp_assert(s->buf_cur <= s->buf_end); + mp_assert(buf_size >= 0); if (s->buf_cur == s->buf_end && buf_size > 0) { if (buf_size > (s->buffer_mask + 1) / 2) { // Direct read if the buffer is too small anyway. @@ -735,8 +735,8 @@ bool stream_seek(stream_t *s, int64_t pos) int64_t x = pos - (s->pos - (int)s->buf_end); if (x >= (int)s->buf_start) { s->buf_cur = x; - assert(s->buf_cur >= s->buf_start); - assert(s->buf_cur <= s->buf_end); + mp_assert(s->buf_cur >= s->buf_start); + mp_assert(s->buf_cur <= s->buf_end); return true; } } diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index 891c05c8b9..90aec96b87 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -705,10 +705,10 @@ int dvb_set_channel(stream_t *stream, unsigned int adapter, unsigned int n) dvb_priv_t *priv = stream->priv; dvb_state_t *state = priv->state; - assert(adapter < state->adapters_count); + mp_assert(adapter < state->adapters_count); int devno = state->adapters[adapter].devno; dvb_channels_list_t *new_list = state->adapters[adapter].list; - assert(n < new_list->NUM_CHANNELS); + mp_assert(n < new_list->NUM_CHANNELS); dvb_channel_t *channel = &(new_list->channels[n]); if (state->is_on) { //the fds are already open and we have to stop the demuxers diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index 7f12768728..3592624817 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -198,7 +198,7 @@ static int dvd_probe(const char *path, const char *ext, const char *sig) char data[50]; - assert(strlen(sig) <= sizeof(data)); + mp_assert(strlen(sig) <= sizeof(data)); if (fread(data, 50, 1, temp) == 1) { if (memcmp(data, sig, strlen(sig)) == 0) diff --git a/stream/stream_libarchive.c b/stream/stream_libarchive.c index d5c4e6c712..f113658766 100644 --- a/stream/stream_libarchive.c +++ b/stream/stream_libarchive.c @@ -80,7 +80,7 @@ static bool probe_zip(struct stream *s) static int mp_archive_probe(struct stream *src) { int flags = 0; - assert(stream_tell(src) == 0); + mp_assert(stream_tell(src) == 0); if (probe_zip(src)) flags |= MP_ARCHIVE_FLAG_MAYBE_ZIP; diff --git a/stream/stream_memory.c b/stream/stream_memory.c index e4696a73ad..0d8800e672 100644 --- a/stream/stream_memory.c +++ b/stream/stream_memory.c @@ -83,7 +83,7 @@ const stream_info_t stream_info_memory = { // Caller may need to set stream.stream_origin correctly. struct stream *stream_memory_open(struct mpv_global *global, void *data, int len) { - assert(len >= 0); + mp_assert(len >= 0); struct stream_open_args sargs = { .global = global, diff --git a/sub/dec_sub.c b/sub/dec_sub.c index 0386e9bf3a..118221a658 100644 --- a/sub/dec_sub.c +++ b/sub/dec_sub.c @@ -187,7 +187,7 @@ static struct sd *init_decoder(struct dec_sub *sub) struct dec_sub *sub_create(struct mpv_global *global, struct track *track, struct attachment_list *attachments, int order) { - assert(track->stream && track->stream->type == STREAM_SUB); + mp_assert(track->stream && track->stream->type == STREAM_SUB); struct dec_sub *sub = talloc(NULL, struct dec_sub); *sub = (struct dec_sub){ diff --git a/sub/draw_bmp.c b/sub/draw_bmp.c index 78e29f491b..fe72a74aef 100644 --- a/sub/draw_bmp.c +++ b/sub/draw_bmp.c @@ -169,9 +169,9 @@ static bool blend_overlay_with_video(struct mp_draw_sub_cache *p, continue; int x = sx * SLICE_W + s->x0; - assert(MP_IS_ALIGNED(x, p->align_x)); - assert(MP_IS_ALIGNED(w, p->align_x)); - assert(x + w <= p->w); + mp_assert(MP_IS_ALIGNED(x, p->align_x)); + mp_assert(MP_IS_ALIGNED(w, p->align_x)); + mp_assert(x + w <= p->w); repack_line(p->overlay_to_f32, 0, 0, x, y, w); repack_line(p->video_to_f32, 0, 0, x, y, w); @@ -257,8 +257,8 @@ static void mark_rect(struct mp_draw_sub_cache *p, int x0, int y0, int x1, int y x1 = MP_ALIGN_UP(x1, p->align_x); y1 = MP_ALIGN_UP(y1, p->align_y); - assert(x0 >= 0 && x0 <= x1 && x1 <= p->w); - assert(y0 >= 0 && y0 <= y1 && y1 <= p->h); + mp_assert(x0 >= 0 && x0 <= x1 && x1 <= p->w); + mp_assert(y0 >= 0 && y0 <= y1 && y1 <= p->h); const int sx0 = x0 / SLICE_W; const int sx1 = MPMIN(x1 / SLICE_W, p->s_w - 1); @@ -324,7 +324,7 @@ static void draw_ass_rgba(uint8_t *dst, ptrdiff_t dst_stride, static void render_ass(struct mp_draw_sub_cache *p, struct sub_bitmaps *sb) { - assert(sb->format == SUBBITMAP_LIBASS); + mp_assert(sb->format == SUBBITMAP_LIBASS); for (int i = 0; i < sb->num_parts; i++) { struct sub_bitmap *s = &sb->parts[i]; @@ -368,7 +368,7 @@ static void draw_rgba(uint8_t *dst, ptrdiff_t dst_stride, static bool render_rgba(struct mp_draw_sub_cache *p, struct part *part, struct sub_bitmaps *sb) { - assert(sb->format == SUBBITMAP_BGRA); + mp_assert(sb->format == SUBBITMAP_BGRA); if (part->change_id != sb->change_id) { for (int n = 0; n < part->num_imgs; n++) @@ -416,8 +416,8 @@ static bool render_rgba(struct mp_draw_sub_cache *p, struct part *part, sh = MPCLAMP(dh / fy, 1, s->h); } - assert(sx >= 0 && sw > 0 && sx + sw <= s->w); - assert(sy >= 0 && sh > 0 && sy + sh <= s->h); + mp_assert(sx >= 0 && sw > 0 && sx + sw <= s->w); + mp_assert(sy >= 0 && sh > 0 && sy + sh <= s->h); ptrdiff_t s_stride = s->stride; void *s_ptr = (char *)s->bitmap + s_stride * sy + sx * 4; @@ -443,8 +443,8 @@ static bool render_rgba(struct mp_draw_sub_cache *p, struct part *part, return false; } - assert(scaled->w == dw); - assert(scaled->h == dh); + mp_assert(scaled->w == dw); + mp_assert(scaled->h == dh); s_stride = scaled->stride[0]; s_ptr = scaled->planes[0]; @@ -476,7 +476,7 @@ static bool render_sb(struct mp_draw_sub_cache *p, struct sub_bitmaps *sb) static void clear_rgba_overlay(struct mp_draw_sub_cache *p) { - assert(p->rgba_overlay->imgfmt == IMGFMT_BGRA); + mp_assert(p->rgba_overlay->imgfmt == IMGFMT_BGRA); for (int y = 0; y < p->rgba_overlay->h; y++) { uint32_t *px = mp_image_pixel_ptr(p->rgba_overlay, 0, 0, y); @@ -544,7 +544,7 @@ static bool reinit_to_video(struct mp_draw_sub_cache *p) if (!p->video_to_f32) return false; mp_get_regular_imgfmt(&vfdesc, mp_repack_get_format_dst(p->video_to_f32)); - assert(vfdesc.num_planes); // must have succeeded + mp_assert(vfdesc.num_planes); // must have succeeded if (params->repr.sys == PL_COLOR_SYSTEM_RGB && vfdesc.num_planes >= 3) { use_shortcut = true; @@ -566,7 +566,7 @@ static bool reinit_to_video(struct mp_draw_sub_cache *p) return false; mp_get_regular_imgfmt(&vfdesc, mp_repack_get_format_dst(p->video_to_f32)); - assert(vfdesc.component_type == MP_COMPONENT_TYPE_FLOAT); + mp_assert(vfdesc.component_type == MP_COMPONENT_TYPE_FLOAT); p->blend_line = blend_line_f32; } @@ -580,7 +580,7 @@ static bool reinit_to_video(struct mp_draw_sub_cache *p) if (!p->video_from_f32) return false; - assert(mp_repack_get_format_dst(p->video_to_f32) == + mp_assert(mp_repack_get_format_dst(p->video_to_f32) == mp_repack_get_format_src(p->video_from_f32)); int overlay_fmt = 0; @@ -634,8 +634,8 @@ static bool reinit_to_video(struct mp_draw_sub_cache *p) p->align_x = mp_repack_get_align_x(p->video_to_f32); p->align_y = mp_repack_get_align_y(p->video_to_f32); - assert(p->align_x >= mp_repack_get_align_x(p->overlay_to_f32)); - assert(p->align_y >= mp_repack_get_align_y(p->overlay_to_f32)); + mp_assert(p->align_x >= mp_repack_get_align_x(p->overlay_to_f32)); + mp_assert(p->align_y >= mp_repack_get_align_y(p->overlay_to_f32)); if (p->align_x > SLICE_W || p->align_y > TILE_H) return false; @@ -700,16 +700,16 @@ static bool reinit_to_video(struct mp_draw_sub_cache *p) int ys = p->video_overlay->fmt.chroma_ys; if (xs || ys) { // Require float so format selection becomes simpler (maybe). - assert(rflags & REPACK_CREATE_PLANAR_F32); + mp_assert(rflags & REPACK_CREATE_PLANAR_F32); // For extracting the alpha plane, construct a gray format that is // compatible with the alpha one. struct mp_regular_imgfmt odesc = {0}; mp_get_regular_imgfmt(&odesc, overlay_fmt); - assert(odesc.component_size); + mp_assert(odesc.component_size); int aplane = odesc.num_planes - 1; - assert(odesc.planes[aplane].num_components == 1); - assert(odesc.planes[aplane].components[0] == 4); + mp_assert(odesc.planes[aplane].num_components == 1); + mp_assert(odesc.planes[aplane].components[0] == 4); struct mp_regular_imgfmt cadesc = odesc; cadesc.num_planes = 1; cadesc.planes[0] = (struct mp_regular_imgfmt_plane){1, {1}}; @@ -828,7 +828,7 @@ static bool check_reinit(struct mp_draw_sub_cache *p, char *mp_draw_sub_get_dbg_info(struct mp_draw_sub_cache *p) { - assert(p); + mp_assert(p); return talloc_asprintf(NULL, "align=%d:%d ov=%-7s, ov_f=%s, v_f=%s, a=%s, ca=%s, ca_f=%s", @@ -863,8 +863,8 @@ bool mp_draw_sub_bitmaps(struct mp_draw_sub_cache *p, struct mp_image *dst, // dst must at least be as large as the bounding box, or you may get memory // corruption. - assert(dst->w >= sbs_list->w); - assert(dst->h >= sbs_list->h); + mp_assert(dst->w >= sbs_list->w); + mp_assert(dst->h >= sbs_list->h); if (!check_reinit(p, &dst->params, true)) return false; @@ -941,9 +941,9 @@ static void init_rc_grid(struct rc_grid *gr, struct mp_draw_sub_cache *p, } } - assert(gr->r_h * gr->h >= p->h); - assert(!(gr->r_w & (SLICE_W - 1))); - assert(gr->r_w * gr->w >= p->w); + mp_assert(gr->r_h * gr->h >= p->h); + mp_assert(!(gr->r_w & (SLICE_W - 1))); + mp_assert(gr->r_w * gr->w >= p->w); // Init with empty (degenerate) rectangles. for (int y = 0; y < gr->h; y++) { diff --git a/sub/osd.c b/sub/osd.c index 75fbf90675..1fd9c5d9df 100644 --- a/sub/osd.c +++ b/sub/osd.c @@ -543,7 +543,7 @@ void osd_rescale_bitmaps(struct sub_bitmaps *imgs, int frame_w, int frame_h, double xscale = (double)vidw / frame_w; double yscale = (double)vidh / frame_h; if (compensate_par < 0) { - assert(res.display_par); + mp_assert(res.display_par); compensate_par = xscale / yscale / res.display_par / compensate_par * -1; } if (compensate_par > 0) @@ -589,7 +589,7 @@ struct sub_bitmaps *sub_bitmaps_copy(struct sub_bitmap_copy_cache **p_cache, // The bitmaps being refcounted is essential for performance, and for // not invalidating in->parts[*].bitmap pointers. - assert(in->packed && in->packed->bufs[0]); + mp_assert(in->packed && in->packed->bufs[0]); res->packed = mp_image_new_ref(res->packed); talloc_steal(res, res->packed); diff --git a/sub/osd_libass.c b/sub/osd_libass.c index 76a4c2d429..56ccca0627 100644 --- a/sub/osd_libass.c +++ b/sub/osd_libass.c @@ -170,7 +170,7 @@ static ASS_Event *add_osd_ass_event(ASS_Track *track, const char *style, event->Duration = 100; event->Style = find_style(track, style, 0); event->ReadOrder = n; - assert(event->Text == NULL); + mp_assert(event->Text == NULL); if (text) event->Text = strdup(text); return event; diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c index 3ae7e63c84..9a21c5b34b 100644 --- a/sub/sd_lavc.c +++ b/sub/sd_lavc.c @@ -284,8 +284,8 @@ static void read_sub_bitmaps(struct sd *sd, struct sub *sub) sub->src_w = MPMAX(sub->src_w, b->x + b->w); sub->src_h = MPMAX(sub->src_h, b->y + b->h); - assert(r->nb_colors > 0); - assert(r->nb_colors <= 256); + mp_assert(r->nb_colors > 0); + mp_assert(r->nb_colors <= 256); uint32_t pal[256] = {0}; memcpy(pal, data[1], r->nb_colors * 4); convert_pal(pal, 256, opts->sub_gray); @@ -541,7 +541,7 @@ static struct sub_bitmaps *get_bitmaps(struct sd *sd, struct mp_osd_res d, res->change_id++; if (!res->change_id) { - assert(priv->prevret_num == res->num_parts); + mp_assert(priv->prevret_num == res->num_parts); for (int n = 0; n < priv->prevret_num; n++) { struct sub_bitmap *a = &res->parts[n]; struct sub_bitmap *b = &priv->prevret[n]; diff --git a/test/img_format.c b/test/img_format.c index 3b553f6531..45bce258ed 100644 --- a/test/img_format.c +++ b/test/img_format.c @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) fprintf(f, " {"); for (int n = 0; n < MP_MAX_PLANES; n++) { if (n >= d.num_planes) { - assert(d.bpp[n] == 0 && d.xs[n] == 0 && d.ys[n] == 0); + mp_assert(d.bpp[n] == 0 && d.xs[n] == 0 && d.ys[n] == 0); continue; } fprintf(f, "%d/[%d:%d] ", d.bpp[n], d.xs[n], d.ys[n]); @@ -91,24 +91,24 @@ int main(int argc, char *argv[]) if (cm.pad) fprintf(f, "/%d", cm.pad); } else { - assert(cm.offset == 0); - assert(cm.pad == 0); + mp_assert(cm.offset == 0); + mp_assert(cm.pad == 0); } } fprintf(f, "}"); if (!(d.flags & (MP_IMGFLAG_PACKED_SS_YUV | MP_IMGFLAG_HAS_COMPS))) { - assert(cm.size == 0); - assert(cm.offset == 0); - assert(cm.pad == 0); + mp_assert(cm.size == 0); + mp_assert(cm.offset == 0); + mp_assert(cm.pad == 0); } } fprintf(f, "\n"); if (d.flags & MP_IMGFLAG_PACKED_SS_YUV) { - assert(!(d.flags & MP_IMGFLAG_HAS_COMPS)); + mp_assert(!(d.flags & MP_IMGFLAG_HAS_COMPS)); uint8_t offsets[10]; bool r = mp_imgfmt_get_packed_yuv_locations(mpfmt, offsets); - assert(r); + mp_assert(r); fprintf(f, " luma_offsets=["); for (int x = 0; x < d.align_x; x++) fprintf(f, " %d", offsets[x]); @@ -122,7 +122,7 @@ int main(int argc, char *argv[]) fr->width = 128; fr->height = 128; int err = av_frame_get_buffer(fr, MP_IMAGE_BYTE_ALIGN); - assert(err >= 0); + mp_assert(err >= 0); struct mp_image *mpi = mp_image_alloc(mpfmt, fr->width, fr->height); if (mpi) { // A rather fuzzy test, which might fail even if there's no bug. @@ -190,8 +190,8 @@ int main(int argc, char *argv[]) } for (int n = avd->nb_components; n < 4; n++) { const AVComponentDescriptor *cd = &avd->comp[n]; - assert(!cd->plane && !cd->step && !cd->offset && !cd->shift && - !cd->depth); + mp_assert(!cd->plane && !cd->step && !cd->offset && !cd->shift && + !cd->depth); } } diff --git a/test/img_utils.c b/test/img_utils.c index 71764f304f..ec2cd8ef49 100644 --- a/test/img_utils.c +++ b/test/img_utils.c @@ -45,7 +45,7 @@ void init_imgfmts_list(void) enum AVPixelFormat fmt = av_pix_fmt_desc_get_id(avd); int mpfmt = pixfmt2imgfmt(fmt); if (!mpfmt) { - assert(num_pixfmt_unsup < MP_ARRAY_SIZE(pixfmt_unsup)); + mp_assert(num_pixfmt_unsup < MP_ARRAY_SIZE(pixfmt_unsup)); pixfmt_unsup[num_pixfmt_unsup++] = fmt; } } @@ -54,7 +54,7 @@ void init_imgfmts_list(void) struct mp_imgfmt_desc d = mp_imgfmt_get_desc(fmt); enum AVPixelFormat pixfmt = imgfmt2pixfmt(fmt); if (d.id || pixfmt != AV_PIX_FMT_NONE) { - assert(num_imgfmts < MP_ARRAY_SIZE(imgfmts)); // enlarge that array + mp_assert(num_imgfmts < MP_ARRAY_SIZE(imgfmts)); // enlarge that array imgfmts[num_imgfmts++] = fmt; } } diff --git a/test/repack.c b/test/repack.c index cf6de36aa9..811d96318b 100644 --- a/test/repack.c +++ b/test/repack.c @@ -195,10 +195,10 @@ static int try_repack(FILE *f, int imgfmt, int flags, int not_if_fmt) // If both exists, they must be always symmetric. if (un && pa) { - assert(mp_repack_get_format_src(pa) == mp_repack_get_format_dst(un)); - assert(mp_repack_get_format_src(un) == mp_repack_get_format_dst(pa)); - assert(mp_repack_get_align_x(pa) == mp_repack_get_align_x(un)); - assert(mp_repack_get_align_y(pa) == mp_repack_get_align_y(un)); + mp_assert(mp_repack_get_format_src(pa) == mp_repack_get_format_dst(un)); + mp_assert(mp_repack_get_format_src(un) == mp_repack_get_format_dst(pa)); + mp_assert(mp_repack_get_align_x(pa) == mp_repack_get_align_x(un)); + mp_assert(mp_repack_get_align_y(pa) == mp_repack_get_align_y(un)); } int a = 0; @@ -214,10 +214,10 @@ static int try_repack(FILE *f, int imgfmt, int flags, int not_if_fmt) // Skip the identity ones because they're uninteresting, and add too much // noise. But still make sure they behave as expected. if (a == imgfmt && b == imgfmt) { - assert(is_true_planar(imgfmt)); + mp_assert(is_true_planar(imgfmt)); // (note that we require alpha-enabled zimg) - assert(mp_zimg_supports_in_format(imgfmt)); - assert(un && pa); + mp_assert(mp_zimg_supports_in_format(imgfmt)); + mp_assert(un && pa); talloc_free(pa); talloc_free(un); return b; @@ -230,7 +230,7 @@ static int try_repack(FILE *f, int imgfmt, int flags, int not_if_fmt) return 0; } - assert(a == imgfmt); + mp_assert(a == imgfmt); if (b && b == not_if_fmt) { talloc_free(pa); talloc_free(un); @@ -270,7 +270,7 @@ static int try_repack(FILE *f, int imgfmt, int flags, int not_if_fmt) struct mp_image *ib = mp_image_alloc(fmt_b, e->w * 7 * ax, e->h * 6 * ay); int sx = 4 * ax, sy = 3 * ay, dx = 3 * ax, dy = 2 * ay; - assert(ia && ib); + mp_assert(ia && ib); mp_image_params_guess_csp(&ia->params); mp_image_params_guess_csp(&ib->params); @@ -289,7 +289,7 @@ static int try_repack(FILE *f, int imgfmt, int flags, int not_if_fmt) struct mp_image *srci = pack ? ib : ia; bool r = repack_config_buffers(repacker, 0, dsti, 0, srci, NULL); - assert(r); + mp_assert(r); for (int p = 0; p < srci->num_planes; p++) { uint8_t *ptr = mp_image_pixel_ptr(srci, p, sx, sy); @@ -335,7 +335,7 @@ static void check_float_repack(int imgfmt, enum pl_color_system csp, int bpp = desc.component_size; int comp_bits = desc.component_size * 8 + MPMIN(desc.component_pad, 0); - assert(bpp == 1 || bpp == 2); + mp_assert(bpp == 1 || bpp == 2); int w = 1 << (bpp * 8); @@ -346,14 +346,14 @@ static void check_float_repack(int imgfmt, enum pl_color_system csp, } struct mp_image *src = mp_image_alloc(imgfmt, w, 1); - assert(src); + mp_assert(src); src->params.repr.sys = csp; src->params.repr.levels = levels; mp_image_params_guess_csp(&src->params); // mpv may not allow all combinations - assert(src->params.repr.sys == csp); - assert(src->params.repr.levels == levels); + mp_assert(src->params.repr.sys == csp); + mp_assert(src->params.repr.levels == levels); for (int p = 0; p < src->num_planes; p++) { int val = 0; @@ -373,13 +373,13 @@ static void check_float_repack(int imgfmt, enum pl_color_system csp, mp_repack_create_planar(src->imgfmt, false, REPACK_CREATE_PLANAR_F32); struct mp_repack *from_f = mp_repack_create_planar(src->imgfmt, true, REPACK_CREATE_PLANAR_F32); - assert(to_f && from_f); + mp_assert(to_f && from_f); struct mp_image *z_f = mp_image_alloc(mp_repack_get_format_dst(to_f), w, 1); struct mp_image *r_f = mp_image_alloc(z_f->imgfmt, w, 1); struct mp_image *z_i = mp_image_alloc(src->imgfmt, w, 1); struct mp_image *r_i = mp_image_alloc(src->imgfmt, w, 1); - assert(z_f && r_f && z_i && r_i); + mp_assert(z_f && r_f && z_i && r_i); z_f->params.color = r_f->params.color = z_i->params.color = r_i->params.color = src->params.color; diff --git a/test/scale_test.c b/test/scale_test.c index 346fbfbda2..c835a7bb5d 100644 --- a/test/scale_test.c +++ b/test/scale_test.c @@ -20,9 +20,9 @@ static struct mp_image *gen_repack_test_img(int w, int h, int bytes, bool rgb, }, }; int mpfmt = mp_find_regular_imgfmt(&planar_desc); - assert(mpfmt); + mp_assert(mpfmt); struct mp_image *mpi = mp_image_alloc(mpfmt, w, h); - assert(mpi); + mp_assert(mpi); // Well, I have no idea what makes a good test image. So here's some crap. // This contains bars/tiles of solid colors. For each of R/G/B, it toggles @@ -73,12 +73,12 @@ static void dump_image(struct scale_test *stest, const char *name, static void assert_imgs_equal(struct scale_test *stest, FILE *f, struct mp_image *ref, struct mp_image *new) { - assert(ref->imgfmt == new->imgfmt); - assert(ref->w == new->w); - assert(ref->h == new->h); + mp_assert(ref->imgfmt == new->imgfmt); + mp_assert(ref->w == new->w); + mp_assert(ref->h == new->h); - assert(ref->fmt.flags & MP_IMGFLAG_BYTE_ALIGNED); - assert(ref->fmt.bpp[0]); + mp_assert(ref->fmt.flags & MP_IMGFLAG_BYTE_ALIGNED); + mp_assert(ref->fmt.bpp[0]); for (int p = 0; p < ref->num_planes; p++) { for (int y = 0; y < ref->h; y++) { @@ -155,29 +155,29 @@ void repack_test_run(struct scale_test *stest) mp_imgfmt_to_name(test_img->imgfmt)); struct mp_image *dst = mp_image_alloc(mpfmt, test_img->w, test_img->h); - assert(dst); + mp_assert(dst); // This tests packing. bool ok = stest->fns->scale(stest->fns_priv, dst, test_img); - assert(ok); + mp_assert(ok); // Cross-check with swscale in the other direction. // (Mostly so we don't have to worry about padding.) struct mp_image *src2 = mp_image_alloc(test_img->imgfmt, test_img->w, test_img->h); - assert(src2); + mp_assert(src2); ok = mp_sws_scale(stest->sws, src2, dst) >= 0; assert_imgs_equal(stest, f, test_img, src2); // Assume the other conversion direction also works. - assert(stest->fns->supports_fmts(stest->fns_priv, test_img->imgfmt, mpfmt)); + mp_assert(stest->fns->supports_fmts(stest->fns_priv, test_img->imgfmt, mpfmt)); struct mp_image *back = mp_image_alloc(test_img->imgfmt, dst->w, dst->h); - assert(back); + mp_assert(back); // This tests unpacking. ok = stest->fns->scale(stest->fns_priv, back, dst); - assert(ok); + mp_assert(ok); assert_imgs_equal(stest, f, test_img, back); diff --git a/test/test_utils.c b/test/test_utils.c index 22b53b5e32..67ef9f01c3 100644 --- a/test/test_utils.c +++ b/test/test_utils.c @@ -43,7 +43,7 @@ void assert_float_equal_impl(const char *file, int line, FILE *test_open_out(const char *outdir, const char *name) { mp_mkdirp(outdir); - assert(mp_path_isdir(outdir)); + mp_assert(mp_path_isdir(outdir)); char *path = mp_tprintf(4096, "%s/%s", outdir, name); FILE *f = fopen(path, "wb"); if (!f) { diff --git a/test/test_utils.h b/test/test_utils.h index 7db358e21a..3730528685 100644 --- a/test/test_utils.h +++ b/test/test_utils.h @@ -6,8 +6,8 @@ #include "common/common.h" -#define assert_true(x) assert(x) -#define assert_false(x) assert(!(x)) +#define assert_true(x) mp_assert(x) +#define assert_false(x) mp_assert(!(x)) #define assert_int_equal(a, b) \ assert_int_equal_impl(__FILE__, __LINE__, (a), (b)) #define assert_string_equal(a, b) \ diff --git a/video/csputils.c b/video/csputils.c index 0b000a9aac..39bd804d34 100644 --- a/video/csputils.c +++ b/video/csputils.c @@ -224,7 +224,7 @@ static void apply_chromatic_adaptation(struct pl_cie_xy src, // This is broken. Use mp_get_csp_uint_mul(). double mp_get_csp_mul(enum pl_color_system csp, int input_bits, int texture_bits) { - assert(texture_bits >= input_bits); + mp_assert(texture_bits >= input_bits); // Convenience for some irrelevant cases, e.g. rgb565 or disabling expansion. if (!input_bits) @@ -303,7 +303,7 @@ void mp_get_csp_uint_mul(enum pl_color_system csp, enum pl_color_levels levels, */ static void luma_coeffs(struct pl_transform3x3 *mat, float lr, float lg, float lb) { - assert(fabs(lr+lg+lb - 1) < 1e-6); + mp_assert(fabs(lr+lg+lb - 1) < 1e-6); *mat = (struct pl_transform3x3) { { {{1, 0, 2 * (1-lr) }, {1, -2 * (1-lb) * lb/lg, -2 * (1-lr) * lr/lg }, diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index c96a51fe73..3045af9917 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -369,7 +369,7 @@ static void add_all_hwdec_methods(struct hwdec_info **infos, int *num_infos) info.pix_fmt = cfg->pix_fmt; const char *name = av_hwdevice_get_type_name(cfg->device_type); - assert(name); // API violation by libavcodec + mp_assert(name); // API violation by libavcodec // nvdec hwaccels and the cuvid full decoder clash with their // naming, so fix it here; we also prefer nvdec for the hwaccel. @@ -406,7 +406,7 @@ static void add_all_hwdec_methods(struct hwdec_info **infos, int *num_infos) const char *name = wrapper; if (!name) name = av_get_pix_fmt_name(info.pix_fmt); - assert(name); // API violation by libavcodec + mp_assert(name); // API violation by libavcodec snprintf(info.method_name, sizeof(info.method_name), "%s", name); @@ -455,7 +455,7 @@ static AVBufferRef *hwdec_create_dev(struct mp_filter *vd, bool autoprobe) { vd_ffmpeg_ctx *ctx = vd->priv; - assert(hwdec->lavc_device); + mp_assert(hwdec->lavc_device); if (hwdec->copying) { const struct hwcontext_fns *fns = @@ -706,7 +706,7 @@ static void init_avctx(struct mp_filter *vd) m_config_cache_update(ctx->opts_cache); - assert(!ctx->avctx); + mp_assert(!ctx->avctx); const AVCodec *lavc_codec = NULL; @@ -992,7 +992,7 @@ static enum AVPixelFormat get_format_hwdec(struct AVCodecContext *avctx, MP_VERBOSE(vd, "Codec profile: %s (0x%x)\n", profile ? profile : "unknown", avctx->profile); - assert(ctx->use_hwdec); + mp_assert(ctx->use_hwdec); ctx->hwdec_request_reinit |= ctx->hwdec_failed; ctx->hwdec_failed = false; @@ -1188,7 +1188,7 @@ static void send_queued_packet(struct mp_filter *vd) { vd_ffmpeg_ctx *ctx = vd->priv; - assert(ctx->num_requeue_packets); + mp_assert(ctx->num_requeue_packets); if (send_packet(vd, ctx->requeue_packets[0]) != AVERROR(EAGAIN)) { talloc_free(ctx->requeue_packets[0]); @@ -1232,7 +1232,7 @@ static int decode_frame(struct mp_filter *vd) // If something was decoded successfully, it must return a frame with valid // data. - assert(ctx->pic->buf[0]); + mp_assert(ctx->pic->buf[0]); struct mp_image *mpi = mp_image_from_av_frame(ctx->pic); if (!mpi) { diff --git a/video/filter/refqueue.c b/video/filter/refqueue.c index 031feb8c96..078981c65c 100644 --- a/video/filter/refqueue.c +++ b/video/filter/refqueue.c @@ -87,7 +87,7 @@ void mp_refqueue_add_in_format(struct mp_refqueue *q, int fmt, int subfmt) // The minimum number of frames required before and after the current frame. void mp_refqueue_set_refs(struct mp_refqueue *q, int past, int future) { - assert(past >= 0 && future >= 0); + mp_assert(past >= 0 && future >= 0); q->needed_past_frames = past; q->needed_future_frames = MPMAX(future, 1); // at least 1 for determining PTS } @@ -154,12 +154,12 @@ void mp_refqueue_flush(struct mp_refqueue *q) static void mp_refqueue_add_input(struct mp_refqueue *q, struct mp_image *img) { - assert(img); + mp_assert(img); MP_TARRAY_INSERT_AT(q, q->queue, q->num_queue, 0, img); q->pos++; - assert(q->pos >= 0 && q->pos < q->num_queue); + mp_assert(q->pos >= 0 && q->pos < q->num_queue); } static bool mp_refqueue_need_input(struct mp_refqueue *q) @@ -181,7 +181,7 @@ static bool output_next_field(struct mp_refqueue *q) if (!mp_refqueue_should_deint(q)) return false; - assert(q->pos >= 0); + mp_assert(q->pos >= 0); // If there's no (reasonable) timestamp, also skip the field. if (q->pos == 0) @@ -210,16 +210,16 @@ static void mp_refqueue_next(struct mp_refqueue *q) q->pos--; q->second_field = false; - assert(q->pos >= -1 && q->pos < q->num_queue); + mp_assert(q->pos >= -1 && q->pos < q->num_queue); // Discard unneeded past frames. while (q->num_queue - (q->pos + 1) > q->needed_past_frames) { - assert(q->num_queue > 0); + mp_assert(q->num_queue > 0); talloc_free(q->queue[q->num_queue - 1]); q->num_queue--; } - assert(q->pos >= -1 && q->pos < q->num_queue); + mp_assert(q->pos >= -1 && q->pos < q->num_queue); } // Advance current field, depending on interlace flags. diff --git a/video/filter/vf_gpu.c b/video/filter/vf_gpu.c index d2ba990a00..29ad46a848 100644 --- a/video/filter/vf_gpu.c +++ b/video/filter/vf_gpu.c @@ -296,7 +296,7 @@ static struct mp_filter *gpu_create(struct mp_filter *parent, void *options) offscreen_ctx_set_current(priv->ctx, true); priv->renderer = gl_video_init(priv->ctx->ra, f->log, f->global); - assert(priv->renderer); // can't fail (strangely) + mp_assert(priv->renderer); // can't fail (strangely) offscreen_ctx_set_current(priv->ctx, false); diff --git a/video/filter/vf_vapoursynth.c b/video/filter/vf_vapoursynth.c index c0d4fdb474..d2ab916220 100644 --- a/video/filter/vf_vapoursynth.c +++ b/video/filter/vf_vapoursynth.c @@ -289,10 +289,10 @@ static void VS_CC vs_frame_done(void *userData, const VSFrame *f, int n, mp_mutex_lock(&p->lock); // If these assertions fail, n is an unrequested frame (or filtered twice). - assert(n >= p->out_frameno && n < p->out_frameno + p->max_requests); + mp_assert(n >= p->out_frameno && n < p->out_frameno + p->max_requests); int index = n - p->out_frameno; MP_TRACE(p, "filtered frame %d (%d)\n", n, index); - assert(p->requested[index] == &dummy_img); + mp_assert(p->requested[index] == &dummy_img); if (!res && !p->shutdown) { if (p->eof) { @@ -407,7 +407,7 @@ static void vf_vapoursynth_process(struct mp_filter *f) // This happens on EOF draining and format changes. if (p->requested[0] == &dummy_img_eof) { MP_VERBOSE(p, "finishing up\n"); - assert(p->eof); + mp_assert(p->eof); mp_mutex_unlock(&p->lock); destroy_vs(p); mp_filter_internal_mark_progress(f); @@ -567,8 +567,8 @@ static void destroy_vs(struct priv *p) p->drv->unload(p); - assert(!p->in_node_active); - assert(num_requested(p) == 0); // async callback didn't return? + mp_assert(!p->in_node_active); + mp_assert(num_requested(p) == 0); // async callback didn't return? p->shutdown = false; p->eof = false; diff --git a/video/hwdec.c b/video/hwdec.c index 110a44fa12..deba518e82 100644 --- a/video/hwdec.c +++ b/video/hwdec.c @@ -28,8 +28,8 @@ void hwdec_devices_destroy(struct mp_hwdec_devices *devs) { if (!devs) return; - assert(!devs->num_hwctxs); // must have been hwdec_devices_remove()ed - assert(!devs->load_api); // must have been unset + mp_assert(!devs->num_hwctxs); // must have been hwdec_devices_remove()ed + mp_assert(!devs->load_api); // must have been unset mp_mutex_destroy(&devs->lock); talloc_free(devs); } diff --git a/video/img_format.c b/video/img_format.c index 20e23a9eb0..cf3c75254f 100644 --- a/video/img_format.c +++ b/video/img_format.c @@ -480,7 +480,7 @@ bool mp_imgfmt_get_packed_yuv_locations(int imgfmt, uint8_t *luma_offsets) if (!(desc.flags & MP_IMGFLAG_PACKED_SS_YUV)) return false; - assert(desc.num_planes == 1); + mp_assert(desc.num_planes == 1); // Guess at which positions the additional luma samples are. We iterate // starting with the first byte, and then put a luma sample at places diff --git a/video/mp_image.c b/video/mp_image.c index a237ef8d3e..7890b9f9f4 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -165,8 +165,8 @@ fail: static bool mp_image_alloc_planes(struct mp_image *mpi) { - assert(!mpi->planes[0]); - assert(!mpi->bufs[0]); + mp_assert(!mpi->planes[0]); + mp_assert(!mpi->bufs[0]); int align = MP_IMAGE_BYTE_ALIGN; @@ -231,7 +231,7 @@ int mp_image_plane_h(struct mp_image *mpi, int plane) // Caller has to make sure this doesn't exceed the allocated plane data/strides. void mp_image_set_size(struct mp_image *mpi, int w, int h) { - assert(w >= 0 && h >= 0); + mp_assert(w >= 0 && h >= 0); mpi->w = mpi->params.w = w; mpi->h = mpi->params.h = h; } @@ -287,8 +287,8 @@ struct mp_image *mp_image_new_copy(struct mp_image *img) // Only works with ref-counted images, and can't change image size/format. void mp_image_steal_data(struct mp_image *dst, struct mp_image *src) { - assert(dst->imgfmt == src->imgfmt && dst->w == src->w && dst->h == src->h); - assert(dst->bufs[0] && src->bufs[0]); + mp_assert(dst->imgfmt == src->imgfmt && dst->w == src->w && dst->h == src->h); + mp_assert(dst->bufs[0] && src->bufs[0]); mp_image_destructor(dst); // unref old talloc_free_children(dst); @@ -429,7 +429,7 @@ bool mp_image_make_writeable(struct mp_image *img) if (!new) return false; mp_image_steal_data(img, new); - assert(mp_image_is_writeable(img)); + mp_assert(mp_image_is_writeable(img)); return true; } @@ -472,9 +472,9 @@ void memcpy_pic(void *dst, const void *src, int bytesPerLine, int height, void mp_image_copy(struct mp_image *dst, struct mp_image *src) { - assert(dst->imgfmt == src->imgfmt); - assert(dst->w == src->w && dst->h == src->h); - assert(mp_image_is_writeable(dst)); + mp_assert(dst->imgfmt == src->imgfmt); + mp_assert(dst->w == src->w && dst->h == src->h); + mp_assert(mp_image_is_writeable(dst)); for (int n = 0; n < dst->num_planes; n++) { int line_bytes = (mp_image_plane_w(dst, n) * dst->fmt.bpp[n] + 7) / 8; int plane_h = mp_image_plane_h(dst, n); @@ -507,7 +507,7 @@ static void assign_bufref(AVBufferRef **dst, AVBufferRef *new) void mp_image_copy_attributes(struct mp_image *dst, struct mp_image *src) { - assert(dst != src); + mp_assert(dst != src); dst->pict_type = src->pict_type; dst->fields = src->fields; @@ -564,11 +564,11 @@ void mp_image_copy_attributes(struct mp_image *dst, struct mp_image *src) // x0/y0 must be naturally aligned. void mp_image_crop(struct mp_image *img, int x0, int y0, int x1, int y1) { - assert(x0 >= 0 && y0 >= 0); - assert(x0 <= x1 && y0 <= y1); - assert(x1 <= img->w && y1 <= img->h); - assert(!(x0 & (img->fmt.align_x - 1))); - assert(!(y0 & (img->fmt.align_y - 1))); + mp_assert(x0 >= 0 && y0 >= 0); + mp_assert(x0 <= x1 && y0 <= y1); + mp_assert(x1 <= img->w && y1 <= img->h); + mp_assert(!(x0 & (img->fmt.align_x - 1))); + mp_assert(!(y0 & (img->fmt.align_y - 1))); for (int p = 0; p < img->num_planes; ++p) { img->planes[p] += (y0 >> img->fmt.ys[p]) * img->stride[p] + @@ -585,7 +585,7 @@ void mp_image_crop_rc(struct mp_image *img, struct mp_rect rc) // Repeatedly write count patterns of src[0..src_size] to p. static void memset_pattern(void *p, size_t count, uint8_t *src, size_t src_size) { - assert(src_size >= 1); + mp_assert(src_size >= 1); if (src_size == 1) { memset(p, src[0], count); @@ -632,11 +632,11 @@ static bool endian_swap_bytes(void *d, size_t bytes, size_t word_size) // Alpha is cleared to 0 (fully transparent). void mp_image_clear(struct mp_image *img, int x0, int y0, int x1, int y1) { - assert(x0 >= 0 && y0 >= 0); - assert(x0 <= x1 && y0 <= y1); - assert(x1 <= img->w && y1 <= img->h); - assert(!(x0 & (img->fmt.align_x - 1))); - assert(!(y0 & (img->fmt.align_y - 1))); + mp_assert(x0 >= 0 && y0 >= 0); + mp_assert(x0 <= x1 && y0 <= y1); + mp_assert(x1 <= img->w && y1 <= img->h); + mp_assert(!(x0 & (img->fmt.align_x - 1))); + mp_assert(!(y0 & (img->fmt.align_y - 1))); struct mp_image area = *img; struct mp_imgfmt_desc *fmt = &area.fmt; @@ -1313,8 +1313,8 @@ void memset16_pic(void *dst, int fill, int unitsPerLine, int height, int stride) // You cannot access e.g. individual luma pixels on the luma plane with yuv420p. void *mp_image_pixel_ptr(struct mp_image *img, int plane, int x, int y) { - assert(MP_IS_ALIGNED(x, img->fmt.align_x)); - assert(MP_IS_ALIGNED(y, img->fmt.align_y)); + mp_assert(MP_IS_ALIGNED(x, img->fmt.align_x)); + mp_assert(MP_IS_ALIGNED(y, img->fmt.align_y)); return mp_image_pixel_ptr_ny(img, plane, x, y); } @@ -1323,8 +1323,8 @@ void *mp_image_pixel_ptr(struct mp_image *img, int plane, int x, int y) // Useful for addressing luma rows. void *mp_image_pixel_ptr_ny(struct mp_image *img, int plane, int x, int y) { - assert(MP_IS_ALIGNED(x, img->fmt.align_x)); - assert(MP_IS_ALIGNED(y, 1 << img->fmt.ys[plane])); + mp_assert(MP_IS_ALIGNED(x, img->fmt.align_x)); + mp_assert(MP_IS_ALIGNED(y, 1 << img->fmt.ys[plane])); return img->planes[plane] + img->stride[plane] * (ptrdiff_t)(y >> img->fmt.ys[plane]) + (x >> img->fmt.xs[plane]) * (size_t)img->fmt.bpp[plane] / 8; diff --git a/video/mp_image_pool.c b/video/mp_image_pool.c index 3d44a0897c..2ed9fd7395 100644 --- a/video/mp_image_pool.c +++ b/video/mp_image_pool.c @@ -90,7 +90,7 @@ void mp_image_pool_clear(struct mp_image_pool *pool) struct image_flags *it = img->priv; bool referenced; pool_lock(); - assert(it->pool_alive); + mp_assert(it->pool_alive); it->pool_alive = false; referenced = it->referenced; pool_unlock(); @@ -108,7 +108,7 @@ static void unref_image(void *opaque, uint8_t *data) struct image_flags *it = img->priv; bool alive; pool_lock(); - assert(it->referenced); + mp_assert(it->referenced); it->referenced = false; alive = it->pool_alive; pool_unlock(); @@ -126,7 +126,7 @@ struct mp_image *mp_image_pool_get_no_alloc(struct mp_image_pool *pool, int fmt, for (int n = 0; n < pool->num_images; n++) { struct mp_image *img = pool->images[n]; struct image_flags *img_it = img->priv; - assert(img_it->pool_alive); + mp_assert(img_it->pool_alive); if (!img_it->referenced) { if (img->imgfmt == fmt && img->w == w && img->h == h) { if (pool->use_lru) { @@ -148,7 +148,7 @@ struct mp_image *mp_image_pool_get_no_alloc(struct mp_image_pool *pool, int fmt, // and unreffing images from other threads does not allocate new images, // no synchronization is required here. for (int p = 0; p < MP_MAX_PLANES; p++) - assert(!!new->bufs[p] == !p); // only 1 AVBufferRef + mp_assert(!!new->bufs[p] == !p); // only 1 AVBufferRef struct mp_image *ref = mp_image_new_dummy_ref(new); @@ -164,7 +164,7 @@ struct mp_image *mp_image_pool_get_no_alloc(struct mp_image_pool *pool, int fmt, } struct image_flags *it = new->priv; - assert(!it->referenced && it->pool_alive); + mp_assert(!it->referenced && it->pool_alive); it->referenced = true; it->order = ++pool->lru_counter; return ref; @@ -236,7 +236,7 @@ bool mp_image_pool_make_writeable(struct mp_image_pool *pool, if (!new) return false; mp_image_steal_data(img, new); - assert(mp_image_is_writeable(img)); + mp_assert(mp_image_is_writeable(img)); return true; } @@ -292,7 +292,7 @@ struct mp_image *mp_image_hw_download(struct mp_image *src, if (!imgfmt) return NULL; - assert(src->hwctx); + mp_assert(src->hwctx); AVHWFramesContext *fctx = (void *)src->hwctx->data; struct mp_image *dst = diff --git a/video/out/bitmap_packer.c b/video/out/bitmap_packer.c index 5ef090b823..c8b8a6a6bd 100644 --- a/video/out/bitmap_packer.c +++ b/video/out/bitmap_packer.c @@ -157,8 +157,8 @@ int packer_pack(struct bitmap_packer *packer) if (y >= 0) { packer->used_width = MPMIN(used_width, packer->w); packer->used_height = MPMIN(y, packer->h); - assert(packer->w == 0 || IS_POWER_OF_2(packer->w)); - assert(packer->h == 0 || IS_POWER_OF_2(packer->h)); + mp_assert(packer->w == 0 || IS_POWER_OF_2(packer->w)); + mp_assert(packer->h == 0 || IS_POWER_OF_2(packer->h)); if (packer->padding) { for (int i = 0; i < packer->count; i++) { packer->result[i].x += packer->padding; diff --git a/video/out/d3d11/context.c b/video/out/d3d11/context.c index feffca7c5a..1395d00b31 100644 --- a/video/out/d3d11/context.c +++ b/video/out/d3d11/context.c @@ -240,7 +240,7 @@ static bool d3d11_start_frame(struct ra_swapchain *sw, struct ra_fbo *out_fbo) if (!out_fbo) return true; - assert(!p->backbuffer); + mp_assert(!p->backbuffer); p->backbuffer = get_backbuffer(sw->ctx); if (!p->backbuffer) diff --git a/video/out/d3d11/ra_d3d11.c b/video/out/d3d11/ra_d3d11.c index d4273dea50..e36c9eee19 100644 --- a/video/out/d3d11/ra_d3d11.c +++ b/video/out/d3d11/ra_d3d11.c @@ -1250,8 +1250,8 @@ static void blit(struct ra *ra, struct ra_tex *dst, struct ra_tex *src, struct mp_rect dst_rc = *dst_rc_ptr; struct mp_rect src_rc = *src_rc_ptr; - assert(dst->params.dimensions == 2); - assert(src->params.dimensions == 2); + mp_assert(dst->params.dimensions == 2); + mp_assert(src->params.dimensions == 2); // A zero-sized target rectangle is a no-op if (!mp_rect_w(dst_rc) || !mp_rect_h(dst_rc)) diff --git a/video/out/dither.c b/video/out/dither.c index 44558baeea..38c86567f9 100644 --- a/video/out/dither.c +++ b/video/out/dither.c @@ -30,6 +30,7 @@ #include +#include "misc/mp_assert.h" #include "mpv_talloc.h" #include "dither.h" @@ -54,7 +55,7 @@ struct ctx { static void makegauss(struct ctx *k, unsigned int sizeb) { - assert(sizeb >= 1 && sizeb <= MAX_SIZEB); + mp_assert(sizeb >= 1 && sizeb <= MAX_SIZEB); av_lfg_init(&k->avlfg, 123); @@ -94,7 +95,7 @@ static void makegauss(struct ctx *k, unsigned int sizeb) for (unsigned int c = 0; c < k->size2; c++) { uint64_t oldtotal = total; total += k->gauss[c]; - assert(total >= oldtotal); + mp_assert(total >= oldtotal); } } diff --git a/video/out/dr_helper.c b/video/out/dr_helper.c index ac440a745d..0074734f21 100644 --- a/video/out/dr_helper.c +++ b/video/out/dr_helper.c @@ -30,7 +30,7 @@ static void dr_helper_destroy(void *ptr) // All references must have been freed on destruction, or we'll have // dangling pointers. - assert(atomic_load(&dr->dr_in_flight) == 0); + mp_assert(atomic_load(&dr->dr_in_flight) == 0); mp_mutex_destroy(&dr->thread_lock); } @@ -55,7 +55,7 @@ struct dr_helper *dr_helper_create(struct mp_dispatch_queue *dispatch, void dr_helper_acquire_thread(struct dr_helper *dr) { mp_mutex_lock(&dr->thread_lock); - assert(!dr->thread_valid); // fails on API user errors + mp_assert(!dr->thread_valid); // fails on API user errors dr->thread_valid = true; dr->thread_id = mp_thread_current_id(); mp_mutex_unlock(&dr->thread_lock); @@ -65,8 +65,8 @@ void dr_helper_release_thread(struct dr_helper *dr) { mp_mutex_lock(&dr->thread_lock); // Fails on API user errors. - assert(dr->thread_valid); - assert(mp_thread_id_equal(dr->thread_id, mp_thread_current_id())); + mp_assert(dr->thread_valid); + mp_assert(mp_thread_id_equal(dr->thread_id, mp_thread_current_id())); dr->thread_valid = false; mp_mutex_unlock(&dr->thread_lock); } @@ -81,7 +81,7 @@ static void dr_thread_free(void *ptr) struct free_dr_context *ctx = ptr; unsigned long long v = atomic_fetch_add(&ctx->dr->dr_in_flight, -1); - assert(v); // value before sub is 0 - unexpected underflow. + mp_assert(v); // value before sub is 0 - unexpected underflow. av_buffer_unref(&ctx->ref); talloc_free(ctx); @@ -123,14 +123,14 @@ static void sync_get_image(void *ptr) return; // We require exactly 1 AVBufferRef. - assert(cmd->res->bufs[0]); - assert(!cmd->res->bufs[1]); + mp_assert(cmd->res->bufs[0]); + mp_assert(!cmd->res->bufs[1]); // Apply some magic to get it free'd on the DR thread as well. For this to // work, we create a dummy-ref that aliases the original ref, which is why // the original ref must be writable in the first place. (A newly allocated // image should be always writable of course.) - assert(mp_image_is_writeable(cmd->res)); + mp_assert(mp_image_is_writeable(cmd->res)); struct free_dr_context *ctx = talloc_zero(NULL, struct free_dr_context); *ctx = (struct free_dr_context){ diff --git a/video/out/filter_kernels.c b/video/out/filter_kernels.c index d5f46fbb08..99f6b49da7 100644 --- a/video/out/filter_kernels.c +++ b/video/out/filter_kernels.c @@ -55,7 +55,7 @@ const struct filter_kernel *mp_find_filter_kernel(enum scaler_filter function) bool mp_init_filter(struct filter_kernel *filter, const int *sizes, double inv_scale) { - assert(filter->f.radius > 0); + mp_assert(filter->f.radius > 0); double blur = filter->f.blur > 0.0 ? filter->f.blur : 1.0; filter->radius = blur * filter->f.radius; @@ -127,7 +127,7 @@ static double sample_filter(struct filter_kernel *filter, double x) static void mp_compute_weights(struct filter_kernel *filter, double f, float *out_w) { - assert(filter->size > 0); + mp_assert(filter->size > 0); double sum = 0; for (int n = 0; n < filter->size; n++) { double x = f - (n - filter->size / 2 + 1); diff --git a/video/out/gpu/error_diffusion.c b/video/out/gpu/error_diffusion.c index 72063c39a1..ad3188b399 100644 --- a/video/out/gpu/error_diffusion.c +++ b/video/out/gpu/error_diffusion.c @@ -36,7 +36,7 @@ static int compute_rightmost_shifted_column(const struct error_diffusion_kernel // The shift mapping guarantees current column (or left of it) // won't be affected by error diffusion. - assert(shifted_x > 0); + mp_assert(shifted_x > 0); ret = MPMAX(ret, shifted_x); } @@ -75,7 +75,7 @@ void pass_error_diffusion(struct gl_shader_cache *sc, const struct error_diffusion_kernel *k, int tex, int width, int height, int depth, int block_size) { - assert(block_size <= height); + mp_assert(block_size <= height); // The parallel error diffusion works by applying the shift mapping first. // Taking the Floyd and Steinberg algorithm for example. After applying diff --git a/video/out/gpu/hwdec.c b/video/out/gpu/hwdec.c index 4fb9711276..cb68c54be0 100644 --- a/video/out/gpu/hwdec.c +++ b/video/out/gpu/hwdec.c @@ -128,7 +128,7 @@ bool ra_hwdec_test_format(struct ra_hwdec *hwdec, int imgfmt) struct ra_hwdec_mapper *ra_hwdec_mapper_create(struct ra_hwdec *hwdec, const struct mp_image_params *params) { - assert(ra_hwdec_test_format(hwdec, params->imgfmt)); + mp_assert(ra_hwdec_test_format(hwdec, params->imgfmt)); struct ra_hwdec_mapper *mapper = talloc_ptrtype(NULL, mapper); *mapper = (struct ra_hwdec_mapper){ @@ -250,7 +250,7 @@ static void load_hwdecs_all(struct ra_hwdec_ctx *ctx, struct mp_hwdec_devices *d void ra_hwdec_ctx_init(struct ra_hwdec_ctx *ctx, struct mp_hwdec_devices *devs, const char *type, bool load_all_by_default) { - assert(ctx->ra_ctx); + mp_assert(ctx->ra_ctx); /* * By default, or if the option value is "auto", we will not pre-emptively diff --git a/video/out/gpu/osd.c b/video/out/gpu/osd.c index 7892904c74..54861efaae 100644 --- a/video/out/gpu/osd.c +++ b/video/out/gpu/osd.c @@ -124,13 +124,13 @@ static bool upload_osd(struct mpgl_osd *ctx, struct mpgl_osd_part *osd, struct ra *ra = ctx->ra; bool ok = false; - assert(imgs->packed); + mp_assert(imgs->packed); int req_w = next_pow2(imgs->packed_w); int req_h = next_pow2(imgs->packed_h); const struct ra_format *fmt = ctx->fmt_table[imgs->format]; - assert(fmt); + mp_assert(fmt); if (!osd->texture || req_w > osd->w || req_h > osd->h || osd->format != imgs->format) @@ -206,7 +206,7 @@ static void gen_osd_cb(void *pctx, struct sub_bitmaps *imgs) bool mpgl_osd_draw_prepare(struct mpgl_osd *ctx, int index, struct gl_shader_cache *sc) { - assert(index >= 0 && index < MAX_OSD_PARTS); + mp_assert(index >= 0 && index < MAX_OSD_PARTS); struct mpgl_osd_part *part = ctx->parts[index]; enum sub_bitmap_format fmt = part->format; diff --git a/video/out/gpu/ra.c b/video/out/gpu/ra.c index 855f9b6bb2..bc872c06fc 100644 --- a/video/out/gpu/ra.c +++ b/video/out/gpu/ra.c @@ -28,13 +28,13 @@ struct ra_tex *ra_tex_create(struct ra *ra, const struct ra_tex_params *params) { switch (params->dimensions) { case 1: - assert(params->h == 1 && params->d == 1); + mp_assert(params->h == 1 && params->d == 1); break; case 2: - assert(params->d == 1); + mp_assert(params->d == 1); break; default: - assert(params->dimensions >= 1 && params->dimensions <= 3); + mp_assert(params->dimensions >= 1 && params->dimensions <= 3); } return ra->fns->tex_create(ra, params); } diff --git a/video/out/gpu/shader_cache.c b/video/out/gpu/shader_cache.c index c4dff66410..889e5e85d3 100644 --- a/video/out/gpu/shader_cache.c +++ b/video/out/gpu/shader_cache.c @@ -303,7 +303,7 @@ static void update_uniform_params(struct gl_shader_cache *sc, struct sc_uniform } // If all else fails, use global uniforms - assert(sc->ra->caps & RA_CAP_GLOBAL_UNIFORM); + mp_assert(sc->ra->caps & RA_CAP_GLOBAL_UNIFORM); u->type = SC_UNIFORM_TYPE_GLOBAL; } @@ -345,7 +345,7 @@ void gl_sc_uniform_image2D_wo(struct gl_shader_cache *sc, const char *name, void gl_sc_ssbo(struct gl_shader_cache *sc, char *name, struct ra_buf *buf, char *format, ...) { - assert(sc->ra->caps & RA_CAP_BUF_RW); + mp_assert(sc->ra->caps & RA_CAP_BUF_RW); gl_sc_enable_extension(sc, "GL_ARB_shader_storage_buffer_object"); struct sc_uniform *u = find_uniform(sc, name); @@ -472,7 +472,7 @@ const char *gl_sc_bvec(struct gl_shader_cache *sc, int dims) [4] = "vec4", }; - assert(dims > 0 && dims < MP_ARRAY_SIZE(bvecs)); + mp_assert(dims > 0 && dims < MP_ARRAY_SIZE(bvecs)); return sc->ra->glsl_version >= 130 ? bvecs[dims] : vecs[dims]; } @@ -544,11 +544,11 @@ static void update_uniform(struct gl_shader_cache *sc, struct sc_entry *e, break; } case SC_UNIFORM_TYPE_UBO: - assert(e->ubo); + mp_assert(e->ubo); update_ubo(sc->ra, e->ubo, u); break; case SC_UNIFORM_TYPE_PUSHC: - assert(e->pushc); + mp_assert(e->pushc); update_pushc(sc->ra, e->pushc, u); break; default: MP_ASSERT_UNREACHABLE(); @@ -702,7 +702,7 @@ static void add_uniforms(struct gl_shader_cache *sc, bstr *dst) switch (u->input.type) { case RA_VARTYPE_INT: case RA_VARTYPE_FLOAT: - assert(sc->ra->caps & RA_CAP_GLOBAL_UNIFORM); + mp_assert(sc->ra->caps & RA_CAP_GLOBAL_UNIFORM); MP_FALLTHROUGH; case RA_VARTYPE_TEX: // Vulkan requires explicitly assigning the bindings in the shader @@ -763,7 +763,7 @@ static void gl_sc_generate(struct gl_shader_cache *sc, // gl_sc_reset() must be called after ending the previous render process, // and before starting a new one. - assert(!sc->needs_reset); + mp_assert(!sc->needs_reset); sc->needs_reset = true; // If using a UBO, pick a binding (needed for shader generation) @@ -830,7 +830,7 @@ static void gl_sc_generate(struct gl_shader_cache *sc, snprintf(loc, sizeof(loc), "layout(location=%d) ", n); if (strcmp(e->name, "position") == 0) { // setting raster pos. requires setting gl_Position magic variable - assert(e->dim_v == 2 && e->type == RA_VARTYPE_FLOAT); + mp_assert(e->dim_v == 2 && e->type == RA_VARTYPE_FLOAT); ADD(vert_head, "%s%s vec2 vertex_position;\n", loc, vert_in); ADD(vert_body, "gl_Position = vec4(vertex_position, 1.0, 1.0);\n"); } else { @@ -870,7 +870,7 @@ static void gl_sc_generate(struct gl_shader_cache *sc, // We need to fix the format of the render dst at renderpass creation // time - assert(target_format); + mp_assert(target_format); sc->params.target_format = target_format; } @@ -968,7 +968,7 @@ static void gl_sc_generate(struct gl_shader_cache *sc, return; } - assert(sc->num_uniforms == entry->num_cached_uniforms); + mp_assert(sc->num_uniforms == entry->num_cached_uniforms); sc->num_values = 0; for (int n = 0; n < sc->num_uniforms; n++) diff --git a/video/out/gpu/user_shaders.c b/video/out/gpu/user_shaders.c index f2507b63f5..e036de20d5 100644 --- a/video/out/gpu/user_shaders.c +++ b/video/out/gpu/user_shaders.c @@ -90,7 +90,7 @@ bool eval_szexpr(struct mp_log *log, void *priv, case SZEXP_CONST: // Since our SZEXPs are bound by MAX_SZEXP_SIZE, it should be // impossible to overflow the stack - assert(idx < MAX_SZEXP_SIZE); + mp_assert(idx < MAX_SZEXP_SIZE); stack[idx++] = expr[i].val.cval; continue; diff --git a/video/out/gpu/utils.c b/video/out/gpu/utils.c index 7a3a72279c..0377a4a9f8 100644 --- a/video/out/gpu/utils.c +++ b/video/out/gpu/utils.c @@ -42,7 +42,7 @@ void gl_transform_ortho_fbo(struct gl_transform *t, const struct ra_fbo *fbo) double gl_video_scale_ambient_lux(float lmin, float lmax, float rmin, float rmax, double lux) { - assert(lmax > lmin); + mp_assert(lmax > lmin); double num = (rmax - rmin) * (log10(lux) - log10(lmin)); double den = log10(lmax) - log10(lmin); @@ -87,7 +87,7 @@ static bool ra_buf_pool_grow(struct ra *ra, struct ra_buf_pool *pool) struct ra_buf *ra_buf_pool_get(struct ra *ra, struct ra_buf_pool *pool, const struct ra_buf_params *params) { - assert(!params->initial_data); + mp_assert(!params->initial_data); if (!ra_buf_params_compatible(params, &pool->current_params)) { ra_buf_pool_uninit(ra, pool); @@ -272,7 +272,7 @@ void timer_pool_start(struct timer_pool *pool) if (!pool) return; - assert(!pool->running); + mp_assert(!pool->running); pool->ra->fns->timer_start(pool->ra, pool->timer); pool->running = true; } @@ -282,7 +282,7 @@ void timer_pool_stop(struct timer_pool *pool) if (!pool) return; - assert(pool->running); + mp_assert(pool->running); uint64_t res = pool->ra->fns->timer_stop(pool->ra, pool->timer); pool->running = false; diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index cb1b9c1b9b..0f39fc2f0b 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -748,7 +748,7 @@ static bool gl_video_get_lut3d(struct gl_video *p, enum pl_color_primaries prim, static struct image image_wrap(struct ra_tex *tex, enum plane_type type, int components) { - assert(type != PLANE_NONE); + mp_assert(type != PLANE_NONE); return (struct image){ .type = type, .tex = tex, @@ -820,7 +820,7 @@ static enum plane_type merge_plane_types(enum plane_type a, enum plane_type b) static void pass_get_images(struct gl_video *p, struct video_image *vimg, struct image img[4], struct gl_transform off[4]) { - assert(vimg->mpi); + mp_assert(vimg->mpi); int w = p->image_params.w; int h = p->image_params.h; @@ -1079,7 +1079,7 @@ static void unref_current_image(struct gl_video *p) struct video_image *vimg = &p->image; if (vimg->hwdec_mapped) { - assert(p->hwdec_active && p->hwdec_mapper); + mp_assert(p->hwdec_active && p->hwdec_mapper); ra_hwdec_mapper_unmap(p->hwdec_mapper); memset(vimg->planes, 0, sizeof(vimg->planes)); vimg->hwdec_mapped = false; @@ -1401,8 +1401,8 @@ static void copy_image(struct gl_video *p, unsigned int *offset, struct image im char src[5] = {0}; char dst[5] = {0}; - assert(*offset + count < sizeof(dst)); - assert(img.padding + count < sizeof(src)); + mp_assert(*offset + count < sizeof(dst)); + mp_assert(img.padding + count < sizeof(src)); int id = pass_bind(p, img); @@ -1503,7 +1503,7 @@ static bool saved_img_find(struct gl_video *p, const char *name, static void saved_img_store(struct gl_video *p, const char *name, struct image img) { - assert(name); + mp_assert(name); for (int i = 0; i < p->num_saved_imgs; i++) { if (strcmp(p->saved_imgs[i].name, name) == 0) { @@ -1762,7 +1762,7 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler, double scale_factor, int sizes[]) { - assert(conf); + mp_assert(conf); if (scaler_conf_eq(scaler->conf, *conf) && scaler->scale_factor == scale_factor && scaler->initialized) @@ -1827,11 +1827,11 @@ static void reinit_scaler(struct gl_video *p, struct scaler *scaler, int size = scaler->kernel->size; int num_components = size > 2 ? 4 : size; const struct ra_format *fmt = ra_find_float16_format(p->ra, num_components); - assert(fmt); + mp_assert(fmt); int width = (size + num_components - 1) / num_components; // round up int stride = width * num_components; - assert(size <= stride); + mp_assert(size <= stride); static const int lut_size = 256; float *weights = talloc_array(NULL, float, lut_size * stride); @@ -2061,7 +2061,7 @@ static bool szexp_lookup(void *priv, struct bstr var, float size[2]) static bool user_hook_cond(struct gl_video *p, struct image img, void *priv) { struct gl_user_shader_hook *shader = priv; - assert(shader); + mp_assert(shader); float res = false; struct szexp_ctx ctx = {p, img}; @@ -2073,7 +2073,7 @@ static void user_hook(struct gl_video *p, struct image img, struct gl_transform *trans, void *priv) { struct gl_user_shader_hook *shader = priv; - assert(shader); + mp_assert(shader); load_shader(p, shader->pass_body); pass_describe(p, "user shader: %.*s (%s)", BSTR_P(shader->pass_desc), @@ -2671,7 +2671,7 @@ static void pass_colormanage(struct gl_video *p, struct pl_color_space src, if (gl_video_get_lut3d(p, prim_orig, trc_orig)) { dst.primaries = prim_orig; dst.transfer = trc_orig; - assert(dst.primaries && dst.transfer); + mp_assert(dst.primaries && dst.transfer); } } @@ -3264,7 +3264,7 @@ static void gl_video_interpolate_frame(struct gl_video *p, struct vo_frame *t, if (oversample || linear) { size = 2; } else { - assert(tscale->kernel && !tscale->kernel->polar); + mp_assert(tscale->kernel && !tscale->kernel->polar); size = ceil(tscale->kernel->size); } @@ -3272,7 +3272,7 @@ static void gl_video_interpolate_frame(struct gl_video *p, struct vo_frame *t, int surface_now = p->surface_now; int surface_bse = surface_wrap(surface_now - (radius-1)); int surface_end = surface_wrap(surface_now + radius); - assert(surface_wrap(surface_bse + size-1) == surface_end); + mp_assert(surface_wrap(surface_bse + size-1) == surface_end); // Render new frames while there's room in the queue. Note that technically, // this should be done before the step where we find the right frame, but @@ -3378,7 +3378,7 @@ static void gl_video_interpolate_frame(struct gl_video *p, struct vo_frame *t, // the textures are bound in-order and starting at 0, we just // assert to make sure this is the case (which it should always be) int id = pass_bind(p, img); - assert(id == i); + mp_assert(id == i); } MP_TRACE(p, "inter frame dur: %f vsync: %f, mix: %f\n", @@ -3745,7 +3745,7 @@ static bool pass_upload_image(struct gl_video *p, struct mp_image *mpi, uint64_t } // Software decoding - assert(mpi->num_planes == p->plane_count); + mp_assert(mpi->num_planes == p->plane_count); timer_pool_start(p->upload_timer); for (int n = 0; n < p->plane_count; n++) { @@ -4077,7 +4077,7 @@ void gl_video_uninit(struct gl_video *p) gc_pending_dr_fences(p, true); // Should all have been unreffed already. - assert(!p->num_dr_buffers); + mp_assert(!p->num_dr_buffers); talloc_free(p); } @@ -4305,7 +4305,7 @@ static void gl_video_dr_free_buffer(void *opaque, uint8_t *data) for (int n = 0; n < p->num_dr_buffers; n++) { struct dr_buffer *buffer = &p->dr_buffers[n]; if (buffer->buf->data == data) { - assert(!buffer->mpi); // can't be freed while it has a ref + mp_assert(!buffer->mpi); // can't be freed while it has a ref ra_buf_free(p->ra, &buffer->buf); MP_TARRAY_REMOVE_AT(p->dr_buffers, p->num_dr_buffers, n); return; @@ -4351,7 +4351,7 @@ void gl_video_init_hwdecs(struct gl_video *p, struct ra_ctx *ra_ctx, struct mp_hwdec_devices *devs, bool load_all_by_default) { - assert(!p->hwdec_ctx.ra_ctx); + mp_assert(!p->hwdec_ctx.ra_ctx); p->hwdec_ctx = (struct ra_hwdec_ctx) { .log = p->log, .global = p->global, @@ -4364,7 +4364,7 @@ void gl_video_init_hwdecs(struct gl_video *p, struct ra_ctx *ra_ctx, void gl_video_load_hwdecs_for_img_fmt(struct gl_video *p, struct mp_hwdec_devices *devs, struct hwdec_imgfmt_request *params) { - assert(p->hwdec_ctx.ra_ctx); + mp_assert(p->hwdec_ctx.ra_ctx); ra_hwdec_ctx_load_fmt(&p->hwdec_ctx, devs, params); } diff --git a/video/out/hwdec/dmabuf_interop_gl.c b/video/out/hwdec/dmabuf_interop_gl.c index 0f6fb89e20..6adddb75ce 100644 --- a/video/out/hwdec/dmabuf_interop_gl.c +++ b/video/out/hwdec/dmabuf_interop_gl.c @@ -173,7 +173,7 @@ static void vaapi_gl_mapper_uninit(const struct ra_hwdec_mapper *mapper) #define ADD_ATTRIB(name, value) \ do { \ - assert(num_attribs + 3 < MP_ARRAY_SIZE(attribs)); \ + mp_assert(num_attribs + 3 < MP_ARRAY_SIZE(attribs)); \ attribs[num_attribs++] = (name); \ attribs[num_attribs++] = (value); \ attribs[num_attribs] = EGL_NONE; \ diff --git a/video/out/hwdec/hwdec_aimagereader.c b/video/out/hwdec/hwdec_aimagereader.c index acab232a7c..83c2ea87ef 100644 --- a/video/out/hwdec/hwdec_aimagereader.c +++ b/video/out/hwdec/hwdec_aimagereader.c @@ -161,7 +161,7 @@ static int init(struct ra_hwdec *hw) MP_ERR(hw, "newWithUsage failed: %d\n", ret); return -1; } - assert(p->reader); + mp_assert(p->reader); ANativeWindow *window; ret = p->AImageReader_getWindow(p->reader, &window); @@ -169,7 +169,7 @@ static int init(struct ra_hwdec *hw) MP_ERR(hw, "getWindow failed: %d\n", ret); return -1; } - assert(window); + mp_assert(window); jobject surface = p->ANativeWindow_toSurface(env, window); p->surface = (*env)->NewGlobalRef(env, surface); @@ -197,7 +197,7 @@ static void uninit(struct ra_hwdec *hw) if (p->surface) { JNIEnv *env = MP_JNI_GET_ENV(hw); - assert(env); + mp_assert(env); (*env)->DeleteGlobalRef(env, p->surface); p->surface = NULL; } @@ -351,7 +351,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) // flashing frames of render errors. return image_available ? -1 : 0; } - assert(p->image); + mp_assert(p->image); AHardwareBuffer *hwbuf = NULL; ret = o->AImage_getHardwareBuffer(p->image, &hwbuf); @@ -359,7 +359,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) MP_ERR(mapper, "getHardwareBuffer failed: %d\n", ret); return -1; } - assert(hwbuf); + mp_assert(hwbuf); // Update texture size since it may differ AHardwareBuffer_Desc d; diff --git a/video/out/hwdec/hwdec_ios_gl.m b/video/out/hwdec/hwdec_ios_gl.m index 633cc3ddc1..531d465de8 100644 --- a/video/out/hwdec/hwdec_ios_gl.m +++ b/video/out/hwdec/hwdec_ios_gl.m @@ -137,7 +137,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) const bool planar = CVPixelBufferIsPlanar(p->pbuf); const int planes = CVPixelBufferGetPlaneCount(p->pbuf); - assert((planar && planes == p->desc.num_planes) || p->desc.num_planes == 1); + mp_assert((planar && planes == p->desc.num_planes) || p->desc.num_planes == 1); for (int i = 0; i < p->desc.num_planes; i++) { const struct ra_format *fmt = p->desc.planes[i]; diff --git a/video/out/hwdec/hwdec_mac_gl.c b/video/out/hwdec/hwdec_mac_gl.c index 9c3ff5d4d6..7cd1d60f67 100644 --- a/video/out/hwdec/hwdec_mac_gl.c +++ b/video/out/hwdec/hwdec_mac_gl.c @@ -97,7 +97,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) const bool planar = CVPixelBufferIsPlanar(p->pbuf); const int planes = CVPixelBufferGetPlaneCount(p->pbuf); - assert((planar && planes == p->desc.num_planes) || p->desc.num_planes == 1); + mp_assert((planar && planes == p->desc.num_planes) || p->desc.num_planes == 1); GLenum gl_target = GL_TEXTURE_RECTANGLE; diff --git a/video/out/hwdec/hwdec_vt_pl.m b/video/out/hwdec/hwdec_vt_pl.m index cd133a0adc..82df4e94a7 100644 --- a/video/out/hwdec/hwdec_vt_pl.m +++ b/video/out/hwdec/hwdec_vt_pl.m @@ -222,7 +222,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) const bool planar = CVPixelBufferIsPlanar(p->pbuf); const int planes = CVPixelBufferGetPlaneCount(p->pbuf); - assert((planar && planes == p->desc.num_planes) || p->desc.num_planes == 1); + mp_assert((planar && planes == p->desc.num_planes) || p->desc.num_planes == 1); for (int i = 0; i < p->desc.num_planes; i++) { const struct ra_format *fmt = p->desc.planes[i]; diff --git a/video/out/libmpv_sw.c b/video/out/libmpv_sw.c index 0001b40fe8..a4f8189255 100644 --- a/video/out/libmpv_sw.c +++ b/video/out/libmpv_sw.c @@ -162,7 +162,7 @@ static int render(struct render_backend *ctx, mpv_render_param *params, struct mp_image *img = frame->current; if (img) { - assert(p->src_params.imgfmt); + mp_assert(p->src_params.imgfmt); mp_image_clear_rc_inv(&wrap_img, p->dst_rc); diff --git a/video/out/opengl/common.c b/video/out/opengl/common.c index 6d361217b9..a5de79c901 100644 --- a/video/out/opengl/common.c +++ b/video/out/opengl/common.c @@ -61,7 +61,7 @@ static bool is_fast_dr(GL *gl) static void GLAPIENTRY dummy_glBindFramebuffer(GLenum target, GLuint framebuffer) { - assert(framebuffer == 0); + mp_assert(framebuffer == 0); } #define FN_OFFS(name) offsetof(GL, name) @@ -625,7 +625,7 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), } break; } - assert(i < MAX_FN_COUNT); + mp_assert(i < MAX_FN_COUNT); loaded[i] = ptr; } diff --git a/video/out/opengl/hwdec_vdpau.c b/video/out/opengl/hwdec_vdpau.c index 7d40527b39..8585c66eb5 100644 --- a/video/out/opengl/hwdec_vdpau.c +++ b/video/out/opengl/hwdec_vdpau.c @@ -105,7 +105,7 @@ static void mapper_uninit(struct ra_hwdec_mapper *mapper) struct vdp_functions *vdp = &p->ctx->vdp; VdpStatus vdp_st; - assert(!p->mapped); + mp_assert(!p->mapped); if (p->vdpgl_surface) gl->VDPAUUnregisterSurfaceNV(p->vdpgl_surface); diff --git a/video/out/opengl/ra_gl.c b/video/out/opengl/ra_gl.c index f535f1f13d..345a5b848e 100644 --- a/video/out/opengl/ra_gl.c +++ b/video/out/opengl/ra_gl.c @@ -70,7 +70,7 @@ static void probe_real_size(GL *gl, struct ra_format *fmt) GL_TEXTURE_ALPHA_SIZE, }; int comp = is_la ? i + 4 : i; - assert(comp < MP_ARRAY_SIZE(pnames)); + mp_assert(comp < MP_ARRAY_SIZE(pnames)); GLint param = -1; gl->GetTexLevelParameteriv(GL_TEXTURE_2D, 0, pnames[comp], ¶m); fmt->component_depth[i] = param > 0 ? param : 0; @@ -299,11 +299,11 @@ static struct ra_tex *gl_tex_create_blank(struct ra *ra, default: MP_ASSERT_UNREACHABLE(); } if (params->non_normalized) { - assert(params->dimensions == 2); + mp_assert(params->dimensions == 2); tex_gl->target = GL_TEXTURE_RECTANGLE; } if (params->external_oes) { - assert(params->dimensions == 2 && !params->non_normalized); + mp_assert(params->dimensions == 2 && !params->non_normalized); tex_gl->target = GL_TEXTURE_EXTERNAL_OES; } @@ -321,7 +321,7 @@ static struct ra_tex *gl_tex_create(struct ra *ra, const struct ra_tex_params *params) { GL *gl = ra_gl_get(ra); - assert(!params->format->dummy_format); + mp_assert(!params->format->dummy_format); struct ra_tex *tex = gl_tex_create_blank(ra, params); if (!tex) @@ -378,7 +378,7 @@ static struct ra_tex *gl_tex_create(struct ra *ra, return NULL; } - assert(gl->mpgl_caps & MPGL_CAP_FB); + mp_assert(gl->mpgl_caps & MPGL_CAP_FB); gl->GenFramebuffers(1, &tex_gl->fbo); gl->BindFramebuffer(GL_FRAMEBUFFER, tex_gl->fbo); @@ -497,8 +497,8 @@ static bool gl_tex_upload(struct ra *ra, struct ra_buf *buf = params->buf; struct ra_tex_gl *tex_gl = tex->priv; struct ra_buf_gl *buf_gl = buf ? buf->priv : NULL; - assert(tex->params.host_mutable); - assert(!params->buf || !params->src); + mp_assert(tex->params.host_mutable); + mp_assert(!params->buf || !params->src); if (ra->use_pbo && !params->buf) return ra_tex_upload_pbo(ra, &tex_gl->pbo, params); @@ -647,7 +647,7 @@ static void gl_buf_update(struct ra *ra, struct ra_buf *buf, ptrdiff_t offset, { GL *gl = ra_gl_get(ra); struct ra_buf_gl *buf_gl = buf->priv; - assert(buf->params.host_mutable); + mp_assert(buf->params.host_mutable); gl->BindBuffer(buf_gl->target, buf_gl->buffer); gl->BufferSubData(buf_gl->target, offset, size, data); @@ -680,7 +680,7 @@ static void gl_clear(struct ra *ra, struct ra_tex *dst, float color[4], { GL *gl = ra_gl_get(ra); - assert(dst->params.render_dst); + mp_assert(dst->params.render_dst); struct ra_tex_gl *dst_gl = dst->priv; gl->BindFramebuffer(GL_FRAMEBUFFER, dst_gl->fbo); @@ -702,8 +702,8 @@ static void gl_blit(struct ra *ra, struct ra_tex *dst, struct ra_tex *src, { GL *gl = ra_gl_get(ra); - assert(src->params.blit_src); - assert(dst->params.blit_dst); + mp_assert(src->params.blit_src); + mp_assert(dst->params.blit_dst); struct ra_tex_gl *src_gl = src->priv; struct ra_tex_gl *dst_gl = dst->priv; @@ -944,12 +944,12 @@ static void update_uniform(struct ra *ra, struct ra_renderpass *pass, struct ra_renderpass_gl *pass_gl = pass->priv; struct ra_renderpass_input *input = &pass->params.inputs[val->index]; - assert(val->index >= 0 && val->index < pass_gl->num_uniform_loc); + mp_assert(val->index >= 0 && val->index < pass_gl->num_uniform_loc); GLint loc = pass_gl->uniform_loc[val->index]; switch (input->type) { case RA_VARTYPE_INT: { - assert(input->dim_v * input->dim_m == 1); + mp_assert(input->dim_v * input->dim_m == 1); if (loc < 0) break; gl->Uniform1i(loc, *(int *)val->data); @@ -979,7 +979,7 @@ static void update_uniform(struct ra *ra, struct ra_renderpass *pass, case RA_VARTYPE_IMG_W: { struct ra_tex *tex = *(struct ra_tex **)val->data; struct ra_tex_gl *tex_gl = tex->priv; - assert(tex->params.storage_dst); + mp_assert(tex->params.storage_dst); gl->BindImageTexture(input->binding, tex_gl->texture, 0, GL_FALSE, 0, GL_WRITE_ONLY, tex_gl->internal_format); break; @@ -987,7 +987,7 @@ static void update_uniform(struct ra *ra, struct ra_renderpass *pass, case RA_VARTYPE_TEX: { struct ra_tex *tex = *(struct ra_tex **)val->data; struct ra_tex_gl *tex_gl = tex->priv; - assert(tex->params.render_src); + mp_assert(tex->params.render_src); gl->ActiveTexture(GL_TEXTURE0 + input->binding); gl->BindTexture(tex_gl->target, tex_gl->texture); break; @@ -1019,7 +1019,7 @@ static void disable_binding(struct ra *ra, struct ra_renderpass *pass, case RA_VARTYPE_TEX: { struct ra_tex *tex = *(struct ra_tex **)val->data; struct ra_tex_gl *tex_gl = tex->priv; - assert(tex->params.render_src); + mp_assert(tex->params.render_src); if (input->type == RA_VARTYPE_TEX) { gl->ActiveTexture(GL_TEXTURE0 + input->binding); gl->BindTexture(tex_gl->target, 0); @@ -1051,8 +1051,8 @@ static void gl_renderpass_run(struct ra *ra, switch (pass->params.type) { case RA_RENDERPASS_TYPE_RASTER: { struct ra_tex_gl *target_gl = params->target->priv; - assert(params->target->params.render_dst); - assert(params->target->params.format == pass->params.target_format); + mp_assert(params->target->params.render_dst); + mp_assert(params->target->params.format == pass->params.target_format); gl->BindFramebuffer(GL_FRAMEBUFFER, target_gl->fbo); if (pass->params.invalidate_target && gl->InvalidateFramebuffer) { GLenum fb = target_gl->fbo ? GL_COLOR_ATTACHMENT0 : GL_COLOR; diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index db1ea94502..cbf00fd2f6 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -84,7 +84,7 @@ void gl_upload_tex(GL *gl, GLenum target, GLenum format, GLenum type, int y_max = y + h; if (w <= 0 || h <= 0 || !bpp) return; - assert(stride > 0); + mp_assert(stride > 0); gl->PixelStorei(GL_UNPACK_ALIGNMENT, get_alignment(stride)); int slice = h; if (gl->mpgl_caps & MPGL_CAP_ROW_LENGTH) { @@ -108,7 +108,7 @@ void gl_upload_tex(GL *gl, GLenum target, GLenum format, GLenum type, bool gl_read_fbo_contents(GL *gl, int fbo, int dir, GLenum format, GLenum type, int w, int h, uint8_t *dst, int dst_stride) { - assert(dir == 1 || dir == -1); + mp_assert(dir == 1 || dir == -1); if (fbo == 0 && gl->es) return false; // ES can't read from front buffer gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); @@ -146,7 +146,7 @@ static void gl_vao_enable_attribs(struct gl_vao *vao) default: abort(); } - assert(e->dim_m == 1); + mp_assert(e->dim_m == 1); gl->EnableVertexAttribArray(n); gl->VertexAttribPointer(n, e->dim_v, type, normalized, @@ -158,8 +158,8 @@ void gl_vao_init(struct gl_vao *vao, GL *gl, int stride, const struct ra_renderpass_input *entries, int num_entries) { - assert(!vao->vao); - assert(!vao->buffer); + mp_assert(!vao->vao); + mp_assert(!vao->buffer); *vao = (struct gl_vao){ .gl = gl, diff --git a/video/out/placebo/ra_pl.c b/video/out/placebo/ra_pl.c index e6d6433579..16cbad987c 100644 --- a/video/out/placebo/ra_pl.c +++ b/video/out/placebo/ra_pl.c @@ -26,7 +26,7 @@ static pl_timer get_active_timer(const struct ra *ra); struct ra *ra_create_pl(pl_gpu gpu, struct mp_log *log) { - assert(gpu); + mp_assert(gpu); struct ra *ra = talloc_zero(NULL, struct ra); ra->log = log; diff --git a/video/out/vo.c b/video/out/vo.c index c933994f89..997e734065 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -265,7 +265,7 @@ static void dealloc_vo(struct vo *vo) static struct vo *vo_create(bool probing, struct mpv_global *global, struct vo_extra *ex, char *name) { - assert(ex->wakeup_cb); + mp_assert(ex->wakeup_cb); struct mp_log *log = mp_log_new(NULL, global->log, "vo"); struct m_obj_desc desc; @@ -518,7 +518,7 @@ static void update_vsync_timing_after_swap(struct vo *vo, double avg = 0; for (int n = 0; n < in->num_vsync_samples; n++) { - assert(in->vsync_samples[n] > 0); + mp_assert(in->vsync_samples[n] > 0); avg += in->vsync_samples[n]; } in->estimated_vsync_interval = avg / in->num_vsync_samples; @@ -767,7 +767,7 @@ static int64_t get_current_frame_end(struct vo *vo) static int64_t get_display_synced_frame_end(struct vo *vo) { struct vo_internal *in = vo->in; - assert(!in->frame_queued); + mp_assert(!in->frame_queued); int64_t res = 0; if (in->base_vsync && in->vsync_interval > 1 && in->current_frame) { res = in->base_vsync; @@ -877,7 +877,7 @@ void vo_queue_frame(struct vo *vo, struct vo_frame *frame) { struct vo_internal *in = vo->in; mp_mutex_lock(&in->lock); - assert(vo->config_ok && !in->frame_queued && + mp_assert(vo->config_ok && !in->frame_queued && (!in->current_frame || in->current_frame->num_vsyncs < 1)); in->hasframe = true; frame->frame_id = ++(in->current_frame_id); @@ -936,7 +936,7 @@ static bool render_frame(struct vo *vo) } frame = vo_frame_ref(in->current_frame); - assert(frame); + mp_assert(frame); if (frame->display_synced) { frame->pts = 0; diff --git a/video/out/vo_direct3d.c b/video/out/vo_direct3d.c index ff0aec30cb..384cb20d0e 100644 --- a/video/out/vo_direct3d.c +++ b/video/out/vo_direct3d.c @@ -374,7 +374,7 @@ static void destroy_d3d_surfaces(d3d_priv *priv) // Allocate video surface. static bool d3d_configure_video_objects(d3d_priv *priv) { - assert(priv->image_format != 0); + mp_assert(priv->image_format != 0); if (!priv->d3d_surface && FAILED(IDirect3DDevice9_CreateOffscreenPlainSurface( diff --git a/video/out/vo_dmabuf_wayland.c b/video/out/vo_dmabuf_wayland.c index 4c6bcd98c5..ac1f7983f7 100644 --- a/video/out/vo_dmabuf_wayland.c +++ b/video/out/vo_dmabuf_wayland.c @@ -775,7 +775,7 @@ static int preinit(struct vo *vo) if (!p->ctx) goto err; - assert(p->ctx->ra); + mp_assert(p->ctx->ra); if (!vo->wl->dmabuf || !vo->wl->dmabuf_feedback) { MP_FATAL(vo->wl, "Compositor doesn't support the %s (ver. 4) protocol!\n", diff --git a/video/out/vo_gpu.c b/video/out/vo_gpu.c index 53b0fb4087..57e70d179b 100644 --- a/video/out/vo_gpu.c +++ b/video/out/vo_gpu.c @@ -303,8 +303,8 @@ static int preinit(struct vo *vo) talloc_free(ctx_opts); if (!p->ctx) goto err_out; - assert(p->ctx->ra); - assert(p->ctx->swapchain); + mp_assert(p->ctx->ra); + mp_assert(p->ctx->swapchain); p->renderer = gl_video_init(p->ctx->ra, vo->log, vo->global); gl_video_set_osd_source(p->renderer, vo->osd); diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index c8a120662e..8bbb79b24c 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -1320,7 +1320,7 @@ static void video_screenshot(struct vo *vo, struct voctrl_screenshot *args) qparams.drift_compensation = 0; #endif status = pl_queue_update(p->queue, &mix, &qparams); - assert(status != PL_QUEUE_EOF); + mp_assert(status != PL_QUEUE_EOF); if (status == PL_QUEUE_ERR) { MP_ERR(vo, "Unknown error occurred while trying to take screenshot!\n"); return; @@ -1481,14 +1481,14 @@ done: static inline void copy_frame_info_to_mp(struct frame_info *pl, struct mp_frame_perf *mp) { static_assert(MP_ARRAY_SIZE(pl->info) == MP_ARRAY_SIZE(mp->perf), ""); - assert(pl->count <= VO_PASS_PERF_MAX); + mp_assert(pl->count <= VO_PASS_PERF_MAX); mp->count = MPMIN(pl->count, VO_PASS_PERF_MAX); for (int i = 0; i < mp->count; ++i) { const struct pl_dispatch_info *pass = &pl->info[i]; static_assert(VO_PERF_SAMPLE_COUNT >= MP_ARRAY_SIZE(pass->samples), ""); - assert(pass->num_samples <= MP_ARRAY_SIZE(pass->samples)); + mp_assert(pass->num_samples <= MP_ARRAY_SIZE(pass->samples)); struct mp_pass_perf *perf = &mp->perf[i]; perf->count = MPMIN(pass->num_samples, VO_PERF_SAMPLE_COUNT); @@ -1736,8 +1736,8 @@ static void cache_uninit(struct priv *p, struct cache *cache) void *ta_ctx = talloc_new(NULL); struct file_entry *files = NULL; size_t num_files = 0; - assert(cache->dir); - assert(cache->name); + mp_assert(cache->dir); + mp_assert(cache->name); DIR *d = opendir(cache->dir); if (!d) @@ -1816,7 +1816,7 @@ static void uninit(struct vo *vo) hwdec_devices_destroy(vo->hwdec_devs); } - assert(p->num_dr_buffers == 0); + mp_assert(p->num_dr_buffers == 0); mp_mutex_destroy(&p->dr_lock); cache_uninit(p, &p->shader_cache); diff --git a/video/out/vo_libmpv.c b/video/out/vo_libmpv.c index a42cfa65ca..f3f0fd0aaf 100644 --- a/video/out/vo_libmpv.c +++ b/video/out/vo_libmpv.c @@ -294,8 +294,8 @@ void mpv_render_context_free(mpv_render_context *ctx) // and prevented that new VOs can be created.) mp_mutex_unlock(&ctx->lock); - assert(!atomic_load(&ctx->in_use)); - assert(!ctx->vo); + mp_assert(!atomic_load(&ctx->in_use)); + mp_assert(!ctx->vo); // With the dispatch queue not being served anymore, allow frame free // requests from this thread to be served directly. @@ -491,7 +491,7 @@ static bool draw_frame(struct vo *vo, struct vo_frame *frame) struct mpv_render_context *ctx = p->ctx; mp_mutex_lock(&ctx->lock); - assert(!ctx->next_frame); + mp_assert(!ctx->next_frame); ctx->next_frame = vo_frame_ref(frame); ctx->expected_flip_count = ctx->flip_count + 1; ctx->redrawing = frame->redraw || !frame->current; @@ -702,7 +702,7 @@ static void uninit(struct vo *vo) // The following do not normally need ctx->lock, however, ctx itself may // become invalid once we release ctx->lock. bool prev_in_use = atomic_exchange(&ctx->in_use, false); - assert(prev_in_use); // obviously must have been set + mp_assert(prev_in_use); // obviously must have been set mp_dispatch_interrupt(ctx->dispatch); mp_mutex_unlock(&ctx->lock); diff --git a/video/out/vo_mediacodec_embed.c b/video/out/vo_mediacodec_embed.c index 00ac659f62..985b52660f 100644 --- a/video/out/vo_mediacodec_embed.c +++ b/video/out/vo_mediacodec_embed.c @@ -37,7 +37,7 @@ static AVBufferRef *create_mediacodec_device_ref(struct vo *vo) AVHWDeviceContext *ctx = (void *)device_ref->data; AVMediaCodecDeviceContext *hwctx = ctx->hwctx; - assert(vo->opts->WinID != 0 && vo->opts->WinID != -1); + mp_assert(vo->opts->WinID != 0 && vo->opts->WinID != -1); hwctx->surface = (void *)(intptr_t)(vo->opts->WinID); if (av_hwdevice_ctx_init(device_ref) < 0) diff --git a/video/out/vo_tct.c b/video/out/vo_tct.c index 07aefe4b3d..8dd8d08800 100644 --- a/video/out/vo_tct.c +++ b/video/out/vo_tct.c @@ -140,7 +140,7 @@ static void write_plain(bstr *frame, const unsigned char *source, const int source_stride, bool term256, struct lut_item *lut, enum vo_tct_buffering buffering) { - assert(source); + mp_assert(source); const int tx = (dwidth - swidth) / 2; const int ty = (dheight - sheight) / 2; for (int y = 0; y < sheight; y++) { @@ -171,7 +171,7 @@ static void write_half_blocks(bstr *frame, unsigned char *source, int source_stride, bool term256, struct lut_item *lut, enum vo_tct_buffering buffering) { - assert(source); + mp_assert(source); const int tx = (dwidth - swidth) / 2; const int ty = (dheight - sheight) / 2; for (int y = 0; y < sheight * 2; y += 2) { diff --git a/video/out/vo_vaapi.c b/video/out/vo_vaapi.c index cb8b1560c5..bb34fd961e 100644 --- a/video/out/vo_vaapi.c +++ b/video/out/vo_vaapi.c @@ -359,7 +359,7 @@ static int va_surface_upload(struct priv *priv, struct mp_image *va_dst, struct mp_image img; if (!va_image_map(p->ctx, &p->image, &img)) return -1; - assert(sw_src->w <= img.w && sw_src->h <= img.h); + mp_assert(sw_src->w <= img.w && sw_src->h <= img.h); mp_image_set_size(&img, sw_src->w, sw_src->h); // copy only visible part mp_image_copy(&img, sw_src); va_image_unmap(p->ctx, &p->image); diff --git a/video/out/vo_vdpau.c b/video/out/vo_vdpau.c index 4b28106624..a807632512 100644 --- a/video/out/vo_vdpau.c +++ b/video/out/vo_vdpau.c @@ -602,7 +602,7 @@ static void generate_osd_part(struct vo *vo, struct sub_bitmaps *imgs) MP_ASSERT_UNREACHABLE(); }; - assert(imgs->packed); + mp_assert(imgs->packed); int r_w = next_pow2(imgs->packed_w); int r_h = next_pow2(imgs->packed_h); @@ -913,7 +913,7 @@ static struct mp_image *read_output_surface(struct vo *vo, if (vdp_st != VDP_STATUS_OK) return NULL; - assert(fmt == OUTPUT_RGBA_FORMAT); + mp_assert(fmt == OUTPUT_RGBA_FORMAT); struct mp_image *image = mp_image_alloc(IMGFMT_BGR0, w, h); if (!image) diff --git a/video/out/vulkan/context.c b/video/out/vulkan/context.c index 9dd8bd43dd..910aba70bc 100644 --- a/video/out/vulkan/context.c +++ b/video/out/vulkan/context.c @@ -225,8 +225,8 @@ pl_vulkan mppl_create_vulkan(struct vulkan_opts *opts, bool is_uuid = opts->device && av_uuid_parse(opts->device, param_uuid) == 0; - assert(pllog); - assert(vkinst); + mp_assert(pllog); + mp_assert(vkinst); struct pl_vulkan_params device_params = { .instance = vkinst->instance, .get_proc_addr = vkinst->get_proc_addr, diff --git a/video/out/vulkan/utils.c b/video/out/vulkan/utils.c index 57a36645c1..203beaef8b 100644 --- a/video/out/vulkan/utils.c +++ b/video/out/vulkan/utils.c @@ -32,7 +32,7 @@ error: void mpvk_uninit(struct mpvk_ctx *vk) { if (vk->surface) { - assert(vk->vkinst); + mp_assert(vk->vkinst); vkDestroySurfaceKHR(vk->vkinst->instance, vk->surface, NULL); vk->surface = VK_NULL_HANDLE; } diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 70d89fd219..26dd2c36f7 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -228,7 +228,7 @@ static bool check_windows10_build(DWORD build) // Get adjusted title bar height, only relevant for --title-bar=no static int get_title_bar_height(struct vo_w32_state *w32) { - assert(w32->opts->border ? !w32->opts->title_bar : IsMaximized(w32->window)); + mp_assert(w32->opts->border ? !w32->opts->title_bar : IsMaximized(w32->window)); UINT visible_border = 0; // Only available on Windows 11, check in case it's backported and breaks // WM_NCCALCSIZE exception for Windows 10. @@ -1923,7 +1923,7 @@ static void run_message_loop(struct vo_w32_state *w32) // Even if the message loop somehow exits, we still have to respond to // external requests until termination is requested. while (!w32->terminate) { - assert(!w32->in_dispatch); + mp_assert(!w32->in_dispatch); w32->in_dispatch = true; mp_dispatch_queue_process(w32->dispatch, 1000); w32->in_dispatch = false; @@ -2154,7 +2154,7 @@ done: bool vo_w32_init(struct vo *vo) { - assert(!vo->w32); + mp_assert(!vo->w32); struct vo_w32_state *w32 = talloc_ptrtype(vo, w32); *w32 = (struct vo_w32_state){ diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 207177520b..e80d32a326 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -777,7 +777,7 @@ static void data_device_handle_enter(void *data, struct wl_data_device *wl_ddev, return; } - assert(!s->dnd_offer->offer); + mp_assert(!s->dnd_offer->offer); int action = s->dnd_offer->action; *s->dnd_offer = *s->pending_offer; *s->pending_offer = (struct vo_wayland_data_offer){.fd = -1}; diff --git a/video/out/x11_common.c b/video/out/x11_common.c index a3c681a67a..52e661f3f8 100644 --- a/video/out/x11_common.c +++ b/video/out/x11_common.c @@ -190,7 +190,7 @@ static char *x11_atom_name_buf(struct vo_x11_state *x11, Atom atom, static void *x11_get_property(struct vo_x11_state *x11, Window w, Atom property, Atom type, int format, int *out_nitems) { - assert(format == 8 || format == 16 || format == 32); + mp_assert(format == 8 || format == 16 || format == 32); *out_nitems = 0; if (!w) return NULL; @@ -676,7 +676,7 @@ bool vo_x11_init(struct vo *vo) { char *dispName; - assert(!vo->x11); + mp_assert(!vo->x11); XInitThreads(); @@ -1591,8 +1591,8 @@ static void vo_x11_create_window(struct vo *vo, XVisualInfo *vis, { struct vo_x11_state *x11 = vo->x11; - assert(x11->window == None); - assert(!x11->xic); + mp_assert(x11->window == None); + mp_assert(!x11->xic); XVisualInfo vinfo_storage; if (!vis) { @@ -1774,7 +1774,7 @@ bool vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, const char *classname) { struct vo_x11_state *x11 = vo->x11; - assert(!x11->window); + mp_assert(!x11->window); if (x11->parent) { if (x11->parent == x11->rootwin) { @@ -1801,7 +1801,7 @@ void vo_x11_config_vo_window(struct vo *vo) struct vo_x11_state *x11 = vo->x11; struct mp_vo_opts *opts = x11->opts; - assert(x11->window); + mp_assert(x11->window); vo_x11_update_screeninfo(vo); diff --git a/video/repack.c b/video/repack.c index 0388493b28..ab1270277c 100644 --- a/video/repack.c +++ b/video/repack.c @@ -130,7 +130,7 @@ static void copy_plane(struct mp_image *dst, int dst_x, int dst_y, int h = (1 << dst->fmt.chroma_ys) - (1 << dst->fmt.ys[p]) + 1; size_t size = mp_image_plane_bytes(dst, p, dst_x, w); - assert(dst->fmt.bpp[p] == src->fmt.bpp[p]); + mp_assert(dst->fmt.bpp[p] == src->fmt.bpp[p]); for (int y = 0; y < h; y++) { void *restrict pd = mp_image_pixel_ptr_ny(dst, p, dst_x, dst_y + y); @@ -144,7 +144,7 @@ static void swap_endian(struct mp_image *dst, int dst_x, int dst_y, struct mp_image *src, int src_x, int src_y, int w, int endian_size) { - assert(src->fmt.num_planes == dst->fmt.num_planes); + mp_assert(src->fmt.num_planes == dst->fmt.num_planes); for (int p = 0; p < dst->fmt.num_planes; p++) { int xs = dst->fmt.xs[p]; @@ -154,7 +154,7 @@ static void swap_endian(struct mp_image *dst, int dst_x, int dst_y, // Number of lines on this plane. int h = (1 << dst->fmt.chroma_ys) - (1 << dst->fmt.ys[p]) + 1; - assert(src->fmt.bpp[p] == bpp * 8); + mp_assert(src->fmt.bpp[p] == bpp * 8); for (int y = 0; y < h; y++) { void *restrict s = mp_image_pixel_ptr_ny(src, p, src_x, src_y + y); @@ -447,7 +447,7 @@ static void fringe_rgb_repack(struct mp_repack *rp, pb[p] = mp_image_pixel_ptr(b, s, b_x, b_y); } - assert(rp->comp_size == 1 || rp->comp_size == 2); + mp_assert(rp->comp_size == 1 || rp->comp_size == 2); void (*repack)(void *restrict pa, void *restrict pb[], int w, uint8_t *restrict lut, uint8_t s0, uint8_t s1, uint8_t s2) = NULL; @@ -513,10 +513,10 @@ static void setup_fringe_rgb_packer(struct mp_repack *rp) } rp->comp_size = (desc.bpp[0] + 7) / 8; - assert(rp->comp_size == 1 || rp->comp_size == 2); + mp_assert(rp->comp_size == 1 || rp->comp_size == 2); if (desc.endian_shift) { - assert(rp->comp_size == 2 && (1 << desc.endian_shift) == 2); + mp_assert(rp->comp_size == 2 && (1 << desc.endian_shift) == 2); rp->endian_size = 2; } } @@ -714,7 +714,7 @@ static void setup_fringe_yuv_packer(struct mp_repack *rp) if (desc.endian_shift) { rp->endian_size = 1 << desc.endian_shift; - assert(rp->endian_size == 2); + mp_assert(rp->endian_size == 2); } } @@ -819,7 +819,7 @@ static void repack_float(struct mp_repack *rp, struct mp_image *a, int a_x, int a_y, struct mp_image *b, int b_x, int b_y, int w) { - assert(rp->f32_comp_size == 1 || rp->f32_comp_size == 2); + mp_assert(rp->f32_comp_size == 1 || rp->f32_comp_size == 2); void (*packer)(void *restrict a, float *restrict b, int w, float fm, float fb, uint32_t max) = rp->pack ? (rp->f32_comp_size == 1 ? pa_f32_8 : pa_f32_16) @@ -853,7 +853,7 @@ static void update_repack_float(struct mp_repack *rp) // The fixed point format. struct mp_regular_imgfmt desc = {0}; mp_get_regular_imgfmt(&desc, rp->imgfmt_b); - assert(desc.component_size); + mp_assert(desc.component_size); int comp_bits = desc.component_size * 8 + MPMIN(desc.component_pad, 0); for (int p = 0; p < desc.num_planes; p++) { @@ -872,21 +872,21 @@ static void update_repack_float(struct mp_repack *rp) void repack_line(struct mp_repack *rp, int dst_x, int dst_y, int src_x, int src_y, int w) { - assert(rp->configured); + mp_assert(rp->configured); struct repack_step *first = &rp->steps[0]; struct repack_step *last = &rp->steps[rp->num_steps - 1]; - assert(dst_x >= 0 && dst_y >= 0 && src_x >= 0 && src_y >= 0 && w >= 0); - assert(dst_x + w <= MP_ALIGN_UP(last->buf[1]->w, last->fmt[1].align_x)); - assert(src_x + w <= MP_ALIGN_UP(first->buf[0]->w, first->fmt[0].align_x)); - assert(dst_y < last->buf[1]->h); - assert(src_y < first->buf[0]->h); - assert(!(dst_x & (last->fmt[1].align_x - 1))); - assert(!(src_x & (first->fmt[0].align_x - 1))); - assert(!(w & ((1 << first->fmt[0].chroma_xs) - 1))); - assert(!(dst_y & (last->fmt[1].align_y - 1))); - assert(!(src_y & (first->fmt[0].align_y - 1))); + mp_assert(dst_x >= 0 && dst_y >= 0 && src_x >= 0 && src_y >= 0 && w >= 0); + mp_assert(dst_x + w <= MP_ALIGN_UP(last->buf[1]->w, last->fmt[1].align_x)); + mp_assert(src_x + w <= MP_ALIGN_UP(first->buf[0]->w, first->fmt[0].align_x)); + mp_assert(dst_y < last->buf[1]->h); + mp_assert(src_y < first->buf[0]->h); + mp_assert(!(dst_x & (last->fmt[1].align_x - 1))); + mp_assert(!(src_x & (first->fmt[0].align_x - 1))); + mp_assert(!(w & ((1 << first->fmt[0].chroma_xs) - 1))); + mp_assert(!(dst_y & (last->fmt[1].align_y - 1))); + mp_assert(!(src_y & (first->fmt[0].align_y - 1))); for (int n = 0; n < rp->num_steps; n++) { struct repack_step *rs = &rp->steps[n]; @@ -1029,7 +1029,7 @@ static bool setup_format_ne(struct mp_repack *rp) } for (int n = 0; n < rp->num_steps - 1; n++) - assert(rp->steps[n].fmt[1].id == rp->steps[n + 1].fmt[0].id); + mp_assert(rp->steps[n].fmt[1].id == rp->steps[n + 1].fmt[0].id); return true; } @@ -1115,12 +1115,12 @@ bool repack_config_buffers(struct mp_repack *rp, rp->configured = false; - assert(dst && src); + mp_assert(dst && src); int buf_w = MPMAX(dst->w, src->w); - assert(dst->imgfmt == rs_last->fmt[1].id); - assert(src->imgfmt == rs_first->fmt[0].id); + mp_assert(dst->imgfmt == rs_last->fmt[1].id); + mp_assert(src->imgfmt == rs_first->fmt[0].id); // Chain/allocate buffers. @@ -1134,7 +1134,7 @@ bool repack_config_buffers(struct mp_repack *rp, struct repack_step *rs = &rp->steps[n]; if (!rs->buf[0]) { - assert(n > 0); + mp_assert(n > 0); rs->buf[0] = rp->steps[n - 1].buf[1]; } diff --git a/video/sws_utils.c b/video/sws_utils.c index 490c3f7b05..a3aa57e5c2 100644 --- a/video/sws_utils.c +++ b/video/sws_utils.c @@ -353,7 +353,7 @@ static struct mp_image *check_alignment(struct mp_log *log, // and which in most cases is not larger than decoder output. It is smaller // or equal to what most image allocators in mpv/ffmpeg use. size_t align = 32; - assert(align <= MP_IMAGE_BYTE_ALIGN); // or mp_image_alloc will not cut it + mp_assert(align <= MP_IMAGE_BYTE_ALIGN); // or mp_image_alloc will not cut it bool is_aligned = true; for (int p = 0; p < img->num_planes; p++) { diff --git a/video/vdpau.c b/video/vdpau.c index 15985d650f..0b90e886f6 100644 --- a/video/vdpau.c +++ b/video/vdpau.c @@ -197,7 +197,7 @@ static void release_decoder_surface(void *ptr) struct mp_vdpau_ctx *ctx = r->ctx; mp_mutex_lock(&ctx->pool_lock); - assert(ctx->video_surfaces[r->index].in_use); + mp_assert(ctx->video_surfaces[r->index].in_use); ctx->video_surfaces[r->index].in_use = false; mp_mutex_unlock(&ctx->pool_lock); @@ -207,7 +207,7 @@ static void release_decoder_surface(void *ptr) static struct mp_image *create_ref(struct mp_vdpau_ctx *ctx, int index) { struct surface_entry *e = &ctx->video_surfaces[index]; - assert(!e->in_use); + mp_assert(!e->in_use); e->in_use = true; e->age = ctx->age_counter++; struct surface_ref *ref = talloc_ptrtype(NULL, ref); @@ -263,10 +263,10 @@ static struct mp_image *mp_vdpau_get_surface(struct mp_vdpau_ctx *ctx, for (int n = 0; n < MAX_VIDEO_SURFACES; n++) { struct surface_entry *e = &ctx->video_surfaces[n]; if (!e->in_use && e->allocated) { - assert(e->w == w && e->h == h); - assert(e->chroma == chroma); - assert(e->rgb_format == rgb_format); - assert(e->rgb == rgb); + mp_assert(e->w == w && e->h == h); + mp_assert(e->chroma == chroma); + mp_assert(e->rgb_format == rgb_format); + mp_assert(e->rgb == rgb); if (surface_index >= 0) { struct surface_entry *other = &ctx->video_surfaces[surface_index]; if (other->age < e->age) @@ -283,9 +283,9 @@ static struct mp_image *mp_vdpau_get_surface(struct mp_vdpau_ctx *ctx, for (int n = 0; n < MAX_VIDEO_SURFACES; n++) { struct surface_entry *e = &ctx->video_surfaces[n]; if (!e->in_use) { - assert(e->surface == VDP_INVALID_HANDLE); - assert(e->osurface == VDP_INVALID_HANDLE); - assert(!e->allocated); + mp_assert(e->surface == VDP_INVALID_HANDLE); + mp_assert(e->osurface == VDP_INVALID_HANDLE); + mp_assert(!e->allocated); e->chroma = chroma; e->rgb_format = rgb_format; e->rgb = rgb; @@ -339,7 +339,7 @@ static void free_device_ref(struct AVHWDeviceContext *hwctx) for (int i = 0; i < MAX_VIDEO_SURFACES; i++) { // can't hold references past context lifetime - assert(!ctx->video_surfaces[i].in_use); + mp_assert(!ctx->video_surfaces[i].in_use); if (ctx->video_surfaces[i].surface != VDP_INVALID_HANDLE) { vdp_st = vdp->video_surface_destroy(ctx->video_surfaces[i].surface); CHECK_VDP_WARNING(ctx, "Error when calling vdp_video_surface_destroy"); diff --git a/video/vdpau_mixer.c b/video/vdpau_mixer.c index e062dcc06c..0336e09a80 100644 --- a/video/vdpau_mixer.c +++ b/video/vdpau_mixer.c @@ -35,7 +35,7 @@ static void free_mixed_frame(void *arg) // "base" is used only to set parameters, no image data is referenced. struct mp_image *mp_vdpau_mixed_frame_create(struct mp_image *base) { - assert(base->imgfmt == IMGFMT_VDPAU); + mp_assert(base->imgfmt == IMGFMT_VDPAU); struct mp_vdpau_mixer_frame *frame = talloc_zero(NULL, struct mp_vdpau_mixer_frame); diff --git a/video/zimg.c b/video/zimg.c index 907e81deb7..2e176e5061 100644 --- a/video/zimg.c +++ b/video/zimg.c @@ -250,8 +250,8 @@ static int repack_entrypoint(void *user, unsigned i, unsigned x0, unsigned x1) x0 &= ~(unsigned)(mp_repack_get_align_x(r->repack) - 1); // mp_repack requirements and zimg guarantees. - assert(!(i & (mp_repack_get_align_y(r->repack) - 1))); - assert(!(x0 & (mp_repack_get_align_x(r->repack) - 1))); + mp_assert(!(i & (mp_repack_get_align_y(r->repack) - 1))); + mp_assert(!(x0 & (mp_repack_get_align_x(r->repack) - 1))); unsigned i_src = i & (r->pack ? r->zmask[0] : ZIMG_BUFFER_MAX); unsigned i_dst = i & (r->pack ? ZIMG_BUFFER_MAX : r->zmask[0]); @@ -275,7 +275,7 @@ static bool wrap_buffer(struct mp_zimg_state *st, struct mp_zimg_repack *r, // Due to subsampling we may assume the image to be bigger than it // actually is (see real_h in setup_format). if (mpi->h < y1) { - assert(y1 - mpi->h < 4); + mp_assert(y1 - mpi->h < 4); mp_image_set_size(mpi, mpi->w, y1); } mp_image_crop(mpi, 0, st->slice_y, mpi->w, y1); @@ -399,7 +399,7 @@ static bool setup_format(zimg_image_format *zfmt, struct mp_zimg_repack *r, zfmt->height = r->real_h = st->slice_h = MPMIN(st->slice_y + st->slice_h, r->real_h) - st->slice_y; - assert(MP_IS_ALIGNED(r->real_h, 1 << desc.chroma_ys)); + mp_assert(MP_IS_ALIGNED(r->real_h, 1 << desc.chroma_ys)); } else { // Relies on st->dst being initialized first. struct mp_zimg_repack *dst = st->dst; @@ -486,7 +486,7 @@ static bool allocate_buffer(struct mp_zimg_state *st, struct mp_zimg_repack *r) r->zmask[0] = zimg_select_buffer_mask(lines); // Either ZIMG_BUFFER_MAX, or a power-of-2 slice buffer. - assert(r->zmask[0] == ZIMG_BUFFER_MAX || MP_IS_POWER_OF_2(r->zmask[0] + 1)); + mp_assert(r->zmask[0] == ZIMG_BUFFER_MAX || MP_IS_POWER_OF_2(r->zmask[0] + 1)); int h = r->zmask[0] == ZIMG_BUFFER_MAX ? r->real_h : r->zmask[0] + 1; if (h >= r->real_h) { @@ -622,7 +622,7 @@ bool mp_zimg_config(struct mp_zimg_context *ctx) goto fail; } - assert(ctx->num_states == slices); + mp_assert(ctx->num_states == slices); return true; @@ -647,7 +647,7 @@ bool mp_zimg_config_image_params(struct mp_zimg_context *ctx) static void do_convert(struct mp_zimg_state *st) { - assert(st->graph); + mp_assert(st->graph); // An annoyance. zimg_image_buffer *zsrc = &st->src->zbuf; @@ -700,7 +700,7 @@ bool mp_zimg_convert(struct mp_zimg_context *ctx, struct mp_image *dst, bool r = mp_thread_pool_run(ctx->tp, do_convert_thread, st); // This is guaranteed by the API; and unrolling would be inconvenient. - assert(r); + mp_assert(r); } do_convert(ctx->states[0]);