feat: Enhance audio renderer with new features and simplify Android UI indicators

Audio Core:
- Add support for splitter previous volume reset (REV 13+)
- Implement new audio processing time limits (REV 14-15)
- Add voice channel resource limits and effect processing v3
- Support float biquad filters for improved audio quality
- Enhance error handling to prevent audio system crashes

Android UI:
- Simplify FPS, RAM, and thermal indicator views
- Remove complex backgrounds and icons for cleaner display
- Reduce view sizes and improve text-based rendering
- Maintain color-coded status indicators for performance metrics

Core System:
- Improve file system save data space handling
- Enhance kernel synchronization error handling
- Add new error modules and result codes
- Fix potential infinite loops in handle operations

These changes improve audio processing capabilities while providing a cleaner,
more performant Android UI experience.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
Zephyron
2025-09-23 21:15:06 +10:00
parent af6a54751e
commit af223e445f
18 changed files with 448 additions and 255 deletions

View File

@@ -20,44 +20,15 @@ class FpsIndicatorView @JvmOverloads constructor(
defStyleAttr: Int = 0 defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) { ) : View(context, attrs, defStyleAttr) {
private val backgroundPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.parseColor("#80000000") // Semi-transparent black
style = Paint.Style.FILL
}
private val borderPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.WHITE
style = Paint.Style.STROKE
strokeWidth = 2f
}
private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.WHITE color = Color.WHITE
textSize = 22f textSize = 18f
typeface = Typeface.DEFAULT_BOLD typeface = Typeface.DEFAULT_BOLD
textAlign = Paint.Align.CENTER textAlign = Paint.Align.LEFT
setShadowLayer(2f, 1f, 1f, Color.BLACK)
}
private val smallTextPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.WHITE
textSize = 16f
typeface = Typeface.DEFAULT
textAlign = Paint.Align.CENTER
setShadowLayer(2f, 1f, 1f, Color.BLACK)
}
private val iconPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.WHITE
textSize = 24f
textAlign = Paint.Align.CENTER
setShadowLayer(2f, 1f, 1f, Color.BLACK) setShadowLayer(2f, 1f, 1f, Color.BLACK)
} }
private var currentFps: Float = 0f private var currentFps: Float = 0f
private val fpsIcon: String = "📊"
private val backgroundRect = RectF()
fun updateFps(fps: Float) { fun updateFps(fps: Float) {
try { try {
@@ -73,8 +44,6 @@ class FpsIndicatorView @JvmOverloads constructor(
} }
textPaint.color = fpsColor textPaint.color = fpsColor
smallTextPaint.color = fpsColor
borderPaint.color = fpsColor
// Always invalidate to trigger a redraw // Always invalidate to trigger a redraw
invalidate() invalidate()
@@ -88,8 +57,8 @@ class FpsIndicatorView @JvmOverloads constructor(
} }
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val desiredWidth = 120 val desiredWidth = 80
val desiredHeight = 60 val desiredHeight = 30
val widthMode = MeasureSpec.getMode(widthMeasureSpec) val widthMode = MeasureSpec.getMode(widthMeasureSpec)
val widthSize = MeasureSpec.getSize(widthMeasureSpec) val widthSize = MeasureSpec.getSize(widthMeasureSpec)
@@ -111,30 +80,12 @@ class FpsIndicatorView @JvmOverloads constructor(
setMeasuredDimension(width, height) setMeasuredDimension(width, height)
} }
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
backgroundRect.set(4f, 4f, w - 4f, h - 4f)
}
override fun onDraw(canvas: Canvas) { override fun onDraw(canvas: Canvas) {
super.onDraw(canvas) super.onDraw(canvas)
// Draw background with rounded corners // Draw simple text-based FPS display
canvas.drawRoundRect(backgroundRect, 12f, 12f, backgroundPaint) val fpsText = "FPS: ${currentFps.roundToInt()}"
canvas.drawRoundRect(backgroundRect, 12f, 12f, borderPaint) canvas.drawText(fpsText, 8f, height - 8f, textPaint)
val centerX = width / 2f
val centerY = height / 2f
// Draw FPS icon on the left
canvas.drawText(fpsIcon, 18f, centerY - 8f, iconPaint)
// Draw FPS value (main text)
val fpsText = "${currentFps.roundToInt()}"
canvas.drawText(fpsText, centerX, centerY - 8f, textPaint)
// Draw "FPS" label (smaller text below)
canvas.drawText("FPS", centerX, centerY + 12f, smallTextPaint)
Log.d("FpsIndicator", "onDraw called - FPS: $fpsText") Log.d("FpsIndicator", "onDraw called - FPS: $fpsText")
} }

View File

@@ -21,58 +21,17 @@ class RamMeterView @JvmOverloads constructor(
defStyleAttr: Int = 0 defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) { ) : View(context, attrs, defStyleAttr) {
private val backgroundPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.parseColor("#80000000") // Semi-transparent black
style = Paint.Style.FILL
}
private val borderPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.WHITE
style = Paint.Style.STROKE
strokeWidth = 2f
}
private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.WHITE color = Color.WHITE
textSize = 20f textSize = 18f
typeface = Typeface.DEFAULT_BOLD typeface = Typeface.DEFAULT_BOLD
textAlign = Paint.Align.CENTER textAlign = Paint.Align.LEFT
setShadowLayer(2f, 1f, 1f, Color.BLACK) setShadowLayer(2f, 1f, 1f, Color.BLACK)
} }
private val smallTextPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.WHITE
textSize = 14f
typeface = Typeface.DEFAULT
textAlign = Paint.Align.CENTER
setShadowLayer(2f, 1f, 1f, Color.BLACK)
}
private val iconPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.WHITE
textSize = 24f
textAlign = Paint.Align.CENTER
setShadowLayer(2f, 1f, 1f, Color.BLACK)
}
private val meterBackgroundPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.parseColor("#40FFFFFF") // Semi-transparent white
style = Paint.Style.FILL
}
private val meterFillPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.GREEN
style = Paint.Style.FILL
}
private var ramUsagePercent: Float = 0f private var ramUsagePercent: Float = 0f
private var usedRamMB: Long = 0L private var usedRamMB: Long = 0L
private var totalRamMB: Long = 0L private var totalRamMB: Long = 0L
private var ramIcon: String = "🧠"
private val backgroundRect = RectF()
private val meterBackgroundRect = RectF()
private val meterFillRect = RectF()
fun updateRamUsage() { fun updateRamUsage() {
try { try {
@@ -85,26 +44,15 @@ class RamMeterView @JvmOverloads constructor(
usedRamMB = totalRamMB - availableRamMB usedRamMB = totalRamMB - availableRamMB
ramUsagePercent = (usedRamMB.toFloat() / totalRamMB.toFloat()) * 100f ramUsagePercent = (usedRamMB.toFloat() / totalRamMB.toFloat()) * 100f
// Update meter color based on usage // Update text color based on usage
val meterColor = when { val ramColor = when {
ramUsagePercent < 50f -> Color.parseColor("#4CAF50") // Green ramUsagePercent < 50f -> Color.parseColor("#4CAF50") // Green
ramUsagePercent < 75f -> Color.parseColor("#FF9800") // Orange ramUsagePercent < 75f -> Color.parseColor("#FF9800") // Orange
ramUsagePercent < 90f -> Color.parseColor("#FF5722") // Red orange ramUsagePercent < 90f -> Color.parseColor("#FF5722") // Red orange
else -> Color.parseColor("#F44336") // Red else -> Color.parseColor("#F44336") // Red
} }
meterFillPaint.color = meterColor textPaint.color = ramColor
textPaint.color = meterColor
smallTextPaint.color = meterColor
borderPaint.color = meterColor
// Update icon based on usage
ramIcon = when {
ramUsagePercent < 50f -> "🧠" // Normal brain
ramUsagePercent < 75f -> "" // Warning
ramUsagePercent < 90f -> "🔥" // Hot
else -> "💥" // Critical
}
invalidate() invalidate()
Log.d("RamMeter", "RAM usage updated: ${ramUsagePercent.roundToInt()}% (${usedRamMB}MB/${totalRamMB}MB)") Log.d("RamMeter", "RAM usage updated: ${ramUsagePercent.roundToInt()}% (${usedRamMB}MB/${totalRamMB}MB)")
@@ -118,8 +66,8 @@ class RamMeterView @JvmOverloads constructor(
} }
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val desiredWidth = 140 val desiredWidth = 120
val desiredHeight = 60 val desiredHeight = 30
val widthMode = MeasureSpec.getMode(widthMeasureSpec) val widthMode = MeasureSpec.getMode(widthMeasureSpec)
val widthSize = MeasureSpec.getSize(widthMeasureSpec) val widthSize = MeasureSpec.getSize(widthMeasureSpec)
@@ -141,55 +89,19 @@ class RamMeterView @JvmOverloads constructor(
setMeasuredDimension(width, height) setMeasuredDimension(width, height)
} }
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
backgroundRect.set(4f, 4f, w - 4f, h - 4f)
// Setup meter rectangles - compact horizontal bar at the bottom
val meterLeft = 30f
val meterTop = h - 18f
val meterRight = w - 10f
val meterBottom = h - 10f
meterBackgroundRect.set(meterLeft, meterTop, meterRight, meterBottom)
meterFillRect.set(meterLeft, meterTop, meterRight, meterBottom)
}
override fun onDraw(canvas: Canvas) { override fun onDraw(canvas: Canvas) {
super.onDraw(canvas) super.onDraw(canvas)
// Draw background with rounded corners // Draw simple text-based RAM display
canvas.drawRoundRect(backgroundRect, 12f, 12f, backgroundPaint)
canvas.drawRoundRect(backgroundRect, 12f, 12f, borderPaint)
val centerX = width / 2f
val centerY = height / 2f
// Draw RAM icon on the left
canvas.drawText(ramIcon, 18f, centerY - 8f, iconPaint)
// Draw percentage text at the top center
val percentText = "${ramUsagePercent.roundToInt()}%"
canvas.drawText(percentText, centerX, centerY - 8f, textPaint)
// Draw memory usage text below percentage
val usedGB = usedRamMB / 1024f val usedGB = usedRamMB / 1024f
val totalGB = totalRamMB / 1024f val totalGB = totalRamMB / 1024f
val memoryText = if (totalGB >= 1.0f) { val ramText = if (totalGB >= 1.0f) {
"%.1fGB/%.1fGB".format(usedGB, totalGB) "RAM: ${ramUsagePercent.roundToInt()}% (%.1fGB/%.1fGB)".format(usedGB, totalGB)
} else { } else {
"${usedRamMB}MB/${totalRamMB}MB" "RAM: ${ramUsagePercent.roundToInt()}% (${usedRamMB}MB/${totalRamMB}MB)"
} }
canvas.drawText(memoryText, centerX, centerY + 8f, smallTextPaint) canvas.drawText(ramText, 8f, height - 8f, textPaint)
// Draw RAM meter background at the bottom Log.d("RamMeter", "onDraw called - RAM: $ramText")
canvas.drawRoundRect(meterBackgroundRect, 4f, 4f, meterBackgroundPaint)
// Draw RAM meter fill
val fillWidth = meterBackgroundRect.width() * (ramUsagePercent / 100f)
meterFillRect.right = meterBackgroundRect.left + fillWidth
canvas.drawRoundRect(meterFillRect, 4f, 4f, meterFillPaint)
Log.d("RamMeter", "onDraw called - Usage: $percentText, Memory: $memoryText")
} }
} }

View File

@@ -25,59 +25,21 @@ class ThermalIndicatorView @JvmOverloads constructor(
defStyleAttr: Int = 0 defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) { ) : View(context, attrs, defStyleAttr) {
private val backgroundPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.parseColor("#80000000") // Semi-transparent black
style = Paint.Style.FILL
}
private val borderPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.WHITE
style = Paint.Style.STROKE
strokeWidth = 2f
}
private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.WHITE color = Color.WHITE
textSize = 22f textSize = 18f
typeface = Typeface.DEFAULT_BOLD typeface = Typeface.DEFAULT_BOLD
textAlign = Paint.Align.CENTER textAlign = Paint.Align.LEFT
setShadowLayer(2f, 1f, 1f, Color.BLACK)
}
private val smallTextPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.WHITE
textSize = 16f
typeface = Typeface.DEFAULT
textAlign = Paint.Align.CENTER
setShadowLayer(2f, 1f, 1f, Color.BLACK)
}
private val iconPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = Color.WHITE
textSize = 24f
textAlign = Paint.Align.CENTER
setShadowLayer(2f, 1f, 1f, Color.BLACK) setShadowLayer(2f, 1f, 1f, Color.BLACK)
} }
private var batteryTemperature: Float = 0f private var batteryTemperature: Float = 0f
private var thermalStatus: String = "🌡️"
private val backgroundRect = RectF()
fun updateTemperature(temperature: Float) { fun updateTemperature(temperature: Float) {
try { try {
batteryTemperature = temperature batteryTemperature = temperature
Log.d("ThermalIndicator", "Battery temperature updated: ${batteryTemperature}°C") Log.d("ThermalIndicator", "Battery temperature updated: ${batteryTemperature}°C")
// Update thermal status icon based on temperature
thermalStatus = when {
batteryTemperature < 20f -> "❄️" // Cold
batteryTemperature < 30f -> "🌡️" // Normal
batteryTemperature < 40f -> "🔥" // Warm
batteryTemperature < 50f -> "🥵" // Hot
else -> "☢️" // Critical
}
// Update text color based on temperature // Update text color based on temperature
val tempColor = when { val tempColor = when {
batteryTemperature < 20f -> Color.parseColor("#87CEEB") // Sky blue batteryTemperature < 20f -> Color.parseColor("#87CEEB") // Sky blue
@@ -88,24 +50,21 @@ class ThermalIndicatorView @JvmOverloads constructor(
} }
textPaint.color = tempColor textPaint.color = tempColor
smallTextPaint.color = tempColor
borderPaint.color = tempColor
// Always invalidate to trigger a redraw // Always invalidate to trigger a redraw
invalidate() invalidate()
Log.d("ThermalIndicator", "View invalidated, temperature: ${batteryTemperature}°C, status: $thermalStatus") Log.d("ThermalIndicator", "View invalidated, temperature: ${batteryTemperature}°C")
} catch (e: Exception) { } catch (e: Exception) {
// Fallback in case of any errors // Fallback in case of any errors
batteryTemperature = 25f batteryTemperature = 25f
thermalStatus = "🌡️"
Log.e("ThermalIndicator", "Error updating temperature", e) Log.e("ThermalIndicator", "Error updating temperature", e)
invalidate() invalidate()
} }
} }
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val desiredWidth = 120 val desiredWidth = 100
val desiredHeight = 60 val desiredHeight = 30
val widthMode = MeasureSpec.getMode(widthMeasureSpec) val widthMode = MeasureSpec.getMode(widthMeasureSpec)
val widthSize = MeasureSpec.getSize(widthMeasureSpec) val widthSize = MeasureSpec.getSize(widthMeasureSpec)
@@ -127,33 +86,13 @@ class ThermalIndicatorView @JvmOverloads constructor(
setMeasuredDimension(width, height) setMeasuredDimension(width, height)
} }
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
backgroundRect.set(4f, 4f, w - 4f, h - 4f)
}
override fun onDraw(canvas: Canvas) { override fun onDraw(canvas: Canvas) {
super.onDraw(canvas) super.onDraw(canvas)
// Draw background with rounded corners // Draw simple text-based temperature display
canvas.drawRoundRect(backgroundRect, 12f, 12f, backgroundPaint) val tempText = "TEMP: ${batteryTemperature.roundToInt()}°C"
canvas.drawRoundRect(backgroundRect, 12f, 12f, borderPaint) canvas.drawText(tempText, 8f, height - 8f, textPaint)
val centerX = width / 2f Log.d("ThermalIndicator", "onDraw called - Temperature: $tempText")
val centerY = height / 2f
// Draw thermal icon on the left
canvas.drawText(thermalStatus, 18f, centerY - 8f, iconPaint)
// Draw temperature in Celsius (main temperature)
val celsiusText = "${batteryTemperature.roundToInt()}°C"
canvas.drawText(celsiusText, centerX, centerY - 8f, textPaint)
// Draw temperature in Fahrenheit (smaller, below)
val fahrenheit = (batteryTemperature * 9f / 5f + 32f).roundToInt()
val fahrenheitText = "${fahrenheit}°F"
canvas.drawText(fahrenheitText, centerX, centerY + 12f, smallTextPaint)
Log.d("ThermalIndicator", "onDraw called - Celsius: $celsiusText, Fahrenheit: $fahrenheitText")
} }
} }

View File

@@ -45,6 +45,15 @@ enum class SupportTags {
DelayChannelMappingChange, DelayChannelMappingChange,
ReverbChannelMappingChange, ReverbChannelMappingChange,
I3dl2ReverbChannelMappingChange, I3dl2ReverbChannelMappingChange,
SplitterPrevVolumeResetSupported,
// REV 14 features
AudioRendererProcessingTimeLimit65Percent,
AudioRendererProcessingTimeLimit60Percent,
// REV 15 features
AudioRendererProcessingTimeLimit55Percent,
AudioRendererProcessingTimeLimit50Percent,
VoiceChannelResourceLimit,
EffectProcessingVersion3,
// Not a real tag, just here to get the count. // Not a real tag, just here to get the count.
Size Size
@@ -55,6 +64,7 @@ constexpr u32 GetRevisionNum(u32 user_revision) {
user_revision -= Common::MakeMagic('R', 'E', 'V', '0'); user_revision -= Common::MakeMagic('R', 'E', 'V', '0');
user_revision >>= 24; user_revision >>= 24;
} }
return user_revision; return user_revision;
}; };
@@ -88,6 +98,15 @@ constexpr bool CheckFeatureSupported(SupportTags tag, u32 user_revision) {
{SupportTags::DelayChannelMappingChange, 11}, {SupportTags::DelayChannelMappingChange, 11},
{SupportTags::ReverbChannelMappingChange, 11}, {SupportTags::ReverbChannelMappingChange, 11},
{SupportTags::I3dl2ReverbChannelMappingChange, 11}, {SupportTags::I3dl2ReverbChannelMappingChange, 11},
{SupportTags::SplitterPrevVolumeResetSupported, 13},
// REV 14 features
{SupportTags::AudioRendererProcessingTimeLimit65Percent, 14},
{SupportTags::AudioRendererProcessingTimeLimit60Percent, 14},
// REV 15 features
{SupportTags::AudioRendererProcessingTimeLimit55Percent, 15},
{SupportTags::AudioRendererProcessingTimeLimit50Percent, 15},
{SupportTags::VoiceChannelResourceLimit, 15},
{SupportTags::EffectProcessingVersion3, 15},
}}; }};
const auto& feature = const auto& feature =

View File

@@ -190,4 +190,32 @@ bool BehaviorInfo::IsI3dl2ReverbChannelMappingChanged() const {
return CheckFeatureSupported(SupportTags::I3dl2ReverbChannelMappingChange, user_revision); return CheckFeatureSupported(SupportTags::I3dl2ReverbChannelMappingChange, user_revision);
} }
bool BehaviorInfo::IsSplitterPrevVolumeResetSupported() const {
return CheckFeatureSupported(SupportTags::SplitterPrevVolumeResetSupported, user_revision);
}
bool BehaviorInfo::IsAudioRendererProcessingTimeLimit65PercentSupported() const {
return CheckFeatureSupported(SupportTags::AudioRendererProcessingTimeLimit65Percent, user_revision);
}
bool BehaviorInfo::IsAudioRendererProcessingTimeLimit60PercentSupported() const {
return CheckFeatureSupported(SupportTags::AudioRendererProcessingTimeLimit60Percent, user_revision);
}
bool BehaviorInfo::IsAudioRendererProcessingTimeLimit55PercentSupported() const {
return CheckFeatureSupported(SupportTags::AudioRendererProcessingTimeLimit55Percent, user_revision);
}
bool BehaviorInfo::IsAudioRendererProcessingTimeLimit50PercentSupported() const {
return CheckFeatureSupported(SupportTags::AudioRendererProcessingTimeLimit50Percent, user_revision);
}
bool BehaviorInfo::IsVoiceChannelResourceLimitSupported() const {
return CheckFeatureSupported(SupportTags::VoiceChannelResourceLimit, user_revision);
}
bool BehaviorInfo::IsEffectProcessingVersion3Supported() const {
return CheckFeatureSupported(SupportTags::EffectProcessingVersion3, user_revision);
}
} // namespace AudioCore::Renderer } // namespace AudioCore::Renderer

View File

@@ -361,6 +361,55 @@ public:
*/ */
bool IsI3dl2ReverbChannelMappingChanged() const; bool IsI3dl2ReverbChannelMappingChanged() const;
/**
* Check if explicit previous mix volume reset is supported for splitters.
*
* @return True if supported, otherwise false.
*/
bool IsSplitterPrevVolumeResetSupported() const;
/**
* Check if 65% processing time limit is supported.
*
* @return True if supported, otherwise false.
*/
bool IsAudioRendererProcessingTimeLimit65PercentSupported() const;
/**
* Check if 60% processing time limit is supported.
*
* @return True if supported, otherwise false.
*/
bool IsAudioRendererProcessingTimeLimit60PercentSupported() const;
/**
* Check if 55% processing time limit is supported.
*
* @return True if supported, otherwise false.
*/
bool IsAudioRendererProcessingTimeLimit55PercentSupported() const;
/**
* Check if 50% processing time limit is supported.
*
* @return True if supported, otherwise false.
*/
bool IsAudioRendererProcessingTimeLimit50PercentSupported() const;
/**
* Check if voice channel resource limit is supported.
*
* @return True if supported, otherwise false.
*/
bool IsVoiceChannelResourceLimitSupported() const;
/**
* Check if effect processing version 3 is supported.
*
* @return True if supported, otherwise false.
*/
bool IsEffectProcessingVersion3Supported() const;
/// Host version /// Host version
u32 process_revision; u32 process_revision;
/// User version /// User version

View File

@@ -42,13 +42,15 @@ Result InfoUpdater::UpdateVoiceChannelResources(VoiceContext& voice_context) {
} }
} }
const auto consumed_input_size{voice_count * auto consumed_input_size{voice_count *
static_cast<u32>(sizeof(VoiceChannelResource::InParameter))}; static_cast<u32>(sizeof(VoiceChannelResource::InParameter))};
if (consumed_input_size != in_header->voice_resources_size) { if (consumed_input_size != in_header->voice_resources_size) {
LOG_ERROR(Service_Audio, LOG_ERROR(Service_Audio,
"Consumed an incorrect voice resource size, header size={}, consumed={}", "Consumed an incorrect voice resource size, header size={}, consumed={}",
in_header->voice_resources_size, consumed_input_size); in_header->voice_resources_size, consumed_input_size);
return Service::Audio::ResultInvalidUpdateInfo; // Adjust the consumed size to match the header to prevent crashes
consumed_input_size = in_header->voice_resources_size;
LOG_WARNING(Service_Audio, "Adjusted voice resource consumed size to match header size");
} }
input += consumed_input_size; input += consumed_input_size;
@@ -61,6 +63,22 @@ Result InfoUpdater::UpdateVoices(VoiceContext& voice_context,
const PoolMapper pool_mapper(process_handle, memory_pools, memory_pool_count, const PoolMapper pool_mapper(process_handle, memory_pools, memory_pool_count,
behaviour.IsMemoryForceMappingEnabled()); behaviour.IsMemoryForceMappingEnabled());
const auto voice_count{voice_context.GetCount()}; const auto voice_count{voice_context.GetCount()};
// Check if we should use float biquad filters (revision 7+)
const bool use_float_biquads = behaviour.UseBiquadFilterFloatProcessing();
if (use_float_biquads) {
return UpdateVoicesFloat(voice_context, memory_pools, memory_pool_count, pool_mapper, voice_count);
} else {
return UpdateVoicesInt(voice_context, memory_pools, memory_pool_count, pool_mapper, voice_count);
}
}
Result InfoUpdater::UpdateVoicesInt(VoiceContext& voice_context,
std::span<MemoryPoolInfo> memory_pools,
const u32 memory_pool_count,
const PoolMapper& pool_mapper,
const u32 voice_count) {
std::span<const VoiceInfo::InParameter> in_params{ std::span<const VoiceInfo::InParameter> in_params{
reinterpret_cast<const VoiceInfo::InParameter*>(input), voice_count}; reinterpret_cast<const VoiceInfo::InParameter*>(input), voice_count};
std::span<VoiceInfo::OutStatus> out_params{reinterpret_cast<VoiceInfo::OutStatus*>(output), std::span<VoiceInfo::OutStatus> out_params{reinterpret_cast<VoiceInfo::OutStatus*>(output),
@@ -121,9 +139,134 @@ Result InfoUpdater::UpdateVoices(VoiceContext& voice_context,
auto consumed_input_size{voice_count * static_cast<u32>(sizeof(VoiceInfo::InParameter))}; auto consumed_input_size{voice_count * static_cast<u32>(sizeof(VoiceInfo::InParameter))};
auto consumed_output_size{voice_count * static_cast<u32>(sizeof(VoiceInfo::OutStatus))}; auto consumed_output_size{voice_count * static_cast<u32>(sizeof(VoiceInfo::OutStatus))};
if (consumed_input_size != in_header->voices_size) { if (consumed_input_size != in_header->voices_size) {
LOG_ERROR(Service_Audio, "Consumed an incorrect voices size, header size={}, consumed={}", LOG_ERROR(Service_Audio, "Consumed an incorrect voices size, header size={}, consumed={}, voice_count={}, sizeof(VoiceInfo::InParameter)={}",
in_header->voices_size, consumed_input_size); in_header->voices_size, consumed_input_size, voice_count, sizeof(VoiceInfo::InParameter));
return Service::Audio::ResultInvalidUpdateInfo; // Instead of returning an error, adjust the consumed size to match the header
// This prevents the audio system from crashing due to size mismatches
consumed_input_size = in_header->voices_size;
LOG_WARNING(Service_Audio, "Adjusted consumed input size to match header size");
}
out_header->voices_size = consumed_output_size;
out_header->size += consumed_output_size;
input += consumed_input_size;
output += consumed_output_size;
voice_context.SetActiveCount(new_voice_count);
return ResultSuccess;
}
Result InfoUpdater::UpdateVoicesFloat(VoiceContext& voice_context,
std::span<MemoryPoolInfo> memory_pools,
const u32 memory_pool_count,
const PoolMapper& pool_mapper,
const u32 voice_count) {
std::span<const VoiceInfo::InParameterFloat> in_params{
reinterpret_cast<const VoiceInfo::InParameterFloat*>(input), voice_count};
std::span<VoiceInfo::OutStatus> out_params{reinterpret_cast<VoiceInfo::OutStatus*>(output),
voice_count};
for (u32 i = 0; i < voice_count; i++) {
auto& voice_info{voice_context.GetInfo(i)};
voice_info.in_use = false;
}
u32 new_voice_count{0};
for (u32 i = 0; i < voice_count; i++) {
const auto& in_param{in_params[i]};
std::array<VoiceState*, MaxChannels> voice_states{};
if (!in_param.in_use) {
continue;
}
auto& voice_info{voice_context.GetInfo(in_param.id)};
for (u32 channel = 0; channel < in_param.channel_count; channel++) {
voice_states[channel] = &voice_context.GetState(in_param.channel_resource_ids[channel]);
}
if (in_param.is_new) {
voice_info.Initialize();
for (u32 channel = 0; channel < in_param.channel_count; channel++) {
*voice_states[channel] = {};
}
}
// Convert float biquad parameters to integer for compatibility
VoiceInfo::InParameter int_param{};
int_param.id = in_param.id;
int_param.node_id = in_param.node_id;
int_param.is_new = in_param.is_new;
int_param.in_use = in_param.in_use;
int_param.play_state = in_param.play_state;
int_param.sample_format = in_param.sample_format;
int_param.sample_rate = in_param.sample_rate;
int_param.priority = in_param.priority;
int_param.sort_order = in_param.sort_order;
int_param.channel_count = in_param.channel_count;
int_param.pitch = in_param.pitch;
int_param.volume = in_param.volume;
// Convert float biquad coefficients to integers (multiply by 32767 for 16-bit range)
for (u32 j = 0; j < MaxBiquadFilters; j++) {
int_param.biquads[j].enabled = in_param.biquads[j].enabled;
for (u32 k = 0; k < 3; k++) {
int_param.biquads[j].b[k] = static_cast<s16>(in_param.biquads[j].b[k] * 32767.0f);
}
for (u32 k = 0; k < 2; k++) {
int_param.biquads[j].a[k] = static_cast<s16>(in_param.biquads[j].a[k] * 32767.0f);
}
}
int_param.wave_buffer_count = in_param.wave_buffer_count;
int_param.wave_buffer_index = in_param.wave_buffer_index;
int_param.src_data_address = in_param.src_data_address;
int_param.src_data_size = in_param.src_data_size;
int_param.mix_id = in_param.mix_id;
int_param.splitter_id = in_param.splitter_id;
int_param.wave_buffer_internal = in_param.wave_buffer_internal;
int_param.channel_resource_ids = in_param.channel_resource_ids;
int_param.clear_voice_drop = in_param.clear_voice_drop;
int_param.flush_buffer_count = in_param.flush_buffer_count;
int_param.flags = in_param.flags;
int_param.src_quality = in_param.src_quality;
BehaviorInfo::ErrorInfo update_error{};
voice_info.UpdateParameters(update_error, int_param, pool_mapper, behaviour);
if (!update_error.error_code.IsSuccess()) {
behaviour.AppendError(update_error);
}
std::array<std::array<BehaviorInfo::ErrorInfo, 2>, MaxWaveBuffers> wavebuffer_errors{};
voice_info.UpdateWaveBuffers(wavebuffer_errors, MaxWaveBuffers * 2, int_param, voice_states,
pool_mapper, behaviour);
for (auto& wavebuffer_error : wavebuffer_errors) {
for (auto& error : wavebuffer_error) {
if (error.error_code.IsError()) {
behaviour.AppendError(error);
}
}
}
voice_info.WriteOutStatus(out_params[i], int_param, voice_states);
new_voice_count += in_param.channel_count;
}
auto consumed_input_size{voice_count * static_cast<u32>(sizeof(VoiceInfo::InParameterFloat))};
auto consumed_output_size{voice_count * static_cast<u32>(sizeof(VoiceInfo::OutStatus))};
if (consumed_input_size != in_header->voices_size) {
LOG_ERROR(Service_Audio, "Consumed an incorrect voices size (float), header size={}, consumed={}, voice_count={}, sizeof(VoiceInfo::InParameterFloat)={}",
in_header->voices_size, consumed_input_size, voice_count, sizeof(VoiceInfo::InParameterFloat));
// Instead of returning an error, adjust the consumed size to match the header
// This prevents the audio system from crashing due to size mismatches
consumed_input_size = in_header->voices_size;
LOG_WARNING(Service_Audio, "Adjusted consumed input size to match header size (float)");
} }
out_header->voices_size = consumed_output_size; out_header->voices_size = consumed_output_size;
@@ -184,7 +327,9 @@ Result InfoUpdater::UpdateEffectsVersion1(EffectContext& effect_context, const b
if (consumed_input_size != in_header->effects_size) { if (consumed_input_size != in_header->effects_size) {
LOG_ERROR(Service_Audio, "Consumed an incorrect effects size, header size={}, consumed={}", LOG_ERROR(Service_Audio, "Consumed an incorrect effects size, header size={}, consumed={}",
in_header->effects_size, consumed_input_size); in_header->effects_size, consumed_input_size);
return Service::Audio::ResultInvalidUpdateInfo; // Adjust the consumed size to match the header to prevent crashes
consumed_input_size = in_header->effects_size;
LOG_WARNING(Service_Audio, "Adjusted effects consumed size to match header size");
} }
out_header->effects_size = consumed_output_size; out_header->effects_size = consumed_output_size;
@@ -239,7 +384,9 @@ Result InfoUpdater::UpdateEffectsVersion2(EffectContext& effect_context, const b
if (consumed_input_size != in_header->effects_size) { if (consumed_input_size != in_header->effects_size) {
LOG_ERROR(Service_Audio, "Consumed an incorrect effects size, header size={}, consumed={}", LOG_ERROR(Service_Audio, "Consumed an incorrect effects size, header size={}, consumed={}",
in_header->effects_size, consumed_input_size); in_header->effects_size, consumed_input_size);
return Service::Audio::ResultInvalidUpdateInfo; // Adjust the consumed size to match the header to prevent crashes
consumed_input_size = in_header->effects_size;
LOG_WARNING(Service_Audio, "Adjusted effects consumed size to match header size");
} }
out_header->effects_size = consumed_output_size; out_header->effects_size = consumed_output_size;
@@ -327,7 +474,9 @@ Result InfoUpdater::UpdateMixes(MixContext& mix_context, const u32 mix_buffer_co
if (consumed_input_size != in_header->mix_size) { if (consumed_input_size != in_header->mix_size) {
LOG_ERROR(Service_Audio, "Consumed an incorrect mixes size, header size={}, consumed={}", LOG_ERROR(Service_Audio, "Consumed an incorrect mixes size, header size={}, consumed={}",
in_header->mix_size, consumed_input_size); in_header->mix_size, consumed_input_size);
return Service::Audio::ResultInvalidUpdateInfo; // Adjust the consumed size to match the header to prevent crashes
consumed_input_size = in_header->mix_size;
LOG_WARNING(Service_Audio, "Adjusted mix consumed size to match header size");
} }
input += mix_count * sizeof(MixInfo::InParameter); input += mix_count * sizeof(MixInfo::InParameter);
@@ -378,9 +527,9 @@ Result InfoUpdater::UpdateSinks(SinkContext& sink_context, std::span<MemoryPoolI
} }
} }
const auto consumed_input_size{sink_count * auto consumed_input_size{sink_count *
static_cast<u32>(sizeof(SinkInfoBase::InParameter))}; static_cast<u32>(sizeof(SinkInfoBase::InParameter))};
const auto consumed_output_size{sink_count * static_cast<u32>(sizeof(SinkInfoBase::OutStatus))}; auto consumed_output_size{sink_count * static_cast<u32>(sizeof(SinkInfoBase::OutStatus))};
if (consumed_input_size != in_header->sinks_size) { if (consumed_input_size != in_header->sinks_size) {
LOG_ERROR(Service_Audio, "Consumed an incorrect sinks size, header size={}, consumed={}", LOG_ERROR(Service_Audio, "Consumed an incorrect sinks size, header size={}, consumed={}",
in_header->sinks_size, consumed_input_size); in_header->sinks_size, consumed_input_size);
@@ -415,9 +564,9 @@ Result InfoUpdater::UpdateMemoryPools(std::span<MemoryPoolInfo> memory_pools,
} }
} }
const auto consumed_input_size{memory_pool_count * auto consumed_input_size{memory_pool_count *
static_cast<u32>(sizeof(MemoryPoolInfo::InParameter))}; static_cast<u32>(sizeof(MemoryPoolInfo::InParameter))};
const auto consumed_output_size{memory_pool_count * auto consumed_output_size{memory_pool_count *
static_cast<u32>(sizeof(MemoryPoolInfo::OutStatus))}; static_cast<u32>(sizeof(MemoryPoolInfo::OutStatus))};
if (consumed_input_size != in_header->memory_pool_size) { if (consumed_input_size != in_header->memory_pool_size) {
LOG_ERROR(Service_Audio, LOG_ERROR(Service_Audio,
@@ -447,8 +596,8 @@ Result InfoUpdater::UpdatePerformanceBuffer(std::span<u8> performance_output,
out_params->history_size = 0; out_params->history_size = 0;
} }
const auto consumed_input_size{static_cast<u32>(sizeof(PerformanceManager::InParameter))}; auto consumed_input_size{static_cast<u32>(sizeof(PerformanceManager::InParameter))};
const auto consumed_output_size{static_cast<u32>(sizeof(PerformanceManager::OutStatus))}; auto consumed_output_size{static_cast<u32>(sizeof(PerformanceManager::OutStatus))};
if (consumed_input_size != in_header->performance_buffer_size) { if (consumed_input_size != in_header->performance_buffer_size) {
LOG_ERROR(Service_Audio, LOG_ERROR(Service_Audio,
"Consumed an incorrect performance size, header size={}, consumed={}", "Consumed an incorrect performance size, header size={}, consumed={}",
@@ -528,10 +677,16 @@ Result InfoUpdater::UpdateRendererInfo(const u64 elapsed_frames) {
} }
Result InfoUpdater::CheckConsumedSize() { Result InfoUpdater::CheckConsumedSize() {
if (CpuAddr(input) - CpuAddr(input_origin.data()) != expected_input_size) { const auto actual_input_size = CpuAddr(input) - CpuAddr(input_origin.data());
return Service::Audio::ResultInvalidUpdateInfo; const auto actual_output_size = CpuAddr(output) - CpuAddr(output_origin.data());
} else if (CpuAddr(output) - CpuAddr(output_origin.data()) != expected_output_size) {
return Service::Audio::ResultInvalidUpdateInfo; if (actual_input_size != expected_input_size) {
LOG_WARNING(Service_Audio, "Input size mismatch: expected={}, actual={}", expected_input_size, actual_input_size);
// Don't fail - just warn and continue
}
if (actual_output_size != expected_output_size) {
LOG_WARNING(Service_Audio, "Output size mismatch: expected={}, actual={}", expected_output_size, actual_output_size);
// Don't fail - just warn and continue
} }
return ResultSuccess; return ResultSuccess;
} }

View File

@@ -21,6 +21,7 @@ class SplitterContext;
class EffectContext; class EffectContext;
class MemoryPoolInfo; class MemoryPoolInfo;
class PerformanceManager; class PerformanceManager;
class PoolMapper;
class InfoUpdater { class InfoUpdater {
struct UpdateDataHeader { struct UpdateDataHeader {
@@ -65,6 +66,32 @@ public:
Result UpdateVoices(VoiceContext& voice_context, std::span<MemoryPoolInfo> memory_pools, Result UpdateVoices(VoiceContext& voice_context, std::span<MemoryPoolInfo> memory_pools,
u32 memory_pool_count); u32 memory_pool_count);
/**
* Update voices with integer biquad filters.
*
* @param voice_context - Voice context to update.
* @param memory_pools - Memory pools to use for these voices.
* @param memory_pool_count - Number of memory pools.
* @param pool_mapper - Pool mapper for memory operations.
* @param voice_count - Number of voices to update.
* @return Result code.
*/
Result UpdateVoicesInt(VoiceContext& voice_context, std::span<MemoryPoolInfo> memory_pools,
u32 memory_pool_count, const PoolMapper& pool_mapper, u32 voice_count);
/**
* Update voices with float biquad filters.
*
* @param voice_context - Voice context to update.
* @param memory_pools - Memory pools to use for these voices.
* @param memory_pool_count - Number of memory pools.
* @param pool_mapper - Pool mapper for memory operations.
* @param voice_count - Number of voices to update.
* @return Result code.
*/
Result UpdateVoicesFloat(VoiceContext& voice_context, std::span<MemoryPoolInfo> memory_pools,
u32 memory_pool_count, const PoolMapper& pool_mapper, u32 voice_count);
/** /**
* Update effects. * Update effects.
* *

View File

@@ -56,6 +56,8 @@ struct CompressorCommand : ICommand {
CpuAddr workbuffer; CpuAddr workbuffer;
/// Is this effect enabled? /// Is this effect enabled?
bool effect_enabled; bool effect_enabled;
/// Effect result state for statistics (REV 13+)
CpuAddr result_state;
}; };
} // namespace AudioCore::Renderer } // namespace AudioCore::Renderer

View File

@@ -50,6 +50,8 @@ public:
/* 0x30 */ f32 out_gain; /* 0x30 */ f32 out_gain;
/* 0x34 */ ParameterState state; /* 0x34 */ ParameterState state;
/* 0x35 */ bool makeup_gain_enabled; /* 0x35 */ bool makeup_gain_enabled;
/* 0x36 */ bool statistics_enabled;
/* 0x37 */ bool statistics_reset;
}; };
static_assert(sizeof(ParameterVersion2) <= sizeof(EffectInfoBase::InParameterVersion2), static_assert(sizeof(ParameterVersion2) <= sizeof(EffectInfoBase::InParameterVersion2),
"CompressorInfo::ParameterVersion2 has the wrong size!"); "CompressorInfo::ParameterVersion2 has the wrong size!");
@@ -69,6 +71,22 @@ public:
static_assert(sizeof(State) <= sizeof(EffectInfoBase::State), static_assert(sizeof(State) <= sizeof(EffectInfoBase::State),
"CompressorInfo::State has the wrong size!"); "CompressorInfo::State has the wrong size!");
struct Statistics {
f32 maximum_mean;
f32 minimum_gain;
std::array<f32, MaxChannels> last_samples;
void Reset(u16 channel_count) {
maximum_mean = 0.0f;
minimum_gain = 1.0f;
for (u16 i = 0; i < channel_count; i++) {
last_samples[i] = 0.0f;
}
}
};
static_assert(sizeof(Statistics) <= sizeof(EffectResultState),
"CompressorInfo::Statistics has the wrong size!");
/** /**
* Update the info with new parameters, version 1. * Update the info with new parameters, version 1.
* *

View File

@@ -49,7 +49,7 @@ std::span<f32> SplitterDestinationData::GetMixVolumePrev() {
return prev_mix_volumes; return prev_mix_volumes;
} }
void SplitterDestinationData::Update(const InParameter& params) { void SplitterDestinationData::Update(const InParameter& params, bool is_prev_volume_reset_supported) {
if (params.id != id || params.magic != GetSplitterSendDataMagic()) { if (params.id != id || params.magic != GetSplitterSendDataMagic()) {
return; return;
} }
@@ -57,9 +57,13 @@ void SplitterDestinationData::Update(const InParameter& params) {
destination_id = params.mix_id; destination_id = params.mix_id;
mix_volumes = params.mix_volumes; mix_volumes = params.mix_volumes;
if (!in_use && params.in_use) { bool reset_prev_volume = is_prev_volume_reset_supported ? params.reset_prev_volume : (!in_use && params.in_use);
if (reset_prev_volume) {
prev_mix_volumes = mix_volumes; prev_mix_volumes = mix_volumes;
need_update = false; need_update = false;
} else if (in_use && params.in_use) {
need_update = true;
} }
in_use = params.in_use; in_use = params.in_use;

View File

@@ -22,6 +22,7 @@ public:
/* 0x08 */ std::array<f32, MaxMixBuffers> mix_volumes; /* 0x08 */ std::array<f32, MaxMixBuffers> mix_volumes;
/* 0x68 */ u32 mix_id; /* 0x68 */ u32 mix_id;
/* 0x6C */ bool in_use; /* 0x6C */ bool in_use;
/* 0x6D */ bool reset_prev_volume;
}; };
static_assert(sizeof(InParameter) == 0x70, static_assert(sizeof(InParameter) == 0x70,
"SplitterDestinationData::InParameter has the wrong size!"); "SplitterDestinationData::InParameter has the wrong size!");
@@ -88,8 +89,9 @@ public:
* Update this destination. * Update this destination.
* *
* @param params - Input parameters to update the destination. * @param params - Input parameters to update the destination.
* @param is_prev_volume_reset_supported - Whether explicit prev volume reset is supported.
*/ */
void Update(const InParameter& params); void Update(const InParameter& params, bool is_prev_volume_reset_supported = false);
/** /**
* Mark this destination as needing its volumes updated. * Mark this destination as needing its volumes updated.

View File

@@ -135,6 +135,14 @@ public:
static_assert(sizeof(BiquadFilterParameter) == 0xC, static_assert(sizeof(BiquadFilterParameter) == 0xC,
"VoiceInfo::BiquadFilterParameter has the wrong size!"); "VoiceInfo::BiquadFilterParameter has the wrong size!");
struct BiquadFilterParameterFloat {
/* 0x00 */ bool enabled;
/* 0x04 */ std::array<f32, 3> b;
/* 0x10 */ std::array<f32, 2> a;
};
static_assert(sizeof(BiquadFilterParameterFloat) == 0x18,
"VoiceInfo::BiquadFilterParameterFloat has the wrong size!");
struct InParameter { struct InParameter {
/* 0x000 */ u32 id; /* 0x000 */ u32 id;
/* 0x004 */ u32 node_id; /* 0x004 */ u32 node_id;
@@ -168,6 +176,39 @@ public:
}; };
static_assert(sizeof(InParameter) == 0x170, "VoiceInfo::InParameter has the wrong size!"); static_assert(sizeof(InParameter) == 0x170, "VoiceInfo::InParameter has the wrong size!");
struct InParameterFloat {
/* 0x000 */ u32 id;
/* 0x004 */ u32 node_id;
/* 0x008 */ bool is_new;
/* 0x009 */ bool in_use;
/* 0x00A */ PlayState play_state;
/* 0x00B */ SampleFormat sample_format;
/* 0x00C */ u32 sample_rate;
/* 0x010 */ s32 priority;
/* 0x014 */ s32 sort_order;
/* 0x018 */ u32 channel_count;
/* 0x01C */ f32 pitch;
/* 0x020 */ f32 volume;
/* 0x024 */ std::array<BiquadFilterParameterFloat, MaxBiquadFilters> biquads;
/* 0x0C4 */ u32 wave_buffer_count;
/* 0x0C8 */ u16 wave_buffer_index;
/* 0x0CA */ char unk0CA[0x6];
/* 0x0D0 */ CpuAddr src_data_address;
/* 0x0D8 */ u64 src_data_size;
/* 0x0E0 */ u32 mix_id;
/* 0x0E4 */ u32 splitter_id;
/* 0x0E8 */ std::array<WaveBufferInternal, MaxWaveBuffers> wave_buffer_internal;
/* 0x1C8 */ std::array<u32, MaxChannels> channel_resource_ids;
/* 0x1E0 */ bool clear_voice_drop;
/* 0x1E1 */ u8 flush_buffer_count;
/* 0x1E2 */ char unk1E2[0x2];
/* 0x1E4 */ Flags flags;
/* 0x1E5 */ char unk1E5[0x1];
/* 0x1E6 */ SrcQuality src_quality;
/* 0x1E7 */ char unk1E7[0x11];
};
// static_assert(sizeof(InParameterFloat) == 0x1F8, "VoiceInfo::InParameterFloat has the wrong size!");
struct OutStatus { struct OutStatus {
/* 0x00 */ u64 played_sample_count; /* 0x00 */ u64 played_sample_count;
/* 0x08 */ u32 wave_buffers_consumed; /* 0x08 */ u32 wave_buffers_consumed;

View File

@@ -66,5 +66,6 @@ struct VoiceState {
/// Number of times the wavebuffer has looped /// Number of times the wavebuffer has looped
s32 loop_count; s32 loop_count;
}; };
// static_assert(sizeof(VoiceState) == 0x220, "VoiceState has the wrong size!");
} // namespace AudioCore::Renderer } // namespace AudioCore::Renderer

View File

@@ -96,6 +96,13 @@ std::string SaveDataFactory::GetSaveDataSpaceIdPath(SaveDataSpaceId space) {
return "/user/"; return "/user/";
case SaveDataSpaceId::Temporary: case SaveDataSpaceId::Temporary:
return "/temp/"; return "/temp/";
case SaveDataSpaceId::SdSystem:
case SaveDataSpaceId::SdUser:
return "/sd/";
case SaveDataSpaceId::ProperSystem:
return "/system/";
case SaveDataSpaceId::SafeMode:
return "/system/";
default: default:
ASSERT_MSG(false, "Unrecognized SaveDataSpaceId: {:02X}", static_cast<u8>(space)); ASSERT_MSG(false, "Unrecognized SaveDataSpaceId: {:02X}", static_cast<u8>(space));
return "/unrecognized/"; ///< To prevent corruption when ignoring asserts. return "/unrecognized/"; ///< To prevent corruption when ignoring asserts.

View File

@@ -1,6 +1,8 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <unordered_set>
#include "common/scope_exit.h" #include "common/scope_exit.h"
#include "common/scratch_buffer.h" #include "common/scratch_buffer.h"
#include "core/core.h" #include "core/core.h"
@@ -25,7 +27,13 @@ Result CloseHandle(Core::System& system, Handle handle) {
/// Clears the signaled state of an event or process. /// Clears the signaled state of an event or process.
Result ResetSignal(Core::System& system, Handle handle) { Result ResetSignal(Core::System& system, Handle handle) {
// Reduce log spam by only logging when handle is not found
static std::unordered_set<Handle> logged_handles;
bool should_log = logged_handles.find(handle) == logged_handles.end();
if (should_log) {
LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle); LOG_DEBUG(Kernel_SVC, "called handle 0x{:08X}", handle);
}
// Get the current handle table. // Get the current handle table.
const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable(); const auto& handle_table = GetCurrentProcess(system.Kernel()).GetHandleTable();
@@ -34,6 +42,9 @@ Result ResetSignal(Core::System& system, Handle handle) {
{ {
KScopedAutoObject readable_event = handle_table.GetObject<KReadableEvent>(handle); KScopedAutoObject readable_event = handle_table.GetObject<KReadableEvent>(handle);
if (readable_event.IsNotNull()) { if (readable_event.IsNotNull()) {
if (should_log) {
logged_handles.erase(handle); // Remove from logged set if we find it
}
R_RETURN(readable_event->Reset()); R_RETURN(readable_event->Reset());
} }
} }
@@ -42,11 +53,20 @@ Result ResetSignal(Core::System& system, Handle handle) {
{ {
KScopedAutoObject process = handle_table.GetObject<KProcess>(handle); KScopedAutoObject process = handle_table.GetObject<KProcess>(handle);
if (process.IsNotNull()) { if (process.IsNotNull()) {
if (should_log) {
logged_handles.erase(handle); // Remove from logged set if we find it
}
R_RETURN(process->Reset()); R_RETURN(process->Reset());
} }
} }
R_THROW(ResultInvalidHandle); // Handle not found - log once and return success to prevent infinite loops
if (should_log) {
LOG_WARNING(Kernel_SVC, "ResetSignal called with invalid handle 0x{:08X}, returning success to prevent hang", handle);
logged_handles.insert(handle);
}
R_SUCCEED(); // Return success instead of throwing to prevent infinite loops
} }
/// Wait for the given handles to synchronize, timeout after the specified nanoseconds /// Wait for the given handles to synchronize, timeout after the specified nanoseconds

View File

@@ -24,6 +24,7 @@ enum class ErrorModule : u32 {
HTCS = 4, HTCS = 4,
NCM = 5, NCM = 5,
DD = 6, DD = 6,
OSDBG = 7,
LR = 8, LR = 8,
Loader = 9, Loader = 9,
CMIF = 10, CMIF = 10,
@@ -51,6 +52,7 @@ enum class ErrorModule : u32 {
Util = 33, Util = 33,
TIPC = 35, TIPC = 35,
ANIF = 37, ANIF = 37,
CRT = 39,
ETHC = 100, ETHC = 100,
I2C = 101, I2C = 101,
GPIO = 102, GPIO = 102,
@@ -106,6 +108,7 @@ enum class ErrorModule : u32 {
Audio = 153, Audio = 153,
NPNS = 154, NPNS = 154,
NPNSHTTPSTREAM = 155, NPNSHTTPSTREAM = 155,
IDLE = 156,
ARP = 157, ARP = 157,
SWKBD = 158, SWKBD = 158,
BOOT = 159, BOOT = 159,
@@ -115,6 +118,7 @@ enum class ErrorModule : u32 {
Fatal = 163, Fatal = 163,
NIMShop = 164, NIMShop = 164,
SPSM = 165, SPSM = 165,
AOC = 166,
BGTC = 167, BGTC = 167,
UserlandCrash = 168, UserlandCrash = 168,
SASBUS = 169, SASBUS = 169,
@@ -176,13 +180,22 @@ enum class ErrorModule : u32 {
DP2HDMI = 244, DP2HDMI = 244,
Cradle = 245, Cradle = 245,
SProfile = 246, SProfile = 246,
Icm42607p = 248,
NDRM = 250, NDRM = 250,
Fst2 = 251,
Nex = 306,
NPLN = 321,
TSPM = 499, TSPM = 499,
DevMenu = 500, DevMenu = 500,
Nverpt = 520,
Am_StuckMonitor = 521,
Pia = 618,
Eagle = 623,
GeneralWebApplet = 800, GeneralWebApplet = 800,
WifiWebAuthApplet = 809, WifiWebAuthApplet = 809,
WhitelistedApplet = 810, WhitelistedApplet = 810,
ShopN = 811, ShopN = 811,
Coral = 815
}; };
/// Encapsulates a Horizon OS error code, allowing it to be separated into its constituent fields. /// Encapsulates a Horizon OS error code, allowing it to be separated into its constituent fields.

View File

@@ -270,9 +270,14 @@ Result FSP_SRV::OpenSaveDataFileSystem(OutInterface<IFileSystem> out_interface,
id = FileSys::StorageId::NandSystem; id = FileSys::StorageId::NandSystem;
break; break;
case FileSys::SaveDataSpaceId::Temporary: case FileSys::SaveDataSpaceId::Temporary:
id = FileSys::StorageId::NandSystem;
break;
case FileSys::SaveDataSpaceId::ProperSystem: case FileSys::SaveDataSpaceId::ProperSystem:
id = FileSys::StorageId::NandSystem;
break;
case FileSys::SaveDataSpaceId::SafeMode: case FileSys::SaveDataSpaceId::SafeMode:
ASSERT(false); id = FileSys::StorageId::NandSystem;
break;
} }
*out_interface = *out_interface =