1515// Aegisub Project http://www.aegisub.org/
1616
1717// / @file audio_provider_vs.cpp
18- // / @brief Vapoursynth -based audio provider
18+ // / @brief VapourSynth -based audio provider
1919// / @ingroup audio_input
2020// /
2121
3838#include " VSScript4.h"
3939
4040namespace {
41- class VapoursynthAudioProvider final : public agi::AudioProvider {
41+ class VapourSynthAudioProvider final : public agi::AudioProvider {
4242 VapourSynthWrapper vs;
4343 VSScript *script = nullptr ;
4444 VSNode *node = nullptr ;
@@ -47,36 +47,36 @@ class VapoursynthAudioProvider final : public agi::AudioProvider {
4747 void FillBufferWithFrame (void *buf, int frame, int64_t start, int64_t count) const ;
4848 void FillBuffer (void *buf, int64_t start, int64_t count) const override ;
4949public:
50- VapoursynthAudioProvider (agi::fs::path const & filename);
51- ~VapoursynthAudioProvider ();
50+ VapourSynthAudioProvider (agi::fs::path const & filename);
51+ ~VapourSynthAudioProvider ();
5252
5353 bool NeedsCache () const override { return true ; }
5454};
5555
56- VapoursynthAudioProvider::VapoursynthAudioProvider (agi::fs::path const & filename) try {
56+ VapourSynthAudioProvider::VapourSynthAudioProvider (agi::fs::path const & filename) try {
5757 std::lock_guard<std::mutex> lock (vs.GetMutex ());
5858
5959 VSCleanCache ();
6060
6161 script = vs.GetScriptAPI ()->createScript (nullptr );
6262 if (script == nullptr ) {
63- throw VapoursynthError (" Error creating script API" );
63+ throw VapourSynthError (" Error creating script API" );
6464 }
6565 vs.GetScriptAPI ()->evalSetWorkingDir (script, 1 );
6666 if (OpenScriptOrVideo (vs.GetAPI (), vs.GetScriptAPI (), script, filename, OPT_GET (" Provider/Audio/VapourSynth/Default Script" )->GetString ())) {
6767 std::string msg = agi::format (" Error executing VapourSynth script: %s" , vs.GetScriptAPI ()->getError (script));
6868 vs.GetScriptAPI ()->freeScript (script);
69- throw VapoursynthError (msg);
69+ throw VapourSynthError (msg);
7070 }
7171 node = vs.GetScriptAPI ()->getOutputNode (script, 0 );
7272 if (node == nullptr ) {
7373 vs.GetScriptAPI ()->freeScript (script);
74- throw VapoursynthError (" No output node set" );
74+ throw VapourSynthError (" No output node set" );
7575 }
7676 if (vs.GetAPI ()->getNodeType (node) != mtAudio) {
7777 vs.GetAPI ()->freeNode (node);
7878 vs.GetScriptAPI ()->freeScript (script);
79- throw VapoursynthError (" Output node isn't an audio node" );
79+ throw VapourSynthError (" Output node isn't an audio node" );
8080 }
8181 vi = vs.GetAPI ()->getAudioInfo (node);
8282 float_samples = vi->format .sampleType == stFloat;
@@ -85,10 +85,10 @@ VapoursynthAudioProvider::VapoursynthAudioProvider(agi::fs::path const& filename
8585 channels = vi->format .numChannels ;
8686 num_samples = vi->numSamples ;
8787}
88- catch (VapoursynthError const & err) {
88+ catch (VapourSynthError const & err) {
8989 // Unlike the video provider manager, the audio provider factory catches AudioProviderErrors and picks whichever source doesn't throw one.
9090 // So just rethrow the Error here with an extra label so the user will see the error message and know the audio wasn't loaded with VS
91- throw VapoursynthError (agi::format (" Vapoursynth error: %s" , err.GetMessage ()));
91+ throw VapourSynthError (agi::format (" VapourSynth error: %s" , err.GetMessage ()));
9292}
9393
9494template <typename T>
@@ -102,27 +102,27 @@ static void PackChannels(const uint8_t **Src, void *Dst, size_t Length, size_t C
102102 }
103103}
104104
105- void VapoursynthAudioProvider ::FillBufferWithFrame (void *buf, int n, int64_t start, int64_t count) const {
105+ void VapourSynthAudioProvider ::FillBufferWithFrame (void *buf, int n, int64_t start, int64_t count) const {
106106 char errorMsg[1024 ];
107107 const VSFrame *frame = vs.GetAPI ()->getFrame (n, node, errorMsg, sizeof (errorMsg));
108108 if (frame == nullptr ) {
109- throw VapoursynthError (agi::format (" Error getting frame: %s" , errorMsg));
109+ throw VapourSynthError (agi::format (" Error getting frame: %s" , errorMsg));
110110 }
111111 if (vs.GetAPI ()->getFrameLength (frame) < count) {
112112 vs.GetAPI ()->freeFrame (frame);
113- throw VapoursynthError (" Audio frame too short" );
113+ throw VapourSynthError (" Audio frame too short" );
114114 }
115115 if (vs.GetAPI ()->getAudioFrameFormat (frame)->numChannels != channels || vs.GetAPI ()->getAudioFrameFormat (frame)->bytesPerSample != bytes_per_sample) {
116116 vs.GetAPI ()->freeFrame (frame);
117- throw VapoursynthError (" Audio format is not constant" );
117+ throw VapourSynthError (" Audio format is not constant" );
118118 }
119119
120120 std::vector<const uint8_t *> planes (channels);
121121 for (int c = 0 ; c < channels; c++) {
122122 planes[c] = vs.GetAPI ()->getReadPtr (frame, c) + bytes_per_sample * start;
123123 if (planes[c] == nullptr ) {
124124 vs.GetAPI ()->freeFrame (frame);
125- throw VapoursynthError (" Failed to read audio channel" );
125+ throw VapourSynthError (" Failed to read audio channel" );
126126 }
127127 }
128128
@@ -138,7 +138,7 @@ void VapoursynthAudioProvider::FillBufferWithFrame(void *buf, int n, int64_t sta
138138 vs.GetAPI ()->freeFrame (frame);
139139}
140140
141- void VapoursynthAudioProvider ::FillBuffer (void *buf, int64_t start, int64_t count) const {
141+ void VapourSynthAudioProvider ::FillBuffer (void *buf, int64_t start, int64_t count) const {
142142 int end = start + count; // exclusive
143143 int startframe = start / VS_AUDIO_FRAME_SAMPLES ;
144144 int endframe = (end - 1 ) / VS_AUDIO_FRAME_SAMPLES ;
@@ -154,7 +154,7 @@ void VapoursynthAudioProvider::FillBuffer(void *buf, int64_t start, int64_t coun
154154 }
155155}
156156
157- VapoursynthAudioProvider ::~VapoursynthAudioProvider () {
157+ VapourSynthAudioProvider ::~VapourSynthAudioProvider () {
158158 if (node != nullptr ) {
159159 vs.GetAPI ()->freeNode (node);
160160 }
@@ -164,7 +164,7 @@ VapoursynthAudioProvider::~VapoursynthAudioProvider() {
164164}
165165}
166166
167- std::unique_ptr<agi::AudioProvider> CreateVapoursynthAudioProvider (agi::fs::path const & file, agi::BackgroundRunner *) {
168- return agi::make_unique<VapoursynthAudioProvider >(file);
167+ std::unique_ptr<agi::AudioProvider> CreateVapourSynthAudioProvider (agi::fs::path const & file, agi::BackgroundRunner *) {
168+ return agi::make_unique<VapourSynthAudioProvider >(file);
169169}
170170#endif
0 commit comments