Added support of AL_LOOP_COUNT Source parameter 85/73585/7
authorIevgen Vagin <i.vagin@samsung.com>
Wed, 8 Jun 2016 17:18:34 +0000 (20:18 +0300)
committerIevgen Vagin <i.vagin@samsung.com>
Tue, 5 Jul 2016 07:05:36 +0000 (10:05 +0300)
Change-Id: Iac87a36be76939b6b244c706c34c68ac046086db
Signed-off-by: Ievgen Vagin <i.vagin@samsung.com>
Alc/ALc.c
Alc/mixer.c
CMakeLists.txt
OpenAL32/Include/alSource.h
OpenAL32/alSource.c
include/AL/al.h
packaging/openal-soft.spec

index d6d23eb..5114228 100644 (file)
--- 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),
index 712075f..636b8c8 100644 (file)
@@ -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;
index f319d01..62267a1 100644 (file)
@@ -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}")
index 1359616..a47e4b2 100644 (file)
@@ -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;
index 7382b87..b54a68a 100644 (file)
@@ -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;
index 413b383..8feb73e 100644 (file)
@@ -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
index 1fe4d74..f3f0b03 100644 (file)
@@ -32,6 +32,7 @@ cp %{SOURCE1001} .
 %build
 
 export CFLAGS+=" -D__TIZEN__ -DUSE_DLOG "
+export TIZEN_BUILD=1
 
 %cmake .
 make %{?_smp_mflags}