Finally, the archos directory sandbox works in the same way for both X11 and win32 simulators. Unfortunately, this breaks the VC++ compatibility. Also, the plugin API now supports DEBUGF. Last, but not least, we have a new plugin, vbrfix.rock.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4726 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
5fc1b64ae0
commit
a6142ab7ab
21 changed files with 415 additions and 397 deletions
|
@ -21,6 +21,7 @@
|
|||
#include <stdio.h>
|
||||
#include <atoi.h>
|
||||
#include <timefuncs.h>
|
||||
#include "debug.h"
|
||||
#include "button.h"
|
||||
#include "lcd.h"
|
||||
#include "dir.h"
|
||||
|
@ -39,6 +40,7 @@
|
|||
#include "backlight.h"
|
||||
#include "ata.h"
|
||||
#include "talk.h"
|
||||
#include "mp3data.h"
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "widgets.h"
|
||||
|
@ -48,11 +50,10 @@
|
|||
#include <debug.h>
|
||||
#ifdef WIN32
|
||||
#include "plugin-win32.h"
|
||||
#define PREFIX(_x_) _x_
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#define PREFIX(_x_) x11_ ## _x_
|
||||
#endif
|
||||
#define PREFIX(_x_) sim_ ## _x_
|
||||
#else
|
||||
#define PREFIX(_x_) _x_
|
||||
#endif
|
||||
|
@ -213,6 +214,12 @@ static struct plugin_api rockbox_api = {
|
|||
#ifdef HAVE_LCD_BITMAP
|
||||
font_get,
|
||||
#endif
|
||||
#if defined(DEBUG) || defined(SIMULATOR)
|
||||
debugf,
|
||||
#endif
|
||||
mp3info,
|
||||
count_mp3_frames,
|
||||
create_xing_header,
|
||||
};
|
||||
|
||||
int plugin_load(char* plugin, void* parameter)
|
||||
|
@ -246,11 +253,8 @@ int plugin_load(char* plugin, void* parameter)
|
|||
lcd_clear_display();
|
||||
#endif
|
||||
#ifdef SIMULATOR
|
||||
#ifdef WIN32
|
||||
snprintf(path, sizeof path, "%s", plugin);
|
||||
#else
|
||||
snprintf(path, sizeof path, "archos%s", plugin);
|
||||
#endif
|
||||
|
||||
pd = dlopen(path, RTLD_NOW);
|
||||
if (!pd) {
|
||||
snprintf(buf, sizeof buf, "Can't open %s", plugin);
|
||||
|
|
|
@ -45,6 +45,16 @@
|
|||
#include "settings.h"
|
||||
#include "thread.h"
|
||||
|
||||
#ifdef PLUGIN
|
||||
#if defined(DEBUG) || defined(SIMULATOR)
|
||||
#define DEBUGF rb->debugf
|
||||
#define LDEBUGF rb->debugf
|
||||
#else
|
||||
#define DEBUGF(...)
|
||||
#define LDEBUGF(...)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* increase this every time the api struct changes */
|
||||
#define PLUGIN_API_VERSION 14
|
||||
|
||||
|
@ -235,6 +245,16 @@ struct plugin_api {
|
|||
#ifdef HAVE_LCD_BITMAP
|
||||
struct font* (*font_get)(int font);
|
||||
#endif
|
||||
#if defined(DEBUG) || defined(SIMULATOR)
|
||||
void (*debugf)(char *fmt, ...);
|
||||
#endif
|
||||
bool (*mp3info)(struct mp3entry *entry, char *filename) ;
|
||||
int (*count_mp3_frames)(int fd, int startpos, int filesize,
|
||||
void (*progressfunc)(int));
|
||||
int (*create_xing_header)(int fd, int startpos, int filesize,
|
||||
unsigned char *buf, int num_frames,
|
||||
unsigned long header_template,
|
||||
void (*progressfunc)(int), bool generate_toc);
|
||||
};
|
||||
|
||||
/* defined by the plugin loader (plugin.c) */
|
||||
|
|
|
@ -15,7 +15,7 @@ FIRMWARE = ../../firmware
|
|||
INCLUDES = -I$(FIRMWARE)/include -I$(FIRMWARE)/export -I$(FIRMWARE)/common \
|
||||
-I$(FIRMWARE)/drivers -I.. -Ilib
|
||||
CFLAGS = -O -W -Wall -m1 -nostdlib -ffreestanding -Wstrict-prototypes \
|
||||
$(INCLUDES) $(TARGET) $(EXTRA_DEFINES) -DMEM=${MEM}
|
||||
$(INCLUDES) $(TARGET) $(EXTRA_DEFINES) -DMEM=${MEM} -DPLUGIN
|
||||
|
||||
LDS := plugin.lds
|
||||
LINKFILE := $(OBJDIR)/pluginlink.lds
|
||||
|
|
280
apps/plugins/vbrfix.c
Normal file
280
apps/plugins/vbrfix.c
Normal file
|
@ -0,0 +1,280 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2004 Linus Nielsen Feltzing
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
#include "plugin.h"
|
||||
|
||||
static struct plugin_api* rb;
|
||||
|
||||
static char *mp3buf;
|
||||
static int mp3buflen;
|
||||
|
||||
static void xingupdate(int percent)
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
rb->snprintf(buf, 32, "%d%%", percent);
|
||||
rb->lcd_puts(0, 1, buf);
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
rb->lcd_update();
|
||||
#endif
|
||||
}
|
||||
|
||||
static int insert_data_in_file(char *fname, int fpos, char *buf, int num_bytes)
|
||||
{
|
||||
int readlen;
|
||||
int rc;
|
||||
int orig_fd, fd;
|
||||
char tmpname[MAX_PATH];
|
||||
|
||||
rb->snprintf(tmpname, MAX_PATH, "%s.tmp", fname);
|
||||
|
||||
orig_fd = rb->open(fname, O_RDONLY);
|
||||
if(orig_fd < 0) {
|
||||
return 10*orig_fd - 1;
|
||||
}
|
||||
|
||||
fd = rb->creat(tmpname, O_WRONLY);
|
||||
if(fd < 0) {
|
||||
rb->close(orig_fd);
|
||||
return 10*fd - 2;
|
||||
}
|
||||
|
||||
/* First, copy the initial portion (the ID3 tag) */
|
||||
if(fpos) {
|
||||
readlen = rb->read(orig_fd, mp3buf, fpos);
|
||||
if(readlen < 0) {
|
||||
rb->close(fd);
|
||||
rb->close(orig_fd);
|
||||
return 10*readlen - 3;
|
||||
}
|
||||
|
||||
rc = rb->write(fd, mp3buf, readlen);
|
||||
if(rc < 0) {
|
||||
rb->close(fd);
|
||||
rb->close(orig_fd);
|
||||
return 10*rc - 4;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now insert the data into the file */
|
||||
rc = rb->write(fd, buf, num_bytes);
|
||||
if(rc < 0) {
|
||||
rb->close(orig_fd);
|
||||
rb->close(fd);
|
||||
return 10*rc - 5;
|
||||
}
|
||||
|
||||
/* Copy the file */
|
||||
do {
|
||||
readlen = rb->read(orig_fd, mp3buf, mp3buflen);
|
||||
if(readlen < 0) {
|
||||
rb->close(fd);
|
||||
rb->close(orig_fd);
|
||||
return 10*readlen - 7;
|
||||
}
|
||||
|
||||
rc = rb->write(fd, mp3buf, readlen);
|
||||
if(rc < 0) {
|
||||
rb->close(fd);
|
||||
rb->close(orig_fd);
|
||||
return 10*rc - 8;
|
||||
}
|
||||
} while(readlen > 0);
|
||||
|
||||
rb->close(fd);
|
||||
rb->close(orig_fd);
|
||||
|
||||
/* Remove the old file */
|
||||
rc = rb->remove(fname);
|
||||
if(rc < 0) {
|
||||
return 10*rc - 9;
|
||||
}
|
||||
|
||||
/* Replace the old file with the new */
|
||||
rc = rb->rename(tmpname, fname);
|
||||
if(rc < 0) {
|
||||
return 10*rc - 9;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fileerror(int rc)
|
||||
{
|
||||
rb->splash(HZ*2, true, "File error: %d", rc);
|
||||
}
|
||||
|
||||
static const unsigned char empty_id3_header[] =
|
||||
{
|
||||
'I', 'D', '3', 0x04, 0x00, 0x00,
|
||||
0x00, 0x00, 0x1f, 0x76 /* Size is 4096 minus 10 bytes for the header */
|
||||
};
|
||||
|
||||
static bool vbr_fix(char *selected_file)
|
||||
{
|
||||
unsigned char xingbuf[1500];
|
||||
struct mp3entry entry;
|
||||
int fd;
|
||||
int rc;
|
||||
int flen;
|
||||
int num_frames;
|
||||
int numbytes;
|
||||
int framelen;
|
||||
int unused_space;
|
||||
|
||||
rb->lcd_clear_display();
|
||||
rb->lcd_puts_scroll(0, 0, selected_file);
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
rb->lcd_update();
|
||||
#endif
|
||||
|
||||
xingupdate(0);
|
||||
|
||||
rc = rb->mp3info(&entry, selected_file);
|
||||
if(rc < 0) {
|
||||
fileerror(rc);
|
||||
return true;
|
||||
}
|
||||
|
||||
fd = rb->open(selected_file, O_RDWR);
|
||||
if(fd < 0) {
|
||||
fileerror(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
flen = rb->lseek(fd, 0, SEEK_END);
|
||||
|
||||
xingupdate(0);
|
||||
|
||||
num_frames = rb->count_mp3_frames(fd, entry.first_frame_offset,
|
||||
flen, xingupdate);
|
||||
|
||||
if(num_frames) {
|
||||
/* Note: We don't need to pass a template header because it will be
|
||||
taken from the mpeg stream */
|
||||
framelen = rb->create_xing_header(fd, entry.first_frame_offset,
|
||||
flen, xingbuf, num_frames,
|
||||
0, xingupdate, true);
|
||||
|
||||
/* Try to fit the Xing header first in the stream. Replace the existing
|
||||
VBR header if there is one, else see if there is room between the
|
||||
ID3 tag and the first MP3 frame. */
|
||||
if(entry.first_frame_offset - entry.id3v2len >=
|
||||
(unsigned int)framelen) {
|
||||
DEBUGF("Using existing space between ID3 and first frame\n");
|
||||
|
||||
/* Seek to the beginning of the unused space */
|
||||
rc = rb->lseek(fd, entry.id3v2len, SEEK_SET);
|
||||
if(rc < 0) {
|
||||
rb->close(fd);
|
||||
fileerror(rc);
|
||||
return true;
|
||||
}
|
||||
|
||||
unused_space =
|
||||
entry.first_frame_offset - entry.id3v2len - framelen;
|
||||
|
||||
/* Fill the unused space with 0's (using the MP3 buffer)
|
||||
and write it to the file */
|
||||
if(unused_space)
|
||||
{
|
||||
rb->memset(mp3buf, 0, unused_space);
|
||||
rc = rb->write(fd, mp3buf, unused_space);
|
||||
if(rc < 0) {
|
||||
rb->close(fd);
|
||||
fileerror(rc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Then write the Xing header */
|
||||
rc = rb->write(fd, xingbuf, framelen);
|
||||
if(rc < 0) {
|
||||
rb->close(fd);
|
||||
fileerror(rc);
|
||||
return true;
|
||||
}
|
||||
|
||||
rb->close(fd);
|
||||
} else {
|
||||
/* If not, insert some space. If there is an ID3 tag in the
|
||||
file we only insert just enough to squeeze the Xing header
|
||||
in. If not, we insert an additional empty ID3 tag of 4K. */
|
||||
|
||||
rb->close(fd);
|
||||
|
||||
/* Nasty trick alert! The insert_data_in_file() function
|
||||
uses the MP3 buffer when copying the data. We assume
|
||||
that the ID3 tag isn't longer than 1MB so the xing
|
||||
buffer won't be overwritten. */
|
||||
|
||||
if(entry.first_frame_offset) {
|
||||
DEBUGF("Inserting %d bytes\n", framelen);
|
||||
numbytes = framelen;
|
||||
} else {
|
||||
DEBUGF("Inserting 4096+%d bytes\n", framelen);
|
||||
numbytes = 4096 + framelen;
|
||||
|
||||
rb->memset(mp3buf + 0x100000, 0, numbytes);
|
||||
|
||||
/* Insert the ID3 header */
|
||||
rb->memcpy(mp3buf + 0x100000, empty_id3_header,
|
||||
sizeof(empty_id3_header));
|
||||
}
|
||||
|
||||
/* Copy the Xing header */
|
||||
rb->memcpy(mp3buf + 0x100000 + numbytes - framelen,
|
||||
xingbuf, framelen);
|
||||
|
||||
rc = insert_data_in_file(selected_file,
|
||||
entry.first_frame_offset,
|
||||
mp3buf + 0x100000, numbytes);
|
||||
|
||||
if(rc < 0) {
|
||||
fileerror(rc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
xingupdate(100);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Not a VBR file */
|
||||
DEBUGF("Not a VBR file\n");
|
||||
rb->splash(HZ*2, true, "Not a VBR file");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
enum plugin_status plugin_start(struct plugin_api* api, void *parameter)
|
||||
{
|
||||
TEST_PLUGIN_API(api);
|
||||
|
||||
rb = api;
|
||||
|
||||
if (!parameter)
|
||||
return PLUGIN_ERROR;
|
||||
|
||||
mp3buf = rb->plugin_get_mp3_buffer(&mp3buflen);
|
||||
|
||||
vbr_fix(parameter);
|
||||
|
||||
return PLUGIN_OK;
|
||||
}
|
|
@ -3,3 +3,4 @@ txt,viewer.rock,55 55 55 55 55 55
|
|||
jpg,jpeg.rock,18 24 3C 3C 24 18
|
||||
ucl,rockbox_flash.rock,2A 7F 41 41 7F 2A
|
||||
rvf,video.rock,5D 7F 5D 7F 5D 7F
|
||||
mp3,vbrfix.rock,10 08 58 38 04 02
|
||||
|
|
|
@ -75,18 +75,6 @@ typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
|
|||
typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
|
||||
int(*_compar)(const void *, const void *));
|
||||
|
||||
|
||||
#if defined(__MINGW32__) && defined(SIMULATOR)
|
||||
extern int open(const char*, int flags, ...);
|
||||
extern int close(int fd);
|
||||
extern int read(int, void*, unsigned int);
|
||||
extern long lseek(int, long, int);
|
||||
extern int creat(const char *, int);
|
||||
extern int write(int, const void*, unsigned int);
|
||||
extern int remove(const char*);
|
||||
|
||||
#else
|
||||
|
||||
#ifndef SIMULATOR
|
||||
extern int open(const char* pathname, int flags);
|
||||
extern int close(int fd);
|
||||
|
@ -100,6 +88,5 @@ extern int rename(const char* path, const char* newname);
|
|||
extern int ftruncate(int fd, off_t length);
|
||||
extern int filesize(int fd);
|
||||
#endif /* SIMULATOR */
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,35 +16,30 @@
|
|||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _X11_DIR_H_
|
||||
#define _X11_DIR_H_
|
||||
#ifndef _SIM_DIR_H_
|
||||
#define _SIM_DIR_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
typedef void DIR;
|
||||
|
||||
#define DIRFUNCTIONS_DEFINED /* prevent those prototypes */
|
||||
#define dirent x11_dirent
|
||||
#define dirent sim_dirent
|
||||
#include "../../firmware/include/dir.h"
|
||||
#undef dirent
|
||||
|
||||
typedef void * MYDIR;
|
||||
|
||||
extern MYDIR *x11_opendir(const char *name);
|
||||
extern struct x11_dirent* x11_readdir(MYDIR* dir);
|
||||
extern int x11_closedir(MYDIR *dir);
|
||||
extern int x11_mkdir(char *name, int mode);
|
||||
extern int x11_rmdir(char *name);
|
||||
|
||||
#ifndef NO_REDEFINES_PLEASE
|
||||
extern MYDIR *sim_opendir(const char *name);
|
||||
extern struct sim_dirent* sim_readdir(MYDIR* dir);
|
||||
extern int sim_closedir(MYDIR *dir);
|
||||
extern int sim_mkdir(char *name, int mode);
|
||||
extern int sim_rmdir(char *name);
|
||||
|
||||
#define DIR MYDIR
|
||||
#define dirent x11_dirent
|
||||
#define opendir(x) x11_opendir(x)
|
||||
#define readdir(x) x11_readdir(x)
|
||||
#define closedir(x) x11_closedir(x)
|
||||
#define mkdir(x, y) x11_mkdir(x, y)
|
||||
#define rmdir(x) x11_rmdir(x)
|
||||
|
||||
#endif
|
||||
#define dirent sim_dirent
|
||||
#define opendir(x) sim_opendir(x)
|
||||
#define readdir(x) sim_readdir(x)
|
||||
#define closedir(x) sim_closedir(x)
|
||||
#define mkdir(x, y) sim_mkdir(x, y)
|
||||
#define rmdir(x) sim_rmdir(x)
|
||||
|
||||
#endif
|
|
@ -17,30 +17,46 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ROCKBOX_FILE_H
|
||||
#define ROCKBOX_FILE_H
|
||||
#ifndef _SIM_FILE_H_
|
||||
#define _SIM_FILE_H_
|
||||
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
int x11_open(const char *name, int opts);
|
||||
int x11_close(int fd);
|
||||
int x11_filesize(int fd);
|
||||
int x11_creat(const char *name, mode_t mode);
|
||||
int x11_remove(char *name);
|
||||
int x11_rename(char *oldpath, char *newpath);
|
||||
#ifdef WIN32
|
||||
#ifndef _commit
|
||||
extern int _commit( int handle );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int sim_open(const char *name, int opts);
|
||||
int sim_close(int fd);
|
||||
int sim_rename(const char *oldpath, const char *newpath);
|
||||
int sim_filesize(int fd);
|
||||
int sim_creat(const char *name, mode_t mode);
|
||||
int sim_remove(const char *name);
|
||||
|
||||
#ifndef NO_REDEFINES_PLEASE
|
||||
#define open(x,y) x11_open(x,y)
|
||||
#define close(x) x11_close(x)
|
||||
#define filesize(x) x11_filesize(x)
|
||||
#define creat(x,y) x11_creat(x,y)
|
||||
#define remove(x) x11_remove(x)
|
||||
#define rename(x,y) x11_rename(x,y)
|
||||
#define open(x,y) sim_open(x,y)
|
||||
#define close(x) sim_close(x)
|
||||
#define filesize(x) sim_filesize(x)
|
||||
#define creat(x,y) sim_creat(x,y)
|
||||
#define remove(x) sim_remove(x)
|
||||
#define rename(x,y) sim_rename(x,y)
|
||||
#ifdef WIN32
|
||||
#define fsync _commit
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "../../firmware/include/file.h"
|
||||
|
||||
#ifndef WIN32
|
||||
int open(const char* pathname, int flags);
|
||||
int close(int fd);
|
||||
int printf(const char *format, ...);
|
||||
|
@ -50,5 +66,6 @@ int fsync(int fd);
|
|||
off_t lseek(int fildes, off_t offset, int whence);
|
||||
ssize_t read(int fd, void *buf, size_t count);
|
||||
ssize_t write(int fd, const void *buf, size_t count);
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -24,7 +24,7 @@
|
|||
#ifdef __FreeBSD__
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#else
|
||||
#elif !defined(WIN32)
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
|
@ -34,9 +34,11 @@
|
|||
#include "debug.h"
|
||||
|
||||
#define DIRFUNCTIONS_DEFINED /* prevent those prototypes */
|
||||
#define dirent x11_dirent
|
||||
#define dirent sim_dirent
|
||||
#define DIR SIMDIR
|
||||
#include "../../firmware/include/dir.h"
|
||||
#undef dirent
|
||||
#undef DIR
|
||||
|
||||
#define SIMULATOR_ARCHOS_ROOT "archos"
|
||||
|
||||
|
@ -47,7 +49,7 @@ struct mydir {
|
|||
|
||||
typedef struct mydir MYDIR;
|
||||
|
||||
MYDIR *x11_opendir(const char *name)
|
||||
MYDIR *sim_opendir(const char *name)
|
||||
{
|
||||
char buffer[256]; /* sufficiently big */
|
||||
DIR *dir;
|
||||
|
@ -70,15 +72,15 @@ MYDIR *x11_opendir(const char *name)
|
|||
return (MYDIR *)0;
|
||||
}
|
||||
|
||||
struct x11_dirent *x11_readdir(MYDIR *dir)
|
||||
struct sim_dirent *sim_readdir(MYDIR *dir)
|
||||
{
|
||||
char buffer[512]; /* sufficiently big */
|
||||
static struct x11_dirent secret;
|
||||
static struct sim_dirent secret;
|
||||
struct stat s;
|
||||
struct dirent *x11 = (readdir)(dir->dir);
|
||||
|
||||
if(!x11)
|
||||
return (struct x11_dirent *)0;
|
||||
return (struct sim_dirent *)0;
|
||||
|
||||
strcpy(secret.d_name, x11->d_name);
|
||||
|
||||
|
@ -93,7 +95,7 @@ struct x11_dirent *x11_readdir(MYDIR *dir)
|
|||
return &secret;
|
||||
}
|
||||
|
||||
void x11_closedir(MYDIR *dir)
|
||||
void sim_closedir(MYDIR *dir)
|
||||
{
|
||||
free(dir->name);
|
||||
(closedir)(dir->dir);
|
||||
|
@ -102,7 +104,7 @@ void x11_closedir(MYDIR *dir)
|
|||
}
|
||||
|
||||
|
||||
int x11_open(const char *name, int opts)
|
||||
int sim_open(const char *name, int opts)
|
||||
{
|
||||
char buffer[256]; /* sufficiently big */
|
||||
|
||||
|
@ -115,12 +117,12 @@ int x11_open(const char *name, int opts)
|
|||
return (open)(name, opts);
|
||||
}
|
||||
|
||||
int x11_close(int fd)
|
||||
int sim_close(int fd)
|
||||
{
|
||||
return (close)(fd);
|
||||
}
|
||||
|
||||
int x11_creat(const char *name, mode_t mode)
|
||||
int sim_creat(const char *name, mode_t mode)
|
||||
{
|
||||
char buffer[256]; /* sufficiently big */
|
||||
(void)mode;
|
||||
|
@ -133,20 +135,22 @@ int x11_creat(const char *name, mode_t mode)
|
|||
return (creat)(name, 0666);
|
||||
}
|
||||
|
||||
int x11_mkdir(const char *name, mode_t mode)
|
||||
int sim_mkdir(const char *name, mode_t mode)
|
||||
{
|
||||
char buffer[256]; /* sufficiently big */
|
||||
(void)mode;
|
||||
if(name[0] == '/') {
|
||||
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
|
||||
|
||||
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
|
||||
|
||||
debugf("We create the real directory '%s'\n", buffer);
|
||||
return (mkdir)(buffer, 0666);
|
||||
}
|
||||
return (mkdir)(name, 0666);
|
||||
debugf("We create the real directory '%s'\n", buffer);
|
||||
#ifdef WIN32
|
||||
return (mkdir)(buffer);
|
||||
#else
|
||||
return (mkdir)(buffer, 0666);
|
||||
#endif
|
||||
}
|
||||
|
||||
int x11_rmdir(const char *name)
|
||||
int sim_rmdir(const char *name)
|
||||
{
|
||||
char buffer[256]; /* sufficiently big */
|
||||
if(name[0] == '/') {
|
||||
|
@ -158,7 +162,7 @@ int x11_rmdir(const char *name)
|
|||
return (rmdir)(name);
|
||||
}
|
||||
|
||||
int x11_remove(char *name)
|
||||
int sim_remove(const char *name)
|
||||
{
|
||||
char buffer[256]; /* sufficiently big */
|
||||
|
||||
|
@ -171,7 +175,7 @@ int x11_remove(char *name)
|
|||
return (remove)(name);
|
||||
}
|
||||
|
||||
int x11_rename(char *oldpath, char* newpath)
|
||||
int sim_rename(const char *oldpath, const char* newpath)
|
||||
{
|
||||
char buffer1[256];
|
||||
char buffer2[256];
|
||||
|
@ -186,7 +190,7 @@ int x11_rename(char *oldpath, char* newpath)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int x11_filesize(int fd)
|
||||
int sim_filesize(int fd)
|
||||
{
|
||||
int old = lseek(fd, 0, SEEK_CUR);
|
||||
int size = lseek(fd, 0, SEEK_END);
|
||||
|
@ -197,6 +201,10 @@ int x11_filesize(int fd)
|
|||
|
||||
void fat_size(unsigned int* size, unsigned int* free)
|
||||
{
|
||||
#ifdef WIN32
|
||||
*size = 2049;
|
||||
*free = 1037;
|
||||
#else
|
||||
struct statfs fs;
|
||||
|
||||
if (!statfs(".", &fs)) {
|
||||
|
@ -213,4 +221,5 @@ void fat_size(unsigned int* size, unsigned int* free)
|
|||
if (free)
|
||||
*free = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -96,6 +96,8 @@ ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP)
|
|||
else
|
||||
LCDSRSC = lcd-playersim.c lcd-player.c lcd-player-charset.c font-player.c
|
||||
endif
|
||||
COMMONSRCS = io.c
|
||||
|
||||
FIRMSRCS = $(LCDSRSC) id3.c mp3data.c usb.c mpeg.c mp3_playback.c \
|
||||
powermgmt.c power.c sprintf.c buffer.c lcd-common.c strtok.c random.c \
|
||||
timefuncs.c
|
||||
|
@ -111,9 +113,9 @@ ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP)
|
|||
APPS += bmp.c widgets.c
|
||||
endif
|
||||
|
||||
SRCS = button.c dir-win32.c lcd-win32.c panic-win32.c thread-win32.c \
|
||||
SRCS = button.c lcd-win32.c panic-win32.c thread-win32.c \
|
||||
debug-win32.c kernel.c string-win32.c uisw32.c stubs.c \
|
||||
$(APPS) $(MENUS) $(FIRMSRCS) sim_icons.c io.c
|
||||
$(APPS) $(MENUS) $(FIRMSRCS) $(COMMONSRCS) sim_icons.c
|
||||
|
||||
OBJS := $(OBJDIR)/lang.o $(SRCS:%.c=$(OBJDIR)/%.o) $(OBJDIR)/uisw32-res.o
|
||||
|
||||
|
@ -303,6 +305,9 @@ $(OBJDIR)/font-player.o: $(SIMCOMMON)/font-player.c
|
|||
$(OBJDIR)/sim_icons.o: $(SIMCOMMON)/sim_icons.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/io.o: $(SIMCOMMON)/io.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/lcd-playersim.o: $(SIMCOMMON)/lcd-playersim.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
|
@ -315,7 +320,7 @@ $(OBJDIR)/%.o: %.c
|
|||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/%.po : $(PLUGINDIR)/%.c
|
||||
$(CC) $(APPCFLAGS) -c $< -o $@
|
||||
$(CC) $(APPCFLAGS) -DPLUGIN -c $< -o $@
|
||||
|
||||
$(OBJDIR)/%.rock : $(OBJDIR)/%.po
|
||||
$(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $<
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 by Felix Arends
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <io.h>
|
||||
#include <windows.h>
|
||||
#include <malloc.h>
|
||||
#include "dir-win32.h"
|
||||
|
||||
// Directory operations
|
||||
//
|
||||
|
||||
// opendir
|
||||
// open directory for scanning
|
||||
DIR *opendir (
|
||||
const char *dirname // directory name
|
||||
)
|
||||
{
|
||||
DIR *p = (DIR*)malloc(sizeof(DIR));
|
||||
struct _finddata_t fd;
|
||||
unsigned int i;
|
||||
char *s = (char*)malloc(strlen(dirname) + 5);
|
||||
wsprintf (s, "%s", dirname);
|
||||
|
||||
for (i = 0; i < strlen(s); i++)
|
||||
if (s[i] == '/')
|
||||
s[i] = '\\';
|
||||
|
||||
if (s[i - 1] != '\\')
|
||||
{
|
||||
s[i] = '\\';
|
||||
s[++i] = '\0';
|
||||
}
|
||||
|
||||
OutputDebugString (s);
|
||||
|
||||
wsprintf (s, "%s*.*", s);
|
||||
|
||||
if ((p->handle = _findfirst (s, &fd)) == -1)
|
||||
{
|
||||
free (s);
|
||||
free (p);
|
||||
return 0;
|
||||
}
|
||||
free (s);
|
||||
return p;
|
||||
}
|
||||
|
||||
// closedir
|
||||
// close directory
|
||||
int closedir (
|
||||
DIR *dir // previously opened dir search
|
||||
)
|
||||
{
|
||||
free(dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// read dir
|
||||
// read next entry in directory
|
||||
struct dirent *readdir (
|
||||
DIR *dir
|
||||
)
|
||||
{
|
||||
struct _finddata_t fd;
|
||||
if (_findnext (dir->handle, &fd) == -1)
|
||||
return 0;
|
||||
memcpy (dir->fd.d_name, fd.name, 256);
|
||||
|
||||
dir->fd.attribute = fd.attrib & 0x3f;
|
||||
dir->fd.size = fd.size;
|
||||
dir->fd.startcluster = 0 ;
|
||||
|
||||
|
||||
return &dir->fd;
|
||||
}
|
||||
|
||||
void fat_size(unsigned int* size, unsigned int* free)
|
||||
{
|
||||
*size = 2049;
|
||||
*free = 1037;
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 by Felix Arends
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __DIR_WIN32_H__
|
||||
#define __DIR_WIN32_H__
|
||||
|
||||
#include <io.h>
|
||||
#include "../../firmware/include/dir.h"
|
||||
|
||||
#endif // #ifndef __DIR_WIN32_H__
|
|
@ -1,82 +0,0 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 by Björn Stenberg
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef _DIR_H_
|
||||
#define _DIR_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "file.h"
|
||||
|
||||
#ifndef DIRENT_DEFINED
|
||||
|
||||
#define ATTR_READ_ONLY 0x01
|
||||
#define ATTR_HIDDEN 0x02
|
||||
#define ATTR_SYSTEM 0x04
|
||||
#define ATTR_VOLUME_ID 0x08
|
||||
#define ATTR_DIRECTORY 0x10
|
||||
#define ATTR_ARCHIVE 0x20
|
||||
|
||||
struct dirent {
|
||||
unsigned char d_name[MAX_PATH];
|
||||
int attribute;
|
||||
int size;
|
||||
int startcluster;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
#include "fat.h"
|
||||
|
||||
typedef struct {
|
||||
bool busy;
|
||||
int startcluster;
|
||||
struct fat_dir fatdir;
|
||||
struct dirent theent;
|
||||
} DIR;
|
||||
|
||||
#else // SIMULATOR
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef __MINGW32__
|
||||
#include <io.h>
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
typedef struct DIRtag
|
||||
{
|
||||
struct dirent fd;
|
||||
int handle;
|
||||
} DIR;
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
#endif // SIMULATOR
|
||||
|
||||
#ifndef DIRFUNCTIONS_DEFINED
|
||||
|
||||
extern DIR* opendir(const char* name);
|
||||
extern int closedir(DIR* dir);
|
||||
extern int mkdir(const char* name, int mode);
|
||||
extern int rmdir(const char* name);
|
||||
|
||||
extern struct dirent* readdir(DIR* dir);
|
||||
|
||||
#endif /* DIRFUNCTIONS_DEFINED */
|
||||
|
||||
#endif
|
|
@ -1,43 +0,0 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 by Daniel Stenberg <daniel@haxx.se>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _FILE_H_
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#ifndef _commit
|
||||
extern int _commit( int handle );
|
||||
#endif
|
||||
|
||||
int win32_rename(char *oldpath, char *newpath);
|
||||
int win32_filesize(int fd);
|
||||
|
||||
#define rename win32_rename
|
||||
#define filesize win32_filesize
|
||||
#define fsync _commit
|
||||
|
||||
#include "../../firmware/include/file.h"
|
||||
|
||||
#undef rename
|
||||
#define mkdir(x,y) win32_mkdir(x,y)
|
||||
|
||||
#endif
|
|
@ -1,63 +0,0 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 Daniel Stenberg
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "file.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define SIMULATOR_ARCHOS_ROOT "archos"
|
||||
|
||||
int win32_rename(char *oldpath, char* newpath)
|
||||
{
|
||||
char buffer1[256];
|
||||
char buffer2[256];
|
||||
|
||||
if(oldpath[0] == '/') {
|
||||
sprintf(buffer1, "%s%s", SIMULATOR_ARCHOS_ROOT, oldpath);
|
||||
sprintf(buffer2, "%s%s", SIMULATOR_ARCHOS_ROOT, newpath);
|
||||
|
||||
debugf("We rename the real file '%s' to '%s'\n", buffer1, buffer2);
|
||||
return rename(buffer1, buffer2);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int win32_filesize(int fd)
|
||||
{
|
||||
int old = lseek(fd, 0, SEEK_CUR);
|
||||
int size = lseek(fd, 0, SEEK_END);
|
||||
lseek(fd, old, SEEK_SET);
|
||||
|
||||
return(size);
|
||||
}
|
||||
|
||||
extern int (mkdir)(const char *name);
|
||||
|
||||
int win32_mkdir(const char *name, int mode)
|
||||
{
|
||||
char buffer[256]; /* sufficiently big */
|
||||
(void)mode;
|
||||
if(name[0] == '/') {
|
||||
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
|
||||
|
||||
debugf("We create the real directory '%s'\n", buffer);
|
||||
return (mkdir)(buffer);
|
||||
}
|
||||
return (mkdir)(name);
|
||||
}
|
|
@ -34,7 +34,7 @@ int set_irq_level (int level)
|
|||
return (_lv = level);
|
||||
}
|
||||
|
||||
void sleep(int ticks)
|
||||
void sim_sleep(int ticks)
|
||||
{
|
||||
Sleep (1000 / HZ * ticks);
|
||||
}
|
||||
|
|
|
@ -18,3 +18,9 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "../../firmware/export/kernel.h"
|
||||
|
||||
#ifndef NO_REDEFINES_PLEASE
|
||||
#define sleep(x) sim_sleep(x)
|
||||
#endif
|
||||
|
||||
void sim_sleep(int);
|
||||
|
|
|
@ -96,6 +96,8 @@ ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP)
|
|||
else
|
||||
LCDSRSC = lcd-playersim.c lcd-player.c font-player.c lcd-player-charset.c
|
||||
endif
|
||||
COMMONSRCS = io.c
|
||||
|
||||
FIRMSRCS = $(LCDSRSC) id3.c debug.c usb.c mpeg.c mp3_playback.c power.c\
|
||||
powermgmt.c panic.c mp3data.c sprintf.c buffer.c timefuncs.c
|
||||
|
||||
|
@ -111,8 +113,8 @@ ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP)
|
|||
endif
|
||||
|
||||
SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c stubs.c \
|
||||
button-x11.c io.c thread.c sim_icons.c $(APPS) $(MENUS) $(FIRMSRCS) \
|
||||
lcd-common.c
|
||||
button-x11.c thread.c sim_icons.c $(APPS) $(MENUS) $(FIRMSRCS) \
|
||||
$(COMMONSRCS) lcd-common.c
|
||||
|
||||
ROCKSRC := $(wildcard $(APPDIR)/plugins/*.c)
|
||||
ROCKS := $(ROCKSRC:$(APPDIR)/plugins/%.c=$(OBJDIR)/%.rock)
|
||||
|
@ -276,6 +278,9 @@ $(OBJDIR)/stubs.o: $(SIMCOMMON)/stubs.c
|
|||
$(OBJDIR)/sim_icons.o: $(SIMCOMMON)/sim_icons.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/io.o: $(SIMCOMMON)/io.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(OBJDIR)/usb.o: $(FIRMWAREDIR)/usb.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ int button_get_w_tmo(int ticks)
|
|||
for(i=0; i< ticks; i++) {
|
||||
bits = get_raw_button();
|
||||
if(!bits)
|
||||
x11_sleep(1);
|
||||
sim_sleep(1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
@ -193,14 +193,14 @@ int button_get(bool block)
|
|||
do {
|
||||
bits = get_raw_button();
|
||||
if(block && !bits)
|
||||
x11_sleep(HZ/10);
|
||||
sim_sleep(HZ/10);
|
||||
else
|
||||
break;
|
||||
} while(1);
|
||||
|
||||
if(!block)
|
||||
/* delay a bit */
|
||||
x11_sleep(1);
|
||||
sim_sleep(1);
|
||||
|
||||
return bits;
|
||||
}
|
||||
|
|
|
@ -21,11 +21,11 @@
|
|||
|
||||
#ifndef NO_REDEFINES_PLEASE
|
||||
|
||||
#define sleep(x) x11_sleep(x)
|
||||
#define sleep(x) sim_sleep(x)
|
||||
#define mutex_init(x) (void)x
|
||||
#define mutex_lock(x) (void)x
|
||||
#define mutex_unlock(x) (void)x
|
||||
|
||||
#endif
|
||||
|
||||
void x11_sleep(int);
|
||||
void sim_sleep(int);
|
||||
|
|
|
@ -85,7 +85,7 @@ int create_thread(void* fp, void* sp, int stk_size)
|
|||
}
|
||||
|
||||
/* ticks is HZ per second */
|
||||
void x11_sleep(int ticks)
|
||||
void sim_sleep(int ticks)
|
||||
{
|
||||
current_tick+=5;
|
||||
pthread_mutex_unlock(&mp); /* return */
|
||||
|
|
Loading…
Reference in a new issue