summaryrefslogtreecommitdiff
path: root/apps/codecs.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-04-27 03:08:23 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-04-27 03:08:23 +0000
commitc537d5958e8b421ac4f9bef6c8b9e7425a6cf167 (patch)
tree7ed36518fb6524da7bbd913ba7619b85b5d15d23 /apps/codecs.c
parentdcf0f8de4a37ff1d2ea510aef75fa67977a8bdcc (diff)
downloadrockbox-c537d5958e8b421ac4f9bef6c8b9e7425a6cf167.zip
rockbox-c537d5958e8b421ac4f9bef6c8b9e7425a6cf167.tar.gz
rockbox-c537d5958e8b421ac4f9bef6c8b9e7425a6cf167.tar.bz2
rockbox-c537d5958e8b421ac4f9bef6c8b9e7425a6cf167.tar.xz
Commit FS#12069 - Playback rework - first stages. Gives as thorough as 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
Diffstat (limited to 'apps/codecs.c')
-rw-r--r--apps/codecs.c96
1 files changed, 52 insertions, 44 deletions
diff --git a/apps/codecs.c b/apps/codecs.c
index 28e8c2a..25ace49 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -79,13 +79,10 @@ static int open(const char* pathname, int flags, ...)
#endif
struct codec_api ci = {
- 0, /* filesize */
- 0, /* curpos */
+ 0, /* filesize */
+ 0, /* curpos */
NULL, /* id3 */
- NULL, /* taginfo_ready */
- false, /* stop_codec */
- 0, /* new_track */
- 0, /* seek_time */
+ ERR_HANDLE_NOT_FOUND, /* audio_hid */
NULL, /* struct dsp_config *dsp */
NULL, /* codec_get_buffer */
NULL, /* pcmbuf_insert */
@@ -95,9 +92,9 @@ struct codec_api ci = {
NULL, /* advance_buffer */
NULL, /* seek_buffer */
NULL, /* seek_complete */
- NULL, /* request_next_track */
NULL, /* set_offset */
NULL, /* configure */
+ NULL, /* get_command */
/* kernel/ system */
#if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE
@@ -174,10 +171,16 @@ void codec_get_full_path(char *path, const char *codec_root_fn)
CODECS_DIR, codec_root_fn);
}
-static void * codec_load_ram(void *handle, struct codec_api *api)
+/** codec loading and call interface **/
+static void *curr_handle = NULL;
+static struct codec_header *c_hdr = NULL;
+
+static int codec_load_ram(struct codec_api *api)
{
- struct codec_header *c_hdr = lc_get_header(handle);
- struct lc_header *hdr = c_hdr ? &c_hdr->lc_hdr : NULL;
+ struct lc_header *hdr;
+
+ c_hdr = lc_get_header(curr_handle);
+ hdr = c_hdr ? &c_hdr->lc_hdr : NULL;
if (hdr == NULL
|| (hdr->magic != CODEC_MAGIC
@@ -193,15 +196,17 @@ static void * codec_load_ram(void *handle, struct codec_api *api)
)
{
logf("codec header error");
- lc_close(handle);
- return NULL;
+ lc_close(curr_handle);
+ curr_handle = NULL;
+ return CODEC_ERROR;
}
if (hdr->api_version > CODEC_API_VERSION
|| hdr->api_version < CODEC_MIN_API_VERSION) {
logf("codec api version error");
- lc_close(handle);
- return NULL;
+ lc_close(curr_handle);
+ curr_handle = NULL;
+ return CODEC_ERROR;
}
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
@@ -212,63 +217,66 @@ static void * codec_load_ram(void *handle, struct codec_api *api)
*(c_hdr->api) = api;
- return handle;
+ logf("Codec: calling entrypoint");
+ return c_hdr->entry_point(CODEC_LOAD);
}
-void * codec_load_buf(int hid, struct codec_api *api)
+int codec_load_buf(int hid, struct codec_api *api)
{
- int rc;
- void *handle;
- rc = bufread(hid, CODEC_SIZE, codecbuf);
+ int rc = bufread(hid, CODEC_SIZE, codecbuf);
+
if (rc < 0) {
logf("Codec: cannot read buf handle");
- return NULL;
+ return CODEC_ERROR;
}
- handle = lc_open_from_mem(codecbuf, rc);
+ curr_handle = lc_open_from_mem(codecbuf, rc);
- if (handle == NULL) {
- logf("error loading codec");
- return NULL;
+ if (curr_handle == NULL) {
+ logf("Codec: load error");
+ return CODEC_ERROR;
}
- return codec_load_ram(handle, api);
+ return codec_load_ram(api);
}
-void * codec_load_file(const char *plugin, struct codec_api *api)
+int codec_load_file(const char *plugin, struct codec_api *api)
{
char path[MAX_PATH];
- void *handle;
codec_get_full_path(path, plugin);
- handle = lc_open(path, codecbuf, CODEC_SIZE);
+ curr_handle = lc_open(path, codecbuf, CODEC_SIZE);
- if (handle == NULL) {
+ if (curr_handle == NULL) {
logf("Codec: cannot read file");
- return NULL;
+ return CODEC_ERROR;
}
- return codec_load_ram(handle, api);
+ return codec_load_ram(api);
}
-int codec_begin(void *handle)
+int codec_run_proc(void)
{
- int status = CODEC_ERROR;
- struct codec_header *c_hdr;
-
- c_hdr = lc_get_header(handle);
-
- if (c_hdr != NULL) {
- logf("Codec: calling entry_point");
- status = c_hdr->entry_point();
+ if (curr_handle == NULL) {
+ logf("Codec: no codec to run");
+ return CODEC_ERROR;
}
- return status;
+ logf("Codec: entering run state");
+ return c_hdr->run_proc();
}
-void codec_close(void *handle)
+int codec_close(void)
{
- if (handle)
- lc_close(handle);
+ int status = CODEC_OK;
+
+ if (curr_handle != NULL) {
+ logf("Codec: cleaning up");
+ status = c_hdr->entry_point(CODEC_UNLOAD);
+ lc_close(curr_handle);
+ curr_handle = NULL;
+ }
+
+ return status;
}