ijksdl_aout_internal.h 1.8 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 29
/*****************************************************************************
 * ijksdl_aout_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_AOUT_INTERNAL_H
#define IJKSDL__IJKSDL_AOUT_INTERNAL_H

#include "ijksdl_mutex.h"
#include "ijksdl_aout.h"

30
inline static SDL_Aout *SDL_Aout_CreateInternal(size_t opaque_size)
Z
Zhang Rui 已提交
31
{
Z
Zhang Rui 已提交
32
    SDL_Aout *aout = (SDL_Aout*) mallocz(sizeof(SDL_Aout));
Z
Zhang Rui 已提交
33 34
    if (!aout)
        return NULL;
35

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

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

    return aout;
}

inline static void SDL_Aout_FreeInternal(SDL_Aout *aout)
{
    if (!aout)
        return;

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

61
    free(aout->opaque);
Z
Zhang Rui 已提交
62 63 64 65 66
    memset(aout, 0, sizeof(SDL_Aout));
    free(aout);
}

#endif