2005-06-05 23:05:10 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Miika Pekkarinen
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2005-06-14 22:27:57 +00:00
|
|
|
#ifndef _PLAYBACK_H
|
|
|
|
#define _PLAYBACK_H
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
#include "id3.h"
|
|
|
|
#include "mp3data.h"
|
2005-06-05 23:05:10 +00:00
|
|
|
|
2005-06-13 15:26:53 +00:00
|
|
|
/* File buffer configuration keys. */
|
2005-06-10 15:02:10 +00:00
|
|
|
#define CODEC_SET_FILEBUF_WATERMARK 1
|
|
|
|
#define CODEC_SET_FILEBUF_CHUNKSIZE 2
|
|
|
|
#define CODEC_SET_FILEBUF_LIMIT 3
|
|
|
|
|
|
|
|
/* Not yet implemented. */
|
|
|
|
#define CODEC_SET_AUDIOBUF_WATERMARK 4
|
|
|
|
|
2005-06-14 22:27:57 +00:00
|
|
|
#define MAX_TRACK 10
|
|
|
|
struct track_info {
|
|
|
|
struct mp3entry id3; /* TAG metadata */
|
|
|
|
struct mp3info mp3data; /* MP3 metadata */
|
|
|
|
char *codecbuf; /* Pointer to codec buffer */
|
|
|
|
size_t codecsize; /* Codec length in bytes */
|
|
|
|
|
|
|
|
off_t filerem; /* Remaining bytes of file NOT in buffer */
|
|
|
|
off_t filesize; /* File total length */
|
|
|
|
off_t filepos; /* Read position of file for next buffer fill */
|
|
|
|
off_t start_pos; /* Position to first bytes of file in buffer */
|
|
|
|
volatile int available; /* Available bytes to read from buffer */
|
|
|
|
bool taginfo_ready; /* Is metadata read */
|
|
|
|
int playlist_offset; /* File location in playlist */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Codec Interface */
|
2005-06-05 23:05:10 +00:00
|
|
|
struct codec_api {
|
2005-06-13 15:26:53 +00:00
|
|
|
off_t filesize; /* Total file length */
|
|
|
|
off_t curpos; /* Current buffer position */
|
2005-06-05 23:05:10 +00:00
|
|
|
|
|
|
|
/* For gapless mp3 */
|
2005-06-13 15:26:53 +00:00
|
|
|
struct mp3entry *id3; /* TAG metadata pointer */
|
|
|
|
struct mp3info *mp3data; /* MP3 metadata pointer */
|
|
|
|
bool *taginfo_ready; /* Is metadata read */
|
2005-06-05 23:05:10 +00:00
|
|
|
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Codec should periodically check if stop_codec is set to true.
|
|
|
|
In case it's, codec must return with PLUGIN_OK status immediately. */
|
2005-06-05 23:05:10 +00:00
|
|
|
bool stop_codec;
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Codec should periodically check if reload_codec is set to true.
|
|
|
|
In case it's, codec should reload itself without exiting. */
|
2005-06-05 23:05:10 +00:00
|
|
|
bool reload_codec;
|
2005-06-13 15:26:53 +00:00
|
|
|
/* If seek_time != 0, codec should seek to that song position (in ms)
|
|
|
|
if codec supports seeking. */
|
2005-06-05 23:05:10 +00:00
|
|
|
int seek_time;
|
|
|
|
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Returns buffer to malloc array. Only codeclib should need this. */
|
2005-06-05 23:05:10 +00:00
|
|
|
void* (*get_codec_memory)(size_t *size);
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Insert PCM data into audio buffer for playback. Playback will start
|
|
|
|
automatically. */
|
2005-06-05 23:05:10 +00:00
|
|
|
bool (*audiobuffer_insert)(char *data, size_t length);
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Set song position in WPS (value in ms). */
|
2005-06-05 23:05:10 +00:00
|
|
|
void (*set_elapsed)(unsigned int value);
|
|
|
|
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Read next <size> amount bytes from file buffer to <ptr>.
|
|
|
|
Will return number of bytes read or 0 if end of file. */
|
2005-06-05 23:05:10 +00:00
|
|
|
size_t (*read_filebuf)(void *ptr, size_t size);
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Request pointer to file buffer which can be used to read
|
|
|
|
<realsize> amount of data. <reqsize> tells the buffer system
|
|
|
|
how much data it should try to allocate. If <realsize> is 0,
|
|
|
|
end of file is reached. */
|
2005-06-05 23:05:10 +00:00
|
|
|
void* (*request_buffer)(size_t *realsize, size_t reqsize);
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Advance file buffer position by <amount> amount of bytes. */
|
2005-06-05 23:05:10 +00:00
|
|
|
void (*advance_buffer)(size_t amount);
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Advance file buffer to a pointer location inside file buffer. */
|
2005-06-05 23:05:10 +00:00
|
|
|
void (*advance_buffer_loc)(void *ptr);
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Seek file buffer to position <newpos> beginning of file. */
|
2005-06-05 23:05:10 +00:00
|
|
|
bool (*seek_buffer)(off_t newpos);
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Calculate mp3 seek position from given time data in ms. */
|
2005-06-05 23:05:10 +00:00
|
|
|
off_t (*mp3_get_filepos)(int newtime);
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Request file change from file buffer. Returns true is next
|
|
|
|
track is available and changed. If return value is false,
|
|
|
|
codec should exit immediately with PLUGIN_OK status. */
|
2005-06-05 23:05:10 +00:00
|
|
|
bool (*request_next_track)(void);
|
2005-06-10 15:02:10 +00:00
|
|
|
|
2005-06-13 15:26:53 +00:00
|
|
|
/* Configure different codec buffer parameters. */
|
2005-06-10 15:02:10 +00:00
|
|
|
void (*configure)(int setting, void *value);
|
2005-06-05 23:05:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|