<feed xmlns='http://www.w3.org/2005/Atom'>
<title>dolphin/Source/Core/AudioCommon, branch release-prep-2512</title>
<subtitle>GameCube and Wii emulator</subtitle>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/'/>
<entry>
<title>CubebStream: Use WorkQueueThread::PushBlocking instead of sync_event</title>
<updated>2025-11-07T21:19:18+00:00</updated>
<author>
<name>Dentomologist</name>
<email>dentomologist@gmail.com</email>
</author>
<published>2025-11-06T19:38:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=3b97a7bded04912e97bd510209a52d859e08d006'/>
<id>3b97a7bded04912e97bd510209a52d859e08d006</id>
<content type='text'>
Push and wait on WorkQueueThread items using PushBlocking. Previously we
created a Common::Event sync_event on the caller's stack, called Wait on
it, then had the WorkQueueThread call Set on the sync_event once the
thread was done.

In addition to being simpler the new way avoids a use-after-free that
could happen in convoluted and unlikely yet possible thread scheduling
sequences.

One such case can be triggered as follows:

* Set your audio backend to Cubeb
* In CubebStream::SetVolume set a breakpoint at the call to Wait and at
  the call to cubeb_stream_set_volume.
* Start a game.
* Continue until the Cubeb Worker thread hits the
  cubeb_stream_set_volume breakpoint and Emuthread hits the Wait
  breakpoint, freezing each thread when it hits its breakpoint.
* Unfreeze Cubeb Worker.
* In Event::Set set a breakpoint at the end of the scope containing the
  lock_guard such that the guard has been constructed but not destructed
  when the breakpoint is hit.
* Continue until that breakpoint is hit by Cubeb Worker. If other
  threads hit it first keep going.
* Freeze Cubeb Worker.
* For convenience remove the breakpoint in Event::Set so other threads
  don't trigger it.
* In CubebStream::SetRunning set a breakpoint at the call to Wait.
* Unfreeze Emuthread and continue until the breakpoint is hit.
* In Cubeb Worker go to Event::Set and examine the values of m_mutex's
  member variables. In Visual Studio Debug these are locking_thread_id
  == 0xcccccc01 and ownership_levels == 0xcccccccc. This is the result
  of Visual Studio overwriting the memory used on the stack by
  sync_event in CubebStream::SetVolume with cc bytes to represent
  uninitialized memory on the stack (since that function already
  returned), and then allocating enough memory on the stack when calling
  AudioCommon::SetSoundStreamRunning and then CubebStream::SetRunning
  that it overwrote one byte of the memory formerly occupied by
  locking_thread_id.
* If you unfreeze Cubeb Worker at this point it will trigger the lock
  guard's destructor which will then try to unlock m_mutex. Since
  m_mutex is no longer in scope this is a use-after-free, and in VS
  debug triggers a debug assert due to locking_thread_id not matching
  the current thread id.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Push and wait on WorkQueueThread items using PushBlocking. Previously we
created a Common::Event sync_event on the caller's stack, called Wait on
it, then had the WorkQueueThread call Set on the sync_event once the
thread was done.

In addition to being simpler the new way avoids a use-after-free that
could happen in convoluted and unlikely yet possible thread scheduling
sequences.

One such case can be triggered as follows:

* Set your audio backend to Cubeb
* In CubebStream::SetVolume set a breakpoint at the call to Wait and at
  the call to cubeb_stream_set_volume.
* Start a game.
* Continue until the Cubeb Worker thread hits the
  cubeb_stream_set_volume breakpoint and Emuthread hits the Wait
  breakpoint, freezing each thread when it hits its breakpoint.
* Unfreeze Cubeb Worker.
* In Event::Set set a breakpoint at the end of the scope containing the
  lock_guard such that the guard has been constructed but not destructed
  when the breakpoint is hit.
* Continue until that breakpoint is hit by Cubeb Worker. If other
  threads hit it first keep going.
* Freeze Cubeb Worker.
* For convenience remove the breakpoint in Event::Set so other threads
  don't trigger it.
* In CubebStream::SetRunning set a breakpoint at the call to Wait.
* Unfreeze Emuthread and continue until the breakpoint is hit.
* In Cubeb Worker go to Event::Set and examine the values of m_mutex's
  member variables. In Visual Studio Debug these are locking_thread_id
  == 0xcccccc01 and ownership_levels == 0xcccccccc. This is the result
  of Visual Studio overwriting the memory used on the stack by
  sync_event in CubebStream::SetVolume with cc bytes to represent
  uninitialized memory on the stack (since that function already
  returned), and then allocating enough memory on the stack when calling
  AudioCommon::SetSoundStreamRunning and then CubebStream::SetRunning
  that it overwrote one byte of the memory formerly occupied by
  locking_thread_id.
* If you unfreeze Cubeb Worker at this point it will trigger the lock
  guard's destructor which will then try to unlock m_mutex. Since
  m_mutex is no longer in scope this is a use-after-free, and in VS
  debug triggers a debug assert due to locking_thread_id not matching
  the current thread id.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #13725 from Sam-Belliveau/more-consistent-looping</title>
<updated>2025-08-06T00:02:58+00:00</updated>
<author>
<name>JMC47</name>
<email>JMC4789@gmail.com</email>
</author>
<published>2025-08-06T00:02:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=3111a785a106e4d184d9c3037e1df9a35ce06d31'/>
<id>3111a785a106e4d184d9c3037e1df9a35ce06d31</id>
<content type='text'>
Fade audio after an entire loop</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fade audio after an entire loop</pre>
</div>
</content>
</entry>
<entry>
<title>AudioCommon/Mixer: Skip sample processing when NullSoundStream is being used.</title>
<updated>2025-07-23T22:53:21+00:00</updated>
<author>
<name>Jordan Woyak</name>
<email>jordan.woyak@gmail.com</email>
</author>
<published>2025-07-22T14:11:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=ff0560574e50e384d33f2620d231461b9bd8662f'/>
<id>ff0560574e50e384d33f2620d231461b9bd8662f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>AudioCommon/Mixer:  make large array in Mixer::MixerFifo::Enqueue() static so that it's not created on the stack.</title>
<updated>2025-07-11T00:01:03+00:00</updated>
<author>
<name>ITotalJustice</name>
<email>47043333+ITotalJustice@users.noreply.github.com</email>
</author>
<published>2025-07-11T00:01:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=8d2a15be3f8f9e3f5bc1620cf11603b2a910bd56'/>
<id>8d2a15be3f8f9e3f5bc1620cf11603b2a910bd56</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>AudioCommon: Re-add missing includes</title>
<updated>2025-06-08T09:35:02+00:00</updated>
<author>
<name>JosJuice</name>
<email>josjuice@gmail.com</email>
</author>
<published>2025-06-08T09:35:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=1b7d42f77515e512d3e80890ce8a6bb5231e1dbf'/>
<id>1b7d42f77515e512d3e80890ce8a6bb5231e1dbf</id>
<content type='text'>
7c237bb ("AudioCommon: Remove unused includes") removed some includes
that were in fact in use.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
7c237bb ("AudioCommon: Remove unused includes") removed some includes
that were in fact in use.
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #12836 from JosJuice/opensles-buffer-size</title>
<updated>2025-06-08T03:07:37+00:00</updated>
<author>
<name>JMC47</name>
<email>JMC4789@gmail.com</email>
</author>
<published>2025-06-08T03:07:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=24b0bf01d54cf15977e7e2f4d2b529bb8230b060'/>
<id>24b0bf01d54cf15977e7e2f4d2b529bb8230b060</id>
<content type='text'>
Android: Ask system for optimal audio buffer size and sample rate</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Android: Ask system for optimal audio buffer size and sample rate</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #13727 from JoshuaVandaele/fmt-11.2.0-localtime-deprec</title>
<updated>2025-06-08T03:04:37+00:00</updated>
<author>
<name>Tilka</name>
<email>tilkax@gmail.com</email>
</author>
<published>2025-06-08T03:04:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=19fbbf0dba32ad98fe791804cfd464ced91464f5'/>
<id>19fbbf0dba32ad98fe791804cfd464ced91464f5</id>
<content type='text'>
fmt: Replace deprecated `fmt::localtime` usage with `Common::LocalTime`</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
fmt: Replace deprecated `fmt::localtime` usage with `Common::LocalTime`</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #13522 from tygyh/Enforce-overriding-destructor-style-Core&amp;UnitTests</title>
<updated>2025-06-07T22:55:14+00:00</updated>
<author>
<name>Jordan Woyak</name>
<email>jordan.woyak@gmail.com</email>
</author>
<published>2025-06-07T22:55:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=65f3ba70f5a88a25eeb7fef143b8e46093e30a7a'/>
<id>65f3ba70f5a88a25eeb7fef143b8e46093e30a7a</id>
<content type='text'>
Core &amp; UnitTests: Make overriding explicit and remove redundant virtual specifiers on overriding destructors</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Core &amp; UnitTests: Make overriding explicit and remove redundant virtual specifiers on overriding destructors</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #13697 from tygyh/AudioCommon/Remove-unused-includes</title>
<updated>2025-06-07T22:45:50+00:00</updated>
<author>
<name>Jordan Woyak</name>
<email>jordan.woyak@gmail.com</email>
</author>
<published>2025-06-07T22:45:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=056ece6f291735ea7709ee762261ad7e13024503'/>
<id>056ece6f291735ea7709ee762261ad7e13024503</id>
<content type='text'>
AudioCommon: Remove unused includes</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
AudioCommon: Remove unused includes</pre>
</div>
</content>
</entry>
<entry>
<title>Merge pull request #13698 from tygyh/AudioCommon/Remove-unused-qualifiers-and-make-variables-constant</title>
<updated>2025-06-07T22:45:33+00:00</updated>
<author>
<name>Jordan Woyak</name>
<email>jordan.woyak@gmail.com</email>
</author>
<published>2025-06-07T22:45:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=a07a2fe398146fa9acf2891818dc418dfbd7a357'/>
<id>a07a2fe398146fa9acf2891818dc418dfbd7a357</id>
<content type='text'>
AudioCommon: Remove unused qualifiers and make variables constant</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
AudioCommon: Remove unused qualifiers and make variables constant</pre>
</div>
</content>
</entry>
</feed>
