<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rockbox/apps/buffering.c, branch master</title>
<subtitle>My Rockbox tree</subtitle>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/rockbox/'/>
<entry>
<title>Buffering: Switch to a more general handle caching type</title>
<updated>2017-05-08T10:24:02+00:00</updated>
<author>
<name>Michael Sevakis</name>
<email>jethead71@rockbox.org</email>
</author>
<published>2017-04-13T22:53:17+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/rockbox/commit/?id=65c6a14e5fa41906176f93aa04512508e719d970'/>
<id>65c6a14e5fa41906176f93aa04512508e719d970</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix some problems with playback crashing</title>
<updated>2017-04-08T22:32:54+00:00</updated>
<author>
<name>Michael Sevakis</name>
<email>jethead71@rockbox.org</email>
</author>
<published>2017-04-08T22:11:25+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/rockbox/commit/?id=eefc7c73e2495decdc6f242515696fe0e3f85609'/>
<id>eefc7c73e2495decdc6f242515696fe0e3f85609</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>Cleanup unused function</title>
<updated>2016-04-04T09:06:29+00:00</updated>
<author>
<name>Mihail Zenkov</name>
<email>mihail.zenkov@gmail.com</email>
</author>
<published>2014-10-02T11:27:46+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/rockbox/commit/?id=47d6d268c031dacb60929a21f6cceb09400c5e46'/>
<id>47d6d268c031dacb60929a21f6cceb09400c5e46</id>
<content type='text'>
Change-Id: I10aac94906607a74f05a687cb3d0029cb6faea6e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change-Id: I10aac94906607a74f05a687cb3d0029cb6faea6e
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove I/O priority. It is harmful when used with the new file code.</title>
<updated>2014-08-30T18:01:21+00:00</updated>
<author>
<name>Michael Sevakis</name>
<email>jethead71@rockbox.org</email>
</author>
<published>2014-08-30T15:28:50+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/rockbox/commit/?id=5b08f1a5b99136ef052b6f430b62bc618cd44946'/>
<id>5b08f1a5b99136ef052b6f430b62bc618cd44946</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>buffering.c: Patch up some straggling strlcpy warnings</title>
<updated>2014-04-03T22:49:16+00:00</updated>
<author>
<name>Michael Sevakis</name>
<email>jethead71@rockbox.org</email>
</author>
<published>2014-04-03T22:49:16+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/rockbox/commit/?id=8375b691e629bfbfb2a6ea213c35fe645085d9b7'/>
<id>8375b691e629bfbfb2a6ea213c35fe645085d9b7</id>
<content type='text'>
Originating from 3661581

Some build clients finding their "standard" string.h's that don't declare
strlcpy?

Change-Id: I50d19c7cecf5ae96ee1855f77d3c2e1f42620108
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Originating from 3661581

Some build clients finding their "standard" string.h's that don't declare
strlcpy?

Change-Id: I50d19c7cecf5ae96ee1855f77d3c2e1f42620108
</pre>
</div>
</content>
</entry>
<entry>
<title>Apparently some builds still need string.h in buffering.c</title>
<updated>2014-04-03T01:07:30+00:00</updated>
<author>
<name>Michael Sevakis</name>
<email>jethead71@rockbox.org</email>
</author>
<published>2014-04-03T01:03:30+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/rockbox/commit/?id=f9d60e14c9dd020ca892e0e4328a5b48274aedf2'/>
<id>f9d60e14c9dd020ca892e0e4328a5b48274aedf2</id>
<content type='text'>
Change-Id: I99b90ab7e5b7d074b1d2d1de72267f9f2eea975b
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change-Id: I99b90ab7e5b7d074b1d2d1de72267f9f2eea975b
</pre>
</div>
</content>
</entry>
<entry>
<title>Buffering: Remove buf_ridx and buf_widx; these data are verbose.</title>
<updated>2014-04-03T00:24:03+00:00</updated>
<author>
<name>Michael Sevakis</name>
<email>jethead71@rockbox.org</email>
</author>
<published>2013-08-26T20:49:53+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/rockbox/commit/?id=36615815bf92ec0f6d4ed067689bb72f695e3bf9'/>
<id>36615815bf92ec0f6d4ed067689bb72f695e3bf9</id>
<content type='text'>
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 &lt;jethead71@rockbox.org&gt;
Tested: Michael Sevakis &lt;jethead71@rockbox.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;jethead71@rockbox.org&gt;
Tested: Michael Sevakis &lt;jethead71@rockbox.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>SWCODEC Audio: Add some INIT_ATTR's to get a few bytes back.</title>
<updated>2013-06-30T02:29:23+00:00</updated>
<author>
<name>Michael Sevakis</name>
<email>jethead71@rockbox.org</email>
</author>
<published>2013-06-30T02:19:59+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/rockbox/commit/?id=9b990bdab1eda4d242346a0614b9410993ab275a'/>
<id>9b990bdab1eda4d242346a0614b9410993ab275a</id>
<content type='text'>
Change-Id: Ie7b04ecf3b3535e0ed45a6e0e8d81af89e38378e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change-Id: Ie7b04ecf3b3535e0ed45a6e0e8d81af89e38378e
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix whitespace</title>
<updated>2013-06-30T02:29:03+00:00</updated>
<author>
<name>Michael Sevakis</name>
<email>jethead71@rockbox.org</email>
</author>
<published>2013-06-30T02:18:17+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/rockbox/commit/?id=89b05af4967806fb75411a8ccb122f299f79cf52'/>
<id>89b05af4967806fb75411a8ccb122f299f79cf52</id>
<content type='text'>
Change-Id: I2072c355f05b6e709a5c179512bc2b71756163a5
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change-Id: I2072c355f05b6e709a5c179512bc2b71756163a5
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix some lockup caused by handles not being initialized to &lt; 0...</title>
<updated>2012-05-21T06:28:13+00:00</updated>
<author>
<name>Michael Sevakis</name>
<email>jethead71@rockbox.org</email>
</author>
<published>2012-05-21T06:18:46+00:00</published>
<link rel='alternate' type='text/html' href='https://www.franklinwei.com/cgit/rockbox/commit/?id=0ebfb937aaa073282415e561f8d1f150813a00fd'/>
<id>0ebfb937aaa073282415e561f8d1f150813a00fd</id>
<content type='text'>
...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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
...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
</pre>
</div>
</content>
</entry>
</feed>
