Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
Nicolas Pennequin | 357ffb3 | 2008-05-05 10:32:46 +0000 | [diff] [blame] | 10 | * Copyright (C) 2002 Björn Stenberg |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame] | 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License |
| 14 | * as published by the Free Software Foundation; either version 2 |
| 15 | * of the License, or (at your option) any later version. |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
Thom Johansen | c91e0bb | 2005-10-13 11:32:52 +0000 | [diff] [blame] | 21 | |
| 22 | #include "codeclib.h" |
Björn Stenberg | 45bd7e0 | 2008-11-05 13:30:58 +0000 | [diff] [blame] | 23 | #include "libtremor/ivorbisfile.h" |
| 24 | #include "libtremor/ogg.h" |
Magnus Holmgren | 3fad152 | 2009-08-29 12:23:40 +0000 | [diff] [blame] | 25 | #ifdef SIMULATOR |
| 26 | #include "lib/tlsf/src/tlsf.h" |
| 27 | #endif |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 28 | |
Jens Arnold | b8749fd | 2006-01-18 00:05:14 +0000 | [diff] [blame] | 29 | CODEC_HEADER |
| 30 | |
Magnus Holmgren | 3fad152 | 2009-08-29 12:23:40 +0000 | [diff] [blame] | 31 | #if defined(CPU_ARM) || defined(CPU_COLDFIRE) || defined(CPU_MIPS) |
Magnus Holmgren | f4515c3 | 2009-03-08 12:48:58 +0000 | [diff] [blame] | 32 | #include <setjmp.h> |
| 33 | jmp_buf rb_jump_buf; |
| 34 | #endif |
| 35 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 36 | /* Some standard functions and variables needed by Tremor */ |
| 37 | |
Bertrik Sikken | 1e3ed74 | 2008-08-12 22:01:55 +0000 | [diff] [blame] | 38 | static size_t read_handler(void *ptr, size_t size, size_t nmemb, void *datasource) |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 39 | { |
Daniel Stenberg | 31efab4 | 2005-06-22 19:55:09 +0000 | [diff] [blame] | 40 | (void)datasource; |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 41 | return ci->read_filebuf(ptr, nmemb*size); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 42 | } |
| 43 | |
Bertrik Sikken | 1e3ed74 | 2008-08-12 22:01:55 +0000 | [diff] [blame] | 44 | static int initial_seek_handler(void *datasource, ogg_int64_t offset, int whence) |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 45 | { |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 46 | (void)datasource; |
| 47 | (void)offset; |
| 48 | (void)whence; |
| 49 | return -1; |
| 50 | } |
| 51 | |
Bertrik Sikken | 1e3ed74 | 2008-08-12 22:01:55 +0000 | [diff] [blame] | 52 | static int seek_handler(void *datasource, ogg_int64_t offset, int whence) |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 53 | { |
| 54 | (void)datasource; |
| 55 | |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 56 | if (whence == SEEK_CUR) { |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 57 | offset += ci->curpos; |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 58 | } else if (whence == SEEK_END) { |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 59 | offset += ci->filesize; |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 62 | if (ci->seek_buffer(offset)) { |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 63 | return 0; |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | return -1; |
| 67 | } |
| 68 | |
Bertrik Sikken | 1e3ed74 | 2008-08-12 22:01:55 +0000 | [diff] [blame] | 69 | static int close_handler(void *datasource) |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 70 | { |
| 71 | (void)datasource; |
| 72 | return 0; |
| 73 | } |
| 74 | |
Bertrik Sikken | 1e3ed74 | 2008-08-12 22:01:55 +0000 | [diff] [blame] | 75 | static long tell_handler(void *datasource) |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 76 | { |
Daniel Stenberg | 31efab4 | 2005-06-22 19:55:09 +0000 | [diff] [blame] | 77 | (void)datasource; |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 78 | return ci->curpos; |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 81 | /* This sets the DSP parameters based on the current logical bitstream |
Magnus Holmgren | 3fad152 | 2009-08-29 12:23:40 +0000 | [diff] [blame] | 82 | * (sampling rate, number of channels, etc). |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 83 | */ |
Bertrik Sikken | 1e3ed74 | 2008-08-12 22:01:55 +0000 | [diff] [blame] | 84 | static bool vorbis_set_codec_parameters(OggVorbis_File *vf) |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 85 | { |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 86 | vorbis_info *vi; |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 87 | |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 88 | vi = ov_info(vf, -1); |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 89 | |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 90 | if (vi == NULL) { |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 91 | return false; |
| 92 | } |
| 93 | |
Michael Sevakis | 97f369a | 2007-02-10 16:34:16 +0000 | [diff] [blame] | 94 | ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 95 | codec_set_replaygain(ci->id3); |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 96 | |
| 97 | if (vi->channels == 2) { |
Michael Sevakis | 97f369a | 2007-02-10 16:34:16 +0000 | [diff] [blame] | 98 | ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 99 | } else if (vi->channels == 1) { |
Michael Sevakis | 97f369a | 2007-02-10 16:34:16 +0000 | [diff] [blame] | 100 | ci->configure(DSP_SET_STEREO_MODE, STEREO_MONO); |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | return true; |
| 104 | } |
| 105 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 106 | /* this is the codec entry point */ |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 107 | enum codec_status codec_main(enum codec_entry_call_reason reason) |
| 108 | { |
| 109 | if (reason == CODEC_LOAD) { |
| 110 | if (codec_init()) |
| 111 | return CODEC_ERROR; |
| 112 | ci->configure(DSP_SET_SAMPLE_DEPTH, 24); |
| 113 | } |
| 114 | |
| 115 | return CODEC_OK; |
| 116 | } |
| 117 | |
| 118 | /* this is called for each file to process */ |
| 119 | enum codec_status codec_run(void) |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 120 | { |
| 121 | ov_callbacks callbacks; |
| 122 | OggVorbis_File vf; |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 123 | ogg_int32_t **pcm; |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 124 | |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 125 | int error = CODEC_ERROR; |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 126 | long n; |
| 127 | int current_section; |
Magnus Holmgren | f4515c3 | 2009-03-08 12:48:58 +0000 | [diff] [blame] | 128 | int previous_section; |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 129 | int eof; |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 130 | ogg_int64_t vf_offsets[2]; |
| 131 | ogg_int64_t vf_dataoffsets; |
| 132 | ogg_uint32_t vf_serialnos; |
| 133 | ogg_int64_t vf_pcmlengths[2]; |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 134 | intptr_t param; |
Magnus Holmgren | 3fad152 | 2009-08-29 12:23:40 +0000 | [diff] [blame] | 135 | |
Magnus Holmgren | 3fad152 | 2009-08-29 12:23:40 +0000 | [diff] [blame] | 136 | #if defined(CPU_ARM) || defined(CPU_COLDFIRE) || defined(CPU_MIPS) |
| 137 | if (setjmp(rb_jump_buf) != 0) { |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 138 | /* malloc failed; finish with this track */ |
Magnus Holmgren | f4515c3 | 2009-03-08 12:48:58 +0000 | [diff] [blame] | 139 | goto done; |
| 140 | } |
| 141 | #endif |
Bertrik Sikken | e70bc18 | 2010-08-23 20:09:58 +0000 | [diff] [blame] | 142 | ogg_malloc_init(); |
| 143 | |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 144 | /* Create a decoder instance */ |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 145 | callbacks.read_func = read_handler; |
| 146 | callbacks.seek_func = initial_seek_handler; |
| 147 | callbacks.tell_func = tell_handler; |
| 148 | callbacks.close_func = close_handler; |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 149 | |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 150 | ci->seek_buffer(0); |
| 151 | |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 152 | /* Open a non-seekable stream */ |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 153 | error = ov_open_callbacks(ci, &vf, NULL, 0, callbacks); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 154 | |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 155 | /* If the non-seekable open was successful, we need to supply the missing |
| 156 | * data to make it seekable. This is a hack, but it's reasonable since we |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 157 | * don't want to run the whole file through the buffer before we start |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 158 | * playing. Using Tremor's seekable open routine would cause us to do |
| 159 | * this, so we pretend not to be seekable at first. Then we fill in the |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 160 | * missing fields of vf with 1) information in ci->id3, and 2) info |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 161 | * obtained by Tremor in the above ov_open call. |
| 162 | * |
| 163 | * Note that this assumes there is only ONE logical Vorbis bitstream in our |
| 164 | * physical Ogg bitstream. This is verified in metadata.c, well before we |
| 165 | * get here. |
| 166 | */ |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 167 | if (!error) { |
Andree Buschmann | 4d5e882 | 2010-02-07 18:38:47 +0000 | [diff] [blame] | 168 | ogg_free(vf.offsets); |
| 169 | ogg_free(vf.dataoffsets); |
| 170 | ogg_free(vf.serialnos); |
Magnus Holmgren | 3fad152 | 2009-08-29 12:23:40 +0000 | [diff] [blame] | 171 | |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 172 | vf.offsets = vf_offsets; |
| 173 | vf.dataoffsets = &vf_dataoffsets; |
| 174 | vf.serialnos = &vf_serialnos; |
| 175 | vf.pcmlengths = vf_pcmlengths; |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 176 | |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 177 | vf.offsets[0] = 0; |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 178 | vf.offsets[1] = ci->id3->filesize; |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 179 | vf.dataoffsets[0] = vf.offset; |
| 180 | vf.pcmlengths[0] = 0; |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 181 | vf.pcmlengths[1] = ci->id3->samples; |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 182 | vf.serialnos[0] = vf.current_serialno; |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 183 | vf.callbacks.seek_func = seek_handler; |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 184 | vf.seekable = 1; |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 185 | vf.end = ci->id3->filesize; |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 186 | vf.ready_state = OPENED; |
| 187 | vf.links = 1; |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 188 | } else { |
Nils Wallménius | 984e1a8 | 2010-12-15 21:28:52 +0000 | [diff] [blame] | 189 | DEBUGF("Vorbis: ov_open failed: %d\n", error); |
Brandon Low | f3bc1ef | 2006-04-22 14:40:13 +0000 | [diff] [blame] | 190 | goto done; |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 191 | } |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 192 | |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 193 | if (ci->id3->offset) { |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 194 | ci->seek_buffer(ci->id3->offset); |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 195 | ov_raw_seek(&vf, ci->id3->offset); |
| 196 | ci->set_elapsed(ov_time_tell(&vf)); |
| 197 | ci->set_offset(ov_raw_tell(&vf)); |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 198 | } |
| 199 | |
Magnus Holmgren | f4515c3 | 2009-03-08 12:48:58 +0000 | [diff] [blame] | 200 | previous_section = -1; |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 201 | eof = 0; |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 202 | while (!eof) { |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 203 | enum codec_command_action action = ci->get_command(¶m); |
| 204 | |
| 205 | if (action == CODEC_ACTION_HALT) |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 206 | break; |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 207 | |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 208 | if (action == CODEC_ACTION_SEEK_TIME) { |
| 209 | if (ov_time_seek(&vf, param)) { |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 210 | //ci->logf("ov_time_seek failed"); |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 211 | } |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 212 | |
| 213 | ci->set_elapsed(ov_time_tell(&vf)); |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 214 | ci->seek_complete(); |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 215 | } |
Magnus Holmgren | 4a53787 | 2005-07-24 15:32:28 +0000 | [diff] [blame] | 216 | |
| 217 | /* Read host-endian signed 24-bit PCM samples */ |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 218 | n = ov_read_fixed(&vf, &pcm, 1024, ¤t_section); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 219 | |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 220 | /* Change DSP and buffer settings for this bitstream */ |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 221 | if (current_section != previous_section) { |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 222 | if (!vorbis_set_codec_parameters(&vf)) { |
Brandon Low | f3bc1ef | 2006-04-22 14:40:13 +0000 | [diff] [blame] | 223 | goto done; |
Linus Nielsen Feltzing | c4b7c67 | 2005-07-11 06:47:35 +0000 | [diff] [blame] | 224 | } else { |
| 225 | previous_section = current_section; |
| 226 | } |
| 227 | } |
| 228 | |
Thom Johansen | 0ad1ed6 | 2005-10-10 20:19:09 +0000 | [diff] [blame] | 229 | if (n == 0) { |
| 230 | eof = 1; |
Linus Nielsen Feltzing | eaf8b2d | 2005-07-05 08:43:36 +0000 | [diff] [blame] | 231 | } else if (n < 0) { |
Magnus Holmgren | 3fad152 | 2009-08-29 12:23:40 +0000 | [diff] [blame] | 232 | DEBUGF("Vorbis: Error decoding frame\n"); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 233 | } else { |
Michael Sevakis | aba6ca0 | 2007-02-07 00:51:50 +0000 | [diff] [blame] | 234 | ci->pcmbuf_insert(pcm[0], pcm[1], n); |
Tomasz Malesinski | 80da8b1 | 2006-11-26 18:31:41 +0000 | [diff] [blame] | 235 | ci->set_offset(ov_raw_tell(&vf)); |
| 236 | ci->set_elapsed(ov_time_tell(&vf)); |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 237 | } |
| 238 | } |
Michael Sevakis | 85e4025 | 2011-02-20 15:27:10 +0000 | [diff] [blame] | 239 | |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 240 | error = CODEC_OK; |
Brandon Low | f3bc1ef | 2006-04-22 14:40:13 +0000 | [diff] [blame] | 241 | done: |
Magnus Holmgren | 3fad152 | 2009-08-29 12:23:40 +0000 | [diff] [blame] | 242 | #if 0 /* defined(SIMULATOR) */ |
| 243 | { |
| 244 | size_t bufsize; |
| 245 | void* buf = ci->codec_get_buffer(&bufsize); |
| 246 | |
| 247 | DEBUGF("Vorbis: Memory max: %u\n", get_max_size(buf)); |
| 248 | } |
| 249 | #endif |
Bertrik Sikken | e70bc18 | 2010-08-23 20:09:58 +0000 | [diff] [blame] | 250 | ogg_malloc_destroy(); |
Magnus Holmgren | 3fad152 | 2009-08-29 12:23:40 +0000 | [diff] [blame] | 251 | |
Michael Sevakis | c537d59 | 2011-04-27 03:08:23 +0000 | [diff] [blame^] | 252 | /* Clean things up for the next track */ |
| 253 | vf.dataoffsets = NULL; |
| 254 | vf.offsets = NULL; |
| 255 | vf.serialnos = NULL; |
| 256 | vf.pcmlengths = NULL; |
| 257 | ov_clear(&vf); |
| 258 | |
Brandon Low | 1060e44 | 2006-01-18 20:22:03 +0000 | [diff] [blame] | 259 | return error; |
Daniel Stenberg | 1dd672f | 2005-06-22 19:41:30 +0000 | [diff] [blame] | 260 | } |