misc/libopenalbridge/wrappers.c
changeset 9373 b769a8e38cbd
parent 9372 915436ff64ab
child 9374 60063430445b
equal deleted inserted replaced
9372:915436ff64ab 9373:b769a8e38cbd
     1 /*
       
     2 * OpenAL Bridge - a simple portable library for OpenAL interface
       
     3 * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
       
     4 *
       
     5 * This program is free software; you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation; version 2 of the License
       
     8 *
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program; if not, write to the Free Software
       
    16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
       
    17 */
       
    18 
       
    19 #include "wrappers.h"
       
    20 #include "openalbridge_t.h"
       
    21 
       
    22 
       
    23 void *Malloc (size_t nbytes) {
       
    24     void *aptr;
       
    25 
       
    26     if ((aptr = malloc(nbytes)) == NULL) {
       
    27         fprintf(stderr,"(Bridge FATAL) - not enough memory\n");
       
    28         abort();
       
    29     }
       
    30 
       
    31     return aptr;
       
    32 }
       
    33 
       
    34 
       
    35 void *Realloc (void *aptr, size_t nbytes) {
       
    36     aptr = realloc(aptr, nbytes);
       
    37 
       
    38     if (aptr == NULL) {
       
    39         fprintf(stderr,"(Bridge FATAL) - not enough memory\n");
       
    40         abort();
       
    41     }
       
    42 
       
    43     return aptr;
       
    44 }
       
    45 
       
    46 
       
    47 FILE *Fopen (const char *fname, char *mode) {
       
    48     FILE *fp;
       
    49 
       
    50     fp = fopen(fname,mode);
       
    51     if (fp == NULL)
       
    52         fprintf(stderr,"(Bridge Error) - can't open file %s in mode '%s'\n", fname, mode);
       
    53 
       
    54     return fp;
       
    55 }
       
    56 
       
    57 
       
    58 al_sound_t new_sound_el (void) {
       
    59     al_sound_t sound;
       
    60 
       
    61     sound.filename = NULL;
       
    62     sound.buffer = -1;
       
    63     sound.source_index = -1;
       
    64     sound.is_used = AL_FALSE;
       
    65 
       
    66     return sound;
       
    67 }
       
    68 
       
    69 al_sound_t init_sound_el (const char *str) {
       
    70     al_sound_t sound;
       
    71 
       
    72     sound.filename = str;
       
    73     sound.source_index = -1;
       
    74     sound.is_used = AL_TRUE;
       
    75     alGenBuffers(1, &sound.buffer);
       
    76 
       
    77     return sound;
       
    78 }