PageRenderTime 21ms CodeModel.GetById 11ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/project/jni/sdl_mixer/dynamic_ogg.c

https://github.com/aichunyu/FFPlayer
C | 128 lines | 99 code | 8 blank | 21 comment | 26 complexity | 58f4867eebc005e7ad20437e1615b6e6 MD5 | raw file
  1/*
  2    SDL_mixer:  An audio mixer library based on the SDL library
  3    Copyright (C) 1997-2009 Sam Lantinga
  4
  5    This library is free software; you can redistribute it and/or
  6    modify it under the terms of the GNU Library General Public
  7    License as published by the Free Software Foundation; either
  8    version 2 of the License, or (at your option) any later version.
  9
 10    This library is distributed in the hope that it will be useful,
 11    but WITHOUT ANY WARRANTY; without even the implied warranty of
 12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13    Library General Public License for more details.
 14
 15    You should have received a copy of the GNU Library General Public
 16    License along with this library; if not, write to the Free
 17    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18
 19    Sam Lantinga
 20    slouken@libsdl.org
 21*/
 22
 23#ifdef OGG_MUSIC
 24
 25#include "SDL_loadso.h"
 26
 27#include "dynamic_ogg.h"
 28
 29vorbis_loader vorbis = {
 30	0, NULL
 31};
 32
 33#ifdef OGG_DYNAMIC
 34int Mix_InitOgg()
 35{
 36	if ( vorbis.loaded == 0 ) {
 37		vorbis.handle = SDL_LoadObject(OGG_DYNAMIC);
 38		if ( vorbis.handle == NULL ) {
 39			return -1;
 40		}
 41		vorbis.ov_clear =
 42			(int (*)(OggVorbis_File *))
 43			SDL_LoadFunction(vorbis.handle, "ov_clear");
 44		if ( vorbis.ov_clear == NULL ) {
 45			SDL_UnloadObject(vorbis.handle);
 46			return -1;
 47		}
 48		vorbis.ov_info =
 49			(vorbis_info *(*)(OggVorbis_File *,int))
 50			SDL_LoadFunction(vorbis.handle, "ov_info");
 51		if ( vorbis.ov_info == NULL ) {
 52			SDL_UnloadObject(vorbis.handle);
 53			return -1;
 54		}
 55		vorbis.ov_open_callbacks =
 56			(int (*)(void *, OggVorbis_File *, char *, long, ov_callbacks))
 57			SDL_LoadFunction(vorbis.handle, "ov_open_callbacks");
 58		if ( vorbis.ov_open_callbacks == NULL ) {
 59			SDL_UnloadObject(vorbis.handle);
 60			return -1;
 61		}
 62		vorbis.ov_pcm_total =
 63			(ogg_int64_t (*)(OggVorbis_File *,int))
 64			SDL_LoadFunction(vorbis.handle, "ov_pcm_total");
 65		if ( vorbis.ov_pcm_total == NULL ) {
 66			SDL_UnloadObject(vorbis.handle);
 67			return -1;
 68		}
 69		vorbis.ov_read =
 70#ifdef OGG_USE_TREMOR
 71			(long (*)(OggVorbis_File *,char *,int,int *))
 72#else
 73			(long (*)(OggVorbis_File *,char *,int,int,int,int,int *))
 74#endif
 75			SDL_LoadFunction(vorbis.handle, "ov_read");
 76		if ( vorbis.ov_read == NULL ) {
 77			SDL_UnloadObject(vorbis.handle);
 78			return -1;
 79		}
 80		vorbis.ov_time_seek =
 81			(int (*)(OggVorbis_File *,double))
 82			SDL_LoadFunction(vorbis.handle, "ov_time_seek");
 83		if ( vorbis.ov_time_seek == NULL ) {
 84			SDL_UnloadObject(vorbis.handle);
 85			return -1;
 86		}
 87	}
 88	++vorbis.loaded;
 89
 90	return 0;
 91}
 92void Mix_QuitOgg()
 93{
 94	if ( vorbis.loaded == 0 ) {
 95		return;
 96	}
 97	if ( vorbis.loaded == 1 ) {
 98		SDL_UnloadObject(vorbis.handle);
 99	}
100	--vorbis.loaded;
101}
102#else
103int Mix_InitOgg()
104{
105	if ( vorbis.loaded == 0 ) {
106		vorbis.ov_clear = ov_clear;
107		vorbis.ov_info = ov_info;
108		vorbis.ov_open_callbacks = ov_open_callbacks;
109		vorbis.ov_pcm_total = ov_pcm_total;
110		vorbis.ov_read = ov_read;
111		vorbis.ov_time_seek = ov_time_seek;
112	}
113	++vorbis.loaded;
114
115	return 0;
116}
117void Mix_QuitOgg()
118{
119	if ( vorbis.loaded == 0 ) {
120		return;
121	}
122	if ( vorbis.loaded == 1 ) {
123	}
124	--vorbis.loaded;
125}
126#endif /* OGG_DYNAMIC */
127
128#endif /* OGG_MUSIC */