Skip to content

Commit

Permalink
Add proper exception handling and update README
Browse files Browse the repository at this point in the history
  • Loading branch information
bozbez committed Oct 31, 2021
1 parent 01f0551 commit 8a15f94
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Internally it uses [ActivateAudioInterfaceAsync](https://docs.microsoft.com/en-u

## Installation and Usage

1. Head over to the [Releases](https://github.com/bozbez/win-capture-audio/releases) page and download the latest installer (or zip if you are using a portable installation)
2. Run the setup wizard, selecting your OBS folder when asked (or extract the zip to the portable OBS root directory)
1. Head over to the [Releases](https://github.com/bozbez/win-capture-audio/releases/tag/v2.1.0-beta) page and download the latest installer (or zip if you are using a portable installation)
2. Run the setup wizard, selecting your root OBS folder (`obs-studio/`, _not_ `obs-studio/obs-plugins/`) when asked (or extract the zip to the portable OBS root directory)
3. Launch OBS and check out the newly available "Application Audio Output Capture" source

## Troubleshooting

- **Application Audio Output Capture source not showing up after install:** this means that either your OBS is out-of-date (check that it is at least 27.1.x) or you have installed the plugin to the wrong location. To re-install, first uninstall via "Add or remove programs" in the Windows settings, and then run the installer again. Make sure to select the top-level `obs-studio/` folder in (probably) `C:/Program Files/`.

- **Application Audio Output Capture source not picking up any audio:** this happens when your Windows is too old and does not have support for the API. Note that even if you have a more recent major version such as `20H2` you will still need the latest updates for the plugin to work. If you are on a very old version you might need more than one update for this to work, and the second update might not show up for a few days after the first update.
2 changes: 1 addition & 1 deletion data/locale/en-GB.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Window.Priority.Exe="Match title, otherwise find window of same executable"
Hotkey.Start="Capture foreground window"
Hotkey.Stop="Deactivate capture"

ExcludeProcessTree="Capture all audio EXCEPT the selected window"
ExcludeProcessTree="Capture all audio EXCEPT the selected window (if the window exists)"
17 changes: 14 additions & 3 deletions src/audio-capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <util/bmem.h>
#include <util/platform.h>

#include "wil/result_macros.h"
#include "window-helpers.h"
#include "audio-capture.h"
#include "obfuscate.h"
Expand Down Expand Up @@ -77,8 +78,13 @@ static inline bool process_is_alive(DWORD pid)

static void start_capture(audio_capture_context_t *ctx)
{
ctx->helper.emplace(ctx->source, ctx->process_id,
!ctx->exclude_process_tree);
try {
ctx->helper.emplace(ctx->source, ctx->process_id,
!ctx->exclude_process_tree);
} catch (wil::ResultException e) {
error("failed to create helper... update Windows?");
error("%s", e.what());
}

ctx->process = open_process(PROCESS_QUERY_INFORMATION | SYNCHRONIZE,
false, ctx->process_id);
Expand All @@ -89,7 +95,12 @@ static void start_capture(audio_capture_context_t *ctx)

static void stop_capture(audio_capture_context_t *ctx)
{
ctx->helper.reset();
try {
ctx->helper.reset();
} catch (wil::ResultException e) {
error("failed to destruct helper");
error("%s", e.what());
}
}

static void audio_capture_worker_recapture(audio_capture_context_t *ctx)
Expand Down

0 comments on commit 8a15f94

Please sign in to comment.