/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2007 Dave Chapman
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "plugin.h"
PLUGIN_HEADER
/* All swcodec targets have BUTTON_SELECT apart from the H10 and M3 */
#if CONFIG_KEYPAD == IRIVER_H10_PAD
#define TESTCODEC_EXITBUTTON BUTTON_RIGHT
#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
#define TESTCODEC_EXITBUTTON BUTTON_RC_PLAY
#elif CONFIG_KEYPAD == COWOND2_PAD || CONFIG_KEYPAD == ONDAVX747_PAD
#define TESTCODEC_EXITBUTTON BUTTON_POWER
#else
#define TESTCODEC_EXITBUTTON BUTTON_SELECT
#endif
/* Log functions copied from test_disk.c */
static int line = 0;
static int max_line = 0;
static int log_fd = -1;
static char logfilename[MAX_PATH];
static bool log_init(bool use_logfile)
{
int h;
rb->lcd_getstringsize("A", NULL, &h);
max_line = LCD_HEIGHT / h;
line = 0;
rb->lcd_clear_display();
rb->lcd_update();
if (use_logfile) {
rb->create_numbered_filename(logfilename, "/", "test_codec_log_", ".txt",
2 IF_CNFN_NUM_(, NULL));
log_fd = rb->open(logfilename, O_RDWR|O_CREAT|O_TRUNC);
return log_fd >= 0;
}
return true;
}
static void log_text(char *text, bool advance)
{
rb->lcd_puts(0, line, text);
rb->lcd_update();
if (advance)
{
if (++line >= max_line)
line = 0;
if (log_fd >= 0)
rb->fdprintf(log_fd, "%s\n", text);
}
}
static void log_close(void)
{
if (log_fd >= 0)
rb->close(log_fd);
}
struct wavinfo_t
{
int fd;
int samplerate;
int channels;
int sampledepth;
int stereomode;
int totalsamples;
};
static void* audiobuf;
static void* codec_mallocbuf;
static size_t audiosize;
static char str[MAX_PATH];
/* Our local implementation of the codec API */
static struct codec_api ci;
struct test_track_info {
struct mp3entry id3; /* TAG metadata */
size_t filesize; /* File total length */
};
static struct test_track_info track;
static bool taginfo_ready = true;
static volatile unsigned int elapsed;
static volatile bool codec_playing;
static volatile long endtick;
struct wavinfo_t wavinfo;
|