- applied Chriss OpenAL patch to make it uzable without GStreamer.

SVN r2984 (openal)
This commit is contained in:
Christoph Oelckers 2010-11-07 07:17:57 +00:00
parent d64fcbd01e
commit f3d05e2699
2 changed files with 191 additions and 92 deletions

View file

@ -167,11 +167,15 @@ if( WIN32 )
message( STATUS "Looking for al.h - not found" ) message( STATUS "Looking for al.h - not found" )
endif( OPENAL_INCLUDE_DIR ) endif( OPENAL_INCLUDE_DIR )
if( NOT OPENAL_INCLUDE_DIR OR NOT GLIB_INCLUDE_DIR OR NOT GST_INCLUDE_DIR ) if( NOT OPENAL_INCLUDE_DIR )
set( NO_OPENAL ON ) set( NO_OPENAL ON )
else( NOT OPENAL_INCLUDE_DIR OR NOT GLIB_INCLUDE_DIR OR NOT GST_INCLUDE_DIR ) else( NOT OPENAL_INCLUDE_DIR )
include_directories( ${OPENAL_INCLUDE_DIR} ${GLIB_INCLUDE_DIR} ${GST_INCLUDE_DIR} ) include_directories( ${OPENAL_INCLUDE_DIR} )
endif( NOT OPENAL_INCLUDE_DIR OR NOT GLIB_INCLUDE_DIR OR NOT GST_INCLUDE_DIR ) if( GLIB_INCLUDE_DIR AND GST_INCLUDE_DIR )
include_directories( ${OPENAL_INCLUDE_DIR} ${GLIB_INCLUDE_DIR} ${GST_INCLUDE_DIR} )
set( WITH_GSTREAMER ON )
endif( GLIB_INCLUDE_DIR AND GST_INCLUDE_DIR )
endif( NOT OPENAL_INCLUDE_DIR )
endif( NOT NO_OPENAL ) endif( NOT NO_OPENAL )
@ -191,38 +195,51 @@ if( WIN32 )
oleaut32 ) oleaut32 )
if( NOT NO_OPENAL ) if( NOT NO_OPENAL )
message( STATUS "Looking for GST libraries" ) message( STATUS "Looking for OpenAL library" )
find_library( OPENAL_LIBRARY NAMES OpenAL32 find_library( OPENAL_LIBRARY NAMES OpenAL32
PATHS ${OPENAL_SEARCH_PATHS} PATHS ${OPENAL_SEARCH_PATHS}
PATH_SUFFIXES lib ) PATH_SUFFIXES lib )
find_library( GST_LIBRARY1 NAMES gstapp-0.10
PATHS ${GST_SEARCH_PATHS} if( NOT OPENAL_LIBRARY )
PATH_SUFFIXES lib )
find_library( GST_LIBRARY2 NAMES gstaudio-0.10
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
find_library( GST_LIBRARY3 NAMES gstreamer-0.10
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
find_library( GST_LIBRARY4 NAMES gthread-2.0
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
find_library( GST_LIBRARY5 NAMES gmodule-2.0
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
find_library( GST_LIBRARY6 NAMES gobject-2.0
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
find_library( GST_LIBRARY7 NAMES glib-2.0
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
if( OPENAL_LIBRARY AND GST_LIBRARY1 AND GST_LIBRARY2 AND GST_LIBRARY3 AND GST_LIBRARY4 AND GST_LIBRARY5 AND GST_LIBRARY6 AND GST_LIBRARY7 )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${OPENAL_LIBRARY}" "${GST_LIBRARY1}" "${GST_LIBRARY2}" "${GST_LIBRARY3}" "${GST_LIBRARY4}" "${GST_LIBRARY5}" "${GST_LIBRARY6}" "${GST_LIBRARY7}" )
message( STATUS "Looking for GST libraries - found" )
else( OPENAL_LIBRARY AND GST_LIBRARY1 AND GST_LIBRARY2 AND GST_LIBRARY3 AND GST_LIBRARY4 AND GST_LIBRARY5 AND GST_LIBRARY6 AND GST_LIBRARY7 )
set( NO_OPENAL ON ) set( NO_OPENAL ON )
message( STATUS "Looking for GST libraries - not found" ) message( STATUS "Looking for OpenAL library - not found" )
endif( OPENAL_LIBRARY AND GST_LIBRARY1 AND GST_LIBRARY2 AND GST_LIBRARY3 AND GST_LIBRARY4 AND GST_LIBRARY5 AND GST_LIBRARY6 AND GST_LIBRARY7 ) else( NOT OPENAL_LIBRARY )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${OPENAL_LIBRARY}" )
message( STATUS "Looking for OpenAL library - found" )
endif( NOT OPENAL_LIBRARY )
if( WITH_GSTREAMER AND NOT NO_OPENAL )
message( STATUS "Looking for GST libraries" )
find_library( GST_LIBRARY1 NAMES gstapp-0.10
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
find_library( GST_LIBRARY2 NAMES gstaudio-0.10
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
find_library( GST_LIBRARY3 NAMES gstreamer-0.10
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
find_library( GST_LIBRARY4 NAMES gthread-2.0
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
find_library( GST_LIBRARY5 NAMES gmodule-2.0
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
find_library( GST_LIBRARY6 NAMES gobject-2.0
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
find_library( GST_LIBRARY7 NAMES glib-2.0
PATHS ${GST_SEARCH_PATHS}
PATH_SUFFIXES lib )
if( GST_LIBRARY1 AND GST_LIBRARY2 AND GST_LIBRARY3 AND GST_LIBRARY4 AND GST_LIBRARY5 AND GST_LIBRARY6 AND GST_LIBRARY7 )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "${GST_LIBRARY1}" "${GST_LIBRARY2}" "${GST_LIBRARY3}" "${GST_LIBRARY4}" "${GST_LIBRARY5}" "${GST_LIBRARY6}" "${GST_LIBRARY7}" )
message( STATUS "Looking for GST libraries - found" )
else( GST_LIBRARY1 AND GST_LIBRARY2 AND GST_LIBRARY3 AND GST_LIBRARY4 AND GST_LIBRARY5 AND GST_LIBRARY6 AND GST_LIBRARY7 )
set( WITH_GSTREAMER OFF )
message( STATUS "Looking for GST libraries - not found" )
endif( GST_LIBRARY1 AND GST_LIBRARY2 AND GST_LIBRARY3 AND GST_LIBRARY4 AND GST_LIBRARY5 AND GST_LIBRARY6 AND GST_LIBRARY7 )
endif( WITH_GSTREAMER AND NOT NO_OPENAL )
endif( NOT NO_OPENAL ) endif( NOT NO_OPENAL )
else( WIN32 ) else( WIN32 )
if( APPLE ) if( APPLE )
@ -232,12 +249,13 @@ else( WIN32 )
set( NO_GTK ON ) set( NO_GTK ON )
if( NOT NO_OPENAL ) if( NOT NO_OPENAL )
set( ZDOOM_LIBS ${ZDOOM_LIBS} "-framework OpenAL")
check_library_exists( gstapp-0.10 gst_app_src_set_callbacks "" HAS_GSTAPP ) check_library_exists( gstapp-0.10 gst_app_src_set_callbacks "" HAS_GSTAPP )
check_library_exists( gstaudio-0.10 gst_audio_set_channel_positions "" HAS_GSTAUDIO ) check_library_exists( gstaudio-0.10 gst_audio_set_channel_positions "" HAS_GSTAUDIO )
if( HAS_GSTAPP AND HAS_GSTAUDIO ) if( HAS_GSTAPP AND HAS_GSTAUDIO )
set( ZDOOM_LIBS ${ZDOOM_LIBS} gstapp-0.10 gst-audio-0.10 "-framework OpenAL") set( ZDOOM_LIBS ${ZDOOM_LIBS} gstapp-0.10 gst-audio-0.10 "-framework OpenAL")
else( HAS_GSTAPP AND HAS_GSTAUDIO ) set( WITH_GSTREAMER ON )
set( NO_OPENAL ON )
endif( HAS_GSTAPP AND HAS_GSTAUDIO ) endif( HAS_GSTAPP AND HAS_GSTAUDIO )
endif( NOT NO_OPENAL ) endif( NOT NO_OPENAL )
else( APPLE ) else( APPLE )
@ -266,13 +284,20 @@ else( WIN32 )
endif( GTK2_FOUND ) endif( GTK2_FOUND )
endif( NOT NO_GTK ) endif( NOT NO_GTK )
pkg_check_modules( OPENAL openal gstreamer-app-0.10>=0.10.23 gstreamer-audio-0.10 ) pkg_check_modules( OPENAL openal )
if( OPENAL_FOUND ) if( NOT OPENAL_FOUND )
set( NO_OPENAL ON )
else( NOT OPENAL_FOUND )
set( ZDOOM_LIBS ${ZDOOM_LIBS} ${OPENAL_LIBRARIES} ) set( ZDOOM_LIBS ${ZDOOM_LIBS} ${OPENAL_LIBRARIES} )
include_directories( ${OPENAL_INCLUDE_DIRS} ) include_directories( ${OPENAL_INCLUDE_DIRS} )
else( OPENAL_FOUND )
set( NO_OPENAL ON ) pkg_check_modules( GSTREAMER gstreamer-app-0.10>=0.10.23 gstreamer-audio-0.10 )
endif( OPENAL_FOUND ) if( GSTREAMER_FOUND )
set( ZDOOM_LIBS ${ZDOOM_LIBS} ${GSTREAMER_LIBRARIES} )
include_directories( ${GSTREAMER_INCLUDE_DIRS} )
set( WITH_GSTREAMER ON )
endif( GSTREAMER_FOUND )
endif( NOT OPENAL_FOUND )
endif( APPLE ) endif( APPLE )
set( NASM_NAMES nasm ) set( NASM_NAMES nasm )
@ -357,6 +382,8 @@ if( NO_FMOD )
endif( NO_FMOD ) endif( NO_FMOD )
if( NO_OPENAL ) if( NO_OPENAL )
add_definitions( -DNO_OPENAL=1 ) add_definitions( -DNO_OPENAL=1 )
elseif( WITH_GSTREAMER )
add_definitions( -DWITH_GSTREAMER=1 )
endif( NO_OPENAL ) endif( NO_OPENAL )
# Search for FluidSynth # Search for FluidSynth

View file

@ -177,7 +177,40 @@ static float GetRolloff(const FRolloffInfo *rolloff, float distance)
} }
/*** GStreamer start ***/ static ALenum FormatFromDesc(int bits, int channels)
{
if(bits == 8)
{
if(channels == 1) return AL_FORMAT_MONO8;
if(channels == 2) return AL_FORMAT_STEREO8;
if(channels == 4) return AL_FORMAT_QUAD8;
if(channels == 6) return AL_FORMAT_51CHN8;
if(channels == 7) return AL_FORMAT_61CHN8;
if(channels == 8) return AL_FORMAT_71CHN8;
}
if(bits == 16)
{
if(channels == 1) return AL_FORMAT_MONO16;
if(channels == 2) return AL_FORMAT_STEREO16;
if(channels == 4) return AL_FORMAT_QUAD16;
if(channels == 6) return AL_FORMAT_51CHN16;
if(channels == 7) return AL_FORMAT_61CHN16;
if(channels == 8) return AL_FORMAT_71CHN16;
}
if(bits == 32)
{
if(channels == 1) return AL_FORMAT_MONO_FLOAT32;
if(channels == 2) return AL_FORMAT_STEREO_FLOAT32;
if(channels == 4) return AL_FORMAT_QUAD32;
if(channels == 6) return AL_FORMAT_51CHN32;
if(channels == 7) return AL_FORMAT_61CHN32;
if(channels == 8) return AL_FORMAT_71CHN32;
}
return AL_NONE;
}
#ifdef WITH_GSTREAMER
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/app/gstappsrc.h> #include <gst/app/gstappsrc.h>
#include <gst/app/gstappsink.h> #include <gst/app/gstappsink.h>
@ -358,38 +391,6 @@ static GstCaps *SupportedBufferFormatCaps(int forcebits=0)
return caps; return caps;
} }
static ALenum FormatFromDesc(int bits, int channels)
{
if(bits == 8)
{
if(channels == 1) return AL_FORMAT_MONO8;
if(channels == 2) return AL_FORMAT_STEREO8;
if(channels == 4) return AL_FORMAT_QUAD8;
if(channels == 6) return AL_FORMAT_51CHN8;
if(channels == 7) return AL_FORMAT_61CHN8;
if(channels == 8) return AL_FORMAT_71CHN8;
}
if(bits == 16)
{
if(channels == 1) return AL_FORMAT_MONO16;
if(channels == 2) return AL_FORMAT_STEREO16;
if(channels == 4) return AL_FORMAT_QUAD16;
if(channels == 6) return AL_FORMAT_51CHN16;
if(channels == 7) return AL_FORMAT_61CHN16;
if(channels == 8) return AL_FORMAT_71CHN16;
}
if(bits == 32)
{
if(channels == 1) return AL_FORMAT_MONO_FLOAT32;
if(channels == 2) return AL_FORMAT_STEREO_FLOAT32;
if(channels == 4) return AL_FORMAT_QUAD32;
if(channels == 6) return AL_FORMAT_51CHN32;
if(channels == 7) return AL_FORMAT_61CHN32;
if(channels == 8) return AL_FORMAT_71CHN32;
}
return AL_NONE;
}
class OpenALSoundStream : public SoundStream class OpenALSoundStream : public SoundStream
{ {
OpenALSoundRenderer *Renderer; OpenALSoundRenderer *Renderer;
@ -783,18 +784,21 @@ class OpenALSoundStream : public SoundStream
{ {
PrintErrMsg("Prepare Error", msg); PrintErrMsg("Prepare Error", msg);
ret = GST_STATE_CHANGE_FAILURE; ret = GST_STATE_CHANGE_FAILURE;
gst_message_unref(msg);
break; break;
} }
else if(GST_MESSAGE_TYPE(msg) == GST_MESSAGE_TAG) else if(GST_MESSAGE_TYPE(msg) != GST_MESSAGE_TAG)
{ {
GstTagList *tags = NULL; gst_message_unref(msg);
gst_message_parse_tag(msg, &tags); break;
gst_tag_list_insert(TagList, tags, GST_TAG_MERGE_KEEP);
gst_tag_list_free(tags);
} }
else break;
GstTagList *tags = NULL;
gst_message_parse_tag(msg, &tags);
gst_tag_list_insert(TagList, tags, GST_TAG_MERGE_KEEP);
gst_tag_list_free(tags);
gst_message_unref(msg); gst_message_unref(msg);
} }
} }
@ -1403,22 +1407,22 @@ public:
if(GST_MESSAGE_TYPE(msg) == GST_MESSAGE_EOS) if(GST_MESSAGE_TYPE(msg) == GST_MESSAGE_EOS)
{ {
err = false; err = false;
gst_message_unref(msg);
break; break;
} }
else if(GST_MESSAGE_TYPE(msg) == GST_MESSAGE_TAG) if(GST_MESSAGE_TYPE(msg) != GST_MESSAGE_TAG)
{
GstTagList *tags = NULL;
gst_message_parse_tag(msg, &tags);
gst_tag_list_insert(TagList, tags, GST_TAG_MERGE_KEEP);
gst_tag_list_free(tags);
}
else if(GST_MESSAGE_TYPE(msg) == GST_MESSAGE_ERROR)
{ {
PrintErrMsg("Decoder Error", msg); PrintErrMsg("Decoder Error", msg);
gst_message_unref(msg);
break; break;
} }
GstTagList *tags = NULL;
gst_message_parse_tag(msg, &tags);
gst_tag_list_insert(TagList, tags, GST_TAG_MERGE_KEEP);
gst_tag_list_free(tags);
gst_message_unref(msg); gst_message_unref(msg);
} }
} }
@ -1437,8 +1441,8 @@ public:
unsigned int looppt[2] = { 0, 0 }; unsigned int looppt[2] = { 0, 0 };
bool looppt_is_samples[2] = { true, true }; bool looppt_is_samples[2] = { true, true };
bool has_looppt[2] = { false, false }; bool has_looppt[2] = { false, false };
HandleLoopTags(looppt, looppt_is_samples, has_looppt);
HandleLoopTags(looppt, looppt_is_samples, has_looppt);
if(has_looppt[0] || has_looppt[1]) if(has_looppt[0] || has_looppt[1])
{ {
if(!has_looppt[0]) if(!has_looppt[0])
@ -1467,7 +1471,73 @@ public:
return !err; return !err;
} }
}; };
/*** GStreamer end ***/ #else /* WITH_GSTREAMER */
class OpenALSoundStream : public SoundStream
{
OpenALSoundRenderer *Renderer;
public:
FTempFileName tmpfile;
ALfloat Volume;
OpenALSoundStream(OpenALSoundRenderer *renderer)
: Renderer(renderer), Volume(1.0f)
{ Renderer->Streams.push_back(this); }
virtual ~OpenALSoundStream()
{
Renderer->Streams.erase(find(Renderer->Streams.begin(),
Renderer->Streams.end(), this));
Renderer = NULL;
}
virtual bool Play(bool, float)
{ return false; }
virtual void Stop()
{ }
virtual void SetVolume(float vol)
{ Volume = vol; }
virtual bool SetPaused(bool)
{ return false; }
virtual unsigned int GetPosition()
{ return 0; }
virtual bool IsEnded()
{ return true; }
bool Init(const char*)
{ return false; }
bool Init(const BYTE*, unsigned int)
{ return false; }
bool Init(SoundStreamCallback, int, int, int, void*)
{ return false; }
};
class Decoder
{
public:
std::vector<BYTE> OutData;
ALint LoopPts[2];
ALsizei OutRate;
ALuint OutChannels;
ALuint OutBits;
Decoder()
: OutRate(0), OutChannels(0), OutBits(0)
{ LoopPts[0] = LoopPts[1] = 0; }
bool Decode(const void*, unsigned int, int=0)
{ return false; }
};
#endif /* WITH_GSTREAMER */
template<typename T> template<typename T>
static void LoadALFunc(const char *name, T *x) static void LoadALFunc(const char *name, T *x)
@ -1481,6 +1551,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
Printf("I_InitSound: Initializing OpenAL\n"); Printf("I_InitSound: Initializing OpenAL\n");
#ifdef WITH_GSTREAMER
static bool GSTInited = false; static bool GSTInited = false;
if(!GSTInited) if(!GSTInited)
{ {
@ -1493,6 +1564,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
} }
GSTInited = true; GSTInited = true;
} }
#endif
if(snd_aldevice != "Default") if(snd_aldevice != "Default")
{ {