mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Fixed seeking in multi channel FLAC files.
Updated seek() documentation.
This commit is contained in:
parent
698bbccd6a
commit
c78c8106da
@ -153,6 +153,9 @@ public:
|
|||||||
/// precision. If you need to jump to a given time, use the
|
/// precision. If you need to jump to a given time, use the
|
||||||
/// other overload.
|
/// other overload.
|
||||||
///
|
///
|
||||||
|
/// The sample offset takes the channels into account.
|
||||||
|
/// Offsets can be calculated like this:
|
||||||
|
/// `sampleNumber * sampleRate * channelCount`
|
||||||
/// If the given offset exceeds to total number of samples,
|
/// If the given offset exceeds to total number of samples,
|
||||||
/// this function jumps to the end of the sound file.
|
/// this function jumps to the end of the sound file.
|
||||||
///
|
///
|
||||||
|
@ -79,6 +79,9 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the current read position to the given sample offset
|
/// \brief Change the current read position to the given sample offset
|
||||||
///
|
///
|
||||||
|
/// The sample offset takes the channels into account.
|
||||||
|
/// Offsets can be calculated like this:
|
||||||
|
/// `sampleNumber * sampleRate * channelCount`
|
||||||
/// If the given offset exceeds to total number of samples,
|
/// If the given offset exceeds to total number of samples,
|
||||||
/// this function must jump to the end of the file.
|
/// this function must jump to the end of the file.
|
||||||
///
|
///
|
||||||
|
@ -210,7 +210,8 @@ bool SoundFileReaderFlac::check(InputStream& stream)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
SoundFileReaderFlac::SoundFileReaderFlac() :
|
SoundFileReaderFlac::SoundFileReaderFlac() :
|
||||||
m_decoder(NULL),
|
m_decoder(NULL),
|
||||||
m_clientData()
|
m_clientData(),
|
||||||
|
m_channelCount(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,6 +249,9 @@ bool SoundFileReaderFlac::open(InputStream& stream, Info& info)
|
|||||||
// Retrieve the sound properties
|
// Retrieve the sound properties
|
||||||
info = m_clientData.info; // was filled in the "metadata" callback
|
info = m_clientData.info; // was filled in the "metadata" callback
|
||||||
|
|
||||||
|
// We must keep the channel count for the seek function
|
||||||
|
m_channelCount = info.channelCount;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,7 +266,8 @@ void SoundFileReaderFlac::seek(Uint64 sampleOffset)
|
|||||||
m_clientData.remaining = 0;
|
m_clientData.remaining = 0;
|
||||||
m_clientData.leftovers.clear();
|
m_clientData.leftovers.clear();
|
||||||
|
|
||||||
FLAC__stream_decoder_seek_absolute(m_decoder, sampleOffset);
|
// FLAC decoder expects absolute sample offset, so we take the channel count out
|
||||||
|
FLAC__stream_decoder_seek_absolute(m_decoder, sampleOffset / m_channelCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,6 +82,9 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the current read position to the given sample offset
|
/// \brief Change the current read position to the given sample offset
|
||||||
///
|
///
|
||||||
|
/// The sample offset takes the channels into account.
|
||||||
|
/// Offsets can be calculated like this:
|
||||||
|
/// `sampleNumber * sampleRate * channelCount`
|
||||||
/// If the given offset exceeds to total number of samples,
|
/// If the given offset exceeds to total number of samples,
|
||||||
/// this function must jump to the end of the file.
|
/// this function must jump to the end of the file.
|
||||||
///
|
///
|
||||||
@ -128,8 +131,9 @@ private:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Member data
|
// Member data
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
FLAC__StreamDecoder* m_decoder; ///< FLAC decoder
|
FLAC__StreamDecoder* m_decoder; ///< FLAC decoder
|
||||||
ClientData m_clientData; ///< Structure passed to the decoder callbacks
|
ClientData m_clientData; ///< Structure passed to the decoder callbacks
|
||||||
|
unsigned int m_channelCount; ///< number of channels of the sound file
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
@ -82,6 +82,9 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the current read position to the given sample offset
|
/// \brief Change the current read position to the given sample offset
|
||||||
///
|
///
|
||||||
|
/// The sample offset takes the channels into account.
|
||||||
|
/// Offsets can be calculated like this:
|
||||||
|
/// `sampleNumber * sampleRate * channelCount`
|
||||||
/// If the given offset exceeds to total number of samples,
|
/// If the given offset exceeds to total number of samples,
|
||||||
/// this function must jump to the end of the file.
|
/// this function must jump to the end of the file.
|
||||||
///
|
///
|
||||||
|
@ -74,6 +74,9 @@ public:
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Change the current read position to the given sample offset
|
/// \brief Change the current read position to the given sample offset
|
||||||
///
|
///
|
||||||
|
/// The sample offset takes the channels into account.
|
||||||
|
/// Offsets can be calculated like this:
|
||||||
|
/// `sampleNumber * sampleRate * channelCount`
|
||||||
/// If the given offset exceeds to total number of samples,
|
/// If the given offset exceeds to total number of samples,
|
||||||
/// this function must jump to the end of the file.
|
/// this function must jump to the end of the file.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user