<feed xmlns='http://www.w3.org/2005/Atom'>
<title>dolphin/Source/Core/AudioCommon/CubebStream.cpp, branch 2603</title>
<subtitle>GameCube and Wii emulator</subtitle>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/'/>
<entry>
<title>Remove unused imports</title>
<updated>2026-01-25T15:12:15+00:00</updated>
<author>
<name>Martino Fontana</name>
<email>tinozzo123@gmail.com</email>
</author>
<published>2026-01-23T20:30:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=a14c88ba67a51b0a563a5fc800cd089e82ffacaf'/>
<id>a14c88ba67a51b0a563a5fc800cd089e82ffacaf</id>
<content type='text'>
Yellow squiggly lines begone!
Done automatically on .cpp files through `run-clang-tidy`, with manual corrections to the mistakes.
If an import is directly used, but is technically unnecessary since it's recursively imported by something else, it is *not* removed.
The tool doesn't touch .h files, so I did some of them by hand while fixing errors due to old recursive imports.
Not everything is removed, but the cleanup should be substantial enough.
Because this done on Linux, code that isn't used on it is mostly untouched.
(Hopefully no open PR is depending on these imports...)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Yellow squiggly lines begone!
Done automatically on .cpp files through `run-clang-tidy`, with manual corrections to the mistakes.
If an import is directly used, but is technically unnecessary since it's recursively imported by something else, it is *not* removed.
The tool doesn't touch .h files, so I did some of them by hand while fixing errors due to old recursive imports.
Not everything is removed, but the cleanup should be substantial enough.
Because this done on Linux, code that isn't used on it is mostly untouched.
(Hopefully no open PR is depending on these imports...)
</pre>
</div>
</content>
</entry>
<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 #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>AudioCommon: Remove unused qualifiers and make variables constant</title>
<updated>2025-05-30T19:48:38+00:00</updated>
<author>
<name>Dr. Dystopia</name>
<email>jonis9898@hotmail.com</email>
</author>
<published>2025-05-22T09:28:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=a6b04f53e09810d4a9a1db37c23636889e54dfbe'/>
<id>a6b04f53e09810d4a9a1db37c23636889e54dfbe</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>AudioCommon: Remove unused includes</title>
<updated>2025-05-25T08:30:41+00:00</updated>
<author>
<name>Dr. Dystopia</name>
<email>jonis9898@hotmail.com</email>
</author>
<published>2025-05-22T09:16:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=7c237bbd7c5b120cdee35f98f3f165196277be10'/>
<id>7c237bbd7c5b120cdee35f98f3f165196277be10</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Core and AudioCommon: Use AsyncWorkThread.</title>
<updated>2025-05-02T03:55:23+00:00</updated>
<author>
<name>Jordan Woyak</name>
<email>jordan.woyak@gmail.com</email>
</author>
<published>2025-04-30T01:21:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=4e736d60db295c0700fa1391b473544a9cb5ed72'/>
<id>4e736d60db295c0700fa1391b473544a9cb5ed72</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>WorkQueueThread: provide name and function at same time</title>
<updated>2023-02-04T02:56:27+00:00</updated>
<author>
<name>Scott Mansell</name>
<email>phiren@gmail.com</email>
</author>
<published>2023-02-04T02:56:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=7c4fcc30a369763b9fd5f04964d275c707fb17c2'/>
<id>7c4fcc30a369763b9fd5f04964d275c707fb17c2</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Correctly call CoUninitialize() on Cubeb helper class destruction.</title>
<updated>2022-11-27T02:58:50+00:00</updated>
<author>
<name>Admiral H. Curtiss</name>
<email>pikachu025@gmail.com</email>
</author>
<published>2022-11-27T02:58:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=64bb9ae9a95b953879a8e581cef0e5dbb346704b'/>
<id>64bb9ae9a95b953879a8e581cef0e5dbb346704b</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Core: Use extra thread for Cubeb on Windows to not disturb the CoInitialize state of whatever thread happens to call a Cubeb function.</title>
<updated>2022-11-26T04:05:57+00:00</updated>
<author>
<name>Admiral H. Curtiss</name>
<email>pikachu025@gmail.com</email>
</author>
<published>2022-06-18T03:31:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=e085bf14f99c52eff514e2317af740869691ba82'/>
<id>e085bf14f99c52eff514e2317af740869691ba82</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Core: Abide by COM MTA requirement for cubeb on Windows. Partially based on https://github.com/dolphin-emu/dolphin/pull/8920#discussion_r459746604</title>
<updated>2022-11-26T04:05:56+00:00</updated>
<author>
<name>Admiral H. Curtiss</name>
<email>pikachu025@gmail.com</email>
</author>
<published>2022-06-17T22:39:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.dog6.net/dolphin/commit/?id=ca10e92ab92afeb4cb6d3ac935cf86767ab469eb'/>
<id>ca10e92ab92afeb4cb6d3ac935cf86767ab469eb</id>
<content type='text'>
Co-authored-by: Michael M &lt;mchtly@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Co-authored-by: Michael M &lt;mchtly@gmail.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
