Skip to content

Commit

Permalink
fixed memory sharing between dlog view and ext. assets
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Nov 13, 2020
1 parent cfd070b commit 0d6bed2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/eez/gui/assets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,14 @@ bool loadExternalAssets(const char *filePath, int *err) {
return false;
}

if (fileSize > FILE_VIEW_BUFFER_SIZE) {
if (fileSize > EXTERNAL_ASSETS_BUFFER_SIZE) {
if (err) {
*err = SCPI_ERROR_OUT_OF_DEVICE_MEMORY;
}
return false;
}

uint8_t *fileData = FILE_VIEW_BUFFER + FILE_VIEW_BUFFER_SIZE - ((fileSize + 3) / 4) * 4;
uint8_t *fileData = EXTERNAL_ASSETS_BUFFER + EXTERNAL_ASSETS_BUFFER_SIZE - ((fileSize + 3) / 4) * 4;
uint32_t bytesRead = file.read(fileData, fileSize);
file.close();

Expand All @@ -289,14 +289,14 @@ bool loadExternalAssets(const char *filePath, int *err) {
// first 4 bytes (uint32_t) are decompressed size
uint32_t decompressedSize = ((uint32_t *)fileData)[0];

if (decompressedSize > (uint32_t)(fileData - FILE_VIEW_BUFFER)) {
if (decompressedSize > (uint32_t)(fileData - EXTERNAL_ASSETS_BUFFER)) {
if (err) {
*err = SCPI_ERROR_OUT_OF_DEVICE_MEMORY;
}
return false;
}

uint8_t *decompressedAssets = FILE_VIEW_BUFFER;
uint8_t *decompressedAssets = EXTERNAL_ASSETS_BUFFER;

int result = LZ4_decompress_safe((const char *)fileData + 4, (char *)decompressedAssets, compressedSize, (int)decompressedSize);
if (result != (int)decompressedSize) {
Expand Down
5 changes: 4 additions & 1 deletion src/eez/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ static const uint32_t FILE_VIEW_BUFFER_SIZE = 1024 * 1024;
static const uint32_t FILE_VIEW_BUFFER_SIZE = 3 * 512 * 1024;
#endif

static uint8_t * const MP_BUFFER = FILE_VIEW_BUFFER + FILE_VIEW_BUFFER_SIZE;
static uint8_t * const EXTERNAL_ASSETS_BUFFER = FILE_VIEW_BUFFER + FILE_VIEW_BUFFER_SIZE;
static const uint32_t EXTERNAL_ASSETS_BUFFER_SIZE = 256 * 1024;

static uint8_t * const MP_BUFFER = EXTERNAL_ASSETS_BUFFER + EXTERNAL_ASSETS_BUFFER_SIZE;
static const uint32_t MP_BUFFER_SIZE = 512 * 1024;

static uint8_t * const SOUND_TUNES_MEMORY = MP_BUFFER + MP_BUFFER_SIZE;
Expand Down

0 comments on commit 0d6bed2

Please sign in to comment.