mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 08:52:36 +00:00
cubeb_audio: Add debug logging callback.
This commit is contained in:
parent
01959bdee5
commit
dc0725aa91
@ -1,6 +1,7 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include <cstdarg>
|
||||||
#include <cubeb/cubeb.h>
|
#include <cubeb/cubeb.h>
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
@ -130,6 +131,7 @@ struct CubebStream {
|
|||||||
};
|
};
|
||||||
|
|
||||||
CubebAudioOut::CubebAudioOut() {
|
CubebAudioOut::CubebAudioOut() {
|
||||||
|
cubeb_set_log_callback(CUBEB_LOG_NORMAL, LogCallback);
|
||||||
if (const auto ret = cubeb_init(&ctx, "shadPS4", nullptr); ret != CUBEB_OK) {
|
if (const auto ret = cubeb_init(&ctx, "shadPS4", nullptr); ret != CUBEB_OK) {
|
||||||
LOG_CRITICAL(Lib_AudioOut, "Failed to create cubeb context: {}", ret);
|
LOG_CRITICAL(Lib_AudioOut, "Failed to create cubeb context: {}", ret);
|
||||||
}
|
}
|
||||||
@ -168,4 +170,13 @@ void CubebAudioOut::SetVolume(void* impl, const std::array<int, 8>& ch_volumes)
|
|||||||
static_cast<CubebStream*>(impl)->SetVolume(ch_volumes);
|
static_cast<CubebStream*>(impl)->SetVolume(ch_volumes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CubebAudioOut::LogCallback(const char* format, ...) {
|
||||||
|
std::array<char, 512> buffer{};
|
||||||
|
std::va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
vsnprintf(buffer.data(), buffer.size(), format, args);
|
||||||
|
va_end(args);
|
||||||
|
LOG_DEBUG(Lib_Audio3d, "[cubeb] {}", buffer.data());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Libraries::AudioOut
|
} // namespace Libraries::AudioOut
|
||||||
|
@ -21,6 +21,8 @@ public:
|
|||||||
void SetVolume(void* impl, const std::array<int, 8>& ch_volumes) override;
|
void SetVolume(void* impl, const std::array<int, 8>& ch_volumes) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static void LogCallback(const char* format, ...);
|
||||||
|
|
||||||
cubeb* ctx = nullptr;
|
cubeb* ctx = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user