From c7be31ae10a2a399cb21593d84703f8278472d72 Mon Sep 17 00:00:00 2001 From: Maksym Veremeyenko Date: Sun, 19 Jun 2011 17:08:50 +0300 Subject: [PATCH] fix playlist loads and display --- src/omnplay.h | 39 ++++++++++++++++++++------------------- src/playlist.c | 27 ++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/omnplay.h b/src/omnplay.h index e2937ff..d2444b9 100644 --- a/src/omnplay.h +++ b/src/omnplay.h @@ -51,35 +51,36 @@ typedef enum control_buttons BUTTON_LAST } control_buttons_t; -#define OMNPLAY_PLAYLIST_BLOCK_BEGIN (1 << 0) // 1 -#define OMNPLAY_PLAYLIST_BLOCK_BODY 0 // 0 -#define OMNPLAY_PLAYLIST_BLOCK_END (1 << 1) // 2 -#define OMNPLAY_PLAYLIST_BLOCK_LOOP (1 << 2) // 4 +#define OMNPLAY_PLAYLIST_BLOCK_BEGIN 1 +#define OMNPLAY_PLAYLIST_BLOCK_BODY 0 +#define OMNPLAY_PLAYLIST_BLOCK_END 2 +#define OMNPLAY_PLAYLIST_BLOCK_LOOP 4 typedef enum playlist_item_type { + // 1 OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN = OMNPLAY_PLAYLIST_BLOCK_BEGIN, - + // 0 OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY = OMNPLAY_PLAYLIST_BLOCK_BODY, - + // 2 OMNPLAY_PLAYLIST_ITEM_BLOCK_END = OMNPLAY_PLAYLIST_BLOCK_END, - - OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE = OMNPLAY_PLAYLIST_BLOCK_END | \ - OMNPLAY_PLAYLIST_BLOCK_BODY | \ + // 3 + OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE = OMNPLAY_PLAYLIST_BLOCK_BEGIN | + OMNPLAY_PLAYLIST_BLOCK_BODY | OMNPLAY_PLAYLIST_BLOCK_END, - - OMNPLAY_PLAYLIST_ITEM_LOOP_BEGIN = OMNPLAY_PLAYLIST_BLOCK_BEGIN | \ + // 5 + OMNPLAY_PLAYLIST_ITEM_LOOP_BEGIN = OMNPLAY_PLAYLIST_BLOCK_BEGIN | OMNPLAY_PLAYLIST_BLOCK_LOOP, - - OMNPLAY_PLAYLIST_ITEM_LOOP_BODY = OMNPLAY_PLAYLIST_BLOCK_BODY | \ + // 4 + OMNPLAY_PLAYLIST_ITEM_LOOP_BODY = OMNPLAY_PLAYLIST_BLOCK_BODY | OMNPLAY_PLAYLIST_BLOCK_LOOP, - - OMNPLAY_PLAYLIST_ITEM_LOOP_END = OMNPLAY_PLAYLIST_BLOCK_END | \ + // 6 + OMNPLAY_PLAYLIST_ITEM_LOOP_END = OMNPLAY_PLAYLIST_BLOCK_END | OMNPLAY_PLAYLIST_BLOCK_LOOP, - - OMNPLAY_PLAYLIST_ITEM_LOOP_SINGLE = OMNPLAY_PLAYLIST_BLOCK_END | \ - OMNPLAY_PLAYLIST_BLOCK_BODY | \ - OMNPLAY_PLAYLIST_BLOCK_END | \ + // 7 + OMNPLAY_PLAYLIST_ITEM_LOOP_SINGLE = OMNPLAY_PLAYLIST_BLOCK_BEGIN | + OMNPLAY_PLAYLIST_BLOCK_BODY | + OMNPLAY_PLAYLIST_BLOCK_END | OMNPLAY_PLAYLIST_BLOCK_LOOP, } playlist_item_type_t; diff --git a/src/playlist.c b/src/playlist.c index 4c47bf0..0d325d3 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -87,13 +87,34 @@ static int load_file_ply(omnplay_instance_t* app, char* filename) case 4: items[count].type = OMNPLAY_PLAYLIST_ITEM_LOOP_END; break; case 6: items[count].type = OMNPLAY_PLAYLIST_ITEM_BLOCK_END; break; case 0: - if(!count || items[count - 1].type != OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY) + if(!count) items[count].type = OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN; - else + else if(items[count - 1].type == OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN || + items[count - 1].type == OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY) items[count].type = OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY; + else + items[count].type = OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN; break; }; + { + char* n; + switch(items[count].type) + { + case OMNPLAY_PLAYLIST_ITEM_BLOCK_BEGIN: n = "BLOCK_BEGIN"; break; + case OMNPLAY_PLAYLIST_ITEM_BLOCK_BODY: n = "BLOCK_BODY"; break; + case OMNPLAY_PLAYLIST_ITEM_BLOCK_END: n = "BLOCK_END"; break; + case OMNPLAY_PLAYLIST_ITEM_BLOCK_SINGLE: n = "BLOCK_SINGLE"; break; + case OMNPLAY_PLAYLIST_ITEM_LOOP_BEGIN: n = "LOOP_BEGIN"; break; + case OMNPLAY_PLAYLIST_ITEM_LOOP_BODY: n = "LOOP_BODY"; break; + case OMNPLAY_PLAYLIST_ITEM_LOOP_END: n = "LOOP_END"; break; + case OMNPLAY_PLAYLIST_ITEM_LOOP_SINGLE: n = "LOOP_SINGLE"; break; + }; + fprintf(stderr, "src=[%s]\ndst=[idx=%d,block=%s,block_id=%d,in=%d,out=%d]\n", + l, count, n, items[count].type, items[count].in, items[count].dur); + }; + + count++; } }; @@ -191,7 +212,7 @@ void omnplay_playlist_draw(omnplay_instance_t* app) 2, (0 == app->playlist.item[i].player)?"A":"B", 3, app->playlist.item[i].id, 4, frames2tc(app->playlist.item[i].in, 25.0, tc1), - 5, frames2tc(app->playlist.item[i].in, 25.0, tc2), + 5, frames2tc(app->playlist.item[i].dur, 25.0, tc2), 6, app->playlist.item[i].title, -1 ); } -- 1.7.4.4