Skip to content

Commit aa40406

Browse files
committed
Merge branch 'custom-snap-bounds' of https://github.com/uvcat7/ArrowVortex into custom-snap-bounds
2 parents 42e09d4 + 7a6a26e commit aa40406

File tree

4 files changed

+35
-26
lines changed

4 files changed

+35
-26
lines changed

.github/workflows/windows.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
unzip oggenc.zip -d .
2929
- name: Build AV
3030
run: msbuild build\VisualStudio\ArrowVortex.vcxproj /p:Configuration=Release /p:Platform=x64
31-
- name: Collect into a zip
31+
- name: Collect into a directory
3232
run: |
3333
mkdir AV
3434
cd AV
@@ -37,12 +37,9 @@ jobs:
3737
cp -r ../bin/settings .
3838
cp ../bin/ArrowVortex.exe .
3939
cp ../oggenc2.exe .
40-
cd ..
41-
7z.exe a -tzip av.zip AV
42-
- name: Upload to Delta VPS
43-
run: |
44-
mkdir -p ~/.ssh
45-
echo "${{ secrets.DROPLET_SSH }}" > ~/.ssh/arrow_vortex
46-
chmod 400 ~/.ssh/arrow_vortex
47-
echo "arrowvortex@167.71.33.176:~/av/ArrowVortex-$(date +'%Y-%m-%d %H-%M-%S').zip" > DROPLET_PATH
48-
scp -o StrictHostKeyChecking=no -o PasswordAuthentication=no -i ~/.ssh/arrow_vortex av.zip $(cat DROPLET_PATH)
40+
- name: Upload artifact
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: AV
44+
path: main/AV/
45+
if-no-files-found: error

src/Editor/LoadMp3.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <stdio.h>
66
#include <string.h>
7+
#include <memory>
78

89
#include <System/File.h>
910

@@ -431,19 +432,18 @@ int MP3Loader::readFrames(int frames, short* buffer)
431432

432433
SoundSource* LoadMP3(FileReader* file, String& title, String& artist)
433434
{
434-
MP3Loader* loader = new MP3Loader;
435+
std::unique_ptr<MP3Loader> loader = std::make_unique<MP3Loader>();
435436
loader->file = file;
436437

437438
// Decode and synth the first frame to check if the file is valid.
438439
if(!loader->decodeFirstFrame())
439440
{
440441
loader->file = nullptr;
441-
delete loader;
442442
return nullptr;
443443
}
444444

445445
// The file is valid, return the MP3 loader.
446-
return loader;
446+
return loader.release();
447447
}
448448

449449
}; // namespace Vortex

src/Editor/LoadWav.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ namespace {
1414
#pragma pack(1)
1515
struct WaveHeader
1616
{
17-
uint8_t chunkId[4];
17+
uint8_t chunkId[4]; // "RIFF"
1818
uint32_t chunkSize;
19-
uint8_t format[4];
20-
uint8_t subChunkId[4];
21-
uint32_t subChunkSize;
19+
uint8_t format[4]; // "WAVE"
20+
uint8_t subchunk1Id[4]; // "fmt "
21+
uint32_t subchunk1Size;
2222
uint16_t audioFormat;
2323
uint16_t numChannels;
2424
uint32_t sampleRate;
2525
uint32_t byteRate;
2626
uint16_t blockAlign;
27-
uint16_t bps;
27+
uint16_t bitsPerSample;
2828
};
2929
struct WaveData
3030
{
@@ -72,32 +72,38 @@ SoundSource* LoadWav(FileReader* file, String& title, String& artist)
7272
if(file->read(&header, sizeof(WaveHeader), 1) == 0
7373
|| memcmp(header.chunkId, "RIFF", 4) != 0
7474
|| memcmp(header.format, "WAVE", 4) != 0
75-
|| memcmp(header.subChunkId, "fmt ", 4) != 0
75+
|| memcmp(header.subchunk1Id, "fmt ", 4) != 0
7676
|| header.audioFormat != 1
7777
|| header.sampleRate == 0
7878
|| header.numChannels == 0
79-
|| (header.bps != 8 && header.bps != 16 && header.bps != 24))
79+
|| (header.bitsPerSample != 8 && header.bitsPerSample != 16 && header.bitsPerSample != 24))
8080
{
8181
return nullptr;
8282
}
8383

8484
// Skip over additional parameters at the end of the format chunk.
85-
file->skip(header.subChunkSize - 16);
85+
if (header.subchunk1Size > 16)
86+
{
87+
size_t extraBytes = static_cast<size_t>(header.subchunk1Size) - 16;
88+
file->skip(extraBytes);
89+
}
8690

8791
// Read the start of the data chunk.
8892
WaveData data;
89-
if(file->read(&data, sizeof(WaveData), 1) == 0
90-
|| memcmp(data.chunkId, "data", 4) != 0)
91-
{
92-
return nullptr;
93+
while (true) {
94+
if (file->read(&data, sizeof(WaveData), 1) == 0)
95+
return nullptr;
96+
if (memcmp(data.chunkId, "data", 4) == 0)
97+
break;
98+
file->skip(data.chunkSize);
9399
}
94100

95101
// Create a wav loader that will read the contents of the data chunk.
96102
WavLoader* loader = new WavLoader;
97103

98104
loader->frequency = header.sampleRate;
99105
loader->numChannels = header.numChannels;
100-
loader->bytesPerSample = header.bps / 8;
106+
loader->bytesPerSample = header.bitsPerSample / 8;
101107
loader->numFrames = data.chunkSize / (loader->bytesPerSample * loader->numChannels);
102108
loader->numFramesLeft = loader->numFrames;
103109
loader->file = file;

src/Editor/Waveform.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,12 @@ void sampleEdges(WaveEdge* edges, int w, int h, int channel, int blockId, bool f
457457
return;
458458
}
459459

460+
// A crash can occur if another thread is loading the audio. Just do nothing if it is.
461+
if (!music.isAllocated())
462+
{
463+
return;
464+
}
465+
460466
double sampleSkip = max(0.001, (samplesPerPixel / 200.0));
461467
int wh = w / 2 - 1;
462468

0 commit comments

Comments
 (0)