Release the dispatch queue when cubeb context is destroyed

The dispatch queue created within the cubeb context should be released when it's no longer needed, or the allocated memory of the queue will be leaked if it's not deallocated. The memory of the dispatch queue is allocated when the cubeb context is created, so the memory should be deallocated when the cubeb context is destroyed.
This commit is contained in:
Chun-Min Chang 2019-03-07 17:02:40 -08:00 коммит произвёл Paul Adenot
Родитель 6f2420de8f
Коммит b0140a50bf
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -139,7 +139,7 @@ struct cubeb {
// Store list of devices to detect changes
vector<AudioObjectID> input_device_array;
vector<AudioObjectID> output_device_array;
// The queue is asynchronously deallocated once all references to it are released
// The queue should be released when its no longer needed.
dispatch_queue_t serial_queue = dispatch_queue_create(DISPATCH_QUEUE_LABEL, DISPATCH_QUEUE_SERIAL);
// Current used channel layout
atomic<cubeb_channel_layout> layout{ CUBEB_LAYOUT_UNDEFINED };
@ -1432,6 +1432,8 @@ audiounit_destroy(cubeb * ctx)
}
}
dispatch_release(ctx->serial_queue);
delete ctx;
}