mirror of https://github.com/mpv-player/mpv
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:
parent
e22a2f0483
commit
aa362fdcf4
|
@ -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);
|
ca_print_asbd(ao, "setting stream physical format:", &change_format);
|
||||||
|
|
||||||
mp_sem_t wakeup;
|
mp_sem_t wakeup;
|
||||||
if (mp_sem_init(&wakeup, 0, 0)) {
|
if (mp_sem_init(&wakeup, 0, 0))
|
||||||
MP_WARN(ao, "OOM\n");
|
MP_HANDLE_OOM(0);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
AudioStreamBasicDescription prev_format;
|
AudioStreamBasicDescription prev_format;
|
||||||
err = CA_GET(stream, kAudioStreamPropertyPhysicalFormat, &prev_format);
|
err = CA_GET(stream, kAudioStreamPropertyPhysicalFormat, &prev_format);
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
void mp_blur_rgba_sub_bitmap(struct sub_bitmap *d, double gblur)
|
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);
|
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};
|
struct mp_image s = {0};
|
||||||
mp_image_setfmt(&s, IMGFMT_BGRA);
|
mp_image_setfmt(&s, IMGFMT_BGRA);
|
||||||
mp_image_set_size(&s, d->w, d->h);
|
mp_image_set_size(&s, d->w, d->h);
|
||||||
|
|
|
@ -74,8 +74,7 @@ static void vf_vdpaupp_process(struct mp_filter *f)
|
||||||
|
|
||||||
struct mp_image *mpi =
|
struct mp_image *mpi =
|
||||||
mp_vdpau_mixed_frame_create(mp_refqueue_get_field(p->queue, 0));
|
mp_vdpau_mixed_frame_create(mp_refqueue_get_field(p->queue, 0));
|
||||||
if (!mpi)
|
MP_HANDLE_OOM(mpi);
|
||||||
return; // OOM
|
|
||||||
struct mp_vdpau_mixer_frame *frame = mp_vdpau_mixed_frame_get(mpi);
|
struct mp_vdpau_mixer_frame *frame = mp_vdpau_mixed_frame_get(mpi);
|
||||||
|
|
||||||
if (!mp_refqueue_should_deint(p->queue)) {
|
if (!mp_refqueue_should_deint(p->queue)) {
|
||||||
|
|
|
@ -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
|
override_pos; // for fullscreen and such
|
||||||
|
|
||||||
XSizeHints *hint = XAllocSizeHints();
|
XSizeHints *hint = XAllocSizeHints();
|
||||||
if (!hint)
|
MP_HANDLE_OOM(hint);
|
||||||
return; // OOM
|
|
||||||
|
|
||||||
hint->flags |= PSize | (force_pos ? PPosition : 0);
|
hint->flags |= PSize | (force_pos ? PPosition : 0);
|
||||||
hint->x = rc.x0;
|
hint->x = rc.x0;
|
||||||
|
|
Loading…
Reference in New Issue