Debian Codegraph @

doc/spec/source/snippets/prg_err.c

raw
1 /*############################################################################
2 # Copyright (C) 2020 Intel Corporation
3 #
4 # SPDX-License-Identifier: MIT
5 ############################################################################*/
6
7 #include <stdlib.h>
8 #include <stdio.h>
9 #include <unistd.h>
10
11 #include "mfxdefs.h"
12 #include "mfxvideo.h"
13
14 /* These macro required for code compilation. */
15 #define INFINITE 0
16
17 mfxSession session;
18 mfxBitstream *bitstream;
19 mfxFrameSurface1 *surface_work, *surface_disp;
20 mfxSyncPoint buffered_syncp, syncp;
21 /* end of internal stuff */
22
23 static void prg_handle_device_busy (mfxSession session, mfxSyncPoint sp) {
24 if (sp) {
25 MFXVideoCORE_SyncOperation(session, sp, INFINITE);
26 } else {
27 sleep(5);
28 }
29 }
30
31
32
33 static void prg_err () {
34 /*beg1*/
35 mfxStatus sts=MFX_ERR_NONE;
36 for (;;) {
37 // do something
38 sts=MFXVideoDECODE_DecodeFrameAsync(session, bitstream, surface_work, &surface_disp, &syncp);
39 if (sts == MFX_ERR_NONE) buffered_syncp = syncp;
40 else if (sts == MFX_WRN_DEVICE_BUSY) prg_handle_device_busy(session, syncp ? syncp : buffered_syncp);
41
42 }
43 /*end1*/
44 }