From: Ievgen Vagin Date: Wed, 8 Jun 2016 17:18:34 +0000 (+0300) Subject: Added support of AL_LOOP_COUNT Source parameter X-Git-Tag: accepted/tizen/3.0/common/20161114.111400~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F73585%2F7;p=platform%2Fupstream%2Fopenal-soft.git Added support of AL_LOOP_COUNT Source parameter Change-Id: Iac87a36be76939b6b244c706c34c68ac046086db Signed-off-by: Ievgen Vagin --- diff --git a/Alc/ALc.c b/Alc/ALc.c index d6d23eb..5114228 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -379,6 +379,9 @@ static const ALCenums enumeration[] = { DECL(AL_DIRECTION), DECL(AL_VELOCITY), DECL(AL_LOOPING), +#ifdef __TIZEN__ + DECL(AL_LOOP_COUNT), +#endif DECL(AL_BUFFER), DECL(AL_GAIN), DECL(AL_MIN_GAIN), diff --git a/Alc/mixer.c b/Alc/mixer.c index 712075f..636b8c8 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -374,6 +374,9 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam ALbufferlistitem *BufferListItem; ALuint DataPosInt, DataPosFrac; ALboolean Looping; +#ifdef __TIZEN__ + ALuint LoopCount; +#endif ALuint increment; ALenum State; ALuint OutPos; @@ -389,6 +392,9 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam DataPosInt = Source->position; DataPosFrac = Source->position_fraction; Looping = Source->Looping; +#ifdef __TIZEN__ + LoopCount = Source->LoopCount; +#endif NumChannels = Source->NumChannels; SampleSize = Source->SampleSize; increment = voice->Step; @@ -614,8 +620,16 @@ ALvoid MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALuint Sam if(!(BufferListItem=BufferListItem->next)) { +#ifdef __TIZEN__ + if(Looping || LoopCount > 1) + { + BufferListItem = ATOMIC_LOAD(&Source->queue); + --Source->LoopCount; + } +#else if(Looping) BufferListItem = ATOMIC_LOAD(&Source->queue); +#endif else { State = AL_STOPPED; diff --git a/CMakeLists.txt b/CMakeLists.txt index f319d01..62267a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1077,6 +1077,10 @@ IF(LIBTYPE STREQUAL "STATIC") SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS}) ENDIF() +IF(DEFINED ENV{TIZEN_BUILD}) + SET(PKG_CONFIG_CFLAGS "${PKG_CONFIG_CFLAGS} -D__TIZEN__") +ENDIF() + # Needed for openal.pc.in SET(prefix ${CMAKE_INSTALL_PREFIX}) SET(exec_prefix "\${prefix}") diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index 1359616..a47e4b2 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -98,6 +98,13 @@ typedef struct ALsource { ALuint position; ALuint position_fraction; +#ifdef __TIZEN__ + /** + * Number of repeats Source should be played before finishing playback. + */ + ALuint LoopCount; +#endif + /** Source Buffer Queue info. */ ATOMIC(ALbufferlistitem*) queue; ATOMIC(ALbufferlistitem*) current_buffer; diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 7382b87..b54a68a 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -271,6 +271,9 @@ static ALint IntValsByProp(ALenum prop) case AL_DISTANCE_MODEL: case AL_SOURCE_RELATIVE: case AL_LOOPING: +#ifdef __TIZEN__ + case AL_LOOP_COUNT: +#endif case AL_BUFFER: case AL_SOURCE_STATE: case AL_BUFFERS_QUEUED: @@ -615,6 +618,24 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p Source->Looping = (ALboolean)*values; return AL_TRUE; +#ifdef __TIZEN__ + case AL_LOOP_COUNT: + { + ALuint uValue = (ALuint)(*values); + if(uValue > 0) + { + Source->LoopCount = uValue; + Source->Looping = AL_FALSE; + } + else if(uValue == 0) + { + Source->LoopCount = uValue; + Source->Looping = AL_TRUE; + } + return AL_TRUE; + } +#endif + case AL_BUFFER: CHECKVAL(*values == 0 || (buffer=LookupBuffer(device, *values)) != NULL); @@ -1707,7 +1728,6 @@ AL_API ALvoid AL_APIENTRY alSourcedvSOFT(ALuint source, ALenum param, const ALdo ALCcontext_DecRef(Context); } - AL_API ALvoid AL_APIENTRY alSourcei(ALuint source, ALenum param, ALint value) { ALCcontext *Context; @@ -2563,6 +2583,9 @@ static ALvoid InitSourceParams(ALsource *Source) Source->MaxDistance = FLT_MAX; Source->RollOffFactor = 1.0f; Source->Looping = AL_FALSE; +#ifdef __TIZEN__ + Source->LoopCount = 1; +#endif Source->Gain = 1.0f; Source->MinGain = 0.0f; Source->MaxGain = 1.0f; diff --git a/include/AL/al.h b/include/AL/al.h index 413b383..8feb73e 100644 --- a/include/AL/al.h +++ b/include/AL/al.h @@ -172,6 +172,16 @@ typedef void ALvoid; */ #define AL_LOOPING 0x1007 +#ifdef __TIZEN__ +/** + * Indicate whether source is looping. + * Type: ALuint + * Range: [0 - UINT_MAX] + * Default: 1 + */ +#define AL_LOOP_COUNT 0x1008 +#endif + /** * Source buffer. * Type: ALuint diff --git a/packaging/openal-soft.spec b/packaging/openal-soft.spec index 1fe4d74..f3f0b03 100644 --- a/packaging/openal-soft.spec +++ b/packaging/openal-soft.spec @@ -32,6 +32,7 @@ cp %{SOURCE1001} . %build export CFLAGS+=" -D__TIZEN__ -DUSE_DLOG " +export TIZEN_BUILD=1 %cmake . make %{?_smp_mflags}