various: replace some OOM handling

We prefer to fail fast rather than degrade in unpredictable ways.
The example in sub/ is particularly egregious because the code just
skips the work it's meant to do when an allocation fails.
This commit is contained in:
sfan5 2023-11-23 20:46:25 +01:00
parent e22a2f0483
commit aa362fdcf4
4 changed files with 6 additions and 9 deletions

View File

@ -471,10 +471,8 @@ bool ca_change_physical_format_sync(struct ao *ao, AudioStreamID stream,
ca_print_asbd(ao, "setting stream physical format:", &change_format);
mp_sem_t wakeup;
if (mp_sem_init(&wakeup, 0, 0)) {
MP_WARN(ao, "OOM\n");
return false;
}
if (mp_sem_init(&wakeup, 0, 0))
MP_HANDLE_OOM(0);
AudioStreamBasicDescription prev_format;
err = CA_GET(stream, kAudioStreamPropertyPhysicalFormat, &prev_format);

View File

@ -31,7 +31,8 @@
void mp_blur_rgba_sub_bitmap(struct sub_bitmap *d, double gblur)
{
struct mp_image *tmp1 = mp_image_alloc(IMGFMT_BGRA, d->w, d->h);
if (tmp1) { // on OOM, skip region
MP_HANDLE_OOM(tmp1);
{
struct mp_image s = {0};
mp_image_setfmt(&s, IMGFMT_BGRA);
mp_image_set_size(&s, d->w, d->h);

View File

@ -74,8 +74,7 @@ static void vf_vdpaupp_process(struct mp_filter *f)
struct mp_image *mpi =
mp_vdpau_mixed_frame_create(mp_refqueue_get_field(p->queue, 0));
if (!mpi)
return; // OOM
MP_HANDLE_OOM(mpi);
struct mp_vdpau_mixer_frame *frame = mp_vdpau_mixed_frame_get(mpi);
if (!mp_refqueue_should_deint(p->queue)) {

View File

@ -1372,8 +1372,7 @@ static void vo_x11_sizehint(struct vo *vo, struct mp_rect rc, bool override_pos)
override_pos; // for fullscreen and such
XSizeHints *hint = XAllocSizeHints();
if (!hint)
return; // OOM
MP_HANDLE_OOM(hint);
hint->flags |= PSize | (force_pos ? PPosition : 0);
hint->x = rc.x0;