1
0
Fork 0
forked from len0rd/rockbox

Changed debug to DEBUGF and panic to panicf.

Also some linking changes.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@383 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2002-05-02 14:05:51 +00:00
parent bca0f0f5ea
commit 697dd70ac4
10 changed files with 123 additions and 129 deletions

View file

@ -20,15 +20,11 @@ TARGET = -DARCHOS_PLAYER=1
#TARGET = -DARCHOS_PLAYER_OLD=1 #TARGET = -DARCHOS_PLAYER_OLD=1
#TARGET = -DARCHOS_RECORDER=1 #TARGET = -DARCHOS_RECORDER=1
CFLAGS = -Os -Wall -m1 -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns $(INCLUDES) $(TARGET) CFLAGS = -Os -Wall -m1 -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns $(INCLUDES) $(TARGET) -DDEBUG
AFLAGS += -small -relax AFLAGS += -small -relax
SRC := $(wildcard drivers/*.c common/*.c *.c) SRC := $(wildcard drivers/*.c common/*.c *.c)
OBJS := $(SRC:%.c=%.o) OBJS := $(SRC:%.c=%.o) crt0.o
%.o: %.s
$(CC) -o $@ $(CFLAGS) $(INCLUDES) $(DEFS) -c $<
all : archos.mod # archos.asm all : archos.mod # archos.asm

View file

@ -1,4 +1,4 @@
ENTRY(_start) ENTRY(start)
OUTPUT_FORMAT(elf32-sh) OUTPUT_FORMAT(elf32-sh)
SECTIONS SECTIONS
{ {
@ -6,14 +6,28 @@ SECTIONS
{ {
*(.vectors); *(.vectors);
. = ALIGN(0x200); . = ALIGN(0x200);
*(.text.start) *(.init.text)
*(.text)
*(.rodata)
} }
.text :
{
*(.text)
}
.data :
{
*(.data)
}
.rodata :
{
*(.rodata)
}
.bss : .bss :
{ {
_end = .;
_stack = . + 0x1000; _stack = . + 0x1000;
_edata = .;
} }
.pad 0x0900C800 : .pad 0x0900C800 :

View file

@ -167,7 +167,7 @@ static char *mem2hex (char *mem, char *buf, int count)
return (buf); return (buf);
} }
void debug(char *msg) static void debug(char *msg)
{ {
debugbuf[0] = 'O'; debugbuf[0] = 'O';
@ -177,29 +177,27 @@ void debug(char *msg)
void debugf(char *fmt, ...) void debugf(char *fmt, ...)
{ {
#ifdef DEBUG
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
vsnprintf(debugmembuf, sizeof(debugmembuf), fmt, ap); vsnprintf(debugmembuf, sizeof(debugmembuf), fmt, ap);
va_end(ap); va_end(ap);
debug(debugmembuf); debug(debugmembuf);
#endif
} }
#else #else
void debug( const char *message )
{
printf( message );
}
void debugf(char *fmt, ...) void debugf(char *fmt, ...)
{ {
#ifdef DEBUG
va_list ap; va_list ap;
va_start( ap, fmt ); va_start( ap, fmt );
vsnprintf( debugmembuf, sizeof(debugmembuf), fmt, ap ); vsnprintf( debugmembuf, sizeof(debugmembuf), fmt, ap );
va_end( ap ); va_end( ap );
printf( debugmembuf ); printf( debugmembuf );
#endif
} }
#endif #endif

View file

@ -19,7 +19,23 @@
#ifndef DEBUG_H #ifndef DEBUG_H
#define DEBUG_H #define DEBUG_H
void debug(char *msg); extern void debugf(char* fmt,...);
void debugf(char *fmt, ...);
#ifdef __GNUC__
/* GCC handles ellipses in macros, which
means we can avoid the call completely */
#ifdef DEBUG
#define DEBUGF(fmt,args...) debugf(fmt, ## args)
#else
#define DEBUGF(fmt,args...)
#endif
#else
void DEBUGF debugf
#endif /* GCC */
#endif #endif

View file

@ -25,13 +25,11 @@
void read_file_into_buffer( char **buf, const char *filename ) void read_file_into_buffer( char **buf, const char *filename )
{ {
/*char debug_message[128]; */
int i; int i;
FILE *fp; FILE *fp;
int count = 0; int count = 0;
/*sprintf( debug_message, "read_file_into_buffer( %s, %s )\n", *buf, filename ); /*DEBUG( "read_file_into_buffer( %s, %s )\n", *buf, filename ); */
debug( debug_message );*/
fp = fopen( filename, "r" ); fp = fopen( filename, "r" );

View file

@ -27,6 +27,7 @@
#include "fat.h" #include "fat.h"
#include "ata.h" #include "ata.h"
#include "debug.h"
#define BYTES2INT16(array,pos) \ #define BYTES2INT16(array,pos) \
(array[pos] | (array[pos+1] << 8 )) (array[pos] | (array[pos+1] << 8 ))
@ -134,12 +135,6 @@ static unsigned char lastsector2[SECTOR_SIZE];
#ifdef TEST_FAT #ifdef TEST_FAT
#include "debug.h"
#define DEBUG(x) printf(x)
#define DEBUG1(x,y) printf(x,y)
#define DEBUG2(x,y1,y2) printf(x,y1,y2)
#define DEBUG3(x,y1,y2,y3) printf(x,y1,y2,y3)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
struct bpb bpb; struct bpb bpb;
@ -148,25 +143,20 @@ int main(int argc, char *argv[])
memset(fat_cache_dirty, 0, sizeof(fat_cache_dirty)); memset(fat_cache_dirty, 0, sizeof(fat_cache_dirty));
if(ata_init()) if(ata_init())
DEBUG("*** Warning! The disk is uninitialized\n"); DEBUGF("*** Warning! The disk is uninitialized\n");
else else
fat_mount(&bpb); fat_mount(&bpb);
dbg_console(&bpb); dbg_console(&bpb);
return 0; return 0;
} }
#else
#define DEBUG(x);
#define DEBUG1(x,y);
#define DEBUG2(x,y1,y2);
#define DEBUG3(x,y1,y2,y3);
#endif #endif
static int sec2cluster(struct bpb *bpb, unsigned int sec) static int sec2cluster(struct bpb *bpb, unsigned int sec)
{ {
if ( sec < bpb->firstdatasector ) if ( sec < bpb->firstdatasector )
{ {
DEBUG1( "sec2cluster() - Bad sector number (%d)\n", sec); DEBUGF( "sec2cluster() - Bad sector number (%d)\n", sec);
return -1; return -1;
} }
@ -180,7 +170,7 @@ static int cluster2sec(struct bpb *bpb, unsigned int cluster)
if(cluster > max_cluster) if(cluster > max_cluster)
{ {
DEBUG1( "cluster2sec() - Bad cluster number (%d)\n", DEBUGF( "cluster2sec() - Bad cluster number (%d)\n",
cluster); cluster);
return -1; return -1;
} }
@ -204,7 +194,7 @@ int fat_mount(struct bpb *bpb)
err = ata_read_sectors(0,1,buf); err = ata_read_sectors(0,1,buf);
if(err) if(err)
{ {
DEBUG1( "fat_mount() - Couldn't read BPB (error code %i)\n", DEBUGF( "fat_mount() - Couldn't read BPB (error code %i)\n",
err); err);
return -1; return -1;
} }
@ -256,7 +246,7 @@ int fat_mount(struct bpb *bpb)
if ( countofclusters < 65525 ) if ( countofclusters < 65525 )
#endif #endif
{ {
DEBUG("This is not FAT32. Go away!\n"); DEBUGF("This is not FAT32. Go away!\n");
return -1; return -1;
} }
@ -277,7 +267,7 @@ int fat_mount(struct bpb *bpb)
if (bpb_is_sane(bpb) < 0) if (bpb_is_sane(bpb) < 0)
{ {
DEBUG( "fat_mount() - BPB is not sane\n"); DEBUGF( "fat_mount() - BPB is not sane\n");
return -1; return -1;
} }
@ -290,55 +280,55 @@ static int bpb_is_sane(struct bpb *bpb)
{ {
if(bpb->bpb_bytspersec != 512) if(bpb->bpb_bytspersec != 512)
{ {
DEBUG1( "bpb_is_sane() - Error: sector size is not 512 (%i)\n", DEBUGF( "bpb_is_sane() - Error: sector size is not 512 (%i)\n",
bpb->bpb_bytspersec); bpb->bpb_bytspersec);
return -1; return -1;
} }
if(bpb->bpb_secperclus * bpb->bpb_bytspersec > 32768) if(bpb->bpb_secperclus * bpb->bpb_bytspersec > 32768)
{ {
DEBUG3( "bpb_is_sane() - Warning: cluster size is larger than 32K " DEBUGF( "bpb_is_sane() - Warning: cluster size is larger than 32K "
"(%i * %i = %i)\n", "(%i * %i = %i)\n",
bpb->bpb_bytspersec, bpb->bpb_secperclus, bpb->bpb_bytspersec, bpb->bpb_secperclus,
bpb->bpb_bytspersec * bpb->bpb_secperclus); bpb->bpb_bytspersec * bpb->bpb_secperclus);
} }
if(bpb->bpb_rsvdseccnt != 1) if(bpb->bpb_rsvdseccnt != 1)
{ {
DEBUG1( "bpb_is_sane() - Warning: Reserved sectors is not 1 (%i)\n", DEBUGF( "bpb_is_sane() - Warning: Reserved sectors is not 1 (%i)\n",
bpb->bpb_rsvdseccnt); bpb->bpb_rsvdseccnt);
} }
if(bpb->bpb_numfats != 2) if(bpb->bpb_numfats != 2)
{ {
DEBUG1( "bpb_is_sane() - Warning: NumFATS is not 2 (%i)\n", DEBUGF( "bpb_is_sane() - Warning: NumFATS is not 2 (%i)\n",
bpb->bpb_numfats); bpb->bpb_numfats);
} }
if(bpb->bpb_rootentcnt != 512) if(bpb->bpb_rootentcnt != 512)
{ {
DEBUG1( "bpb_is_sane() - Warning: RootEntCnt is not 512 (%i)\n", DEBUGF( "bpb_is_sane() - Warning: RootEntCnt is not 512 (%i)\n",
bpb->bpb_rootentcnt); bpb->bpb_rootentcnt);
} }
if(bpb->bpb_totsec16 < 200) if(bpb->bpb_totsec16 < 200)
{ {
if(bpb->bpb_totsec16 == 0) if(bpb->bpb_totsec16 == 0)
{ {
DEBUG( "bpb_is_sane() - Error: TotSec16 is 0\n"); DEBUGF( "bpb_is_sane() - Error: TotSec16 is 0\n");
return -1; return -1;
} }
else else
{ {
DEBUG1( "bpb_is_sane() - Warning: TotSec16 " DEBUGF( "bpb_is_sane() - Warning: TotSec16 "
"is quite small (%i)\n", "is quite small (%i)\n",
bpb->bpb_totsec16); bpb->bpb_totsec16);
} }
} }
if(bpb->bpb_media != 0xf0 && bpb->bpb_media < 0xf8) if(bpb->bpb_media != 0xf0 && bpb->bpb_media < 0xf8)
{ {
DEBUG1( "bpb_is_sane() - Warning: Non-standard " DEBUGF( "bpb_is_sane() - Warning: Non-standard "
"media type (0x%02x)\n", "media type (0x%02x)\n",
bpb->bpb_media); bpb->bpb_media);
} }
if(bpb->last_word != 0xaa55) if(bpb->last_word != 0xaa55)
{ {
DEBUG1( "bpb_is_sane() - Error: Last word is not " DEBUGF( "bpb_is_sane() - Error: Last word is not "
"0xaa55 (0x%04x)\n", bpb->last_word); "0xaa55 (0x%04x)\n", bpb->last_word);
return -1; return -1;
} }
@ -356,12 +346,12 @@ static void *cache_fat_sector(struct bpb *bpb, int secnum)
sec = malloc(bpb->bpb_bytspersec); sec = malloc(bpb->bpb_bytspersec);
if(!sec) if(!sec)
{ {
DEBUG( "cache_fat_sector() - Out of memory\n"); DEBUGF( "cache_fat_sector() - Out of memory\n");
return NULL; return NULL;
} }
if(ata_read_sectors(secnum,1,sec)) if(ata_read_sectors(secnum,1,sec))
{ {
DEBUG1( "cache_fat_sector() - Could" DEBUGF( "cache_fat_sector() - Could"
" not read sector %d\n", " not read sector %d\n",
secnum); secnum);
free(sec); free(sec);
@ -388,7 +378,7 @@ static int update_entry(struct bpb *bpb, int entry, unsigned int val)
sec = cache_fat_sector(bpb, thisfatsecnum); sec = cache_fat_sector(bpb, thisfatsecnum);
if(!sec) if(!sec)
{ {
DEBUG1( "update_entry() - Could not cache sector %d\n", DEBUGF( "update_entry() - Could not cache sector %d\n",
thisfatsecnum); thisfatsecnum);
return -1; return -1;
} }
@ -419,7 +409,7 @@ static int read_entry(struct bpb *bpb, int entry)
sec = cache_fat_sector(bpb, thisfatsecnum); sec = cache_fat_sector(bpb, thisfatsecnum);
if(!sec) if(!sec)
{ {
DEBUG1( "update_entry() - Could not cache sector %d\n", DEBUGF( "update_entry() - Could not cache sector %d\n",
thisfatsecnum); thisfatsecnum);
return -1; return -1;
} }
@ -455,19 +445,19 @@ static int flush_fat(struct bpb *bpb)
{ {
if(fat_cache[i] && fat_cache_dirty[i]) if(fat_cache[i] && fat_cache_dirty[i])
{ {
DEBUG1("Flushing FAT sector %d\n", i); DEBUGF("Flushing FAT sector %d\n", i);
sec = fat_cache[i]; sec = fat_cache[i];
err = ata_write_sectors(i + bpb->bpb_rsvdseccnt,1,sec); err = ata_write_sectors(i + bpb->bpb_rsvdseccnt,1,sec);
if(err) if(err)
{ {
DEBUG1( "flush_fat() - Couldn't write" DEBUGF( "flush_fat() - Couldn't write"
" sector (%d)\n", i + bpb->bpb_rsvdseccnt); " sector (%d)\n", i + bpb->bpb_rsvdseccnt);
return -1; return -1;
} }
err = ata_write_sectors(i + bpb->bpb_rsvdseccnt + fatsz,1,sec); err = ata_write_sectors(i + bpb->bpb_rsvdseccnt + fatsz,1,sec);
if(err) if(err)
{ {
DEBUG1( "flush_fat() - Couldn't write" DEBUGF( "flush_fat() - Couldn't write"
" sector (%d)\n", i + bpb->bpb_rsvdseccnt + fatsz); " sector (%d)\n", i + bpb->bpb_rsvdseccnt + fatsz);
return -1; return -1;
} }
@ -543,7 +533,7 @@ static int add_dir_entry(struct bpb *bpb,
} }
else else
{ {
DEBUG( "add_dir_entry() -" DEBUGF( "add_dir_entry() -"
" Root dir is full\n"); " Root dir is full\n");
return -1; return -1;
} }
@ -554,9 +544,9 @@ static int add_dir_entry(struct bpb *bpb,
if(sec_cnt >= bpb->bpb_secperclus) if(sec_cnt >= bpb->bpb_secperclus)
{ {
/* We have reached the end of this cluster */ /* We have reached the end of this cluster */
DEBUG("Moving to the next cluster..."); DEBUGF("Moving to the next cluster...");
currdir = get_next_cluster(bpb, currdir); currdir = get_next_cluster(bpb, currdir);
DEBUG1("new cluster is %d\n", currdir); DEBUGF("new cluster is %d\n", currdir);
if(!currdir) if(!currdir)
{ {
@ -567,12 +557,12 @@ static int add_dir_entry(struct bpb *bpb,
} }
} }
DEBUG1("Reading sector %d...\n", sec); DEBUGF("Reading sector %d...\n", sec);
/* Read the next sector in the current dir */ /* Read the next sector in the current dir */
err = ata_read_sectors(sec,1,buf); err = ata_read_sectors(sec,1,buf);
if(err) if(err)
{ {
DEBUG1( "add_dir_entry() - Couldn't read dir sector" DEBUGF( "add_dir_entry() - Couldn't read dir sector"
" (error code %i)\n", err); " (error code %i)\n", err);
return -1; return -1;
} }
@ -580,7 +570,7 @@ static int add_dir_entry(struct bpb *bpb,
if(need_to_update_last_empty_marker) if(need_to_update_last_empty_marker)
{ {
/* All we need to do is to set the first entry to 0 */ /* All we need to do is to set the first entry to 0 */
DEBUG1("Clearing the first entry in sector %d\n", sec); DEBUGF("Clearing the first entry in sector %d\n", sec);
buf[0] = 0; buf[0] = 0;
done = 1; done = 1;
} }
@ -592,7 +582,7 @@ static int add_dir_entry(struct bpb *bpb,
firstbyte = buf[i]; firstbyte = buf[i];
if(firstbyte == 0xe5 || firstbyte == 0) if(firstbyte == 0xe5 || firstbyte == 0)
{ {
DEBUG2("Found free slot at entry %d in sector %d\n", DEBUGF("Found free slot at entry %d in sector %d\n",
i/32, sec); i/32, sec);
eptr = &buf[i]; eptr = &buf[i];
memset(eptr, 0, 32); memset(eptr, 0, 32);
@ -637,7 +627,7 @@ static int add_dir_entry(struct bpb *bpb,
err = ata_write_sectors(sec,1,buf); err = ata_write_sectors(sec,1,buf);
if(err) if(err)
{ {
DEBUG1( "add_dir_entry() - " DEBUGF( "add_dir_entry() - "
" Couldn't write dir" " Couldn't write dir"
" sector (error code %i)\n", err); " sector (error code %i)\n", err);
return -1; return -1;
@ -752,11 +742,11 @@ int fat_create_dir(struct bpb *bpb, unsigned int currdir, char *name)
struct fat_direntry de; struct fat_direntry de;
int err; int err;
DEBUG("fat_create_file()\n"); DEBUGF("fat_create_file()\n");
memset(&de, 0, sizeof(struct fat_direntry)); memset(&de, 0, sizeof(struct fat_direntry));
if(create_dos_name(name, de.name) < 0) if(create_dos_name(name, de.name) < 0)
{ {
DEBUG1( "fat_create_file() - Illegal file name (%s)\n", name); DEBUGF( "fat_create_file() - Illegal file name (%s)\n", name);
return -1; return -1;
} }
@ -775,11 +765,11 @@ int fat_create_file(struct bpb *bpb, unsigned int currdir, char *name)
struct fat_direntry de; struct fat_direntry de;
int err; int err;
DEBUG("fat_create_file()\n"); DEBUGF("fat_create_file()\n");
memset(&de, 0, sizeof(struct fat_direntry)); memset(&de, 0, sizeof(struct fat_direntry));
if(create_dos_name(name, de.name) < 0) if(create_dos_name(name, de.name) < 0)
{ {
DEBUG1( "fat_create_file() - Illegal file name (%s)\n", name); DEBUGF( "fat_create_file() - Illegal file name (%s)\n", name);
return -1; return -1;
} }
getcurrdostime(&de.crtdate, &de.crttime, &de.crttimetenth); getcurrdostime(&de.crtdate, &de.crttime, &de.crttimetenth);
@ -833,7 +823,7 @@ int fat_read(struct bpb *bpb,
for ( i=0; i<sectorcount; i++ ) { for ( i=0; i<sectorcount; i++ ) {
err = ata_read_sectors(sector,1,(char*)buf+(i*SECTOR_SIZE)); err = ata_read_sectors(sector,1,(char*)buf+(i*SECTOR_SIZE));
if(err) { if(err) {
DEBUG2( "fat_read() - Couldn't read sector %d" DEBUGF( "fat_read() - Couldn't read sector %d"
" (error code %i)\n", sector,err); " (error code %i)\n", sector,err);
return -1; return -1;
} }
@ -911,7 +901,7 @@ int fat_opendir(struct bpb *bpb,
err = ata_read_sectors(sec,1,ent->cached_buf); err = ata_read_sectors(sec,1,ent->cached_buf);
if(err) if(err)
{ {
DEBUG1( "fat_getfirst() - Couldn't read dir sector" DEBUGF( "fat_getfirst() - Couldn't read dir sector"
" (error code %i)\n", err); " (error code %i)\n", err);
return -1; return -1;
} }
@ -1027,20 +1017,20 @@ int fat_getnext(struct bpb *bpb,
{ {
int cluster = sec2cluster(bpb, ent->cached_sec); int cluster = sec2cluster(bpb, ent->cached_sec);
if ( cluster < 0 ) { if ( cluster < 0 ) {
DEBUG("sec2cluster failed\n"); DEBUGF("sec2cluster failed\n");
return -1; return -1;
} }
ent->num_sec = 0; ent->num_sec = 0;
cluster = get_next_cluster( bpb, cluster ); cluster = get_next_cluster( bpb, cluster );
if(!cluster) if(!cluster)
{ {
DEBUG("End of cluster chain.\n"); DEBUGF("End of cluster chain.\n");
return -1; return -1;
} }
ent->cached_sec = cluster2sec(bpb,cluster); ent->cached_sec = cluster2sec(bpb,cluster);
if ( ent->cached_sec < 0 ) if ( ent->cached_sec < 0 )
{ {
DEBUG1("Invalid cluster: %d\n",cluster); DEBUGF("Invalid cluster: %d\n",cluster);
return -1; return -1;
} }
@ -1050,7 +1040,7 @@ int fat_getnext(struct bpb *bpb,
err = ata_read_sectors(ent->cached_sec,1,ent->cached_buf); err = ata_read_sectors(ent->cached_sec,1,ent->cached_buf);
if(err) if(err)
{ {
DEBUG1( "fat_getnext() - Couldn't read dir sector" DEBUGF( "fat_getnext() - Couldn't read dir sector"
" (error code %i)\n", err); " (error code %i)\n", err);
return -1; return -1;
} }

View file

@ -20,23 +20,11 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include "panic.h" #include "panic.h"
#include "drivers/lcd.h" #include "lcd.h"
#include "debug.h" #include "debug.h"
char panic_buf[128]; char panic_buf[128];
/*
* "Dude. This is pretty fucked-up, right here."
*/
void panic( char *message )
{
debug( message );
/*lcd_string( message ); */
while( 1 );
}
/* /*
* "Dude. This is pretty fucked-up, right here." * "Dude. This is pretty fucked-up, right here."
*/ */
@ -48,5 +36,7 @@ void panicf( char *fmt, ...)
vsnprintf( panic_buf, sizeof(panic_buf), fmt, ap ); vsnprintf( panic_buf, sizeof(panic_buf), fmt, ap );
va_end( ap ); va_end( ap );
panic( panic_buf ); lcd_puts(0,0,panic_buf);
DEBUGF(panic_buf);
while(1);
} }

View file

@ -20,7 +20,6 @@
#ifndef __PANIC_H__ #ifndef __PANIC_H__
#define __PANIC_H__ #define __PANIC_H__
void panic( char *message );
void panicf( char *fmt, ... ); void panicf( char *fmt, ... );
#endif /* __PANIC_H__ */ #endif /* __PANIC_H__ */

View file

@ -31,7 +31,7 @@
*/ */
int reload_playlist_info( playlist_info_t *playlist ) int reload_playlist_info( playlist_info_t *playlist )
{ {
debug( "reload_playlist_info()\n" ); DEBUGF( "reload_playlist_info()\n" );
/* this is a TEMP stub version */ /* this is a TEMP stub version */
@ -60,22 +60,16 @@ int reload_playlist_info( playlist_info_t *playlist )
void load_playlist( playlist_info_t *playlist, const char *filename ) { void load_playlist( playlist_info_t *playlist, const char *filename ) {
char *m3u_buf = NULL; char *m3u_buf = NULL;
char debug_message[128];
snprintf( debug_message, sizeof(debug_message), DEBUGF( "load_playlist( %s )\n", filename );
"load_playlist( %s )\n", filename );
debug( debug_message );
/* read file */ /* read file */
read_file_into_buffer( &m3u_buf, filename ); read_file_into_buffer( &m3u_buf, filename );
/* store playlist filename */ /* store playlist filename */
strncpy( playlist->filename, filename, sizeof(playlist->filename) ); strncpy( playlist->filename, filename, sizeof(playlist->filename) );
/* add track indices to playlist data structure */ /* add track indices to playlist data structure */
add_indices_to_playlist( m3u_buf, playlist ); add_indices_to_playlist( m3u_buf, playlist );
} }
@ -84,7 +78,7 @@ void load_playlist( playlist_info_t *playlist, const char *filename ) {
*/ */
void empty_playlist( playlist_info_t *playlist ) { void empty_playlist( playlist_info_t *playlist ) {
debug( "empty_playlist()\n" ); DEBUGF( "empty_playlist()\n" );
playlist->filename[0] = '\0'; playlist->filename[0] = '\0';
playlist->indices_count = 0; playlist->indices_count = 0;
@ -101,7 +95,7 @@ void add_indices_to_playlist( char *buf, playlist_info_t *playlist )
char *p; char *p;
int i = 0; int i = 0;
/*debug( "add_indices_to_playlist()\n" ); */ /*DEBUGF( "add_indices_to_playlist()\n" ); */
p = buf; p = buf;
@ -141,8 +135,7 @@ void add_indices_to_playlist( char *buf, playlist_info_t *playlist )
*/ */
void extend_indices( playlist_info_t *playlist, int new_index ) void extend_indices( playlist_info_t *playlist, int new_index )
{ {
/*sprintf( debug_message, "extend_indices(%d)\n", new_index ); /*DEBUGF( "extend_indices(%d)\n", new_index ); */
debug( debug_message );*/
/* increase array size count */ /* increase array size count */
@ -157,8 +150,8 @@ void extend_indices( playlist_info_t *playlist, int new_index )
playlist->indices[ playlist->indices_count - 1 ] = new_index; playlist->indices[ playlist->indices_count - 1 ] = new_index;
} }
track_t next_playlist_track( playlist_info_t *playlist ) { track_t next_playlist_track( playlist_info_t *playlist )
{
track_t track; track_t track;
strncpy( track.filename, "boogie", sizeof(track.filename) ); strncpy( track.filename, "boogie", sizeof(track.filename) );
return track; return track;
@ -167,8 +160,8 @@ track_t next_playlist_track( playlist_info_t *playlist ) {
/* /*
* randomly rearrange the array of indices for the playlist * randomly rearrange the array of indices for the playlist
*/ */
void randomise_playlist( playlist_info_t *playlist ) { void randomise_playlist( playlist_info_t *playlist )
{
unsigned seed; unsigned seed;
int count = 0; int count = 0;
int candidate; int candidate;
@ -178,7 +171,7 @@ void randomise_playlist( playlist_info_t *playlist ) {
int *randomised_list; int *randomised_list;
int i; int i;
debug( "randomise_playlist()\n" ); DEBUGF( "randomise_playlist()\n" );
/* create dynamic storage for randomised list so it can be freed later */ /* create dynamic storage for randomised list so it can be freed later */
@ -279,7 +272,7 @@ int is_unused_random_in_list( int number, int *new_list, int count )
*/ */
void display_playlist_track( track_t *track ) void display_playlist_track( track_t *track )
{ {
debugf( "track: %s\n", track->filename ); DEBUGF( "track: %s\n", track->filename );
} }
/* /*
@ -290,14 +283,14 @@ void display_current_playlist( playlist_info_t *playlist )
char indices[2048]; char indices[2048];
indices[0]='\0'; indices[0]='\0';
/*debug( "\ndisplay_current_playlist()\n" ); */ /*DEBUGF( "\ndisplay_current_playlist()\n" ); */
if( playlist->indices_count != 0 ) if( playlist->indices_count != 0 )
{ {
get_indices_as_string( indices, playlist ); get_indices_as_string( indices, playlist );
} }
debugf( "\nfilename:\t%s\ntotal:\t\t%d\nindices:\t%s\ncurrent index:\t%d\n\n", DEBUGF( "\nfilename:\t%s\ntotal:\t\t%d\nindices:\t%s\ncurrent index:\t%d\n\n",
playlist->filename, playlist->filename,
playlist->indices_count, playlist->indices_count,
indices, indices,
@ -313,7 +306,7 @@ void get_indices_as_string( char *string, playlist_info_t *playlist )
int count = 0; int count = 0;
int *p = playlist->indices; int *p = playlist->indices;
/*debug( "get_indices_as_string()\n" ); */ /*DEBUGF( "get_indices_as_string()\n" ); */
while( count < playlist->indices_count ) { while( count < playlist->indices_count ) {

View file

@ -31,57 +31,57 @@ int persist_all_settings( void )
{ {
if( ! persist_volume_setting() ) if( ! persist_volume_setting() )
{ {
panic( "failed to persist volume setting" ); panicf( "failed to persist volume setting" );
} }
if( ! persist_balance_setting() ) if( ! persist_balance_setting() )
{ {
panic( "failed to persist balance setting" ); panicf( "failed to persist balance setting" );
} }
if( ! persist_bass_setting() ) if( ! persist_bass_setting() )
{ {
panic( "failed to persist bass setting" ); panicf( "failed to persist bass setting" );
} }
if( ! persist_treble_setting() ) if( ! persist_treble_setting() )
{ {
panic( "failed to persist treble setting" ); panicf( "failed to persist treble setting" );
} }
if( ! persist_loudness_setting() ) if( ! persist_loudness_setting() )
{ {
panic( "failed to persist loudness setting" ); panicf( "failed to persist loudness setting" );
} }
if( ! persist_bass_boost_setting() ) if( ! persist_bass_boost_setting() )
{ {
panic( "failed to persist bass boost setting" ); panicf( "failed to persist bass boost setting" );
} }
if( ! persist_contrast_setting() ) if( ! persist_contrast_setting() )
{ {
panic( "failed to persist contrast setting" ); panicf( "failed to persist contrast setting" );
} }
if( ! persist_poweroff_setting() ) if( ! persist_poweroff_setting() )
{ {
panic( "failed to persist poweroff setting" ); panicf( "failed to persist poweroff setting" );
} }
if( ! persist_backlight_setting() ) if( ! persist_backlight_setting() )
{ {
panic( "failed to persist backlight setting" ); panicf( "failed to persist backlight setting" );
} }
if( ! persist_poweroff_setting() ) if( ! persist_poweroff_setting() )
{ {
panic( "failed to persist poweroff setting" ); panicf( "failed to persist poweroff setting" );
} }
if( ! persist_resume_setting() ) if( ! persist_resume_setting() )
{ {
panic( "failed to persist resume setting" ); panicf( "failed to persist resume setting" );
} }
/* by getting here, we had no problems */ /* by getting here, we had no problems */
@ -96,22 +96,22 @@ int persist_all_playlist_info( void )
{ {
if( ! persist_playlist_filename() ) if( ! persist_playlist_filename() )
{ {
panic( "failed to persist playlist filename" ); panicf( "failed to persist playlist filename" );
} }
if( ! persist_playlist_indices() ) if( ! persist_playlist_indices() )
{ {
panic( "failed to persist playlist indices" ); panicf( "failed to persist playlist indices" );
} }
if( ! persist_playlist_index() ) if( ! persist_playlist_index() )
{ {
panic( "failed to persist playlist index" ); panicf( "failed to persist playlist index" );
} }
if( ! persist_resume_track_time() ) if( ! persist_resume_track_time() )
{ {
panic( "failed to persist resume track time" ); panicf( "failed to persist resume track time" );
} }
/* by getting here, we had no problems */ /* by getting here, we had no problems */
@ -124,7 +124,7 @@ int persist_all_playlist_info( void )
*/ */
void reload_all_settings( user_settings_t *settings ) void reload_all_settings( user_settings_t *settings )
{ {
debug( "reload_all_settings()\n" ); DEBUGF( "reload_all_settings()\n" );
/* this is a TEMP stub version */ /* this is a TEMP stub version */
@ -138,7 +138,7 @@ void reload_all_settings( user_settings_t *settings )
*/ */
void reset_settings( user_settings_t *settings ) { void reset_settings( user_settings_t *settings ) {
debug( "reset_settings()\n" ); DEBUGF( "reset_settings()\n" );
settings->volume = DEFAULT_VOLUME_SETTING; settings->volume = DEFAULT_VOLUME_SETTING;
settings->balance = DEFAULT_BALANCE_SETTING; settings->balance = DEFAULT_BALANCE_SETTING;
@ -156,9 +156,9 @@ void reset_settings( user_settings_t *settings ) {
*/ */
void display_current_settings( user_settings_t *settings ) void display_current_settings( user_settings_t *settings )
{ {
debug( "\ndisplay_current_settings()\n" ); DEBUGF( "\ndisplay_current_settings()\n" );
debugf( "\nvolume:\t\t%d\nbalance:\t%d\nbass:\t\t%d\ntreble:\t\t%d\nloudness:\t%d\nbass boost:\t%d\n", DEBUGF( "\nvolume:\t\t%d\nbalance:\t%d\nbass:\t\t%d\ntreble:\t\t%d\nloudness:\t%d\nbass boost:\t%d\n",
settings->volume, settings->volume,
settings->balance, settings->balance,
settings->bass, settings->bass,
@ -166,7 +166,7 @@ void display_current_settings( user_settings_t *settings )
settings->loudness, settings->loudness,
settings->bass_boost ); settings->bass_boost );
debugf( "contrast:\t%d\npoweroff:\t%d\nbacklight:\t%d\n", DEBUGF( "contrast:\t%d\npoweroff:\t%d\nbacklight:\t%d\n",
settings->contrast, settings->contrast,
settings->poweroff, settings->poweroff,
settings->backlight ); settings->backlight );