mirror of
https://github.com/SFML/SFML.git
synced 2025-02-18 06:18:01 +08:00
Fix integer conversion warnings
This commit is contained in:
parent
c723f8aa22
commit
1fadff6ca4
@ -118,7 +118,7 @@ bool SoundFileReaderOpus::open(InputStream& stream, Info& info)
|
||||
|
||||
// Retrieve the music attributes
|
||||
const OpusHead* opusHead = op_head(m_opus, -1);
|
||||
info.channelCount = opusHead->channel_count;
|
||||
info.channelCount = static_cast<unsigned int>(opusHead->channel_count);
|
||||
info.sampleCount = static_cast<std::size_t>(op_pcm_total(m_opus, -1) * opusHead->channel_count);
|
||||
|
||||
// All Opus audio is encoded at 48kHz
|
||||
@ -137,7 +137,7 @@ void SoundFileReaderOpus::seek(Uint64 sampleOffset)
|
||||
{
|
||||
assert(m_opus != NULL);
|
||||
|
||||
op_pcm_seek(m_opus, sampleOffset / m_channelCount);
|
||||
op_pcm_seek(m_opus, static_cast<ogg_int64_t>(sampleOffset / m_channelCount));
|
||||
}
|
||||
|
||||
|
||||
@ -159,15 +159,15 @@ Uint64 SoundFileReaderOpus::read(Int16* samples, Uint64 maxCount)
|
||||
}
|
||||
else
|
||||
{
|
||||
samplesToRead = maxCount;
|
||||
samplesToRead = static_cast<int>(maxCount);
|
||||
}
|
||||
|
||||
// op_read returns number of SAMPLES read PER CHANNEL
|
||||
int samplesRead = op_read(m_opus, samples, samplesToRead, NULL) * m_channelCount;
|
||||
int samplesRead = op_read(m_opus, samples, samplesToRead, NULL) * static_cast<int>(m_channelCount);
|
||||
if (samplesRead > 0)
|
||||
{
|
||||
maxCount -= samplesRead;
|
||||
count += samplesRead;
|
||||
maxCount -= static_cast<sf::Uint64>(samplesRead);
|
||||
count += static_cast<sf::Uint64>(samplesRead);
|
||||
samples += samplesRead;
|
||||
}
|
||||
else
|
||||
|
@ -92,7 +92,7 @@ bool SoundFileWriterOpus::open(const std::string& filename, unsigned int sampleR
|
||||
}
|
||||
|
||||
int status = OPUS_INTERNAL_ERROR;
|
||||
m_opus = opus_encoder_create(sampleRate, channelCount, OPUS_APPLICATION_AUDIO, &status);
|
||||
m_opus = opus_encoder_create(static_cast<opus_int32>(sampleRate), static_cast<int>(channelCount), OPUS_APPLICATION_AUDIO, &status);
|
||||
if (status != OPUS_OK)
|
||||
{
|
||||
err() << "Failed to write ogg/opus file \"" << filename << "\"" << std::endl;
|
||||
@ -118,7 +118,7 @@ bool SoundFileWriterOpus::open(const std::string& filename, unsigned int sampleR
|
||||
std::vector<unsigned char> headerData(magicBytes.begin(), magicBytes.end());
|
||||
|
||||
headerData.push_back(1); // Version
|
||||
headerData.push_back(channelCount);
|
||||
headerData.push_back(static_cast<unsigned char>(channelCount));
|
||||
headerData.push_back(0); // Preskip
|
||||
headerData.push_back(0);
|
||||
|
||||
@ -132,11 +132,11 @@ bool SoundFileWriterOpus::open(const std::string& filename, unsigned int sampleR
|
||||
// Map opus header to ogg packet
|
||||
ogg_packet op;
|
||||
op.packet = &headerData.front(); // C++11: headerData.data();
|
||||
op.bytes = headerData.size();
|
||||
op.bytes = static_cast<long>(headerData.size());
|
||||
op.b_o_s = 1;
|
||||
op.e_o_s = 0;
|
||||
op.granulepos = 0;
|
||||
op.packetno = m_packageNumber++;
|
||||
op.packetno = static_cast<ogg_int64_t>(m_packageNumber++);
|
||||
|
||||
// Write the header packet to the ogg stream
|
||||
ogg_stream_packetin(&m_ogg, &op);
|
||||
@ -151,18 +151,18 @@ bool SoundFileWriterOpus::open(const std::string& filename, unsigned int sampleR
|
||||
const std::string opusVersion(opus_get_version_string());
|
||||
|
||||
// unsigned 32bit integer: Length of vendor string (encoding library)
|
||||
writeUint32(commentData, opusVersion.size());
|
||||
writeUint32(commentData, static_cast<sf::Uint32>(opusVersion.size()));
|
||||
commentData.insert(commentData.end(), opusVersion.begin(), opusVersion.end());
|
||||
|
||||
// Length of user comments (E.g. you can add a ENCODER tag for SFML)
|
||||
writeUint32(commentData, 0);
|
||||
|
||||
op.packet = &commentData.front();
|
||||
op.bytes = commentData.size();
|
||||
op.bytes = static_cast<long>(commentData.size());
|
||||
op.b_o_s = 0;
|
||||
op.e_o_s = 0;
|
||||
op.granulepos = 0;
|
||||
op.packetno = m_packageNumber++;
|
||||
op.packetno = static_cast<ogg_int64_t>(m_packageNumber++);
|
||||
ogg_stream_packetin(&m_ogg, &op);
|
||||
|
||||
// This ensures the actual audio data will start on a new page, as per spec
|
||||
@ -193,13 +193,13 @@ void SoundFileWriterOpus::write(const Int16* samples, Uint64 count)
|
||||
const Uint32 begin = frameNumber * frameSize * m_channelCount;
|
||||
std::vector<opus_int16> pad(samples + begin, samples + begin + count);
|
||||
pad.insert(pad.end(), (frameSize * m_channelCount) - pad.size(),0);
|
||||
packetSize = opus_encode(m_opus, &pad.front(), frameSize, &buffer.front(), buffer.size()); // C++11: replace &buffer.front() with buffer.data()
|
||||
packetSize = opus_encode(m_opus, &pad.front(), frameSize, &buffer.front(), static_cast<opus_int32>(buffer.size())); // C++11: replace &buffer.front() with buffer.data()
|
||||
endOfStream = 1;
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
packetSize = opus_encode(m_opus, samples + (frameNumber * frameSize * m_channelCount), frameSize, &buffer.front(), buffer.size());
|
||||
packetSize = opus_encode(m_opus, samples + (frameNumber * frameSize * m_channelCount), frameSize, &buffer.front(), static_cast<opus_int32>(buffer.size()));
|
||||
count -= frameSize * m_channelCount;
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ void SoundFileWriterOpus::write(const Int16* samples, Uint64 count)
|
||||
op.packet = &buffer.front();
|
||||
op.bytes = packetSize;
|
||||
op.granulepos = frameNumber * frameSize * 48000ul / m_sampleRate;
|
||||
op.packetno = m_packageNumber++;
|
||||
op.packetno = static_cast<ogg_int64_t>(m_packageNumber++);
|
||||
op.b_o_s = 0;
|
||||
op.e_o_s = endOfStream;
|
||||
ogg_stream_packetin(&m_ogg, &op);
|
||||
|
Loading…
x
Reference in New Issue
Block a user