Skip to content

Commit 0622523

Browse files
Add source loading failed alert
1 parent ee4d35e commit 0622523

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/audioCore/source/SourceIO.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "SourceIO.h"
22
#include "SourceManager.h"
33
#include "SourceInternalPool.h"
4+
#include "../uiCallback/UICallback.h"
45
#include "../misc/PlayPosition.h"
56
#include "../misc/AudioLock.h"
67
#include "../Utils.h"
@@ -59,7 +60,17 @@ void SourceIO::run() {
5960
if (!SourceInternalPool::getInstance()->find(path)) {
6061
/** Load Audio Data */
6162
auto [sampleRate, buffer, metaData, bitDepth] = SourceIO::loadAudio(file);
62-
if (sampleRate <= 0) { continue; }
63+
if (sampleRate <= 0) {
64+
/** Failed */
65+
juce::MessageManager::callAsync(
66+
[path] {
67+
UICallbackAPI<const juce::String&, const juce::String&>::invoke(
68+
UICallbackType::ErrorAlert, "Read Audio",
69+
"Can't read audio file: " + path);
70+
}
71+
);
72+
continue;
73+
}
6374

6475
/** Set Data */
6576
juce::MessageManager::callAsync(
@@ -133,7 +144,17 @@ void SourceIO::run() {
133144
if (!SourceInternalPool::getInstance()->find(path)) {
134145
/** Load MIDI Data */
135146
auto [valid, data] = SourceIO::loadMIDI(file);
136-
if (!valid) { continue; }
147+
if (!valid) {
148+
/** Failed */
149+
juce::MessageManager::callAsync(
150+
[path] {
151+
UICallbackAPI<const juce::String&, const juce::String&>::invoke(
152+
UICallbackType::ErrorAlert, "Read MIDI",
153+
"Can't read MIDI file: " + path);
154+
}
155+
);
156+
continue;
157+
}
137158

138159
/** Split Data */
139160
auto [tempo, buffer] = SourceIO::splitMIDI(data);

0 commit comments

Comments
 (0)