Bug 1308418: [cubeb] P2. Remove redundant assertion. r?padenot draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 18 Oct 2016 16:48:46 +1100
changeset 426228 b3378ab03bd1e96499372e483d238e3dd2b14bee
parent 426227 67e81c8bfcc888415b3b5694d7eda862139c9fb9
child 534132 f656be19690a38f3e9e545bec0ed559d15def2a1
push id32659
push userbmo:jyavenard@mozilla.com
push dateTue, 18 Oct 2016 06:12:24 +0000
reviewerspadenot
bugs1308418
milestone52.0a1
Bug 1308418: [cubeb] P2. Remove redundant assertion. r?padenot new operator is infallibable. MozReview-Commit-ID: 3XuDQ22k07S
media/libcubeb/src/cubeb_audiounit.cpp
--- a/media/libcubeb/src/cubeb_audiounit.cpp
+++ b/media/libcubeb/src/cubeb_audiounit.cpp
@@ -468,17 +468,16 @@ extern "C" {
 int
 audiounit_init(cubeb ** context, char const * context_name)
 {
   cubeb * ctx;
 
   *context = NULL;
 
   ctx = new cubeb;
-  assert(ctx);
 
   ctx->ops = &audiounit_ops;
 
   ctx->active_streams = 0;
 
   ctx->limit_streams = kCFCoreFoundationVersionNumber < kCFCoreFoundationVersionNumber10_7;
 #if !TARGET_OS_IPHONE
   cubeb_set_coreaudio_notification_runloop();
@@ -1016,20 +1015,16 @@ audiounit_init_input_linear_buffer(cubeb
                               stream->input_desc.mChannelsPerFrame) );
   } else {
     stream->input_linear_buffer = new auto_array_wrapper(
         new auto_array<float>(capacity *
                               stream->input_buffer_frames *
                               stream->input_desc.mChannelsPerFrame) );
   }
 
-  if (!stream->input_linear_buffer) {
-    return CUBEB_ERROR;
-  }
-
   assert(stream->input_linear_buffer->length() == 0);
 
   // Pre-buffer silence if needed
   if (capacity != 1) {
     size_t silence_size = stream->input_buffer_frames *
                           stream->input_desc.mChannelsPerFrame;
     stream->input_linear_buffer->push_silence(silence_size);
 
@@ -1159,17 +1154,16 @@ audiounit_stream_init(cubeb * context,
                               output_device);
     if (r != CUBEB_OK) {
       LOG("AudioUnit creation for output failed.");
       return r;
     }
   }
 
   stm = new cubeb_stream;
-  assert(stm);
 
   /* These could be different in the future if we have both
    * full-duplex stream and different devices for input vs output. */
   stm->input_unit  = (input_stream_params != NULL) ? input_unit : NULL;
   stm->output_unit = (output_stream_params != NULL) ? output_unit : NULL;
   stm->context = context;
   stm->data_callback = data_callback;
   stm->state_callback = state_callback;
@@ -1677,35 +1671,29 @@ int audiounit_stream_get_current_device(
 
   *device = NULL;
 
   if (audiounit_get_output_device_id(&output_device_id) != CUBEB_OK) {
     return CUBEB_ERROR;
   }
 
   *device = new cubeb_device;
-  if (!*device) {
-    return CUBEB_ERROR;
-  }
   PodZero(*device, 1);
 
   size = sizeof(UInt32);
   /* This fails with some USB headset, so simply return an empty string. */
   r = AudioObjectGetPropertyData(output_device_id,
                                  &datasource_address,
                                  0, NULL, &size, &data);
   if (r != noErr) {
     size = 0;
     data = 0;
   }
 
   (*device)->output_name = new char[size + 1];
-  if (!(*device)->output_name) {
-    return CUBEB_ERROR;
-  }
 
   // Turn the four chars packed into a uint32 into a string
   strdata[0] = (char)(data >> 24);
   strdata[1] = (char)(data >> 16);
   strdata[2] = (char)(data >> 8);
   strdata[3] = (char)(data);
 
   memcpy((*device)->output_name, strdata, size);
@@ -1719,19 +1707,16 @@ int audiounit_stream_get_current_device(
   r = AudioObjectGetPropertyData(input_device_id, &datasource_address_input, 0, NULL, &size, &data);
   if (r != noErr) {
     LOG("Error when getting device !");
     size = 0;
     data = 0;
   }
 
   (*device)->input_name = new char[size + 1];
-  if (!(*device)->input_name) {
-    return CUBEB_ERROR;
-  }
 
   // Turn the four chars packed into a uint32 into a string
   strdata[0] = (char)(data >> 24);
   strdata[1] = (char)(data >> 16);
   strdata[2] = (char)(data >> 8);
   strdata[3] = (char)(data);
 
   memcpy((*device)->input_name, strdata, size);
@@ -2080,17 +2065,16 @@ audiounit_get_devices_of_type(cubeb_devi
     return 0;
   }
   /* Expected sorted but did not find anything in the docs. */
   qsort(devices, count, sizeof(AudioObjectID), compare_devid);
 
   if (devtype == (CUBEB_DEVICE_TYPE_INPUT | CUBEB_DEVICE_TYPE_OUTPUT)) {
     if (devid_array) {
       *devid_array = new AudioObjectID[count];
-      assert(*devid_array);
       memcpy(*devid_array, &devices, count * sizeof(AudioObjectID));
     }
     return count;
   }
 
   AudioObjectPropertyScope scope = (devtype == CUBEB_DEVICE_TYPE_INPUT) ?
                                          kAudioDevicePropertyScopeInput :
                                          kAudioDevicePropertyScopeOutput;