misc/openalbridge/wrappers.c
changeset 3364 e5403e2bf02c
parent 3362 8d3b4d19ce27
child 3487 b1d00f1950c8
equal deleted inserted replaced
3363:bcd6d76db4f7 3364:e5403e2bf02c
    22 extern ALint *Sources;
    22 extern ALint *Sources;
    23 
    23 
    24 void *Malloc (size_t nbytes) {
    24 void *Malloc (size_t nbytes) {
    25     void *aptr;
    25     void *aptr;
    26 
    26 
    27     if ((aptr = malloc(nbytes)) == NULL)
    27     if ((aptr = malloc(nbytes)) == NULL) {
    28         err_dump("(%s) FATAL - not enough memory");
    28         fprintf(stderr,"(Bridge Fatal Error) - not enough memory");
    29 
    29         abort();
       
    30     }
       
    31     
    30     return aptr;
    32     return aptr;
    31 }
    33 }
    32 
    34 
    33 
    35 
    34 void *Realloc (void *aptr, size_t nbytes) {
    36 void *Realloc (void *aptr, size_t nbytes) {
    35     aptr = realloc(aptr, nbytes);
    37     aptr = realloc(aptr, nbytes);
    36 
    38 
    37     if (aptr == NULL)
    39     if (aptr == NULL) {
    38         err_dump("(%s) FATAL - not enough memory");
    40         fprintf(stderr,"(Bridge Fatal Error) - not enough memory");
       
    41         abort();
       
    42     }
    39 
    43 
    40     return aptr;
    44     return aptr;
    41 }
    45 }
    42 
    46 
    43 
    47 
    44 FILE *Fopen (const char *fname, char *mode)	{
    48 FILE *Fopen (const char *fname, char *mode)	{
    45     FILE *fp;
    49     FILE *fp;
    46 
    50 
    47     fp = fopen(fname,mode);
    51     fp = fopen(fname,mode);
    48     if (fp == NULL)
    52     if (fp == NULL)
    49         err_ret("(%s) ERROR - can't open file %s in mode '%s'", prog, fname, mode);
    53         fprintf(stderr,"(Bridge Error) - can't open file %s in mode '%s'", fname, mode);
    50 
    54 
    51     return fp;
    55     return fp;
    52 }
    56 }
    53 
    57 
    54 
    58 
    95             alSourcef(Sources[index], AL_GAIN, gain);
    99             alSourcef(Sources[index], AL_GAIN, gain);
    96             usleep(10000);
   100             usleep(10000);
    97         }
   101         }
    98 
   102 
    99         if (AL_NO_ERROR != alGetError())
   103         if (AL_NO_ERROR != alGetError())
   100             err_msg("(%s) WARN - Failed to set fade-out effect",prog);
   104             fprintf(stderr,"(Bridge Warning) - Failed to set fade-out effect");
   101 
   105 
   102         // stop that sound and reset its volume
   106         // stop that sound and reset its volume
   103         alSourceStop (Sources[index]);
   107         alSourceStop (Sources[index]);
   104         alSourcef (Sources[index], AL_GAIN, target_gain);
   108         alSourcef (Sources[index], AL_GAIN, target_gain);
   105     }
   109     }
   106 
   110 
   107     if (AL_NO_ERROR != alGetError())
   111     if (AL_NO_ERROR != alGetError())
   108         err_msg("(%s) WARN - Failed to set fade effect",prog);
   112         fprintf(stderr,"(Bridge Warning) - Failed to set fade effect");
   109 
   113 
   110 #ifndef _WIN32
   114 #ifndef _WIN32
   111     pthread_exit(NULL);
   115     pthread_exit(NULL);
   112 #else
   116 #else
   113     _endthread();
   117     _endthread();