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

8153 stopping recording with bt as input causes freeze #8192

Conversation

IliasBergstromMuse
Copy link
Contributor

@IliasBergstromMuse IliasBergstromMuse commented Feb 10, 2025

Resolves: #8153

I reproduced the issue on MacOS Sonoma 14.7.3 - to occur it requires that both input and output are the same bluetooth device.

AU3Player::stop() went into an infinite loop, waiting for bool AudioIOBase::IsBusy() to return false - but it never does, because the AudioIOBase::mStreamToken flag is never set to 0.

The reason is what appears to be a race-condition: mPortStreamV19 is, by the time stop() is called, already NULL, and so the method returns - failing to also set mStreamToken to NULL. I address that by resetting mStreamToken at the point it returns. I cannot see that there would be any undesired side effects, and it fixes the problem.

For the changes made, I have written additional annotation in-line on the code ("Files changed" tab).

On my fix:

Importantly, in terms of program structure, I don't think setting the flag where I do is particularly good code. But I suppose you agree it's consistent with how the AudioIO class is structured currently, and, seeing as it's part of the legacy AU3 engine, I imagine it is set for deprecation.

If not, I would have argued for refactoring the logic to make it less error-prone, more readable, and with a more clearly defined "state machine".

On unit-test:

For the same reason, I have not unit-tested this change. I don't see any unit-tests for this entire class, where I would normally have made my addition.

Question to reviewers:

I have a preference to make small local "scout" cleanup changes in the files I touch, if I see obvious points, either with formatting, or C++ annotation. I've made a commit with such changes in this PR, to ask you, is that OK for Audacity? Some teams prefer to have such changes in separate PR's, others are fine with them being in the same PR, if the changes are separated by distinct commits, and the PR is still easy to read, as is the case here.

I could have made many more (formatting is very inconsistent, NULL is used instead of nullptr, etc), but this is legacy AU3 code so I won't spend the effort - not to mention it would have made this PR so messy that making a separate one would definitely have been required.

  • I signed CLA
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

@IliasBergstromMuse IliasBergstromMuse marked this pull request as draft February 10, 2025 09:48
@IliasBergstromMuse IliasBergstromMuse force-pushed the 8153-stopping-recording-with-bt-as-input-causes-freeze branch 2 times, most recently from 09a9edb to c95c09b Compare February 10, 2025 12:27
…ck would freeze, as the mStreamToken would not be reset when the mPortStreamV19 was found to have been deleted.
@IliasBergstromMuse IliasBergstromMuse force-pushed the 8153-stopping-recording-with-bt-as-input-causes-freeze branch from c95c09b to 191c899 Compare February 10, 2025 12:42
@IliasBergstromMuse IliasBergstromMuse marked this pull request as ready for review February 10, 2025 13:11
@IliasBergstromMuse IliasBergstromMuse self-assigned this Feb 10, 2025
@IliasBergstromMuse IliasBergstromMuse marked this pull request as draft February 10, 2025 13:52
@IliasBergstromMuse IliasBergstromMuse marked this pull request as ready for review February 10, 2025 15:38
@IliasBergstromMuse IliasBergstromMuse merged commit a5a8ee4 into master Feb 12, 2025
5 checks passed
@IliasBergstromMuse IliasBergstromMuse deleted the 8153-stopping-recording-with-bt-as-input-causes-freeze branch February 12, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stopping recording with Bluetooth headphones as the input device causes Audacity to freeze
3 participants