Skip to content

Commit

Permalink
AudioCore/HLE/source: Partially implement last_buffer_id (#7397)
Browse files Browse the repository at this point in the history
* AudioCore/HLE/source: Partially implement last_buffer_id

shared_memory.h: fix typo

* tests\audio_core\hle\source.cpp: Add test cases to verify last_buffer_id
  • Loading branch information
SachinVin authored Feb 5, 2024
1 parent 106364e commit aa6a29d
Show file tree
Hide file tree
Showing 5 changed files with 388 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/audio_core/hle/shared_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ struct SourceStatus {
u16_le sync_count; ///< Is set by the DSP to the value of SourceConfiguration::sync_count
u32_dsp buffer_position; ///< Number of samples into the current buffer
u16_le current_buffer_id; ///< Updated when a buffer finishes playing
INSERT_PADDING_DSPWORDS(1);
u16_le last_buffer_id; ///< Updated when all buffers in the queue finish playing
};

Status status[num_sources];
Expand Down
7 changes: 5 additions & 2 deletions src/audio_core/hle/source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ void Source::GenerateFrame() {
if (state.current_buffer.empty() && !DequeueBuffer()) {
state.enabled = false;
state.buffer_update = true;
state.last_buffer_id = state.current_buffer_id;
state.current_buffer_id = 0;
return;
}
Expand Down Expand Up @@ -411,6 +412,7 @@ bool Source::DequeueBuffer() {
state.next_sample_number = state.current_sample_number;
state.current_buffer_physical_address = buf.physical_address;
state.current_buffer_id = buf.buffer_id;
state.last_buffer_id = 0;
state.buffer_update = buf.from_queue && !buf.has_played;

if (buf.is_looping) {
Expand All @@ -432,9 +434,10 @@ SourceStatus::Status Source::GetCurrentStatus() {
ret.is_enabled = state.enabled;
ret.current_buffer_id_dirty = state.buffer_update ? 1 : 0;
state.buffer_update = false;
ret.current_buffer_id = state.current_buffer_id;
ret.buffer_position = state.current_sample_number;
ret.sync_count = state.sync_count;
ret.buffer_position = state.current_sample_number;
ret.current_buffer_id = state.current_buffer_id;
ret.last_buffer_id = state.last_buffer_id;

return ret;
}
Expand Down
3 changes: 2 additions & 1 deletion src/audio_core/hle/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ class Source final {
// buffer_id state

bool buffer_update = false;
u32 current_buffer_id = 0;
u16 last_buffer_id = 0;
u16 current_buffer_id = 0;

// Decoding state

Expand Down
1 change: 1 addition & 0 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ add_executable(tests
core/memory/vm_manager.cpp
precompiled_headers.h
audio_core/hle/hle.cpp
audio_core/hle/source.cpp
audio_core/lle/lle.cpp
audio_core/audio_fixures.h
audio_core/decoder_tests.cpp
Expand Down
Loading

0 comments on commit aa6a29d

Please sign in to comment.