1/* Copyright (C) 2007 Hong Zhiqian */ 2/** 3 @file misc_tm.h 4 @author Hong Zhiqian 5 @brief Various compatibility routines for Speex (TriMedia version) 6*/ 7/* 8 Redistribution and use in source and binary forms, with or without 9 modification, are permitted provided that the following conditions 10 are met: 11 12 - Redistributions of source code must retain the above copyright 13 notice, this list of conditions and the following disclaimer. 14 15 - Redistributions in binary form must reproduce the above copyright 16 notice, this list of conditions and the following disclaimer in the 17 documentation and/or other materials provided with the distribution. 18 19 - Neither the name of the Xiph.org Foundation nor the names of its 20 contributors may be used to endorse or promote products derived from 21 this software without specific prior written permission. 22 23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 27 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34*/ 35#include <tmml.h> 36 37 38#if TM_PROFILE 39int __profile_begin; 40int __profile_end; 41#endif 42 43#define OVERRIDE_SPEEX_ALLOC 44void *speex_alloc (int size) 45{ 46 void *ptr; 47 48 if ( tmmlMalloc(0, size, (pVoid*)&ptr, tmmlMallocCacheAligned | tmmlMallocCleared) != TM_OK ) 49 { return NULL; 50 } 51 52 return ptr; 53} 54 55 56#define OVERRIDE_SPEEX_ALLOC_SCRATCH 57void *speex_alloc_scratch (int size) 58{ 59 void *ptr; 60 61 if ( tmmlMalloc(0, size, (pVoid*)&ptr, tmmlMallocCacheAligned | tmmlMallocCleared) != TM_OK ) 62 { return NULL; 63 } 64 65 return ptr; 66} 67 68 69#define OVERRIDE_SPEEX_REALLOC 70void *speex_realloc (void *ptr, int size) 71{ 72 if ( tmmlRealloc(0, size, (pVoid)ptr, (pVoid*)&ptr, tmmlMallocCacheAligned | tmmlMallocCleared) != TM_OK ) 73 { return NULL; 74 } 75 76 return ptr; 77} 78 79 80#define OVERRIDE_SPEEX_FREE 81void speex_free (void *ptr) 82{ 83 tmmlFree(ptr); 84} 85 86 87#define OVERRIDE_SPEEX_FREE_SCRATCH 88void speex_free_scratch (void *ptr) 89{ 90 tmmlFree(ptr); 91} 92 93