Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cubeb log callback #16510

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions rpcs3/Emu/Audio/Cubeb/CubebBackend.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Emu/Audio/Cubeb/CubebBackend.h"

#include <algorithm>
#include <cstdarg>
#include "util/logs.hpp"
#include "Emu/Audio/audio_device_enumerator.h"

Expand Down Expand Up @@ -38,6 +39,8 @@ CubebBackend::CubebBackend()
m_dev_collection_cb_enabled = true;
}

cubeb_set_log_callback(CUBEB_LOG_NORMAL, log_cb);

Cubeb.notice("Using backend %s", cubeb_get_backend_id(ctx));

std::lock_guard cb_lock{m_state_cb_mutex};
Expand Down Expand Up @@ -568,3 +571,15 @@ void CubebBackend::device_collection_changed_cb(cubeb* context, void* user_ptr)
cubeb->m_state_callback(AudioStateEvent::DEFAULT_DEVICE_MAYBE_CHANGED);
}
}

void CubebBackend::log_cb(const char* fmt, ...)
{
char buf[256] = "Cubeb log msg: ";
static constexpr size_t prefix_size = sizeof("Cubeb log msg: ") - 1;

va_list va;
va_start(va, fmt);
vsnprintf(buf + prefix_size, sizeof(buf) - prefix_size, fmt, va);
va_end(va);
Cubeb.notice(buf);
}
1 change: 1 addition & 0 deletions rpcs3/Emu/Audio/Cubeb/CubebBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class CubebBackend final : public AudioBackend
static long data_cb(cubeb_stream* stream, void* user_ptr, void const* input_buffer, void* output_buffer, long nframes);
static void state_cb(cubeb_stream* stream, void* user_ptr, cubeb_state state);
static void device_collection_changed_cb(cubeb* context, void* user_ptr);
static void log_cb(const char *fmt, ...);

struct device_handle
{
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/lv2/sys_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ error_code sys_config_register_service(u32 config_hdl, sys_config_service_id ser
sys_config.trace("sys_config_register_service(config_hdl=0x%x, service_id=0x%llx, user_id=0x%llx, verbosity=0x%llx, data_but=*0x%llx, size=%lld, out_service_hdl=*0x%llx)", config_hdl, service_id, user_id, verbosity, data_buf, size, out_service_hdl);

// Find sys_config handle object with the given ID
const auto cfg = idm::get_unlocked<lv2_config_handle>(config_hdl);
const auto cfg = idm::withdraw<lv2_config_handle>(config_hdl);
if (!cfg)
{
return CELL_ESRCH;
Expand All @@ -446,7 +446,7 @@ error_code sys_config_unregister_service(u32 config_hdl, u32 service_hdl)
sys_config.trace("sys_config_unregister_service(config_hdl=0x%x, service_hdl=0x%x)", config_hdl, service_hdl);

// Remove listener from IDM
auto service = idm::withdraw<lv2_config_service>(service_hdl);
auto service = idm::get_unlocked<lv2_config_service>(service_hdl);
if (!service)
{
return CELL_ESRCH;
Expand Down