Skip to content

Commit

Permalink
audiounit: Assigning AudioUnit to nullptr before passing it to audiou…
Browse files Browse the repository at this point in the history
…nit_create_unit (mozilla#259)

* Assigning AudioUnit to nullptr before passing it to audiounit_create_unit

* Assert passed AudioUnit is nullptr in audiounit_create_unit
  • Loading branch information
ChunMinChang authored and achronop committed Mar 23, 2017
1 parent 10dc786 commit 22704b9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/cubeb_audiounit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ audiounit_get_preferred_channel_layout(cubeb * ctx, cubeb_channel_layout * layou

// If there is no existed stream, then we create a default ouput unit and
// use it to get the current used channel layout.
AudioUnit output_unit;
AudioUnit output_unit = nullptr;
audiounit_create_unit(&output_unit, OUTPUT, 0);
*layout = audiounit_get_current_channel_layout(output_unit);
}
Expand Down Expand Up @@ -1823,11 +1823,10 @@ audiounit_create_unit(AudioUnit * unit, io_side side, AudioDeviceID device)
OSStatus rv;
int r;

if (*unit == nullptr) {
int r = audiounit_new_unit_instance(unit, side, device);
if (r != CUBEB_OK) {
return r;
}
assert(*unit == nullptr);
r = audiounit_new_unit_instance(unit, side, device);
if (r != CUBEB_OK) {
return r;
}
assert(*unit);

Expand Down

0 comments on commit 22704b9

Please sign in to comment.