summaryrefslogtreecommitdiff
path: root/apps/buffering.c (follow)
Commit message (Collapse)AuthorAge
* Buffering: Missed converting one case assuming const handle size.Michael Sevakis2017-12-19
| | | | | | Must now be h->size, not sizeof (type). Change-Id: Ia0b1b552a486ddbc28b80542cfa76bed9e7cfdb3
* Buffering: Get rid of disabled code I have no intention of usingMichael Sevakis2017-12-17
| | | | Change-Id: I0e5a20e042291180391b0b0059e44705c256d3e5
* Get rid of useless playlist probing and fix up some data types.Michael Sevakis2017-12-17
| | | | | | | | | | | Playback checked the files' presence before attempting to buffer the track. Just get rid of that and save an extra open/close call. It will find out if the path is bad when the metadata fails. Fix some size_t/off_t conflation. No need to update plugin version because no plugin actually uses bufopen(). Change-Id: I3db112449dc0b2eeb91c546f308880ac82494fc7
* Buffering: Remove statically-sized path buffer from handle structMichael Sevakis2017-12-10
| | | | | | | | Paths are stored after the structure at their actual length plus any aligment padding. In principle, any type of auxilliary data could go there. Change-Id: Ic5487dc4089781b5cc52414d1691ba6d9dc1893c
* buffering.c: Fix oopses with caching handle pointerMichael Sevakis2017-12-09
| | | | | | | | | | | The location of the handle cannot be kept across calls to shrink_handle() since it may move the structure. The error was there in one place at the inception, corrected, then reintroduced. Make shrink_handle() return the new location and use it, which makes the side effects of the function clearer. Change-Id: Icae6a0ad6f7bb0d6645b044cccfa4aef88db42ad
* Remove recursion from shrink_buffer()Michael Sevakis2017-12-09
| | | | | | | | There's no need for it any longer since the list is now doubly- linked. As a bonus, stack limits pose no barrier to the length of the list. Change-Id: I41c567f946b640ef1e3c2d93da2f5aef9a763c66
* Playback: Move internal track list onto bufferMichael Sevakis2017-12-09
| | | | | | | | | | | | | | Does away the statically-allocated track list which frees quite a fair amount of in-RAM size. There's no compile-time hard track limit. Recommended TODO (but not right away): Have data small enough use the handle structure as its buffer data area. Almost the entire handle structure is unused for simple allocations without any associated filesystem path. Change-Id: I74a4561e5a837e049811ac421722ec00dadc0d50
* Buffering: Switch to a more general handle caching typeMichael Sevakis2017-05-08
| | | | | | | | | | | | | | | | | | | It sort of implemented an MRU cache but just kept track of the most recent access and checked the one after it, otherwise searching from the beginning. Implement a true MRU list of all open handles. Handles of the current track will tend to stay up front for faster access. Switch to common linked list functions Use double-linked lists to have insert, remove and move_handle operations in O(1)-- no more searching to find the previous handle, which is very often required. Smaller code too. :) Change-Id: I9ae8f3f96d225a5d54b94133f499268007274784
* Fix some problems with playback crashingMichael Sevakis2017-04-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm not sure all the situations it affects, to be honest. The fix aimed to address the strange symptom here: http://forums.rockbox.org/index.php/topic,50793.0.html It turns out that ringbuf_add_cross was used when handles were butted up against one another with the first parameter equal to the last, which it interprets as being an empty case when it should be interpreted as full in the context it was used. To fix this, introduce full/empty variants of ringbuf_add_cross and ringbuf_sub and use them at the appropriate time. The other way to address the problem is ensure there's always at least a space byte between the end of one handle and the start of another but this make the code a bit trickier to reason about than using additional function variants. bufopen() may yield after creating a handle and so do some more locking so that the buffering thread doesn't mess things up by moving anything or not seeing the yet-to-be linked-in allocation. Add alignof() macro to use proper method to get alignment of struct memory_handle. That should be useful in general anyway. It's merely defined as __alignof__ but looks nicer. Change-Id: If21739eaa33a4f6c084a28ee5b3c8fceecfd87ce
* Cleanup unused functionMihail Zenkov2016-04-04
| | | | Change-Id: I10aac94906607a74f05a687cb3d0029cb6faea6e
* Remove I/O priority. It is harmful when used with the new file code.Michael Sevakis2014-08-30
| | | | | | | | | | HAVE_IO_PRIORITY was defined for native targets with dircache. It is already effectively disabled for the most part since dircache no longer lowers its thread's I/O priority. It existed primarily for the aforementioned configuration. Change-Id: Ia04935305397ba14df34647c8ea29c2acaea92aa
* buffering.c: Patch up some straggling strlcpy warningsMichael Sevakis2014-04-03
| | | | | | | | | Originating from 3661581 Some build clients finding their "standard" string.h's that don't declare strlcpy? Change-Id: I50d19c7cecf5ae96ee1855f77d3c2e1f42620108
* Apparently some builds still need string.h in buffering.cMichael Sevakis2014-04-02
| | | | Change-Id: I99b90ab7e5b7d074b1d2d1de72267f9f2eea975b
* Buffering: Remove buf_ridx and buf_widx; these data are verbose.Michael Sevakis2014-04-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is trivial to obtain all required information from the allocated handles without maintaining global indexes. In fact, it is less complicated and increases general thread safety. Other miscellaneous changes (some are nice to do at this time due to required alterations, with some particularly more relevant than others): * Handle value 0 will no longer be returned as a valid handle but all failures will still return a negative value. Creates consistency with buflib and removes the need to explicitly initialize them. * Linking a new handle is delayed until explicitly added by the code that called add_handle, keeping it invisible until every operation succeeds, which is safer thread-wise. If anything fails, the handle itself may just be abandoned rather than reqiring it be freed. * Dump the special handling to slow buffering when the PCM buffer is low that calls PCM buffer functions. It doesn't seem to help much of anything these days and it's a bit of a nasty hack to directly tie those bits together. It can of course be put back (again!) if there really is a need for it. * Make data waiters ping the buffering thread more than just once if the request is taking too long. Somehow I figured out how the requests could get forgotten about but can't remember why months later after making the change in my branch. :-) * Neaten up some code by using (inline) functions and packing down parameters; remember handle allocation and movement attributes in the handle itself rather than figuring it out each time they're needed. Change-Id: Ibf863370da3dd805132fc135e0ad104953365183 Reviewed-on: http://gerrit.rockbox.org/764 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested: Michael Sevakis <jethead71@rockbox.org>
* SWCODEC Audio: Add some INIT_ATTR's to get a few bytes back.Michael Sevakis2013-06-29
| | | | Change-Id: Ie7b04ecf3b3535e0ed45a6e0e8d81af89e38378e
* Fix whitespaceMichael Sevakis2013-06-29
| | | | Change-Id: I2072c355f05b6e709a5c179512bc2b71756163a5
* Fix some lockup caused by handles not being initialized to < 0...Michael Sevakis2012-05-21
| | | | | | | | | | | | | | ...by default where they would be interpreted as valid but not actually be which would cause calls to buffering while it was not initialized. Add BUFFER_EVENT_BUFFER_RESET to inform users of buffering that the buffer is being reinitialized. Basically, this wraps all the functionality being provided by three events (...START_PLAYBACK, RECORDING_EVENT_START, RECORDING_EVENT_STOP) into one for radioart.c, the only user of those events (perhaps remove them?) and closes some loopholes. Change-Id: I99ec46b9b5fb4e36605db5944c60ed986163db3a
* Provide a reasonable fix for FS#12093 - Playback hanging after ↵Michael Sevakis2011-05-09
| | | | | | codec/playback rework. Also, get rid of an impossible buffering case (BUF_USED is always less than buffer_len) and remove a buffering API that is not used anywhere and shouldn't be needed (plugin API has to be incompatible). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29849 a1c6a512-1295-4272-9138-f99709370657
* Commit FS#12069 - Playback rework - first stages. Gives as thorough as ↵Michael Sevakis2011-04-27
| | | | | | possible a treatment of codec management, track change and metadata logic as possible while maintaining fairly narrow focus and not rewriting everything all at once. Please see the rockbox-dev mail archive on 2011-04-25 (Playback engine rework) for a more thorough manifest of what was addressed. Plugins and codecs become incompatible. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29785 a1c6a512-1295-4272-9138-f99709370657
* Buffering should truncate if read() returns 0 since it's not a valid return ↵Michael Sevakis2011-03-21
| | | | | | there as there should be data left to read. The loop wouldn't break until there was a message in the queue. I just experienced the case with crosslinked files and read stopped making progress, returning 0 each time it was called. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29626 a1c6a512-1295-4272-9138-f99709370657
* Purge buffer and codec APIs existing exclusively in support of mpa.codec and ↵Michael Sevakis2011-03-16
| | | | | | fix that to not require them: buf_get_offset and ci.advance_buffer_loc. Sort APIs; everything must become incompatible. :( git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29595 a1c6a512-1295-4272-9138-f99709370657
* Use ringbuf_add in buffering when incrementing for initial allocation of ↵Michael Sevakis2011-03-13
| | | | | | non-wrapping data. The result of the shortcut would have been wrong if the handle used space exactly to the end of the buffer since buf_widx wouldn't have been properly wrapped to index 0. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29578 a1c6a512-1295-4272-9138-f99709370657
* Do the ridx > widx check where it should be done. A small rebuffering ↵Michael Sevakis2011-03-02
| | | | | | request must completely succeed before buffer can later shrink a handle or else it must reset the handle. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29491 a1c6a512-1295-4272-9138-f99709370657
* buffering: Unusual cases when a handle ridx is briefly seeked ahead of widx ↵Michael Sevakis2011-03-02
| | | | | | need to be handled properly. In the best case, buffer useful would be wrong and in the worst, a packet audio move_handle delta would be quite incorrect, causing the handle to be moved too far. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29490 a1c6a512-1295-4272-9138-f99709370657
* All kernel objects in code shared amongs targets (core, plugins, codecs) ↵Michael Sevakis2011-02-14
| | | | | | should be declared SHAREDBSS_ATTR as any core could potentially touch them even though they seem only to involve threads on one core. The exception is target code for particular CPUs where proper allocation is fixed. playlist.c was a little odd too-- use one mutex for the current playlist and a separate one for created playlists (still pondering the necessity of more than one). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29305 a1c6a512-1295-4272-9138-f99709370657
* Code police buffering.c a little - use already predominant style - shorted ↵Michael Sevakis2011-02-14
| | | | | | lines over 80 cols. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29304 a1c6a512-1295-4272-9138-f99709370657
* Buffering: tin cup. Update threading structure and handle rebuffer more ↵Michael Sevakis2011-02-14
| | | | | | reliably on buffer thread using a single message send. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29303 a1c6a512-1295-4272-9138-f99709370657
* Leave a gap between all handles because ringbuf_add_cross interprets equal ↵Michael Sevakis2011-02-14
| | | | | | pointers as empty, corruption guard check could fail to detect overlap if buffering ran right up to the next handle and it gets asked to buffer again before freeing the following handles (adds a byte on average). Storage alignment on handle reset must at times avoid alignment increments if after a stopped rebuffer, the handle was shrunk too close to the next one or the reading position in a prior rebuffer. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29302 a1c6a512-1295-4272-9138-f99709370657
* Needed to do a few more things to have r29291 correct.Michael Sevakis2011-02-13
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29294 a1c6a512-1295-4272-9138-f99709370657
* Change add_handle to never have side effects on the buffer if it fails. It ↵Michael Sevakis2011-02-13
| | | | | | actually seems ok and I'm not sure if's responsible for anything, but it's more sane and keeps buffer_handle from regressing buf_widx later if buffering cur_handle. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29291 a1c6a512-1295-4272-9138-f99709370657
* Oops. Put back some changes to go only with others.Michael Sevakis2011-02-12
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29289 a1c6a512-1295-4272-9138-f99709370657
* Fix move_handle in buffering. Calculating wraps by buffer_len - 1 is ↵Michael Sevakis2011-02-12
| | | | | | incorrect. Switch handle movement to memmove calls exclusively. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29288 a1c6a512-1295-4272-9138-f99709370657
* buffering: Don't execute move-handle-ony case if handle is of metadata type ↵Michael Sevakis2011-02-10
| | | | | | (atomic) and must be kept fully buffered. Manage handle corruption guard and handle buffering with one set of logic which allows reading of the maximum amount of data without overflow. 'FIXME' regarding handle corruption guard is really part of expected operation when thread that does the handle closing hasn't yet performed the delegated task before rebuffering starts. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29270 a1c6a512-1295-4272-9138-f99709370657
* Disable buffering codecs (and code generally) on RaaA.Thomas Martitz2011-02-09
| | | | | | | It's not useful to do it since you need to write back the code to disk to be able to load it from memory, it also requires writing to an executable directory. Keep it for the simulator for the sake of simulating. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29261 a1c6a512-1295-4272-9138-f99709370657
* Embedded album art support in MP3/ID3v2 tags.Thomas Martitz2011-02-09
| | | | | | | | | | | - Support is limited to non-desync jpeg in id3v2 tags. Other formats (hopefully) follow in the future. - Embedded album art takes precedence over files in album art files. - No additional buffers are used, the jpeg is read directly from the audio file. Flyspray: FS#11216 Author: Yoshihisa Uchida and I git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29259 a1c6a512-1295-4272-9138-f99709370657
* Buffering should align itself and not rely on buffering_reset parameters ↵Michael Sevakis2011-02-09
| | | | | | when storage alignment matters so that wrapped reads maintain alignment. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29258 a1c6a512-1295-4272-9138-f99709370657
* buffering: Fix a case that could allow widx to fully wrap to ridx and ↵Michael Sevakis2011-02-09
| | | | | | overflow the ringbuffer. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29257 a1c6a512-1295-4272-9138-f99709370657
* Roll back unintentionally submitted file.Andree Buschmann2011-02-03
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29200 a1c6a512-1295-4272-9138-f99709370657
* Submit FS#11918: Add 2 more codec types to be able to differentiate between ↵Andree Buschmann2011-02-03
| | | | | | AAC / AAC-HE and MPC SV7 / SV8. Additionally handle ATARI soundfiles in get_codec_base_type() as intended. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29199 a1c6a512-1295-4272-9138-f99709370657
* Clean up multiple definitions of RAM size. Remove -DMEM (make) and MEM ↵Andree Buschmann2011-02-02
| | | | | | (code), use the already defined MEMORYSIZE instead. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29189 a1c6a512-1295-4272-9138-f99709370657
* Fix FS#11586. Corrects rebuffering behaviour which did not allow to play ↵Andree Buschmann2010-08-30
| | | | | | several m4a files. Thanks to Magnus Holmgren. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27950 a1c6a512-1295-4272-9138-f99709370657
* Oops, committed before finishing the removal of "#include "memory.h""Thomas Martitz2010-08-12
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27790 a1c6a512-1295-4272-9138-f99709370657
* Remove some redundant #include'sBertrik Sikken2010-06-29
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27183 a1c6a512-1295-4272-9138-f99709370657
* playback.c: don't assume cacheline size is 16 bytesRafaël Carré2010-06-23
| | | | | | | | | | ideally all targets should define CACHEALIGN_BITS, for now we default it to 16 bytes if it's not specified Since the buffer is already aligned in playback.c no need to align it again in buffering.c git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27073 a1c6a512-1295-4272-9138-f99709370657
* Rockbox as an application: Replace many occurences of #ifdef SIMULATOR with ↵Thomas Martitz2010-06-21
| | | | | | | | | | | #if (CONFIG_PLATFORM & PLATFORM_HOSTED) (or equivalently). The simulator defines PLATFORM_HOSTED, as RaaA will do (RaaA will not define SIMULATOR). The new define is to (de-)select code to compile on hosted platforms generally. Should be no functional change to targets or the simulator. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27019 a1c6a512-1295-4272-9138-f99709370657
* fix: when move_handle() is successful, the return valueYoshihisa Uchida2010-05-24
| | | | | | corrects valid type. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26249 a1c6a512-1295-4272-9138-f99709370657
* FS#11263 - Radio Art support! %C and %Cl tags work in the radio screen and ↵Jonathan Gordon2010-05-16
| | | | | | | | | Base Skin when the radio is running. put your station images in .rockbox/fmpresets/<preset name>.bmp or .jpg. Must be in preset mode and the preset name must match the filename git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26078 a1c6a512-1295-4272-9138-f99709370657
* Eliminate %zd tag in printf format strings, replace them with %ld. The %z ↵Jeffrey Goode2010-05-15
| | | | | | formatter kept generating type mismatch warnings. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26040 a1c6a512-1295-4272-9138-f99709370657
* Hopefully the last warningFrank Gevaerts2010-05-14
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26036 a1c6a512-1295-4272-9138-f99709370657
* Fix various size_t related warnings and errorsFrank Gevaerts2010-05-14
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26035 a1c6a512-1295-4272-9138-f99709370657