Use doubles instead of floats for the time argument in Source:seek. This probably won't affect anything meaningfully, but in theory it's more precise.

This commit is contained in:
Alex Szpakowski
2019-05-26 14:46:52 -03:00
parent 3c77edb68b
commit 38cb56f168
22 changed files with 39 additions and 37 deletions
+1 -1
View File
@@ -98,7 +98,7 @@ public:
* @param s The position in the stream in seconds.
* @return True if success, false on fail/unsupported.
**/
virtual bool seek(float s) = 0;
virtual bool seek(double s) = 0;
/**
* Rewinds the stream to the start.
@@ -227,7 +227,7 @@ int CoreAudioDecoder::decode()
return size;
}
bool CoreAudioDecoder::seek(float s)
bool CoreAudioDecoder::seek(double s)
{
OSStatus err = ExtAudioFileSeek(extAudioFile, (SInt64) (s * inputInfo.mSampleRate));
+1 -1
View File
@@ -54,7 +54,7 @@ public:
love::sound::Decoder *clone();
int decode();
bool seek(float s);
bool seek(double s);
bool rewind();
bool isSeekable();
int getChannelCount() const;
+2 -2
View File
@@ -78,9 +78,9 @@ int FLACDecoder::decode()
return bufferSize;
}
bool FLACDecoder::seek(float s)
bool FLACDecoder::seek(double s)
{
return seek_absolute((int)(s*1000.0f));
return seek_absolute((int)(s*1000.0));
}
bool FLACDecoder::rewind()
+1 -1
View File
@@ -46,7 +46,7 @@ public:
static bool accepts(const std::string &ext);
love::sound::Decoder *clone();
int decode();
bool seek(float s);
bool seek(double s);
bool rewind();
bool isSeekable();
int getChannelCount() const;
+2 -2
View File
@@ -109,9 +109,9 @@ int GmeDecoder::decode()
return bufferSize;
}
bool GmeDecoder::seek(float s)
bool GmeDecoder::seek(double s)
{
return gme_seek(emu, static_cast<long>(s * 1000.f)) != 0;
return gme_seek(emu, static_cast<long>(s * 1000.0)) != 0;
}
bool GmeDecoder::rewind()
+1 -1
View File
@@ -51,7 +51,7 @@ public:
love::sound::Decoder *clone();
int decode();
bool seek(float s);
bool seek(double s);
bool rewind();
bool isSeekable();
int getChannelCount() const;
+2 -2
View File
@@ -111,9 +111,9 @@ int ModPlugDecoder::decode()
return r;
}
bool ModPlugDecoder::seek(float s)
bool ModPlugDecoder::seek(double s)
{
ModPlug_Seek(plug, (int)(s*1000.0f));
ModPlug_Seek(plug, (int)(s*1000.0));
return true;
}
+1 -1
View File
@@ -54,7 +54,7 @@ public:
love::sound::Decoder *clone();
int decode();
bool seek(float s);
bool seek(double s);
bool rewind();
bool isSeekable();
int getChannelCount() const;
+1 -1
View File
@@ -232,7 +232,7 @@ int Mpg123Decoder::decode()
return size;
}
bool Mpg123Decoder::seek(float s)
bool Mpg123Decoder::seek(double s)
{
off_t offset = (off_t) (s * (double) sampleRate);
+1 -1
View File
@@ -66,7 +66,7 @@ public:
love::sound::Decoder *clone();
int decode();
bool seek(float s);
bool seek(double s);
bool rewind();
bool isSeekable();
int getChannelCount() const;
+1 -1
View File
@@ -209,7 +209,7 @@ int VorbisDecoder::decode()
return size;
}
bool VorbisDecoder::seek(float s)
bool VorbisDecoder::seek(double s)
{
int result = 0;
+1 -1
View File
@@ -57,7 +57,7 @@ public:
love::sound::Decoder *clone();
int decode();
bool seek(float s);
bool seek(double s);
bool rewind();
bool isSeekable();
int getChannelCount() const;
+1 -1
View File
@@ -143,7 +143,7 @@ int WaveDecoder::decode()
return (int) size;
}
bool WaveDecoder::seek(float s)
bool WaveDecoder::seek(double s)
{
int wuff_status = wuff_seek(handle, (wuff_uint64) (s * info.sample_rate));
+1 -1
View File
@@ -53,7 +53,7 @@ public:
love::sound::Decoder *clone();
int decode();
bool seek(float s);
bool seek(double s);
bool rewind();
bool isSeekable();
int getChannelCount() const;
+1 -1
View File
@@ -96,7 +96,7 @@ int w_Decoder_decode(lua_State *L)
int w_Decoder_seek(lua_State *L)
{
Decoder *t = luax_checkdecoder(L, 1);
float offset = luaL_checknumber(L, 2);
double offset = luaL_checknumber(L, 2);
if (offset < 0)
return luaL_argerror(L, 2, "can't seek to a negative position");
else if (offset == 0)