summaryrefslogtreecommitdiff
path: root/apps/codecs.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-02-23 14:31:13 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-02-23 14:31:13 +0000
commit65109732230849eeb9eec2f56f9e046ad6b476c3 (patch)
tree51096b18d823cfb05575335b91e3d1eb75ca4e27 /apps/codecs.c
parent43b38b71f5944c1a29060847b58d7e79f7dfe428 (diff)
downloadrockbox-65109732230849eeb9eec2f56f9e046ad6b476c3.zip
rockbox-65109732230849eeb9eec2f56f9e046ad6b476c3.tar.gz
rockbox-65109732230849eeb9eec2f56f9e046ad6b476c3.tar.bz2
rockbox-65109732230849eeb9eec2f56f9e046ad6b476c3.tar.xz
Give playback engine better control over the codec. Codec simply follows commands and doesn't concern itself with audio state. Get track change notification in on the actual last buffer insert of the track because now audio simply waits for a track change notify from PCM on the last track and it must be sent reliably. This is still at an intermediate stage but works. Codecs and plugins become incompatible.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29387 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs.c')
-rw-r--r--apps/codecs.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/apps/codecs.c b/apps/codecs.c
index 646d5f2..86e36ed 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -97,7 +97,6 @@ struct codec_api ci = {
NULL, /* seek_buffer */
NULL, /* seek_complete */
NULL, /* request_next_track */
- NULL, /* discard_codec */
NULL, /* set_offset */
NULL, /* configure */
@@ -149,8 +148,6 @@ struct codec_api ci = {
#endif
#ifdef HAVE_RECORDING
- false, /* stop_encoder */
- 0, /* enc_codec_loaded */
enc_get_inputs,
enc_set_parameters,
enc_get_chunk,
@@ -178,11 +175,10 @@ void codec_get_full_path(char *path, const char *codec_root_fn)
CODECS_DIR, codec_root_fn);
}
-static int codec_load_ram(void *handle, struct codec_api *api)
+static void * codec_load_ram(void *handle, struct codec_api *api)
{
struct codec_header *c_hdr = lc_get_header(handle);
struct lc_header *hdr = c_hdr ? &c_hdr->lc_hdr : NULL;
- int status;
if (hdr == NULL
|| (hdr->magic != CODEC_MAGIC
@@ -199,14 +195,14 @@ static int codec_load_ram(void *handle, struct codec_api *api)
{
logf("codec header error");
lc_close(handle);
- return CODEC_ERROR;
+ return NULL;
}
if (hdr->api_version > CODEC_API_VERSION
|| hdr->api_version < CODEC_MIN_API_VERSION) {
logf("codec api version error");
lc_close(handle);
- return CODEC_ERROR;
+ return NULL;
}
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
@@ -216,34 +212,31 @@ static int codec_load_ram(void *handle, struct codec_api *api)
#endif
*(c_hdr->api) = api;
- status = c_hdr->entry_point();
- lc_close(handle);
-
- return status;
+ return handle;
}
-int codec_load_buf(unsigned int hid, struct codec_api *api)
+void * codec_load_buf(int hid, struct codec_api *api)
{
int rc;
void *handle;
rc = bufread(hid, CODEC_SIZE, codecbuf);
if (rc < 0) {
- logf("error loading codec");
- return CODEC_ERROR;
+ logf("Codec: cannot read buf handle");
+ return NULL;
}
+
handle = lc_open_from_mem(codecbuf, rc);
- if (handle == NULL)
- {
+
+ if (handle == NULL) {
logf("error loading codec");
- return CODEC_ERROR;
+ return NULL;
}
- api->discard_codec();
return codec_load_ram(handle, api);
}
-int codec_load_file(const char *plugin, struct codec_api *api)
+void * codec_load_file(const char *plugin, struct codec_api *api)
{
char path[MAX_PATH];
void *handle;
@@ -253,10 +246,30 @@ int codec_load_file(const char *plugin, struct codec_api *api)
handle = lc_open(path, codecbuf, CODEC_SIZE);
if (handle == NULL) {
- logf("Codec load error");
- splashf(HZ*2, "Couldn't load codec: %s", path);
- return CODEC_ERROR;
+ logf("Codec: cannot read file");
+ return NULL;
}
return codec_load_ram(handle, api);
}
+
+int codec_begin(void *handle)
+{
+ 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();
+ }
+
+ return status;
+}
+
+void codec_close(void *handle)
+{
+ if (handle)
+ lc_close(handle);
+}