sync with sfml:

+ SoundStream.setPlayingOffset
* Listener.getTarget -> getDirection

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1349 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
trass3r 2010-01-11 21:48:15 +00:00
parent 06d91c6020
commit 1c3cdd5058
2 changed files with 41 additions and 29 deletions

View File

@ -109,44 +109,41 @@ class Listener
}
/**
* Change the orientation of the listener (the point
* he must look at).
* The default target is (0, 0, -1)
* Change the orientation of the listener
* The default direction is (0, 0, -1)
*
* Params:
* targetX = X position of the point the listener must look at
* targetY = X position of the point the listener must look at
* targetZ = X position of the point the listener must look at
* directionX = X component of the listener's direction
* directionY = Y component of the listener's direction
* directionZ = Z component of the listener's direction
*/
static void setTarget(float targetX, float targetY, float targetZ)
static void setDirection(float directionX, float directionY, float directionZ)
{
sfListener_SetTarget(targetX, targetY, targetZ);
sfListener_SetDirection(directionX, directionY, directionZ);
}
/**
* Change the orientation of the listener (the point
* he must look at).
* The default target is (0, 0, -1)
* Change the orientation of the listener
* The default direction is (0, 0, -1)
*
* Params:
* target = Position of the point the listener must look at
* direction = Position of the point the listener must look at
*/
static void setTarget(Vector3f position)
static void setDirection(Vector3f position)
{
sfListener_SetTarget(position.x, position.y, position.z);
sfListener_SetDirection(position.x, position.y, position.z);
}
/**
* Get the current orientation of the listener (the point
* he's looking at)
* Get the current orientation of the listener
*
* Returns:
* Position of the point the listener is looking at
*/
static Vector3f getTarget()
static Vector3f getDirection()
{
Vector3f ret;
sfListener_GetTarget(&ret.x, &ret.y, &ret.z);
sfListener_GetDirection(&ret.x, &ret.y, &ret.z);
return ret;
}
@ -160,15 +157,15 @@ private:
typedef float function() pf_sfListener_GetGlobalVolume;
typedef void function(float, float, float) pf_sfListener_SetPosition;
typedef void function(float*, float*, float*) pf_sfListener_GetPosition;
typedef void function(float, float, float) pf_sfListener_SetTarget;
typedef void function(float*, float*, float*) pf_sfListener_GetTarget;
typedef void function(float, float, float) pf_sfListener_SetDirection;
typedef void function(float*, float*, float*) pf_sfListener_GetDirection;
static pf_sfListener_SetGlobalVolume sfListener_SetGlobalVolume;
static pf_sfListener_GetGlobalVolume sfListener_GetGlobalVolume;
static pf_sfListener_SetPosition sfListener_SetPosition;
static pf_sfListener_GetPosition sfListener_GetPosition;
static pf_sfListener_SetTarget sfListener_SetTarget;
static pf_sfListener_GetTarget sfListener_GetTarget;
static pf_sfListener_SetDirection sfListener_SetDirection;
static pf_sfListener_GetDirection sfListener_GetDirection;
}
static this()
@ -182,7 +179,7 @@ private:
sfListener_GetGlobalVolume = cast(pf_sfListener_GetGlobalVolume)dll.getSymbol("sfListener_GetGlobalVolume");
sfListener_SetPosition = cast(pf_sfListener_SetPosition)dll.getSymbol("sfListener_SetPosition");
sfListener_GetPosition = cast(pf_sfListener_GetPosition)dll.getSymbol("sfListener_GetPosition");
sfListener_SetTarget = cast(pf_sfListener_SetTarget)dll.getSymbol("sfListener_SetTarget");
sfListener_GetTarget = cast(pf_sfListener_GetTarget)dll.getSymbol("sfListener_GetTarget");
sfListener_SetDirection = cast(pf_sfListener_SetDirection)dll.getSymbol("sfListener_SetDirection");
sfListener_GetDirection = cast(pf_sfListener_GetDirection)dll.getSymbol("sfListener_GetDirection");
}
}

View File

@ -146,6 +146,17 @@ abstract class SoundStream : SoundSource!("sfSoundStream")
return sfSoundStream_GetPlayingOffset(m_ptr);
}
/**
* Set the current playing position of a music
*
* Params:
* timeOffset = New playing position, expressed in seconds
*/
void setPlayingOffset(float timeOffset)
{
sfSoundStream_SetPlayingOffset(m_ptr, timeOffset);
}
/**
* Tell whether or not the stream is looping
*
@ -188,7 +199,7 @@ protected:
m_channelsCount = channelsCount;
m_sampleRate = sampleRate;
m_ptr = sfSoundStream_Create(&externalOnStart, &externalOnGetData, channelsCount, sampleRate, &m_id); // TODO: hack
m_ptr = sfSoundStream_Create(&externalOnGetData, &externalOnSeek, channelsCount, sampleRate, &m_id); // TODO: hack
m_mutex = new Mutex();
@ -222,7 +233,8 @@ protected:
private:
// Called sync when user calling play()
extern(C) static int externalOnStart(void* user)
// FIXME: this needs to be transformed from OnStart to OnSeek
extern(C) static void externalOnSeek(float t, void* user)
{
int id;
if ((id = *cast(int*) user) in s_instances)
@ -230,7 +242,7 @@ private:
SoundStream temp = s_instances[id];
return (temp.m_flag = temp.onStart());
}
return true;
// return true;
}
// C Thread callback (no allocation can be done)
@ -324,10 +336,10 @@ private:
{
struct sfSoundStreamChunk{ short* Samples; uint NbSamples; }
alias int function(void*) sfSoundStreamStartCallback;
alias void function(float, void*) sfSoundStreamSeekCallback;
alias int function (sfSoundStreamChunk*, void*) sfSoundStreamGetDataCallback;
alias void* function(sfSoundStreamStartCallback, sfSoundStreamGetDataCallback, uint, uint, void*) pf_sfSoundStream_Create;
alias void* function(sfSoundStreamGetDataCallback, sfSoundStreamSeekCallback, uint, uint, void*) pf_sfSoundStream_Create;
alias void function(void*) pf_sfSoundStream_Destroy;
alias void function(void*) pf_sfSoundStream_Play;
alias void function(void*) pf_sfSoundStream_Pause;
@ -335,6 +347,7 @@ private:
alias uint function(void*) pf_sfSoundStream_GetChannelsCount;
alias uint function(void*) pf_sfSoundStream_GetSampleRate;
alias float function(void*) pf_sfSoundStream_GetPlayingOffset;
alias void function(void*, float) pf_sfSoundStream_SetPlayingOffset;
alias int function(void*) pf_sfSoundStream_GetLoop;
alias void function(void*, int) pf_sfSoundStream_SetLoop;
@ -347,6 +360,7 @@ private:
static pf_sfSoundStream_GetChannelsCount sfSoundStream_GetChannelsCount;
static pf_sfSoundStream_GetSampleRate sfSoundStream_GetSampleRate;
static pf_sfSoundStream_GetPlayingOffset sfSoundStream_GetPlayingOffset;
static pf_sfSoundStream_SetPlayingOffset sfSoundStream_SetPlayingOffset;
static pf_sfSoundStream_GetLoop sfSoundStream_GetLoop;
static pf_sfSoundStream_SetLoop sfSoundStream_SetLoop;
}
@ -366,6 +380,7 @@ private:
sfSoundStream_GetChannelsCount = cast(pf_sfSoundStream_GetChannelsCount)dll.getSymbol("sfSoundStream_GetChannelsCount");
sfSoundStream_GetSampleRate = cast(pf_sfSoundStream_GetSampleRate)dll.getSymbol("sfSoundStream_GetSampleRate");
sfSoundStream_GetPlayingOffset = cast(pf_sfSoundStream_GetPlayingOffset)dll.getSymbol("sfSoundStream_GetPlayingOffset");
sfSoundStream_SetPlayingOffset = cast(pf_sfSoundStream_SetPlayingOffset)dll.getSymbol("sfSoundStream_SetPlayingOffset");
sfSoundStream_GetLoop = cast(pf_sfSoundStream_GetLoop)dll.getSymbol("sfSoundStream_GetLoop");
sfSoundStream_SetLoop = cast(pf_sfSoundStream_SetLoop)dll.getSymbol("sfSoundStream_SetLoop");
}