summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2009-08-14 19:50:35 +0200
committerGravatar waker <wakeroid@gmail.com>2009-08-14 19:50:35 +0200
commit9714adc59ea1d46750bd24153ce82c5cfaa5df78 (patch)
tree72ec05221c6c0da840da04cedaef9a804e966cc3
parent6d82e1b24c2e98ed627b5d8ed6a2064bebd44d9d (diff)
added filetype to playlist format
-rw-r--r--cdumb.c25
-rw-r--r--cflac.c5
-rw-r--r--cgme.c5
-rw-r--r--cmp3.c15
-rw-r--r--codec.h1
-rw-r--r--csid.cpp3
-rw-r--r--cvorbis.c3
-rw-r--r--playlist.c20
8 files changed, 49 insertions, 28 deletions
diff --git a/cdumb.c b/cdumb.c
index 42c0077a..13def61d 100644
--- a/cdumb.c
+++ b/cdumb.c
@@ -278,19 +278,19 @@ static DUH * open_module(const char *fname, const char *ext, int *start_order, i
{
*is_it = 1;
duh = dumb_read_it_quick(f);
- *filetype = "IT";
+ *filetype = "it";
}
else if (size >= 17 && !memcmp(ptr, "Extended Module: ", 17))
{
duh = dumb_read_xm_quick(f);
- *filetype = "XM";
+ *filetype = "xm";
}
else if (size >= 0x30 &&
ptr[0x2C] == 'S' && ptr[0x2D] == 'C' &&
ptr[0x2E] == 'R' && ptr[0x2F] == 'M')
{
duh = dumb_read_s3m_quick(f);
- *filetype = "S3M";
+ *filetype = "s3m";
}
else if (size >= 1168 &&
/*ptr[28] == 0x1A &&*/ ptr[29] == 2 &&
@@ -299,7 +299,7 @@ static DUH * open_module(const char *fname, const char *ext, int *start_order, i
! strncasecmp( ( const char * ) ptr + 20, "WUZAMOD!", 8 ) ) )
{
duh = dumb_read_stm_quick(f);
- *filetype = "STM";
+ *filetype = "stm";
}
else if (size >= 2 &&
((ptr[0] == 0x69 && ptr[1] == 0x66) ||
@@ -313,7 +313,7 @@ static DUH * open_module(const char *fname, const char *ext, int *start_order, i
ptr[0x2E] == 'M' && ptr[0x2F] == 'F')
{
duh = dumb_read_ptm_quick(f);
- *filetype = "PTM";
+ *filetype = "ptm";
}
else if (size >= 4 &&
ptr[0] == 'P' && ptr[1] == 'S' &&
@@ -321,35 +321,35 @@ static DUH * open_module(const char *fname, const char *ext, int *start_order, i
{
duh = dumb_read_psm_quick(f, *start_order);
*start_order = 0;
- *filetype = "PSM";
+ *filetype = "psm";
}
else if (size >= 4 &&
ptr[0] == 'P' && ptr[1] == 'S' &&
ptr[2] == 'M' && ptr[3] == 254)
{
duh = dumb_read_old_psm_quick(f);
- *filetype = "PSM";
+ *filetype = "psm";
}
else if (size >= 3 &&
ptr[0] == 'M' && ptr[1] == 'T' &&
ptr[2] == 'M')
{
duh = dumb_read_mtm_quick(f);
- *filetype = "MTM";
+ *filetype = "mtm";
}
else if ( size >= 4 &&
ptr[0] == 'R' && ptr[1] == 'I' &&
ptr[2] == 'F' && ptr[3] == 'F')
{
duh = dumb_read_riff_quick(f);
- *filetype = "RIFF";
+ *filetype = "riff";
}
else if ( size >= 32 &&
!memcmp( ptr, "ASYLUM Music Format", 19 ) &&
!memcmp( ptr + 19, " V1.0", 5 ) )
{
duh = dumb_read_asy_quick(f);
- *filetype = "ASY";
+ *filetype = "asy";
}
if (!duh)
@@ -358,7 +358,7 @@ static DUH * open_module(const char *fname, const char *ext, int *start_order, i
f = dumbfile_open (fname);
*is_dos = 0;
duh = dumb_read_mod_quick (f, (!strcasecmp (ext, exts[0]) || !strcasecmp (ext, exts[1])) ? 0 : 1);
- *filetype = "MOD";
+ *filetype = "mod";
}
if (f) {
@@ -800,6 +800,7 @@ codec_t cdumb = {
.seek = cdumb_seek,
.insert = cdumb_insert,
.getexts = cdumb_getexts,
- .id = "stddumb"
+ .id = "stddumb",
+ .filetypes = { "it", "xm", "s3m", "stm", "669", "ptm", "psm", "mtm", "riff", "asy", "mod", NULL }
};
diff --git a/cflac.c b/cflac.c
index 6d8f2d3e..af560a2c 100644
--- a/cflac.c
+++ b/cflac.c
@@ -406,7 +406,7 @@ cflac_insert (playItem_t *after, const char *fname) {
}
#endif
FLAC__stream_decoder_delete(decoder);
- it->filetype = "FLAC";
+ it->filetype = "flac";
after = pl_insert_item (after, it);
return after;
}
@@ -427,5 +427,6 @@ codec_t cflac = {
.seek = cflac_seek,
.insert = cflac_insert,
.getexts = cflac_getexts,
- .id = "stdflac"
+ .id = "stdflac",
+ .filetypes = { "flac", NULL }
};
diff --git a/cgme.c b/cgme.c
index 372f05d8..30d9d866 100644
--- a/cgme.c
+++ b/cgme.c
@@ -140,7 +140,7 @@ cgme_insert (playItem_t *after, const char *fname) {
else {
it->duration = (float)inf.length/1000.f;
}
- it->filetype = "GME";
+ it->filetype = "gme";
after = pl_insert_item (after, it);
}
else {
@@ -192,6 +192,7 @@ codec_t cgme = {
.getexts = cgme_getexts,
.numvoices = cgme_numvoices,
.mutevoice = cgme_mutevoice,
- .id = "stdgme"
+ .id = "stdgme",
+ .filetypes = { "gme", NULL }
};
diff --git a/cmp3.c b/cmp3.c
index 2702c645..933fe2b9 100644
--- a/cmp3.c
+++ b/cmp3.c
@@ -1328,7 +1328,6 @@ cmp3_insert (playItem_t *after, const char *fname) {
it->tracknum = 0;
it->timestart = 0;
it->timeend = 0;
- it->filetype = "MP3";
if (cmp3_read_id3v2 (it, fp) < 0) {
if (cmp3_read_id3v1 (it, fp) < 0) {
pl_add_meta (it, "title", NULL);
@@ -1356,6 +1355,17 @@ cmp3_insert (playItem_t *after, const char *fname) {
assert (buffer.packetlength);
int nframes = sz / buffer.packetlength;
it->duration = nframes * buffer.frameduration;
+ switch (buffer.layer) {
+ case 1:
+ it->filetype = "mp1";
+ break;
+ case 2:
+ it->filetype = "mp2";
+ break;
+ case 3:
+ it->filetype = "mp3";
+ break;
+ }
after = pl_insert_item (after, it);
fclose (fp);
@@ -1378,7 +1388,8 @@ codec_t cmp3 = {
.seek = cmp3_seek,
.insert = cmp3_insert,
.getexts = cmp3_getexts,
- .id = "stdmp3"
+ .id = "stdmp3",
+ .filetypes = { "mp1", "mp2", "mp3", NULL }
};
diff --git a/codec.h b/codec.h
index 4890a8ed..65bf36bc 100644
--- a/codec.h
+++ b/codec.h
@@ -41,6 +41,7 @@ typedef struct codec_s {
int (*numvoices) (void);
void (*mutevoice) (int voice, int mute);
const char *id; // codec id used for playlist serialization
+ const char *filetypes[20]; // NULL terminated array of const strings, representing supported file types (can be NULL)
fileinfo_t info;
} codec_t;
diff --git a/csid.cpp b/csid.cpp
index e791c2bc..aa2b87a1 100644
--- a/csid.cpp
+++ b/csid.cpp
@@ -504,6 +504,7 @@ codec_t csid = {
csid_getexts,
csid_numvoices,
csid_mutevoice,
- "stdsid"
+ "stdsid",
+ { "sid", NULL }
};
diff --git a/cvorbis.c b/cvorbis.c
index 0e00de5b..c4b879c6 100644
--- a/cvorbis.c
+++ b/cvorbis.c
@@ -179,6 +179,7 @@ codec_t cvorbis = {
.seek = cvorbis_seek,
.insert = cvorbis_insert,
.getexts = cvorbis_getexts,
- .id = "stdogg"
+ .id = "stdogg",
+ .filetypes = { "OggVorbis", NULL }
};
diff --git a/playlist.c b/playlist.c
index 7769bfb0..7f5f072b 100644
--- a/playlist.c
+++ b/playlist.c
@@ -958,7 +958,6 @@ pl_save (const char *fname) {
if (fwrite (&it->duration, 1, 4, fp) != 4) {
goto save_fail;
}
-#if 0
uint8_t ft = it->filetype ? strlen (it->filetype) : 0;
if (fwrite (&ft, 1, 1, fp) != 1) {
goto save_fail;
@@ -968,7 +967,6 @@ pl_save (const char *fname) {
goto save_fail;
}
}
-#endif
int16_t nm = 0;
metaInfo_t *m;
for (m = it->meta; m; m = m->next) {
@@ -1093,20 +1091,26 @@ pl_load (const char *fname) {
if (fread (&it->duration, 1, 4, fp) != 4) {
goto load_fail;
}
-#if 0
- // filetype
+ // get const filetype string from codec
uint8_t ft;
if (fread (&ft, 1, 1, fp) != 1) {
goto load_fail;
}
if (ft) {
- it->filetype = malloc (ft+1)
- if (fread (it->filetype, 1, ft, fp) != ft) {
+ char ftype[ft+1];
+ if (fread (ftype, 1, ft, fp) != ft) {
goto load_fail;
}
- it->filetype[ft] = 0;
+ ftype[ft] = 0;
+ if (it->codec && it->codec->filetypes) {
+ for (int i = 0; it->codec->filetypes[i]; i++) {
+ if (!strcasecmp (it->codec->filetypes[i], ftype)) {
+ it->filetype = it->codec->filetypes[i];
+ break;
+ }
+ }
+ }
}
-#endif
// printf ("loading file %s\n", it->fname);
int16_t nm = 0;
if (fread (&nm, 1, 2, fp) != 2) {