00001 /* 00002 Copyright (c) 2008 Francisco Muņoz 'Hermes' <www.elotrolado.net> 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, are 00006 permitted provided that the following conditions are met: 00007 00008 - Redistributions of source code must retain the above copyright notice, this list of 00009 conditions and the following disclaimer. 00010 - Redistributions in binary form must reproduce the above copyright notice, this list 00011 of conditions and the following disclaimer in the documentation and/or other 00012 materials provided with the distribution. 00013 - The names of the contributors may not be used to endorse or promote products derived 00014 from this software without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 00017 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00019 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00020 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00021 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00022 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00023 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00024 THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 */ 00026 00027 #ifndef NO_SOUND 00028 00029 #ifndef __OGGPLAYER_H__ 00030 #define __OGGPLAYER_H__ 00031 00032 #include <asndlib.h> 00033 #include <tremor/ivorbiscodec.h> 00034 #include <tremor/ivorbisfile.h> 00035 00036 #ifdef __cplusplus 00037 extern "C" 00038 { 00039 #endif 00040 00041 #define OGG_ONE_TIME 0 00042 #define OGG_INFINITE_TIME 1 00043 00044 #define OGG_STATUS_RUNNING 1 00045 #define OGG_STATUS_ERR -1 00046 #define OGG_STATUS_PAUSED 2 00047 #define OGG_STATUS_EOF 255 00048 00049 /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ 00050 /* Player OGG functions */ 00051 /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ 00052 00053 /* int PlayOgg(int fd, int time_pos, int mode); 00054 00055 Play an Ogg file. This file can be loaded from memory (mem_open(void *ogg, int size_ogg)) or from device with open("device:file.ogg",O_RDONLY,0); 00056 00057 NOTE: The file is closed by the player when you call PlayOgg(), StopOgg() or if it fail. 00058 00059 -- Params --- 00060 00061 fd: file descriptor from open() or mem_open() 00062 00063 time_pos: initial time position in the file (in milliseconds). For example, use 30000 to advance 30 seconds 00064 00065 mode: Use OGG_ONE_TIME or OGG_INFINITE_TIME. When you use OGG_ONE_TIME the sound stops and StatusOgg() return OGG_STATUS_EOF 00066 00067 return: 0- Ok, -1 Error 00068 00069 */ 00070 00071 int PlayOgg(char * buf, int buflen, int time_pos, int mode); 00072 00073 /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ 00074 00075 /* void StopOgg(); 00076 00077 Stop an Ogg file. 00078 00079 NOTE: The file is closed and the player thread is released 00080 00081 -- Params --- 00082 00083 00084 */ 00085 00086 void StopOgg(); 00087 00088 /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ 00089 00090 /* void PauseOgg(int pause); 00091 00092 Pause an Ogg file. 00093 00094 -- Params --- 00095 00096 pause: 0 -> continue, 1-> pause 00097 00098 */ 00099 00100 void PauseOgg(int pause); 00101 00102 /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ 00103 00104 /* int StatusOgg(); 00105 00106 Return the Ogg status 00107 00108 -- Params --- 00109 00110 00111 return: OGG_STATUS_RUNNING 00112 OGG_STATUS_ERR -> not initialized? 00113 OGG_STATUS_PAUSED 00114 OGG_STATUS_EOF -> player stopped by End Of File 00115 00116 */ 00117 00118 int StatusOgg(); 00119 00120 /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ 00121 00122 /* void SetVolumeOgg(int volume); 00123 00124 Set the Ogg playing volume. 00125 NOTE: it change the volume of voice 0 (used for the Ogg player) 00126 00127 -- Params --- 00128 00129 volume: 0 to 255 (max) 00130 00131 */ 00132 00133 void SetVolumeOgg(int volume); 00134 00135 /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ 00136 00137 /* s32 GetTimeOgg(); 00138 00139 Return the Ogg time from the starts of the file 00140 00141 -- Params --- 00142 00143 return: 0 -> Ok or error condition (you must ignore this value) 00144 >0 -> time in milliseconds from the starts 00145 00146 */ 00147 00148 s32 GetTimeOgg(); 00149 00150 /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ 00151 00152 /* void SetTimeOgg(s32 time_pos); 00153 00154 Set the time position 00155 00156 NOTE: The file is closed by the player when you call PlayOgg(), StopOgg() or if it fail. 00157 00158 -- Params --- 00159 00160 time_pos: time position in the file (in milliseconds). For example, use 30000 to advance 30 seconds 00161 00162 */ 00163 00164 void SetTimeOgg(s32 time_pos); 00165 00166 /*------------------------------------------------------------------------------------------------------------------------------------------------------*/ 00167 00168 #ifdef __cplusplus 00169 } 00170 #endif 00171 00172 #endif 00173 00174 #endif