Fix race condition in lime_image_load, lime_audio_load
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
#include <hx/CFFI.h>
|
||||
#include <graphics/ImageBuffer.h>
|
||||
#include <utils/ByteArray.h>
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
@@ -155,6 +155,7 @@ namespace lime {
|
||||
|
||||
AudioBuffer audioBuffer;
|
||||
Resource resource;
|
||||
Bytes bytes;
|
||||
|
||||
if (val_is_string (data)) {
|
||||
|
||||
@@ -162,7 +163,7 @@ namespace lime {
|
||||
|
||||
} else {
|
||||
|
||||
Bytes bytes (data);
|
||||
bytes = Bytes (data);
|
||||
resource = Resource (&bytes);
|
||||
|
||||
}
|
||||
@@ -448,6 +449,7 @@ namespace lime {
|
||||
|
||||
#ifdef LIME_FREETYPE
|
||||
Resource resource;
|
||||
Bytes bytes;
|
||||
|
||||
if (val_is_string (data)) {
|
||||
|
||||
@@ -455,7 +457,7 @@ namespace lime {
|
||||
|
||||
} else {
|
||||
|
||||
Bytes bytes (data);
|
||||
bytes = Bytes (data);
|
||||
resource = Resource (&bytes);
|
||||
|
||||
}
|
||||
@@ -612,6 +614,7 @@ namespace lime {
|
||||
|
||||
ImageBuffer buffer;
|
||||
Resource resource;
|
||||
Bytes bytes;
|
||||
|
||||
if (val_is_string (data)) {
|
||||
|
||||
@@ -619,7 +622,7 @@ namespace lime {
|
||||
|
||||
} else {
|
||||
|
||||
Bytes bytes (data);
|
||||
bytes = Bytes (data);
|
||||
resource = Resource (&bytes);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
namespace lime {
|
||||
|
||||
|
||||
static int id_b;
|
||||
static int id_bitsPerSample;
|
||||
static int id_channels;
|
||||
static int id_data;
|
||||
static int id_length;
|
||||
static int id_sampleRate;
|
||||
static bool init = false;
|
||||
|
||||
@@ -32,18 +33,20 @@ namespace lime {
|
||||
|
||||
if (!init) {
|
||||
|
||||
id_b = val_id ("b");
|
||||
id_bitsPerSample = val_id ("bitsPerSample");
|
||||
id_channels = val_id ("channels");
|
||||
id_data = val_id ("data");
|
||||
id_length = val_id ("length");
|
||||
id_sampleRate = val_id ("sampleRate");
|
||||
init = true;
|
||||
|
||||
}
|
||||
|
||||
mValue = alloc_empty_object ();
|
||||
alloc_field (mValue, id_b, data ? val_field (data->Value (), id_b) : alloc_null ());
|
||||
alloc_field (mValue, id_bitsPerSample, alloc_int (bitsPerSample));
|
||||
alloc_field (mValue, id_channels, alloc_int (channels));
|
||||
alloc_field (mValue, id_data, data ? data->Value () : alloc_null ());
|
||||
alloc_field (mValue, id_length, data ? val_field (data->Value (), id_length) : alloc_null ());
|
||||
alloc_field (mValue, id_sampleRate, alloc_int (sampleRate));
|
||||
return mValue;
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
namespace lime {
|
||||
|
||||
|
||||
static int id_b;
|
||||
static int id_bitsPerPixel;
|
||||
static int id_buffer;
|
||||
static int id_data;
|
||||
static int id_format;
|
||||
static int id_height;
|
||||
static int id_length;
|
||||
static int id_premultiplied;
|
||||
static int id_transparent;
|
||||
static int id_width;
|
||||
@@ -32,13 +34,15 @@ namespace lime {
|
||||
|
||||
if (!init) {
|
||||
|
||||
id_b = val_id ("b");
|
||||
id_bitsPerPixel = val_id ("bitsPerPixel");
|
||||
id_transparent = val_id ("transparent");
|
||||
id_buffer = val_id ("buffer");
|
||||
id_data = val_id ("data");
|
||||
id_width = val_id ("width");
|
||||
id_height = val_id ("height");
|
||||
id_data = val_id ("data");
|
||||
id_format = val_id ("format");
|
||||
id_length = val_id ("length");
|
||||
id_premultiplied = val_id ("premultiplied");
|
||||
init = true;
|
||||
|
||||
@@ -116,13 +120,14 @@ namespace lime {
|
||||
|
||||
if (!init) {
|
||||
|
||||
id_b = val_id ("b");
|
||||
id_bitsPerPixel = val_id ("bitsPerPixel");
|
||||
id_transparent = val_id ("transparent");
|
||||
id_buffer = val_id ("buffer");
|
||||
id_width = val_id ("width");
|
||||
id_height = val_id ("height");
|
||||
id_data = val_id ("data");
|
||||
id_format = val_id ("format");
|
||||
id_length = val_id ("length");
|
||||
id_premultiplied = val_id ("premultiplied");
|
||||
init = true;
|
||||
|
||||
@@ -132,7 +137,8 @@ namespace lime {
|
||||
alloc_field (mValue, id_width, alloc_int (width));
|
||||
alloc_field (mValue, id_height, alloc_int (height));
|
||||
alloc_field (mValue, id_bitsPerPixel, alloc_int (bitsPerPixel));
|
||||
alloc_field (mValue, id_data, data ? data->Value () : alloc_null ());
|
||||
alloc_field (mValue, id_b, data ? val_field (data->Value (), id_b) : alloc_null ());
|
||||
alloc_field (mValue, id_length, data ? val_field (data->Value (), id_length) : alloc_null ());
|
||||
alloc_field (mValue, id_transparent, alloc_bool (transparent));
|
||||
alloc_field (mValue, id_format, alloc_int (format));
|
||||
alloc_field (mValue, id_premultiplied, alloc_bool (premultiplied));
|
||||
|
||||
Reference in New Issue
Block a user