@@ -2498,7 +2498,9 @@ audiounit_stream_init(cubeb * context,
2498
2498
cubeb_state_callback state_callback,
2499
2499
void * user_ptr)
2500
2500
{
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 ;
2502
2504
int r;
2503
2505
2504
2506
assert (context);
@@ -2509,8 +2511,6 @@ audiounit_stream_init(cubeb * context,
2509
2511
return CUBEB_ERROR_INVALID_PARAMETER;
2510
2512
}
2511
2513
2512
- stm.reset (new cubeb_stream (context));
2513
-
2514
2514
/* These could be different in the future if we have both
2515
2515
* full-duplex stream and different devices for input vs output. */
2516
2516
stm->data_callback = data_callback;
@@ -2539,7 +2539,6 @@ audiounit_stream_init(cubeb * context,
2539
2539
// It's not critical to lock here, because no other thread has been started
2540
2540
// yet, but it allows to assert that the lock has been taken in
2541
2541
// `audiounit_setup_stream`.
2542
- context->active_streams += 1 ;
2543
2542
auto_lock lock (stm->mutex );
2544
2543
r = audiounit_setup_stream (stm.get ());
2545
2544
}
0 commit comments