Skip to content

Commit c2bd582

Browse files
achronoppadenot
authored andcommitted
audiounit: advance active stream counter earlier in stream init (#367)
1 parent ee7c747 commit c2bd582

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/cubeb_audiounit.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2498,7 +2498,9 @@ audiounit_stream_init(cubeb * context,
24982498
cubeb_state_callback state_callback,
24992499
void * user_ptr)
25002500
{
2501-
std::unique_ptr<cubeb_stream, decltype(&audiounit_stream_destroy)> stm(nullptr, audiounit_stream_destroy);
2501+
std::unique_ptr<cubeb_stream, decltype(&audiounit_stream_destroy)> stm(new cubeb_stream(context),
2502+
audiounit_stream_destroy);
2503+
context->active_streams += 1;
25022504
int r;
25032505

25042506
assert(context);
@@ -2509,8 +2511,6 @@ audiounit_stream_init(cubeb * context,
25092511
return CUBEB_ERROR_INVALID_PARAMETER;
25102512
}
25112513

2512-
stm.reset(new cubeb_stream(context));
2513-
25142514
/* These could be different in the future if we have both
25152515
* full-duplex stream and different devices for input vs output. */
25162516
stm->data_callback = data_callback;
@@ -2539,7 +2539,6 @@ audiounit_stream_init(cubeb * context,
25392539
// It's not critical to lock here, because no other thread has been started
25402540
// yet, but it allows to assert that the lock has been taken in
25412541
// `audiounit_setup_stream`.
2542-
context->active_streams += 1;
25432542
auto_lock lock(stm->mutex);
25442543
r = audiounit_setup_stream(stm.get());
25452544
}

0 commit comments

Comments
 (0)