summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-03-16 05:38:37 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-03-16 05:38:37 +0000
commit56dd75d204f861785ca78ae1c6eb506d5f2ea7e9 (patch)
tree19809cf7976dd47513171bac706a061ef130b2b2
parentdce799641d2f75feda39b087f03a1f64620f3d6b (diff)
downloadrockbox-56dd75d204f861785ca78ae1c6eb506d5f2ea7e9.tar.gz
rockbox-56dd75d204f861785ca78ae1c6eb506d5f2ea7e9.zip
Purge buffer and codec APIs existing exclusively in support of mpa.codec and 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
-rw-r--r--apps/buffering.c11
-rw-r--r--apps/buffering.h2
-rw-r--r--apps/codec_thread.c7
-rw-r--r--apps/codecs.c1
-rw-r--r--apps/codecs.h6
-rw-r--r--apps/codecs/mpa.c12
-rw-r--r--apps/plugin.c3
-rw-r--r--apps/plugin.h7
8 files changed, 12 insertions, 37 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index 0cd81df93a..f70400a1ee 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -1444,7 +1444,6 @@ ssize_t bufcuttail(int handle_id, size_t size)
SECONDARY EXPORTED FUNCTIONS
============================
-buf_get_offset
buf_handle_offset
buf_request_buffer_handle
buf_set_base_handle
@@ -1457,16 +1456,6 @@ They take care of the content of the structs, and rely on the linked list
management functions for all the actual handle management work.
*/
-/* Get a handle offset from a pointer */
-ssize_t buf_get_offset(int handle_id, void *ptr)
-{
- const struct memory_handle *h = find_handle(handle_id);
- if (!h)
- return ERR_HANDLE_NOT_FOUND;
-
- return (size_t)ptr - (size_t)&buffer[h->ridx];
-}
-
ssize_t buf_handle_offset(int handle_id)
{
const struct memory_handle *h = find_handle(handle_id);
diff --git a/apps/buffering.h b/apps/buffering.h
index c3a9f928d1..34d6d641c7 100644
--- a/apps/buffering.h
+++ b/apps/buffering.h
@@ -91,14 +91,12 @@ ssize_t bufcuttail(int handle_id, size_t size);
* SECONDARY FUNCTIONS
* ===================
*
- * buf_get_offset: Get a handle offset from a pointer
* buf_handle_offset: Get the offset of the first buffered byte from the file
* buf_request_buffer_handle: Request buffering of a handle
* buf_set_base_handle: Tell the buffering thread which handle is currently read
* buf_used: Total amount of buffer space used (including allocated space)
****************************************************************************/
-ssize_t buf_get_offset(int handle_id, void *ptr);
ssize_t buf_handle_offset(int handle_id);
void buf_request_buffer_handle(int handle_id);
void buf_set_base_handle(int handle_id);
diff --git a/apps/codec_thread.c b/apps/codec_thread.c
index 9b17d7cf42..65a7ebc7d5 100644
--- a/apps/codec_thread.c
+++ b/apps/codec_thread.c
@@ -337,12 +337,6 @@ static void codec_advance_buffer_callback(size_t amount)
codec_set_offset_callback(ci.curpos);
}
-static void codec_advance_buffer_loc_callback(void *ptr)
-{
- size_t amount = buf_get_offset(get_audio_hid(), ptr);
- codec_advance_buffer_callback(amount);
-}
-
static bool codec_seek_buffer_callback(size_t newpos)
{
logf("codec_seek_buffer_callback");
@@ -443,7 +437,6 @@ void codec_init_codec_api(void)
ci.read_filebuf = codec_filebuf_callback;
ci.request_buffer = codec_request_buffer_callback;
ci.advance_buffer = codec_advance_buffer_callback;
- ci.advance_buffer_loc = codec_advance_buffer_loc_callback;
ci.seek_buffer = codec_seek_buffer_callback;
ci.seek_complete = codec_seek_complete_callback;
ci.request_next_track = codec_request_next_track_callback;
diff --git a/apps/codecs.c b/apps/codecs.c
index c9f612b3f4..28e8c2a1c0 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -93,7 +93,6 @@ struct codec_api ci = {
NULL, /* read_filebuf */
NULL, /* request_buffer */
NULL, /* advance_buffer */
- NULL, /* advance_buffer_loc */
NULL, /* seek_buffer */
NULL, /* seek_complete */
NULL, /* request_next_track */
diff --git a/apps/codecs.h b/apps/codecs.h
index 028e3614ff..daf2c8694e 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -75,12 +75,12 @@
#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */
/* increase this every time the api struct changes */
-#define CODEC_API_VERSION 39
+#define CODEC_API_VERSION 40
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
-#define CODEC_MIN_API_VERSION 39
+#define CODEC_MIN_API_VERSION 40
/* codec return codes */
enum codec_status {
@@ -134,8 +134,6 @@ struct codec_api {
void* (*request_buffer)(size_t *realsize, size_t reqsize);
/* Advance file buffer position by <amount> amount of bytes. */
void (*advance_buffer)(size_t amount);
- /* Advance file buffer to a pointer location inside file buffer. */
- void (*advance_buffer_loc)(void *ptr);
/* Seek file buffer to position <newpos> beginning of file. */
bool (*seek_buffer)(size_t newpos);
/* Codec should call this function when it has done the seeking. */
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c
index 4d6c52f2b3..4b49775029 100644
--- a/apps/codecs/mpa.c
+++ b/apps/codecs/mpa.c
@@ -424,24 +424,22 @@ next_track:
/* Fill the buffer */
if (stream.next_frame)
- ci->advance_buffer_loc((void *)stream.next_frame);
+ ci->advance_buffer(stream.next_frame - stream.buffer);
else
ci->advance_buffer(size);
- stream.error = 0;
+ stream.error = 0; /* Must get new inputbuffer next time */
file_end++;
continue;
} else if (MAD_RECOVERABLE(stream.error)) {
+ /* Probably syncing after a seek */
continue;
} else {
/* Some other unrecoverable error */
status = CODEC_ERROR;
break;
}
- break;
}
- file_end = 0;
-
/* Do the pcmbuf insert here. Note, this is the PREVIOUS frame's pcm
data (not the one just decoded above). When we exit the decoding
loop we will need to process the final frame that was decoded. */
@@ -479,9 +477,11 @@ next_track:
}
if (stream.next_frame)
- ci->advance_buffer_loc((void *)stream.next_frame);
+ ci->advance_buffer(stream.next_frame - stream.buffer);
else
ci->advance_buffer(size);
+ stream.error = 0; /* Must get new inputbuffer next time */
+ file_end = 0;
framelength = synth.pcm.length - samples_to_skip;
if (framelength < 0) {
diff --git a/apps/plugin.c b/apps/plugin.c
index 3807ad5d76..ea290c89a7 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -407,6 +407,7 @@ static const struct plugin_api rockbox_api = {
default_event_handler,
default_event_handler_ex,
create_thread,
+ thread_self,
thread_exit,
thread_wait,
#if (CONFIG_CODEC == SWCODEC)
@@ -745,7 +746,6 @@ static const struct plugin_api rockbox_api = {
bufgettail,
bufcuttail,
- buf_get_offset,
buf_handle_offset,
buf_request_buffer_handle,
buf_set_base_handle,
@@ -779,7 +779,6 @@ static const struct plugin_api rockbox_api = {
/* new stuff at the end, sort into place next time
the API gets incompatible */
- thread_self,
};
int plugin_load(const char* plugin, const void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index 43b9818ffd..de720d41eb 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -145,12 +145,12 @@ void* plugin_get_buffer(size_t *buffer_size);
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 201
+#define PLUGIN_API_VERSION 202
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
-#define PLUGIN_MIN_API_VERSION 200
+#define PLUGIN_MIN_API_VERSION 202
/* plugin return codes */
/* internal returns start at 0x100 to make exit(1..255) work */
@@ -479,6 +479,7 @@ struct plugin_api {
const char *name
IF_PRIO(, int priority)
IF_COP(, unsigned int core));
+ unsigned int (*thread_self)(void);
void (*thread_exit)(void);
void (*thread_wait)(unsigned int thread_id);
#if CONFIG_CODEC == SWCODEC
@@ -871,7 +872,6 @@ struct plugin_api {
ssize_t (*bufgettail)(int handle_id, size_t size, void **data);
ssize_t (*bufcuttail)(int handle_id, size_t size);
- ssize_t (*buf_get_offset)(int handle_id, void *ptr);
ssize_t (*buf_handle_offset)(int handle_id);
void (*buf_request_buffer_handle)(int handle_id);
void (*buf_set_base_handle)(int handle_id);
@@ -909,7 +909,6 @@ struct plugin_api {
/* new stuff at the end, sort into place next time
the API gets incompatible */
- unsigned int (*thread_self)(void);
};
/* plugin header */