Avoid implicit conversions with the examples and utils
This commit is contained in:
parent
474d478854
commit
4c76f32dda
@ -213,7 +213,7 @@ class PacketQueue {
|
|||||||
void pop()
|
void pop()
|
||||||
{
|
{
|
||||||
AVPacket *pkt = &mPackets.front();
|
AVPacket *pkt = &mPackets.front();
|
||||||
mTotalSize -= pkt->size;
|
mTotalSize -= static_cast<unsigned int>(pkt->size);
|
||||||
av_packet_unref(pkt);
|
av_packet_unref(pkt);
|
||||||
mPackets.pop_front();
|
mPackets.pop_front();
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mTotalSize += mPackets.back().size;
|
mTotalSize += static_cast<unsigned int>(mPackets.back().size);
|
||||||
}
|
}
|
||||||
mCondVar.notify_one();
|
mCondVar.notify_one();
|
||||||
return true;
|
return true;
|
||||||
@ -299,7 +299,7 @@ struct AudioState {
|
|||||||
SwrContextPtr mSwresCtx;
|
SwrContextPtr mSwresCtx;
|
||||||
|
|
||||||
/* Conversion format, for what gets fed to OpenAL */
|
/* Conversion format, for what gets fed to OpenAL */
|
||||||
int mDstChanLayout{0};
|
uint64_t mDstChanLayout{0};
|
||||||
AVSampleFormat mDstSampleFmt{AV_SAMPLE_FMT_NONE};
|
AVSampleFormat mDstSampleFmt{AV_SAMPLE_FMT_NONE};
|
||||||
|
|
||||||
/* Storage of converted samples */
|
/* Storage of converted samples */
|
||||||
@ -310,14 +310,14 @@ struct AudioState {
|
|||||||
|
|
||||||
/* OpenAL format */
|
/* OpenAL format */
|
||||||
ALenum mFormat{AL_NONE};
|
ALenum mFormat{AL_NONE};
|
||||||
ALsizei mFrameSize{0};
|
ALuint mFrameSize{0};
|
||||||
|
|
||||||
std::mutex mSrcMutex;
|
std::mutex mSrcMutex;
|
||||||
std::condition_variable mSrcCond;
|
std::condition_variable mSrcCond;
|
||||||
std::atomic_flag mConnected;
|
std::atomic_flag mConnected;
|
||||||
ALuint mSource{0};
|
ALuint mSource{0};
|
||||||
std::vector<ALuint> mBuffers;
|
std::vector<ALuint> mBuffers;
|
||||||
ALsizei mBufferIdx{0};
|
ALuint mBufferIdx{0};
|
||||||
|
|
||||||
AudioState(MovieState &movie) : mMovie(movie)
|
AudioState(MovieState &movie) : mMovie(movie)
|
||||||
{ mConnected.test_and_set(std::memory_order_relaxed); }
|
{ mConnected.test_and_set(std::memory_order_relaxed); }
|
||||||
@ -326,7 +326,7 @@ struct AudioState {
|
|||||||
if(mSource)
|
if(mSource)
|
||||||
alDeleteSources(1, &mSource);
|
alDeleteSources(1, &mSource);
|
||||||
if(!mBuffers.empty())
|
if(!mBuffers.empty())
|
||||||
alDeleteBuffers(mBuffers.size(), mBuffers.data());
|
alDeleteBuffers(static_cast<ALsizei>(mBuffers.size()), mBuffers.data());
|
||||||
|
|
||||||
av_freep(&mSamples);
|
av_freep(&mSamples);
|
||||||
}
|
}
|
||||||
@ -348,7 +348,7 @@ struct AudioState {
|
|||||||
|
|
||||||
int getSync();
|
int getSync();
|
||||||
int decodeFrame();
|
int decodeFrame();
|
||||||
bool readAudio(uint8_t *samples, int length);
|
bool readAudio(uint8_t *samples, unsigned int length);
|
||||||
|
|
||||||
int handler();
|
int handler();
|
||||||
};
|
};
|
||||||
@ -441,7 +441,7 @@ struct MovieState {
|
|||||||
|
|
||||||
nanoseconds getDuration();
|
nanoseconds getDuration();
|
||||||
|
|
||||||
int streamComponentOpen(int stream_index);
|
int streamComponentOpen(unsigned int stream_index);
|
||||||
int parse_handler();
|
int parse_handler();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -618,17 +618,17 @@ int AudioState::decodeFrame()
|
|||||||
* multiple of the template type size.
|
* multiple of the template type size.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void sample_dup(uint8_t *out, const uint8_t *in, int count, int frame_size)
|
static void sample_dup(uint8_t *out, const uint8_t *in, unsigned int count, size_t frame_size)
|
||||||
{
|
{
|
||||||
const T *sample = reinterpret_cast<const T*>(in);
|
auto *sample = reinterpret_cast<const T*>(in);
|
||||||
T *dst = reinterpret_cast<T*>(out);
|
auto *dst = reinterpret_cast<T*>(out);
|
||||||
if(frame_size == sizeof(T))
|
if(frame_size == sizeof(T))
|
||||||
std::fill_n(dst, count, *sample);
|
std::fill_n(dst, count, *sample);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* NOTE: frame_size is a multiple of sizeof(T). */
|
/* NOTE: frame_size is a multiple of sizeof(T). */
|
||||||
int type_mult = frame_size / sizeof(T);
|
size_t type_mult{frame_size / sizeof(T)};
|
||||||
int i = 0;
|
size_t i{0};
|
||||||
std::generate_n(dst, count*type_mult,
|
std::generate_n(dst, count*type_mult,
|
||||||
[sample,type_mult,&i]() -> T
|
[sample,type_mult,&i]() -> T
|
||||||
{
|
{
|
||||||
@ -641,10 +641,10 @@ static void sample_dup(uint8_t *out, const uint8_t *in, int count, int frame_siz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool AudioState::readAudio(uint8_t *samples, int length)
|
bool AudioState::readAudio(uint8_t *samples, unsigned int length)
|
||||||
{
|
{
|
||||||
int sample_skip = getSync();
|
int sample_skip{getSync()};
|
||||||
int audio_size = 0;
|
unsigned int audio_size{0};
|
||||||
|
|
||||||
/* Read the next chunk of data, refill the buffer, and queue it
|
/* Read the next chunk of data, refill the buffer, and queue it
|
||||||
* on the source */
|
* on the source */
|
||||||
@ -669,16 +669,17 @@ bool AudioState::readAudio(uint8_t *samples, int length)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rem = length - audio_size;
|
unsigned int rem{length - audio_size};
|
||||||
if(mSamplesPos >= 0)
|
if(mSamplesPos >= 0)
|
||||||
{
|
{
|
||||||
int len = mSamplesLen - mSamplesPos;
|
const auto len = static_cast<unsigned int>(mSamplesLen - mSamplesPos);
|
||||||
if(rem > len) rem = len;
|
if(rem > len) rem = len;
|
||||||
memcpy(samples, mSamples + mSamplesPos*mFrameSize, rem*mFrameSize);
|
std::copy_n(mSamples + static_cast<unsigned int>(mSamplesPos)*mFrameSize,
|
||||||
|
rem*mFrameSize, samples);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rem = std::min(rem, -mSamplesPos);
|
rem = std::min(rem, static_cast<unsigned int>(-mSamplesPos));
|
||||||
|
|
||||||
/* Add samples by copying the first sample */
|
/* Add samples by copying the first sample */
|
||||||
if((mFrameSize&7) == 0)
|
if((mFrameSize&7) == 0)
|
||||||
@ -692,7 +693,7 @@ bool AudioState::readAudio(uint8_t *samples, int length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mSamplesPos += rem;
|
mSamplesPos += rem;
|
||||||
mCurrentPts += nanoseconds(seconds(rem)) / mCodecCtx->sample_rate;
|
mCurrentPts += nanoseconds{seconds{rem}} / mCodecCtx->sample_rate;
|
||||||
samples += rem*mFrameSize;
|
samples += rem*mFrameSize;
|
||||||
audio_size += rem;
|
audio_size += rem;
|
||||||
}
|
}
|
||||||
@ -701,10 +702,10 @@ bool AudioState::readAudio(uint8_t *samples, int length)
|
|||||||
|
|
||||||
if(audio_size < length)
|
if(audio_size < length)
|
||||||
{
|
{
|
||||||
int rem = length - audio_size;
|
const unsigned int rem{length - audio_size};
|
||||||
std::fill_n(samples, rem*mFrameSize,
|
std::fill_n(samples, rem*mFrameSize,
|
||||||
(mDstSampleFmt == AV_SAMPLE_FMT_U8) ? 0x80 : 0x00);
|
(mDstSampleFmt == AV_SAMPLE_FMT_U8) ? 0x80 : 0x00);
|
||||||
mCurrentPts += nanoseconds(seconds(rem)) / mCodecCtx->sample_rate;
|
mCurrentPts += nanoseconds{seconds{rem}} / mCodecCtx->sample_rate;
|
||||||
audio_size += rem;
|
audio_size += rem;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -928,8 +929,8 @@ int AudioState::handler()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void *samples{nullptr};
|
void *samples{nullptr};
|
||||||
ALsizei buffer_len = std::chrono::duration_cast<std::chrono::duration<int>>(
|
ALsizei buffer_len = static_cast<int>(std::chrono::duration_cast<seconds>(
|
||||||
mCodecCtx->sample_rate * AudioBufferTime).count() * mFrameSize;
|
mCodecCtx->sample_rate * AudioBufferTime).count() * mFrameSize);
|
||||||
|
|
||||||
mSamples = nullptr;
|
mSamples = nullptr;
|
||||||
mSamplesMax = 0;
|
mSamplesMax = 0;
|
||||||
@ -968,9 +969,9 @@ int AudioState::handler()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
mSwresCtx.reset(swr_alloc_set_opts(nullptr,
|
mSwresCtx.reset(swr_alloc_set_opts(nullptr,
|
||||||
mDstChanLayout, mDstSampleFmt, mCodecCtx->sample_rate,
|
static_cast<int64_t>(mDstChanLayout), mDstSampleFmt, mCodecCtx->sample_rate,
|
||||||
mCodecCtx->channel_layout ? mCodecCtx->channel_layout :
|
mCodecCtx->channel_layout ? static_cast<int64_t>(mCodecCtx->channel_layout) :
|
||||||
static_cast<uint64_t>(av_get_default_channel_layout(mCodecCtx->channels)),
|
av_get_default_channel_layout(mCodecCtx->channels),
|
||||||
mCodecCtx->sample_fmt, mCodecCtx->sample_rate,
|
mCodecCtx->sample_fmt, mCodecCtx->sample_rate,
|
||||||
0, nullptr));
|
0, nullptr));
|
||||||
if(!mSwresCtx || swr_init(mSwresCtx.get()) != 0)
|
if(!mSwresCtx || swr_init(mSwresCtx.get()) != 0)
|
||||||
@ -980,7 +981,7 @@ int AudioState::handler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
mBuffers.assign(AudioBufferTotalTime / AudioBufferTime, 0);
|
mBuffers.assign(AudioBufferTotalTime / AudioBufferTime, 0);
|
||||||
alGenBuffers(mBuffers.size(), mBuffers.data());
|
alGenBuffers(static_cast<ALsizei>(mBuffers.size()), mBuffers.data());
|
||||||
alGenSources(1, &mSource);
|
alGenSources(1, &mSource);
|
||||||
|
|
||||||
if(EnableDirectOut)
|
if(EnableDirectOut)
|
||||||
@ -1003,12 +1004,12 @@ int AudioState::handler()
|
|||||||
if(alGetError() != AL_NO_ERROR)
|
if(alGetError() != AL_NO_ERROR)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to use mapped buffers\n");
|
fprintf(stderr, "Failed to use mapped buffers\n");
|
||||||
samples = av_malloc(buffer_len);
|
samples = av_malloc(static_cast<ALuint>(buffer_len));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
samples = av_malloc(buffer_len);
|
samples = av_malloc(static_cast<ALuint>(buffer_len));
|
||||||
|
|
||||||
/* Prefill the codec buffer. */
|
/* Prefill the codec buffer. */
|
||||||
do {
|
do {
|
||||||
@ -1053,14 +1054,15 @@ int AudioState::handler()
|
|||||||
{
|
{
|
||||||
auto ptr = static_cast<uint8_t*>(alMapBufferSOFT(bufid, 0, buffer_len,
|
auto ptr = static_cast<uint8_t*>(alMapBufferSOFT(bufid, 0, buffer_len,
|
||||||
AL_MAP_WRITE_BIT_SOFT));
|
AL_MAP_WRITE_BIT_SOFT));
|
||||||
bool got_audio{readAudio(ptr, buffer_len)};
|
bool got_audio{readAudio(ptr, static_cast<unsigned int>(buffer_len))};
|
||||||
alUnmapBufferSOFT(bufid);
|
alUnmapBufferSOFT(bufid);
|
||||||
if(!got_audio) break;
|
if(!got_audio) break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if(!readAudio(static_cast<uint8_t*>(samples), buffer_len))
|
auto ptr = static_cast<uint8_t*>(samples);
|
||||||
|
if(!readAudio(ptr, static_cast<unsigned int>(buffer_len)))
|
||||||
break;
|
break;
|
||||||
alBufferData(bufid, mFormat, samples, buffer_len, mCodecCtx->sample_rate);
|
alBufferData(bufid, mFormat, samples, buffer_len, mCodecCtx->sample_rate);
|
||||||
}
|
}
|
||||||
@ -1138,27 +1140,27 @@ void VideoState::display(SDL_Window *screen, SDL_Renderer *renderer)
|
|||||||
if(!mImage)
|
if(!mImage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float aspect_ratio;
|
double aspect_ratio;
|
||||||
int win_w, win_h;
|
int win_w, win_h;
|
||||||
int w, h, x, y;
|
int w, h, x, y;
|
||||||
|
|
||||||
if(mCodecCtx->sample_aspect_ratio.num == 0)
|
if(mCodecCtx->sample_aspect_ratio.num == 0)
|
||||||
aspect_ratio = 0.0f;
|
aspect_ratio = 0.0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
aspect_ratio = av_q2d(mCodecCtx->sample_aspect_ratio) * mCodecCtx->width /
|
aspect_ratio = av_q2d(mCodecCtx->sample_aspect_ratio) * mCodecCtx->width /
|
||||||
mCodecCtx->height;
|
mCodecCtx->height;
|
||||||
}
|
}
|
||||||
if(aspect_ratio <= 0.0f)
|
if(aspect_ratio <= 0.0)
|
||||||
aspect_ratio = static_cast<float>(mCodecCtx->width) / static_cast<float>(mCodecCtx->height);
|
aspect_ratio = static_cast<double>(mCodecCtx->width) / mCodecCtx->height;
|
||||||
|
|
||||||
SDL_GetWindowSize(screen, &win_w, &win_h);
|
SDL_GetWindowSize(screen, &win_w, &win_h);
|
||||||
h = win_h;
|
h = win_h;
|
||||||
w = (static_cast<int>(rint(h * aspect_ratio)) + 3) & ~3;
|
w = (static_cast<int>(std::rint(h * aspect_ratio)) + 3) & ~3;
|
||||||
if(w > win_w)
|
if(w > win_w)
|
||||||
{
|
{
|
||||||
w = win_w;
|
w = win_w;
|
||||||
h = (static_cast<int>(rint(w / aspect_ratio)) + 3) & ~3;
|
h = (static_cast<int>(std::rint(w / aspect_ratio)) + 3) & ~3;
|
||||||
}
|
}
|
||||||
x = (win_w - w) / 2;
|
x = (win_w - w) / 2;
|
||||||
y = (win_h - h) / 2;
|
y = (win_h - h) / 2;
|
||||||
@ -1460,9 +1462,9 @@ nanoseconds MovieState::getMasterClock()
|
|||||||
nanoseconds MovieState::getDuration()
|
nanoseconds MovieState::getDuration()
|
||||||
{ return std::chrono::duration<int64_t,std::ratio<1,AV_TIME_BASE>>(mFormatCtx->duration); }
|
{ return std::chrono::duration<int64_t,std::ratio<1,AV_TIME_BASE>>(mFormatCtx->duration); }
|
||||||
|
|
||||||
int MovieState::streamComponentOpen(int stream_index)
|
int MovieState::streamComponentOpen(unsigned int stream_index)
|
||||||
{
|
{
|
||||||
if(stream_index < 0 || static_cast<unsigned int>(stream_index) >= mFormatCtx->nb_streams)
|
if(stream_index >= mFormatCtx->nb_streams)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Get a pointer to the codec context for the stream, and open the
|
/* Get a pointer to the codec context for the stream, and open the
|
||||||
@ -1499,7 +1501,7 @@ int MovieState::streamComponentOpen(int stream_index)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream_index;
|
return static_cast<int>(stream_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MovieState::parse_handler()
|
int MovieState::parse_handler()
|
||||||
|
@ -112,7 +112,7 @@ static ALuint LoadSound(const char *filename)
|
|||||||
* close the file. */
|
* close the file. */
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
alGenBuffers(1, &buffer);
|
alGenBuffers(1, &buffer);
|
||||||
alBufferData(buffer, format, sample->buffer, slen, sample->actual.rate);
|
alBufferData(buffer, format, sample->buffer, (ALsizei)slen, (ALsizei)sample->actual.rate);
|
||||||
Sound_FreeSample(sample);
|
Sound_FreeSample(sample);
|
||||||
|
|
||||||
/* Check if an error occured, and clean up if so. */
|
/* Check if an error occured, and clean up if so. */
|
||||||
@ -132,6 +132,7 @@ static ALuint LoadSound(const char *filename)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
ALCdevice *device;
|
ALCdevice *device;
|
||||||
|
ALCcontext *context;
|
||||||
ALboolean has_angle_ext;
|
ALboolean has_angle_ext;
|
||||||
ALuint source, buffer;
|
ALuint source, buffer;
|
||||||
const char *soundname;
|
const char *soundname;
|
||||||
@ -153,7 +154,8 @@ int main(int argc, char **argv)
|
|||||||
if(InitAL(&argv, &argc) != 0)
|
if(InitAL(&argv, &argc) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
device = alcGetContextsDevice(alcGetCurrentContext());
|
context = alcGetCurrentContext();
|
||||||
|
device = alcGetContextsDevice(context);
|
||||||
if(!alcIsExtensionPresent(device, "ALC_SOFT_HRTF"))
|
if(!alcIsExtensionPresent(device, "ALC_SOFT_HRTF"))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Error: ALC_SOFT_HRTF not supported\n");
|
fprintf(stderr, "Error: ALC_SOFT_HRTF not supported\n");
|
||||||
@ -171,7 +173,7 @@ int main(int argc, char **argv)
|
|||||||
* stereo sources.
|
* stereo sources.
|
||||||
*/
|
*/
|
||||||
has_angle_ext = alIsExtensionPresent("AL_EXT_STEREO_ANGLES");
|
has_angle_ext = alIsExtensionPresent("AL_EXT_STEREO_ANGLES");
|
||||||
printf("AL_EXT_STEREO_ANGLES%s found\n", has_angle_ext?"":" not");
|
printf("AL_EXT_STEREO_ANGLES %sfound\n", has_angle_ext?"":"not ");
|
||||||
|
|
||||||
/* Check for user-preferred HRTF */
|
/* Check for user-preferred HRTF */
|
||||||
if(strcmp(argv[0], "-hrtf") == 0)
|
if(strcmp(argv[0], "-hrtf") == 0)
|
||||||
@ -255,7 +257,7 @@ int main(int argc, char **argv)
|
|||||||
alGenSources(1, &source);
|
alGenSources(1, &source);
|
||||||
alSourcei(source, AL_SOURCE_RELATIVE, AL_TRUE);
|
alSourcei(source, AL_SOURCE_RELATIVE, AL_TRUE);
|
||||||
alSource3f(source, AL_POSITION, 0.0f, 0.0f, -1.0f);
|
alSource3f(source, AL_POSITION, 0.0f, 0.0f, -1.0f);
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, (ALint)buffer);
|
||||||
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
||||||
|
|
||||||
/* Play the sound until it finishes. */
|
/* Play the sound until it finishes. */
|
||||||
@ -264,6 +266,8 @@ int main(int argc, char **argv)
|
|||||||
do {
|
do {
|
||||||
al_nssleep(10000000);
|
al_nssleep(10000000);
|
||||||
|
|
||||||
|
alcSuspendContext(context);
|
||||||
|
|
||||||
/* Rotate the source around the listener by about 1/4 cycle per second,
|
/* Rotate the source around the listener by about 1/4 cycle per second,
|
||||||
* and keep it within -pi...+pi.
|
* and keep it within -pi...+pi.
|
||||||
*/
|
*/
|
||||||
@ -282,6 +286,7 @@ int main(int argc, char **argv)
|
|||||||
ALfloat angles[2] = { (ALfloat)(M_PI/6.0 - angle), (ALfloat)(-M_PI/6.0 - angle) };
|
ALfloat angles[2] = { (ALfloat)(M_PI/6.0 - angle), (ALfloat)(-M_PI/6.0 - angle) };
|
||||||
alSourcefv(source, AL_STEREO_ANGLES, angles);
|
alSourcefv(source, AL_STEREO_ANGLES, angles);
|
||||||
}
|
}
|
||||||
|
alcProcessContext(context);
|
||||||
|
|
||||||
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
||||||
} while(alGetError() == AL_NO_ERROR && state == AL_PLAYING);
|
} while(alGetError() == AL_NO_ERROR && state == AL_PLAYING);
|
||||||
|
@ -115,7 +115,7 @@ static ALuint LoadSound(const char *filename)
|
|||||||
* close the file. */
|
* close the file. */
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
alGenBuffers(1, &buffer);
|
alGenBuffers(1, &buffer);
|
||||||
alBufferData(buffer, format, sample->buffer, slen, sample->actual.rate);
|
alBufferData(buffer, format, sample->buffer, (ALsizei)slen, (ALsizei)sample->actual.rate);
|
||||||
Sound_FreeSample(sample);
|
Sound_FreeSample(sample);
|
||||||
|
|
||||||
/* Check if an error occured, and clean up if so. */
|
/* Check if an error occured, and clean up if so. */
|
||||||
@ -188,7 +188,7 @@ int main(int argc, char **argv)
|
|||||||
/* Create the source to play the sound with. */
|
/* Create the source to play the sound with. */
|
||||||
source = 0;
|
source = 0;
|
||||||
alGenSources(1, &source);
|
alGenSources(1, &source);
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, (ALint)buffer);
|
||||||
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
||||||
|
|
||||||
/* Play the sound until it finishes. */
|
/* Play the sound until it finishes. */
|
||||||
|
@ -249,7 +249,7 @@ int main(int argc, char *argv[])
|
|||||||
/* Create the source to play the sound with. */
|
/* Create the source to play the sound with. */
|
||||||
source = 0;
|
source = 0;
|
||||||
alGenSources(1, &source);
|
alGenSources(1, &source);
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, (ALint)buffer);
|
||||||
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
||||||
|
|
||||||
/* Play the sound until it finishes. */
|
/* Play the sound until it finishes. */
|
||||||
|
@ -211,7 +211,7 @@ static ALuint LoadSound(const char *filename)
|
|||||||
* close the file. */
|
* close the file. */
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
alGenBuffers(1, &buffer);
|
alGenBuffers(1, &buffer);
|
||||||
alBufferData(buffer, format, sample->buffer, slen, sample->actual.rate);
|
alBufferData(buffer, format, sample->buffer, (ALsizei)slen, (ALsizei)sample->actual.rate);
|
||||||
Sound_FreeSample(sample);
|
Sound_FreeSample(sample);
|
||||||
|
|
||||||
/* Check if an error occured, and clean up if so. */
|
/* Check if an error occured, and clean up if so. */
|
||||||
@ -443,8 +443,8 @@ static void UpdateListenerAndEffects(float timediff, const ALuint slots[2], cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Finally, update the effect slots with the updated effect parameters. */
|
/* Finally, update the effect slots with the updated effect parameters. */
|
||||||
alAuxiliaryEffectSloti(slots[0], AL_EFFECTSLOT_EFFECT, effects[0]);
|
alAuxiliaryEffectSloti(slots[0], AL_EFFECTSLOT_EFFECT, (ALint)effects[0]);
|
||||||
alAuxiliaryEffectSloti(slots[1], AL_EFFECTSLOT_EFFECT, effects[1]);
|
alAuxiliaryEffectSloti(slots[1], AL_EFFECTSLOT_EFFECT, (ALint)effects[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -598,8 +598,8 @@ int main(int argc, char **argv)
|
|||||||
* effect properties. Modifying or deleting the effect object afterward
|
* effect properties. Modifying or deleting the effect object afterward
|
||||||
* won't directly affect the effect slot until they're reapplied like this.
|
* won't directly affect the effect slot until they're reapplied like this.
|
||||||
*/
|
*/
|
||||||
alAuxiliaryEffectSloti(slots[0], AL_EFFECTSLOT_EFFECT, effects[0]);
|
alAuxiliaryEffectSloti(slots[0], AL_EFFECTSLOT_EFFECT, (ALint)effects[0]);
|
||||||
alAuxiliaryEffectSloti(slots[1], AL_EFFECTSLOT_EFFECT, effects[1]);
|
alAuxiliaryEffectSloti(slots[1], AL_EFFECTSLOT_EFFECT, (ALint)effects[1]);
|
||||||
assert(alGetError()==AL_NO_ERROR && "Failed to set effect slot");
|
assert(alGetError()==AL_NO_ERROR && "Failed to set effect slot");
|
||||||
|
|
||||||
/* For the purposes of this example, prepare a filter that optionally
|
/* For the purposes of this example, prepare a filter that optionally
|
||||||
@ -621,8 +621,8 @@ int main(int argc, char **argv)
|
|||||||
alGenSources(1, &source);
|
alGenSources(1, &source);
|
||||||
alSourcei(source, AL_LOOPING, AL_TRUE);
|
alSourcei(source, AL_LOOPING, AL_TRUE);
|
||||||
alSource3f(source, AL_POSITION, -5.0f, 0.0f, -2.0f);
|
alSource3f(source, AL_POSITION, -5.0f, 0.0f, -2.0f);
|
||||||
alSourcei(source, AL_DIRECT_FILTER, direct_filter);
|
alSourcei(source, AL_DIRECT_FILTER, (ALint)direct_filter);
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, (ALint)buffer);
|
||||||
|
|
||||||
/* Connect the source to the effect slots. Here, we connect source send 0
|
/* Connect the source to the effect slots. Here, we connect source send 0
|
||||||
* to Zone 0's slot, and send 1 to Zone 1's slot. Filters can be specified
|
* to Zone 0's slot, and send 1 to Zone 1's slot. Filters can be specified
|
||||||
@ -631,8 +631,8 @@ int main(int argc, char **argv)
|
|||||||
* can only see a zone through a window or thin wall may be attenuated for
|
* can only see a zone through a window or thin wall may be attenuated for
|
||||||
* that zone.
|
* that zone.
|
||||||
*/
|
*/
|
||||||
alSource3i(source, AL_AUXILIARY_SEND_FILTER, slots[0], 0, AL_FILTER_NULL);
|
alSource3i(source, AL_AUXILIARY_SEND_FILTER, (ALint)slots[0], 0, AL_FILTER_NULL);
|
||||||
alSource3i(source, AL_AUXILIARY_SEND_FILTER, slots[1], 1, AL_FILTER_NULL);
|
alSource3i(source, AL_AUXILIARY_SEND_FILTER, (ALint)slots[1], 1, AL_FILTER_NULL);
|
||||||
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
||||||
|
|
||||||
/* Get the current time as the base for timing in the main loop. */
|
/* Get the current time as the base for timing in the main loop. */
|
||||||
|
@ -101,7 +101,7 @@ static ALuint LoadSound(const char *filename)
|
|||||||
* close the file. */
|
* close the file. */
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
alGenBuffers(1, &buffer);
|
alGenBuffers(1, &buffer);
|
||||||
alBufferData(buffer, format, sample->buffer, slen, sample->actual.rate);
|
alBufferData(buffer, format, sample->buffer, (ALsizei)slen, (ALsizei)sample->actual.rate);
|
||||||
Sound_FreeSample(sample);
|
Sound_FreeSample(sample);
|
||||||
|
|
||||||
/* Check if an error occured, and clean up if so. */
|
/* Check if an error occured, and clean up if so. */
|
||||||
@ -151,7 +151,7 @@ int main(int argc, char **argv)
|
|||||||
/* Create the source to play the sound with. */
|
/* Create the source to play the sound with. */
|
||||||
source = 0;
|
source = 0;
|
||||||
alGenSources(1, &source);
|
alGenSources(1, &source);
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, (ALint)buffer);
|
||||||
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
||||||
|
|
||||||
/* Play the sound until it finishes. */
|
/* Play the sound until it finishes. */
|
||||||
|
@ -73,9 +73,9 @@ typedef struct Recorder {
|
|||||||
ALuint mDataSize;
|
ALuint mDataSize;
|
||||||
float mRecTime;
|
float mRecTime;
|
||||||
|
|
||||||
int mChannels;
|
ALuint mChannels;
|
||||||
int mBits;
|
ALuint mBits;
|
||||||
int mSampleRate;
|
ALuint mSampleRate;
|
||||||
ALuint mFrameSize;
|
ALuint mFrameSize;
|
||||||
ALbyte *mBuffer;
|
ALbyte *mBuffer;
|
||||||
ALsizei mBufferSize;
|
ALsizei mBufferSize;
|
||||||
@ -139,7 +139,7 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
recorder.mChannels = strtol(argv[1], &end, 0);
|
recorder.mChannels = (ALuint)strtoul(argv[1], &end, 0);
|
||||||
if((recorder.mChannels != 1 && recorder.mChannels != 2) || (end && *end != '\0'))
|
if((recorder.mChannels != 1 && recorder.mChannels != 2) || (end && *end != '\0'))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Invalid channels: %s\n", argv[1]);
|
fprintf(stderr, "Invalid channels: %s\n", argv[1]);
|
||||||
@ -156,7 +156,7 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
recorder.mBits = strtol(argv[1], &end, 0);
|
recorder.mBits = (ALuint)strtoul(argv[1], &end, 0);
|
||||||
if((recorder.mBits != 8 && recorder.mBits != 16 && recorder.mBits != 32) ||
|
if((recorder.mBits != 8 && recorder.mBits != 16 && recorder.mBits != 32) ||
|
||||||
(end && *end != '\0'))
|
(end && *end != '\0'))
|
||||||
{
|
{
|
||||||
@ -174,7 +174,7 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
recorder.mSampleRate = strtol(argv[1], &end, 0);
|
recorder.mSampleRate = (ALuint)strtoul(argv[1], &end, 0);
|
||||||
if(!(recorder.mSampleRate >= 8000 && recorder.mSampleRate <= 96000) || (end && *end != '\0'))
|
if(!(recorder.mSampleRate >= 8000 && recorder.mSampleRate <= 96000) || (end && *end != '\0'))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Invalid sample rate: %s\n", argv[1]);
|
fprintf(stderr, "Invalid sample rate: %s\n", argv[1]);
|
||||||
@ -285,15 +285,15 @@ int main(int argc, char **argv)
|
|||||||
// 16-bit val, format type id (1 = integer PCM, 3 = float PCM)
|
// 16-bit val, format type id (1 = integer PCM, 3 = float PCM)
|
||||||
fwrite16le((recorder.mBits == 32) ? 0x0003 : 0x0001, recorder.mFile);
|
fwrite16le((recorder.mBits == 32) ? 0x0003 : 0x0001, recorder.mFile);
|
||||||
// 16-bit val, channel count
|
// 16-bit val, channel count
|
||||||
fwrite16le(recorder.mChannels, recorder.mFile);
|
fwrite16le((ALushort)recorder.mChannels, recorder.mFile);
|
||||||
// 32-bit val, frequency
|
// 32-bit val, frequency
|
||||||
fwrite32le(recorder.mSampleRate, recorder.mFile);
|
fwrite32le(recorder.mSampleRate, recorder.mFile);
|
||||||
// 32-bit val, bytes per second
|
// 32-bit val, bytes per second
|
||||||
fwrite32le(recorder.mSampleRate * recorder.mFrameSize, recorder.mFile);
|
fwrite32le(recorder.mSampleRate * recorder.mFrameSize, recorder.mFile);
|
||||||
// 16-bit val, frame size
|
// 16-bit val, frame size
|
||||||
fwrite16le(recorder.mFrameSize, recorder.mFile);
|
fwrite16le((ALushort)recorder.mFrameSize, recorder.mFile);
|
||||||
// 16-bit val, bits per sample
|
// 16-bit val, bits per sample
|
||||||
fwrite16le(recorder.mBits, recorder.mFile);
|
fwrite16le((ALushort)recorder.mBits, recorder.mFile);
|
||||||
// 16-bit val, extra byte count
|
// 16-bit val, extra byte count
|
||||||
fwrite16le(0, recorder.mFile);
|
fwrite16le(0, recorder.mFile);
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if(count > recorder.mBufferSize)
|
if(count > recorder.mBufferSize)
|
||||||
{
|
{
|
||||||
ALbyte *data = calloc(recorder.mFrameSize, count);
|
ALbyte *data = calloc(recorder.mFrameSize, (ALuint)count);
|
||||||
free(recorder.mBuffer);
|
free(recorder.mBuffer);
|
||||||
recorder.mBuffer = data;
|
recorder.mBuffer = data;
|
||||||
recorder.mBufferSize = count;
|
recorder.mBufferSize = count;
|
||||||
@ -365,7 +365,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
recorder.mDataSize += (ALuint)fwrite(recorder.mBuffer, recorder.mFrameSize, count,
|
recorder.mDataSize += (ALuint)fwrite(recorder.mBuffer, recorder.mFrameSize, (ALuint)count,
|
||||||
recorder.mFile);
|
recorder.mFile);
|
||||||
}
|
}
|
||||||
alcCaptureStop(recorder.mDevice);
|
alcCaptureStop(recorder.mDevice);
|
||||||
@ -385,7 +385,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
fwrite32le(recorder.mDataSize*recorder.mFrameSize, recorder.mFile);
|
fwrite32le(recorder.mDataSize*recorder.mFrameSize, recorder.mFile);
|
||||||
if(fseek(recorder.mFile, 4, SEEK_SET) == 0)
|
if(fseek(recorder.mFile, 4, SEEK_SET) == 0)
|
||||||
fwrite32le(total_size - 8, recorder.mFile);
|
fwrite32le((ALuint)total_size - 8, recorder.mFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(recorder.mFile);
|
fclose(recorder.mFile);
|
||||||
|
@ -209,7 +209,7 @@ static ALuint LoadSound(const char *filename)
|
|||||||
* close the file. */
|
* close the file. */
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
alGenBuffers(1, &buffer);
|
alGenBuffers(1, &buffer);
|
||||||
alBufferData(buffer, format, sample->buffer, slen, sample->actual.rate);
|
alBufferData(buffer, format, sample->buffer, (ALsizei)slen, (ALsizei)sample->actual.rate);
|
||||||
Sound_FreeSample(sample);
|
Sound_FreeSample(sample);
|
||||||
|
|
||||||
/* Check if an error occured, and clean up if so. */
|
/* Check if an error occured, and clean up if so. */
|
||||||
@ -309,18 +309,18 @@ int main(int argc, char **argv)
|
|||||||
* effectively copies the effect properties. You can modify or delete the
|
* effectively copies the effect properties. You can modify or delete the
|
||||||
* effect object afterward without affecting the effect slot.
|
* effect object afterward without affecting the effect slot.
|
||||||
*/
|
*/
|
||||||
alAuxiliaryEffectSloti(slot, AL_EFFECTSLOT_EFFECT, effect);
|
alAuxiliaryEffectSloti(slot, AL_EFFECTSLOT_EFFECT, (ALint)effect);
|
||||||
assert(alGetError()==AL_NO_ERROR && "Failed to set effect slot");
|
assert(alGetError()==AL_NO_ERROR && "Failed to set effect slot");
|
||||||
|
|
||||||
/* Create the source to play the sound with. */
|
/* Create the source to play the sound with. */
|
||||||
source = 0;
|
source = 0;
|
||||||
alGenSources(1, &source);
|
alGenSources(1, &source);
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, (ALint)buffer);
|
||||||
|
|
||||||
/* Connect the source to the effect slot. This tells the source to use the
|
/* Connect the source to the effect slot. This tells the source to use the
|
||||||
* effect slot 'slot', on send #0 with the AL_FILTER_NULL filter object.
|
* effect slot 'slot', on send #0 with the AL_FILTER_NULL filter object.
|
||||||
*/
|
*/
|
||||||
alSource3i(source, AL_AUXILIARY_SEND_FILTER, slot, 0, AL_FILTER_NULL);
|
alSource3i(source, AL_AUXILIARY_SEND_FILTER, (ALint)slot, 0, AL_FILTER_NULL);
|
||||||
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
||||||
|
|
||||||
/* Play the sound until it finishes. */
|
/* Play the sound until it finishes. */
|
||||||
|
@ -160,10 +160,10 @@ static int OpenPlayerFile(StreamPlayer *player, const char *filename)
|
|||||||
fprintf(stderr, "Unsupported channel count: %d\n", player->sample->actual.channels);
|
fprintf(stderr, "Unsupported channel count: %d\n", player->sample->actual.channels);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
player->srate = player->sample->actual.rate;
|
player->srate = (ALsizei)player->sample->actual.rate;
|
||||||
|
|
||||||
frame_size = player->sample->actual.channels *
|
frame_size = player->sample->actual.channels *
|
||||||
SDL_AUDIO_BITSIZE(player->sample->actual.format) / 8;
|
SDL_AUDIO_BITSIZE(player->sample->actual.format) / 8;
|
||||||
|
|
||||||
/* Set the buffer size, given the desired millisecond length. */
|
/* Set the buffer size, given the desired millisecond length. */
|
||||||
Sound_SetBufferSize(player->sample, (Uint32)((Uint64)player->srate*BUFFER_TIME_MS/1000) *
|
Sound_SetBufferSize(player->sample, (Uint32)((Uint64)player->srate*BUFFER_TIME_MS/1000) *
|
||||||
@ -191,7 +191,7 @@ static void ClosePlayerFile(StreamPlayer *player)
|
|||||||
/* Prebuffers some audio from the file, and starts playing the source */
|
/* Prebuffers some audio from the file, and starts playing the source */
|
||||||
static int StartPlayer(StreamPlayer *player)
|
static int StartPlayer(StreamPlayer *player)
|
||||||
{
|
{
|
||||||
size_t i;
|
ALsizei i;
|
||||||
|
|
||||||
/* Rewind the source position and clear the buffer queue */
|
/* Rewind the source position and clear the buffer queue */
|
||||||
alSourceRewind(player->source);
|
alSourceRewind(player->source);
|
||||||
@ -204,8 +204,8 @@ static int StartPlayer(StreamPlayer *player)
|
|||||||
Uint32 slen = Sound_Decode(player->sample);
|
Uint32 slen = Sound_Decode(player->sample);
|
||||||
if(slen == 0) break;
|
if(slen == 0) break;
|
||||||
|
|
||||||
alBufferData(player->buffers[i], player->format,
|
alBufferData(player->buffers[i], player->format, player->sample->buffer, (ALsizei)slen,
|
||||||
player->sample->buffer, slen, player->srate);
|
player->srate);
|
||||||
}
|
}
|
||||||
if(alGetError() != AL_NO_ERROR)
|
if(alGetError() != AL_NO_ERROR)
|
||||||
{
|
{
|
||||||
@ -255,8 +255,8 @@ static int UpdatePlayer(StreamPlayer *player)
|
|||||||
slen = Sound_Decode(player->sample);
|
slen = Sound_Decode(player->sample);
|
||||||
if(slen > 0)
|
if(slen > 0)
|
||||||
{
|
{
|
||||||
alBufferData(bufid, player->format, player->sample->buffer, slen,
|
alBufferData(bufid, player->format, player->sample->buffer, (ALsizei)slen,
|
||||||
player->srate);
|
player->srate);
|
||||||
alSourceQueueBuffers(player->source, 1, &bufid);
|
alSourceQueueBuffers(player->source, 1, &bufid);
|
||||||
}
|
}
|
||||||
if(alGetError() != AL_NO_ERROR)
|
if(alGetError() != AL_NO_ERROR)
|
||||||
@ -323,8 +323,7 @@ int main(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
namepart = argv[i];
|
namepart = argv[i];
|
||||||
|
|
||||||
printf("Playing: %s (%s, %dhz)\n", namepart, FormatName(player->format),
|
printf("Playing: %s (%s, %dhz)\n", namepart, FormatName(player->format), player->srate);
|
||||||
player->srate);
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
if(!StartPlayer(player))
|
if(!StartPlayer(player))
|
||||||
|
@ -91,7 +91,7 @@ static void ApplySin(ALfloat *data, ALdouble g, ALuint srate, ALuint freq)
|
|||||||
static ALuint CreateWave(enum WaveType type, ALuint freq, ALuint srate)
|
static ALuint CreateWave(enum WaveType type, ALuint freq, ALuint srate)
|
||||||
{
|
{
|
||||||
ALuint seed = 22222;
|
ALuint seed = 22222;
|
||||||
ALint data_size;
|
ALuint data_size;
|
||||||
ALfloat *data;
|
ALfloat *data;
|
||||||
ALuint buffer;
|
ALuint buffer;
|
||||||
ALenum err;
|
ALenum err;
|
||||||
@ -142,7 +142,7 @@ static ALuint CreateWave(enum WaveType type, ALuint freq, ALuint srate)
|
|||||||
/* Buffer the audio data into a new buffer object. */
|
/* Buffer the audio data into a new buffer object. */
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
alGenBuffers(1, &buffer);
|
alGenBuffers(1, &buffer);
|
||||||
alBufferData(buffer, AL_FORMAT_MONO_FLOAT32, data, data_size, srate);
|
alBufferData(buffer, AL_FORMAT_MONO_FLOAT32, data, (ALsizei)data_size, (ALsizei)srate);
|
||||||
free(data);
|
free(data);
|
||||||
|
|
||||||
/* Check if an error occured, and clean up if so. */
|
/* Check if an error occured, and clean up if so. */
|
||||||
@ -257,7 +257,7 @@ int main(int argc, char *argv[])
|
|||||||
srate = dev_rate;
|
srate = dev_rate;
|
||||||
|
|
||||||
/* Load the sound into a buffer. */
|
/* Load the sound into a buffer. */
|
||||||
buffer = CreateWave(wavetype, tone_freq, srate);
|
buffer = CreateWave(wavetype, (ALuint)tone_freq, (ALuint)srate);
|
||||||
if(!buffer)
|
if(!buffer)
|
||||||
{
|
{
|
||||||
CloseAL();
|
CloseAL();
|
||||||
@ -271,7 +271,7 @@ int main(int argc, char *argv[])
|
|||||||
/* Create the source to play the sound with. */
|
/* Create the source to play the sound with. */
|
||||||
source = 0;
|
source = 0;
|
||||||
alGenSources(1, &source);
|
alGenSources(1, &source);
|
||||||
alSourcei(source, AL_BUFFER, buffer);
|
alSourcei(source, AL_BUFFER, (ALint)buffer);
|
||||||
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
|
||||||
|
|
||||||
/* Play the sound for a while. */
|
/* Play the sound for a while. */
|
||||||
|
@ -159,12 +159,12 @@ int altime_get(void)
|
|||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
int ret = clock_gettime(CLOCK_REALTIME, &ts);
|
int ret = clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
if(ret != 0) return 0;
|
if(ret != 0) return 0;
|
||||||
cur_time = ts.tv_sec*1000 + ts.tv_nsec/1000000;
|
cur_time = (int)(ts.tv_sec*1000 + ts.tv_nsec/1000000);
|
||||||
#else /* _POSIX_TIMERS > 0 */
|
#else /* _POSIX_TIMERS > 0 */
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int ret = gettimeofday(&tv, NULL);
|
int ret = gettimeofday(&tv, NULL);
|
||||||
if(ret != 0) return 0;
|
if(ret != 0) return 0;
|
||||||
cur_time = tv.tv_sec*1000 + tv.tv_usec/1000;
|
cur_time = (int)(tv.tv_sec*1000 + tv.tv_usec/1000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(!start_time)
|
if(!start_time)
|
||||||
|
@ -50,7 +50,7 @@ static const char *SofaErrorStr(int err)
|
|||||||
* of other axes as necessary. The epsilons are used to constrain the
|
* of other axes as necessary. The epsilons are used to constrain the
|
||||||
* equality of unique elements.
|
* equality of unique elements.
|
||||||
*/
|
*/
|
||||||
static uint GetUniquelySortedElems(const uint m, const float *triplets, const int axis,
|
static uint GetUniquelySortedElems(const uint m, const float *triplets, const uint axis,
|
||||||
const double *const (&filters)[3], const double (&epsilons)[3], float *elems)
|
const double *const (&filters)[3], const double (&epsilons)[3], float *elems)
|
||||||
{
|
{
|
||||||
uint count{0u};
|
uint count{0u};
|
||||||
|
@ -124,7 +124,7 @@ static void printList(const char *list, char separator)
|
|||||||
next = strchr(list, separator);
|
next = strchr(list, separator);
|
||||||
if(next)
|
if(next)
|
||||||
{
|
{
|
||||||
len = next-list;
|
len = (size_t)(next-list);
|
||||||
do {
|
do {
|
||||||
next++;
|
next++;
|
||||||
} while(*next == separator);
|
} while(*next == separator);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user