Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.   SDL_mixer:  An audio mixer library based on the SDL library
  3.   Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
  4.  
  5.   This software is provided 'as-is', without any express or implied
  6.   warranty.  In no event will the authors be held liable for any damages
  7.   arising from the use of this software.
  8.  
  9.   Permission is granted to anyone to use this software for any purpose,
  10.   including commercial applications, and to alter it and redistribute it
  11.   freely, subject to the following restrictions:
  12.  
  13.   1. The origin of this software must not be misrepresented; you must not
  14.      claim that you wrote the original software. If you use this software
  15.      in a product, an acknowledgment in the product documentation would be
  16.      appreciated but is not required.
  17.   2. Altered source versions must be plainly marked as such, and must not be
  18.      misrepresented as being the original software.
  19.   3. This notice may not be removed or altered from any source distribution.
  20. */
  21.  
  22. #ifdef OGG_MUSIC
  23. #include "dynamic_ogg.h"
  24.  
  25. vorbis_loader vorbis = {
  26.         0, NULL
  27. };
  28.  
  29. #ifdef OGG_DYNAMIC
  30. int Mix_InitOgg()
  31. {
  32.         if ( vorbis.loaded == 0 ) {
  33.                 vorbis.handle = SDL_LoadObject(OGG_DYNAMIC);
  34.                 if ( vorbis.handle == NULL ) {
  35.                         return -1;
  36.                 }
  37.                 vorbis.ov_clear =
  38.                         (int (*)(OggVorbis_File *))
  39.                         SDL_LoadFunction(vorbis.handle, "ov_clear");
  40.                 if ( vorbis.ov_clear == NULL ) {
  41.                         SDL_UnloadObject(vorbis.handle);
  42.                         return -1;
  43.                 }
  44.                 vorbis.ov_info =
  45.                         (vorbis_info *(*)(OggVorbis_File *,int))
  46.                         SDL_LoadFunction(vorbis.handle, "ov_info");
  47.                 if ( vorbis.ov_info == NULL ) {
  48.                         SDL_UnloadObject(vorbis.handle);
  49.                         return -1;
  50.                 }
  51.                 vorbis.ov_open_callbacks =
  52.                         (int (*)(void *, OggVorbis_File *, char *, long, ov_callbacks))
  53.                         SDL_LoadFunction(vorbis.handle, "ov_open_callbacks");
  54.                 if ( vorbis.ov_open_callbacks == NULL ) {
  55.                         SDL_UnloadObject(vorbis.handle);
  56.                         return -1;
  57.                 }
  58.                 vorbis.ov_pcm_total =
  59.                         (ogg_int64_t (*)(OggVorbis_File *,int))
  60.                         SDL_LoadFunction(vorbis.handle, "ov_pcm_total");
  61.                 if ( vorbis.ov_pcm_total == NULL ) {
  62.                         SDL_UnloadObject(vorbis.handle);
  63.                         return -1;
  64.                 }
  65.                 vorbis.ov_read =
  66. #ifdef OGG_USE_TREMOR
  67.                         (long (*)(OggVorbis_File *,char *,int,int *))
  68. #else
  69.                         (long (*)(OggVorbis_File *,char *,int,int,int,int,int *))
  70. #endif
  71.                         SDL_LoadFunction(vorbis.handle, "ov_read");
  72.                 if ( vorbis.ov_read == NULL ) {
  73.                         SDL_UnloadObject(vorbis.handle);
  74.                         return -1;
  75.                 }
  76.                 vorbis.ov_time_seek =
  77. #ifdef OGG_USE_TREMOR
  78.                         (long (*)(OggVorbis_File *,ogg_int64_t))
  79. #else
  80.                         (int (*)(OggVorbis_File *,double))
  81. #endif
  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. }
  92. void 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
  103. int 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. }
  117. void 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 */
  129.