Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 40703105 authored by Ravi Kumar Alamanda's avatar Ravi Kumar Alamanda
Browse files

hal: Ensure all the mutexes are initialized

- Ensure all the mutex locks are initialized before using them,
  to avoid native crashes.

Change-Id: I7b6253f1d08a36a24d366d69004ce969d73c13e1
CRs-Fixed: 654375
parent 87f0102b
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -580,6 +580,11 @@ void audio_extn_usb_init(void *adev)
    usbmod->proxy_card = 0;
    usbmod->proxy_device_id = AFE_PROXY_PLAYBACK_DEVICE;
    usbmod->adev = (struct audio_device*)adev;

     pthread_mutex_init(&usbmod->usb_playback_lock,
                        (const pthread_mutexattr_t *) NULL);
     pthread_mutex_init(&usbmod->usb_record_lock,
                        (const pthread_mutexattr_t *) NULL);
}

void audio_extn_usb_deinit()
+4 −0
Original line number Diff line number Diff line
@@ -2530,6 +2530,8 @@ static int adev_open_input_stream(struct audio_hw_device *dev,

    in = (struct stream_in *)calloc(1, sizeof(struct stream_in));

    pthread_mutex_init(&in->lock, (const pthread_mutexattr_t *) NULL);

    in->stream.common.get_sample_rate = in_get_sample_rate;
    in->stream.common.set_sample_rate = in_set_sample_rate;
    in->stream.common.get_buffer_size = in_get_buffer_size;
@@ -2664,6 +2666,8 @@ static int adev_open(const hw_module_t *module, const char *name,

    adev = calloc(1, sizeof(struct audio_device));

    pthread_mutex_init(&adev->lock, (const pthread_mutexattr_t *) NULL);

    adev->device.common.tag = HARDWARE_DEVICE_TAG;
    adev->device.common.version = AUDIO_DEVICE_API_VERSION_2_0;
    adev->device.common.module = (struct hw_module_t *)module;