summaryrefslogtreecommitdiff
path: root/extmod
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-06-14 18:47:40 -0400
committerDan Halbert <halbert@halwitz.org>2018-06-14 18:47:40 -0400
commite724bc1c4eb1224aa043a1489b29ec3daaa832aa (patch)
treeaa72de23055ef2fb3eae33d11e1fc5536a5eb05c /extmod
parent618943d90a958d36d9b0e2206552100069b10ddb (diff)
Fix playing audio from SD card
Diffstat (limited to 'extmod')
-rw-r--r--extmod/vfs_fat_diskio.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/extmod/vfs_fat_diskio.c b/extmod/vfs_fat_diskio.c
index 3b9d86037..43c390a11 100644
--- a/extmod/vfs_fat_diskio.c
+++ b/extmod/vfs_fat_diskio.c
@@ -131,8 +131,17 @@ DRESULT disk_read (
} else {
vfs->readblocks[2] = MP_OBJ_NEW_SMALL_INT(sector);
vfs->readblocks[3] = mp_obj_new_bytearray_by_ref(count * SECSIZE(&vfs->fatfs), buff);
- mp_call_method_n_kw(2, 0, vfs->readblocks);
- // TODO handle error return
+ nlr_buf_t nlr;
+ if (nlr_push(&nlr) == 0) {
+ mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->readblocks);
+ nlr_pop();
+ if (mp_obj_get_int(ret) != 0) {
+ return RES_ERROR;
+ }
+ } else {
+ // Exception thrown by readblocks or something it calls.
+ return RES_ERROR;
+ }
}
return RES_OK;
@@ -167,8 +176,17 @@ DRESULT disk_write (
} else {
vfs->writeblocks[2] = MP_OBJ_NEW_SMALL_INT(sector);
vfs->writeblocks[3] = mp_obj_new_bytearray_by_ref(count * SECSIZE(&vfs->fatfs), (void*)buff);
- mp_call_method_n_kw(2, 0, vfs->writeblocks);
- // TODO handle error return
+ nlr_buf_t nlr;
+ if (nlr_push(&nlr) == 0) {
+ mp_obj_t ret = mp_call_method_n_kw(2, 0, vfs->writeblocks);
+ nlr_pop();
+ if (mp_obj_get_int(ret) != 0) {
+ return RES_ERROR;
+ }
+ } else {
+ // Exception thrown by writeblocks or something it calls.
+ return RES_ERROR;
+ }
}
return RES_OK;