Skip to content

Commit

Permalink
Error out instead of crash when trying to export variable format audio
Browse files Browse the repository at this point in the history
  • Loading branch information
myrsloik committed May 27, 2024
1 parent 2667416 commit 264513e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/audiosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,9 @@ bool BestAudioSource::FillInFramePlanar(const BestAudioFrame *Frame, int64_t Fra
}

void BestAudioSource::GetPackedAudio(uint8_t *Data, int64_t Start, int64_t Count) {
if (VariableFormat)
throw BestSourceException("GetPackedAudio() can only be used when variable format is disabled");

Start -= SampleDelay;

ZeroFillStartPacked(Data, Start, Count);
Expand All @@ -1005,6 +1008,9 @@ void BestAudioSource::GetPackedAudio(uint8_t *Data, int64_t Start, int64_t Count
}

void BestAudioSource::GetPlanarAudio(uint8_t *const *const Data, int64_t Start, int64_t Count) {
if (VariableFormat)
throw BestSourceException("GetPlanarAudio() can only be used when variable format is disabled");

Start -= SampleDelay;

std::vector<uint8_t *> DataV;
Expand Down
1 change: 0 additions & 1 deletion src/audiosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ class BestAudioSource {
[[nodiscard]] BestAudioFrame *GetFrameInternal(int64_t N);
[[nodiscard]] BestAudioFrame *GetFrameLinearInternal(int64_t N, int64_t SeekFrame = -1, size_t Depth = 0, bool ForceUnseeked = false);
[[nodiscard]] bool IndexTrack(const ProgressFunction &Progress = nullptr);
bool InitializeRFF();
void ZeroFillStartPacked(uint8_t *&Data, int64_t &Start, int64_t &Count);
void ZeroFillEndPacked(uint8_t *Data, int64_t Start, int64_t &Count);
bool FillInFramePacked(const BestAudioFrame *Frame, int64_t FrameStartSample, uint8_t *&Data, int64_t &Start, int64_t &Count);
Expand Down

0 comments on commit 264513e

Please sign in to comment.