diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-06-14 18:57:24 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-14 18:57:24 -0700 |
| commit | 720042f96454ae347b2fe85baa36cde0cf5ce17e (patch) | |
| tree | 4fb938bfdff579e222c968faf0f6f84a95fedec6 /extmod | |
| parent | 618943d90a958d36d9b0e2206552100069b10ddb (diff) | |
| parent | fa814a32ce3a211bcec9b06ad488aa1dde1b669d (diff) | |
Merge pull request #930 from dhalbert/sd_card_audio_play
Fix playing audio from SD card
Diffstat (limited to 'extmod')
| -rw-r--r-- | extmod/vfs_fat_diskio.c | 26 |
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; |
