diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/audio/player.c | 7 | ||||
-rw-r--r-- | src/audio/player.h | 1 | ||||
-rw-r--r-- | src/media.c | 25 |
3 files changed, 31 insertions, 2 deletions
diff --git a/src/audio/player.c b/src/audio/player.c index 9e026561..a2a3955b 100644 --- a/src/audio/player.c +++ b/src/audio/player.c | |||
@@ -724,6 +724,13 @@ void updateSourceData_Player(iPlayer *d, const iString *mimeType, const iBlock * | |||
724 | unlock_Mutex(&input->mtx); | 724 | unlock_Mutex(&input->mtx); |
725 | } | 725 | } |
726 | 726 | ||
727 | size_t sourceDataSize_Player(const iPlayer *d) { | ||
728 | lock_Mutex(&d->data->mtx); | ||
729 | const size_t size = size_Block(&d->data->data); | ||
730 | unlock_Mutex(&d->data->mtx); | ||
731 | return size; | ||
732 | } | ||
733 | |||
727 | iBool start_Player(iPlayer *d) { | 734 | iBool start_Player(iPlayer *d) { |
728 | if (isStarted_Player(d)) { | 735 | if (isStarted_Player(d)) { |
729 | return iFalse; | 736 | return iFalse; |
diff --git a/src/audio/player.h b/src/audio/player.h index 8753d811..b131838d 100644 --- a/src/audio/player.h +++ b/src/audio/player.h | |||
@@ -48,6 +48,7 @@ enum iPlayerTag { | |||
48 | 48 | ||
49 | void updateSourceData_Player (iPlayer *, const iString *mimeType, const iBlock *data, | 49 | void updateSourceData_Player (iPlayer *, const iString *mimeType, const iBlock *data, |
50 | enum iPlayerUpdate update); | 50 | enum iPlayerUpdate update); |
51 | size_t sourceDataSize_Player (const iPlayer *); | ||
51 | 52 | ||
52 | iBool start_Player (iPlayer *); | 53 | iBool start_Player (iPlayer *); |
53 | void stop_Player (iPlayer *); | 54 | void stop_Player (iPlayer *); |
diff --git a/src/media.c b/src/media.c index 180c28e6..eb4a8311 100644 --- a/src/media.c +++ b/src/media.c | |||
@@ -24,6 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
24 | #include "gmdocument.h" | 24 | #include "gmdocument.h" |
25 | #include "gmrequest.h" | 25 | #include "gmrequest.h" |
26 | #include "ui/window.h" | 26 | #include "ui/window.h" |
27 | #include "ui/paint.h" /* size_SDLTexture */ | ||
27 | #include "audio/player.h" | 28 | #include "audio/player.h" |
28 | #include "app.h" | 29 | #include "app.h" |
29 | #include "stb_image.h" | 30 | #include "stb_image.h" |
@@ -262,8 +263,28 @@ void clear_Media(iMedia *d) { | |||
262 | } | 263 | } |
263 | 264 | ||
264 | size_t memorySize_Media(const iMedia *d) { | 265 | size_t memorySize_Media(const iMedia *d) { |
265 | /* TODO: Calculate the actual memory use. */ | 266 | size_t memSize = 0; |
266 | return 0; | 267 | iConstForEach(PtrArray, i, &d->images) { |
268 | const iGmImage *img = i.ptr; | ||
269 | if (img->texture) { | ||
270 | const iInt2 texSize = size_SDLTexture(img->texture); | ||
271 | memSize += 4 * texSize.x * texSize.y; /* RGBA */ | ||
272 | } | ||
273 | else { | ||
274 | memSize += size_Block(&img->partialData); | ||
275 | } | ||
276 | } | ||
277 | iConstForEach(PtrArray, a, &d->audio) { | ||
278 | const iGmAudio *audio = a.ptr; | ||
279 | if (audio->player) { | ||
280 | memSize += sourceDataSize_Player(audio->player); | ||
281 | } | ||
282 | } | ||
283 | iConstForEach(PtrArray, n, &d->downloads) { | ||
284 | const iGmDownload *down = n.ptr; | ||
285 | memSize += down->numBytes; | ||
286 | } | ||
287 | return memSize; | ||
267 | } | 288 | } |
268 | 289 | ||
269 | iBool setDownloadUrl_Media(iMedia *d, iGmLinkId linkId, const iString *url) { | 290 | iBool setDownloadUrl_Media(iMedia *d, iGmLinkId linkId, const iString *url) { |