ijksdl_vout_internal.h 2.4 KB
Newer Older
Z
Zhang Rui 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*****************************************************************************
 * ijksdl_vout_internal.h
 *****************************************************************************
 *
 * copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
 *
 * This file is part of ijkPlayer.
 *
 * ijkPlayer is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * ijkPlayer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with ijkPlayer; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef IJKSDL__IJKSDL_VOUT_INTERNAL_H
#define IJKSDL__IJKSDL_VOUT_INTERNAL_H

#include "ijksdl_vout.h"

29
inline static SDL_Vout *SDL_Vout_CreateInternal(size_t opaque_size)
Z
Zhang Rui 已提交
30
{
Z
Zhang Rui 已提交
31
    SDL_Vout *vout = (SDL_Vout*) mallocz(sizeof(SDL_Vout));
Z
Zhang Rui 已提交
32 33
    if (!vout)
        return NULL;
34

Z
Zhang Rui 已提交
35
    vout->opaque = mallocz(opaque_size);
36 37 38 39 40
    if (!vout->opaque) {
        free(vout);
        return NULL;
    }

Z
Zhang Rui 已提交
41 42
    vout->mutex = SDL_CreateMutex();
    if (vout->mutex == NULL) {
43
        free(vout->opaque);
Z
Zhang Rui 已提交
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
        free(vout);
        return NULL;
    }

    return vout;
}

inline static void SDL_Vout_FreeInternal(SDL_Vout *vout)
{
    if (!vout)
        return;

    if (vout->mutex) {
        SDL_DestroyMutex(vout->mutex);
    }

60
    free(vout->opaque);
Z
Zhang Rui 已提交
61
    memset(vout, 0, sizeof(SDL_Vout));
Z
Zhang Rui 已提交
62 63 64
    free(vout);
}

65 66
inline static SDL_VoutOverlay *SDL_VoutOverlay_CreateInternal(size_t opaque_size)
{
Z
Zhang Rui 已提交
67
    SDL_VoutOverlay *overlay = (SDL_VoutOverlay*) mallocz(sizeof(SDL_VoutOverlay));
68 69 70
    if (!overlay)
        return NULL;

Z
Zhang Rui 已提交
71
    overlay->opaque = mallocz(opaque_size);
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
    if (!overlay->opaque) {
        free(overlay);
        return NULL;
    }
    return overlay;
}

inline static void SDL_VoutOverlay_FreeInternal(SDL_VoutOverlay *overlay)
{
    if (!overlay)
        return;

    if (overlay->opaque)
        free(overlay->opaque);

    memset(overlay, 0, sizeof(SDL_VoutOverlay));
    free(overlay);
}

Z
Zhang Rui 已提交
91 92
#define SDLTRACE ALOGW

Z
Zhang Rui 已提交
93
#endif