diff options
| author | Michael Sevakis <jethead71@rockbox.org> | 2012-05-21 02:18:46 -0400 |
|---|---|---|
| committer | Michael Sevakis <jethead71@rockbox.org> | 2012-05-21 02:28:13 -0400 |
| commit | 0ebfb937aaa073282415e561f8d1f150813a00fd (patch) | |
| tree | ace0d47f3ee55c289a4b645986615ff9a281a1df /apps/buffering.c | |
| parent | 5f2618c363467648d96ccbc82e14df7d2194a148 (diff) | |
| download | rockbox-0ebfb937aaa073282415e561f8d1f150813a00fd.zip rockbox-0ebfb937aaa073282415e561f8d1f150813a00fd.tar.gz rockbox-0ebfb937aaa073282415e561f8d1f150813a00fd.tar.bz2 rockbox-0ebfb937aaa073282415e561f8d1f150813a00fd.tar.xz | |
Fix some lockup caused by handles not being initialized to < 0...
...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
Diffstat (limited to 'apps/buffering.c')
| -rw-r--r-- | apps/buffering.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index c47564b..b5bf427 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -389,7 +389,7 @@ static bool rm_handle(const struct memory_handle *h) NULL if the handle wasn't found */ static struct memory_handle *find_handle(int handle_id) { - if (handle_id < 0) + if (handle_id < 0 || !first_handle) return NULL; /* simple caching because most of the time the requested handle @@ -1748,12 +1748,22 @@ bool buffering_reset(char *buf, size_t buflen) thus buf and buflen must be a aligned to an integer multiple of the storage alignment */ - buflen -= GUARD_BUFSIZE; + if (buf) { + buflen -= MIN(buflen, GUARD_BUFSIZE); + + STORAGE_ALIGN_BUFFER(buf, buflen); - STORAGE_ALIGN_BUFFER(buf, buflen); + if (!buf || !buflen) + return false; + } else { + buflen = 0; + } - if (!buf || !buflen) - return false; + send_event(BUFFER_EVENT_BUFFER_RESET, NULL); + + /* If handles weren't closed above, just do it */ + while (num_handles != 0) + bufclose(first_handle->id); buffer = buf; buffer_len = buflen; |