Skip to content

Commit

Permalink
fix: Stability fixes and Pipeline tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Axel Nana <[email protected]>
  • Loading branch information
na2axl committed Nov 22, 2024
1 parent 6e0a1a4 commit c95702d
Show file tree
Hide file tree
Showing 21 changed files with 1,104 additions and 73 deletions.
2 changes: 1 addition & 1 deletion include/SparkyStudios/Audio/Amplitude/Mixer/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace SparkyStudios::Audio::Amplitude
/**
* @brief Consumes audio data from the provider node.
*
* The provider node should be specified with the call of @ref Connect `Connect()`.
* The provider node should be specified with the call of @ref Connect `Connect()`.
*/
virtual void Consume() = 0;

Expand Down
2 changes: 2 additions & 0 deletions sample_project/.amignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Test files
**/tests.*.json
33 changes: 33 additions & 0 deletions sample_project/pipelines/tests.double_consume.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"id": 98,
"name": "tests.double_consume",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
1
]
},
{
"id": 2,
"name": "StereoMixer",
"consume": [
8,
8
]
},
{
"id": 9,
"name": "Output",
"consume": [
2
]
}
]
}
32 changes: 32 additions & 0 deletions sample_project/pipelines/tests.invalid.invalid_consumer_node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"id": 99,
"name": "tests.invalid_consumer_node",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
3
]
},
{
"id": 9,
"name": "Output",
"consume": [
8
]
},
{
"id": 3,
"name": "InvalidConsumerNode",
"consume": [
1
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"id": 93,
"name": "tests.invalid_producers_count",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 2,
"name": "Attenuation",
"consume": [
1
]
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
1,
2
]
},
{
"id": 9,
"name": "Output",
"consume": [
8
]
}
]
}
30 changes: 30 additions & 0 deletions sample_project/pipelines/tests.invalid.missing_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": 90,
"name": "tests.missing_input",
"nodes": [
{
"id": 8,
"name": "StereoPanning",
"consume": []
},
{
"id": 11,
"name": "Reflections",
"consume": []
},
{
"id": 12,
"name": "AmbisonicBinauralDecoder",
"consume": [
11
]
},
{
"id": 9,
"name": "Output",
"consume": [
12
]
}
]
}
32 changes: 32 additions & 0 deletions sample_project/pipelines/tests.invalid.missing_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"id": 91,
"name": "tests.missing_output",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
1
]
},
{
"id": 11,
"name": "Reflections",
"consume": [
1
]
},
{
"id": 12,
"name": "AmbisonicBinauralDecoder",
"consume": [
11
]
}
]
}
23 changes: 23 additions & 0 deletions sample_project/pipelines/tests.invalid.missing_producers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": 92,
"name": "tests.missing_producers",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": []
},
{
"id": 9,
"name": "Output",
"consume": [
8
]
}
]
}
30 changes: 30 additions & 0 deletions sample_project/pipelines/tests.invalid.multiple_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"id": 94,
"name": "tests.multiple_input",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 2,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
1
]
},
{
"id": 9,
"name": "Output",
"consume": [
2
]
}
]
}
32 changes: 32 additions & 0 deletions sample_project/pipelines/tests.invalid.multiple_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"id": 95,
"name": "tests.multiple_output",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
1
]
},
{
"id": 9,
"name": "Output",
"consume": [
8
]
},
{
"id": 3,
"name": "Output",
"consume": [
1
]
}
]
}
18 changes: 18 additions & 0 deletions sample_project/pipelines/tests.invalid.self_consume.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"id": 97,
"name": "tests.self_consume",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 9,
"name": "Output",
"consume": [
9
]
}
]
}
32 changes: 32 additions & 0 deletions sample_project/pipelines/tests.invalid.unknown_node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"id": 96,
"name": "tests.unknown_node",
"nodes": [
{
"id": 1,
"name": "Input",
"consume": []
},
{
"id": 8,
"name": "StereoPanning",
"consume": [
3
]
},
{
"id": 9,
"name": "Output",
"consume": [
8
]
},
{
"id": 3,
"name": "DoSomethingWeird",
"consume": [
1
]
}
]
}
10 changes: 7 additions & 3 deletions src/Core/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,8 @@ namespace SparkyStudios::Audio::Amplitude

if (_audioDriver == nullptr)
{
amLogCritical("Failed to load the specified driver, the default driver, and the null driver. Please check your engine configuration, and ensure that all the needed plugins are loaded.");
amLogCritical("Failed to load the specified driver, the default driver, and the null driver. Please check your engine "
"configuration, and ensure that all the needed plugins are loaded.");
Deinitialize();
return false;
}
Expand Down Expand Up @@ -818,7 +819,9 @@ namespace SparkyStudios::Audio::Amplitude
// Open the audio device through the driver
if (!_audioDriver->Open(_state->mixer.GetDeviceDescription()))
{
amLogError("Could not open the audio device using the '%s' driver. Loading the null driver as fallback.", _audioDriver->GetName().c_str());
amLogError(
"Could not open the audio device using the '%s' driver. Loading the null driver as fallback.",
_audioDriver->GetName().c_str());
_audioDriver = sNullDriverPlugin.get();

if (_audioDriver == nullptr || !_audioDriver->Open(_state->mixer.GetDeviceDescription()))
Expand Down Expand Up @@ -860,7 +863,8 @@ namespace SparkyStudios::Audio::Amplitude
_state->mixer.Deinit();

// Unload sound banks
UnloadSoundBanks();
while (HasLoadedSoundBanks())
UnloadSoundBanks();

// Release HRIR sphere
if (_state->hrir_sphere != nullptr)
Expand Down
12 changes: 6 additions & 6 deletions src/Mixer/Amplimix.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ namespace SparkyStudios::Audio::Amplitude
class AmplimixLayerImpl final : public AmplimixLayer
{
public:
AmUInt32 id; // playing id
AmUInt32 id = kAmInvalidObjectId; // playing id
_Atomic(PlayStateFlag) flag; // state
_Atomic(AmUInt64) cursor; // cursor
_Atomic(AmReal32) gain; // gain
_Atomic(AmReal32) pan; // pan
_Atomic(AmReal32) pitch; // pitch
SoundData* snd; // sound data
AmUInt64 start, end; // start and end frames
SoundData* snd = nullptr; // sound data
AmUInt64 start = 0, end = 0; // start and end frames

_Atomic(AmReal32) obstruction; // obstruction factor
_Atomic(AmReal32) occlusion; // occlusion factor
Expand All @@ -79,10 +79,10 @@ namespace SparkyStudios::Audio::Amplitude
_Atomic(AmReal32) sampleRateRatio; // sample rate ratio
_Atomic(AmReal32) baseSampleRateRatio; // base sample rate ratio

AudioConverter* dataConverter; // miniaudio resampler & channel converter
PipelineInstance* pipeline; // pipeline for this layer
AudioConverter* dataConverter = nullptr; // miniaudio resampler & channel converter
PipelineInstance* pipeline = nullptr; // pipeline for this layer

AmMutexHandle mutex; // mutex for thread-safe access
AmMutexHandle mutex = nullptr; // mutex for thread-safe access
std::unordered_map<AmThreadID, bool> mutexLocked; // true if mutex is locked

~AmplimixLayerImpl();
Expand Down
Loading

0 comments on commit c95702d

Please sign in to comment.