Skip to content

Commit 3e301b9

Browse files
committed
fix compiling error.
1 parent 31984d9 commit 3e301b9

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

.gitignore

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,7 @@
1010
/CMakeSettings.json
1111

1212
build/
13-
build-blas/
14-
build-coreml/
15-
build-em/
16-
build-debug/
17-
build-release/
18-
build-rwdi/
19-
build-static/
20-
build-cublas/
21-
build-no-accel/
22-
build-sanitize-addr/
23-
build-sanitize-thread/
13+
build-*/
2414

2515
# SPM
2616
.build/

examples/common-portaudio.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ class VadIterator
350350
void reset_states()
351351
{
352352
// Call reset before each audio start
353-
std::memset(_state.data(), 0.0f, _state.size() * sizeof(float));
353+
std::memset(_state.data(), 0, _state.size() * sizeof(float));
354354
triggered = false;
355355
temp_end = 0;
356356
current_sample = 0;
@@ -715,7 +715,7 @@ class AudioBuffer : public CircularQueue<T>
715715
cout << "AudioBuffer::srcState was NULL!" << endl;
716716
}
717717

718-
resample_outputBuffer = (float *)std::malloc(INPUT_SAMPLE_RATE*2*sizeof(float));
718+
resample_outputBuffer = (float *)std::malloc((size_t)INPUT_SAMPLE_RATE*2*sizeof(float));
719719
if( resample_outputBuffer == NULL )
720720
{
721721
cout << "AudioBuffer::resample_outputBuffer was NULL!" << endl;
@@ -844,11 +844,27 @@ class AudioBuffer : public CircularQueue<T>
844844
return paContinue;
845845
};
846846

847+
inline std::tm localtime_xp(std::time_t timer)
848+
{
849+
std::tm bt{};
850+
#if defined(__unix__)
851+
localtime_r(&timer, &bt);
852+
#elif defined(_MSC_VER)
853+
localtime_s(&bt, &timer);
854+
#else
855+
static std::mutex mtx;
856+
std::lock_guard<std::mutex> lock(mtx);
857+
bt = *std::localtime(&timer);
858+
#endif
859+
return bt;
860+
}
861+
847862
void setSaveAudioFlag(uint8_t save_audio)
848863
{
849-
time_t now = time(0);
864+
auto now = localtime_xp(std::time(0));
850865
char buffer[80];
851-
strftime(buffer, sizeof(buffer), "%Y%m%d%H%M%S", localtime(&now));
866+
867+
strftime(buffer, sizeof(buffer), "%Y%m%d%H%M%S", &now);
852868

853869
m_un8SaveAudioFlag = save_audio;
854870
if(m_un8SaveAudioFlag & SAVE_AUDIO_RAW)

examples/console.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ namespace console {
300300
return expectedWidth;
301301
}
302302
COORD initialPosition = bufferInfo.dwCursorPosition;
303-
DWORD nNumberOfChars = length;
303+
DWORD nNumberOfChars = (DWORD)length;
304304
WriteConsole(hConsole, utf8_codepoint, nNumberOfChars, &nNumberOfChars, NULL);
305305

306306
CONSOLE_SCREEN_BUFFER_INFO newBufferInfo;
@@ -454,7 +454,7 @@ namespace console {
454454
} while (count == 0 && !widths.empty());
455455
}
456456
} else {
457-
int offset = line.length();
457+
int offset = (int)line.length();
458458
append_utf8(input_char, line);
459459
int width = put_codepoint(line.c_str() + offset, line.length() - offset, estimateWidth(input_char));
460460
if (width < 0) {

0 commit comments

Comments
 (0)