Skip to content

Commit

Permalink
Log the buffer format when queueing mismatched buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Mar 23, 2023
1 parent d4bfb62 commit ac01cbf
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
8 changes: 6 additions & 2 deletions al/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3867,17 +3867,21 @@ START_API_FUNC
{
fmt_mismatch |= BufferFmt->mSampleRate != buffer->mSampleRate;
fmt_mismatch |= BufferFmt->mChannels != buffer->mChannels;
fmt_mismatch |= BufferFmt->mType != buffer->mType;
if(BufferFmt->isBFormat())
{
fmt_mismatch |= BufferFmt->mAmbiLayout != buffer->mAmbiLayout;
fmt_mismatch |= BufferFmt->mAmbiScaling != buffer->mAmbiScaling;
}
fmt_mismatch |= BufferFmt->mAmbiOrder != buffer->mAmbiOrder;
fmt_mismatch |= BufferFmt->mType != buffer->mType;
}
if(fmt_mismatch) UNLIKELY
{
context->setError(AL_INVALID_OPERATION, "Queueing buffer with mismatched format");
context->setError(AL_INVALID_OPERATION, "Queueing buffer with mismatched format\n"
" Expected: %uhz, %s, %s ; Got: %uhz, %s, %s\n", BufferFmt->mSampleRate,
NameFromFormat(BufferFmt->mType), NameFromFormat(BufferFmt->mChannels),
buffer->mSampleRate, NameFromFormat(buffer->mType),
NameFromFormat(buffer->mChannels));

buffer_error:
/* A buffer failed (invalid ID or format), so unlock and release
Expand Down
37 changes: 37 additions & 0 deletions core/buffer_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,43 @@
#include <stdint.h>


const char *NameFromFormat(FmtType type) noexcept
{
switch(type)
{
case FmtUByte: return "UInt8";
case FmtShort: return "Int16";
case FmtFloat: return "Float";
case FmtDouble: return "Double";
case FmtMulaw: return "muLaw";
case FmtAlaw: return "aLaw";
case FmtIMA4: return "IMA4 ADPCM";
case FmtMSADPCM: return "MS ADPCM";
}
return "<internal error>";
}

const char *NameFromFormat(FmtChannels channels) noexcept
{
switch(channels)
{
case FmtMono: return "Mono";
case FmtStereo: return "Stereo";
case FmtRear: return "Rear";
case FmtQuad: return "Quadraphonic";
case FmtX51: return "Surround 5.1";
case FmtX61: return "Surround 6.1";
case FmtX71: return "Surround 7.1";
case FmtBFormat2D: return "B-Format 2D";
case FmtBFormat3D: return "B-Format 3D";
case FmtUHJ2: return "UHJ2";
case FmtUHJ3: return "UHJ3";
case FmtUHJ4: return "UHJ4";
case FmtSuperStereo: return "Super Stereo";
}
return "<internal error>";
}

uint BytesFromFmt(FmtType type) noexcept
{
switch(type)
Expand Down
3 changes: 3 additions & 0 deletions core/buffer_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ enum class AmbiScaling : unsigned char {
UHJ,
};

const char *NameFromFormat(FmtType type) noexcept;
const char *NameFromFormat(FmtChannels channels) noexcept;

uint BytesFromFmt(FmtType type) noexcept;
uint ChannelsFromFmt(FmtChannels chans, uint ambiorder) noexcept;
inline uint FrameSizeFromFmt(FmtChannels chans, FmtType type, uint ambiorder) noexcept
Expand Down

0 comments on commit ac01cbf

Please sign in to comment.