Skip to content

Commit

Permalink
audiounit: advance active stream counter earlier in stream init (mozi…
Browse files Browse the repository at this point in the history
  • Loading branch information
achronop authored and padenot committed Oct 19, 2017
1 parent ee7c747 commit c2bd582
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/cubeb_audiounit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2498,7 +2498,9 @@ audiounit_stream_init(cubeb * context,
cubeb_state_callback state_callback,
void * user_ptr)
{
std::unique_ptr<cubeb_stream, decltype(&audiounit_stream_destroy)> stm(nullptr, audiounit_stream_destroy);
std::unique_ptr<cubeb_stream, decltype(&audiounit_stream_destroy)> stm(new cubeb_stream(context),
audiounit_stream_destroy);
context->active_streams += 1;
int r;

assert(context);
Expand All @@ -2509,8 +2511,6 @@ audiounit_stream_init(cubeb * context,
return CUBEB_ERROR_INVALID_PARAMETER;
}

stm.reset(new cubeb_stream(context));

/* These could be different in the future if we have both
* full-duplex stream and different devices for input vs output. */
stm->data_callback = data_callback;
Expand Down Expand Up @@ -2539,7 +2539,6 @@ audiounit_stream_init(cubeb * context,
// It's not critical to lock here, because no other thread has been started
// yet, but it allows to assert that the lock has been taken in
// `audiounit_setup_stream`.
context->active_streams += 1;
auto_lock lock(stm->mutex);
r = audiounit_setup_stream(stm.get());
}
Expand Down

0 comments on commit c2bd582

Please sign in to comment.