2007-12-29 19:46:35 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
2006-08-07 22:11:07 +00:00
|
|
|
*
|
2007-12-29 19:46:35 +00:00
|
|
|
* mpegplayer main entrypoint and UI implementation
|
2007-04-10 14:18:30 +00:00
|
|
|
*
|
2007-12-29 19:46:35 +00:00
|
|
|
* Copyright (c) 2007 Michael Sevakis
|
2006-08-07 22:11:07 +00:00
|
|
|
*
|
2007-12-29 19:46:35 +00:00
|
|
|
* 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.
|
2006-08-07 22:11:07 +00:00
|
|
|
*
|
2007-12-29 19:46:35 +00:00
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
2006-08-07 22:11:07 +00:00
|
|
|
*
|
2007-12-29 19:46:35 +00:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* NOTES:
|
|
|
|
*
|
|
|
|
* mpegplayer is structured as follows:
|
|
|
|
*
|
|
|
|
* +-->Video Thread-->Video Output-->LCD
|
|
|
|
* |
|
|
|
|
* UI-->Stream Manager-->+-->Audio Thread-->PCM buffer--Audio Device
|
|
|
|
* | | | | (ref. clock)
|
|
|
|
* | | +-->Buffer Thread |
|
|
|
|
* Stream Data | | (clock intf./
|
|
|
|
* Requests | File Cache drift adj.)
|
|
|
|
* | Disk I/O
|
|
|
|
* Stream services
|
|
|
|
* (timing, etc.)
|
|
|
|
*
|
|
|
|
* Thread list:
|
|
|
|
* 1) The main thread - Handles user input, settings, basic playback control
|
|
|
|
* and USB connect.
|
|
|
|
*
|
|
|
|
* 2) Stream Manager thread - Handles playback state, events from streams
|
|
|
|
* such as when a stream is finished, stream commands, PCM state. The
|
|
|
|
* layer in which this thread run also handles arbitration of data
|
|
|
|
* requests between the streams and the disk buffer. The actual specific
|
|
|
|
* transport layer code may get moved out to support multiple container
|
|
|
|
* formats.
|
|
|
|
*
|
|
|
|
* 3) Buffer thread - Buffers data in the background, generates notifications
|
|
|
|
* to streams when their data has been buffered, and watches streams'
|
|
|
|
* progress to keep data available during playback. Handles synchronous
|
|
|
|
* random access requests when the file cache is missed.
|
|
|
|
*
|
|
|
|
* 4) Video thread (running on the COP for PortalPlayer targets) - Decodes
|
|
|
|
* the video stream and renders video frames to the LCD. Handles
|
|
|
|
* miscellaneous video tasks like frame and thumbnail printing.
|
|
|
|
*
|
|
|
|
* 5) Audio thread (running on the main CPU to maintain consistency with the
|
|
|
|
* audio FIQ hander on PP) - Decodes audio frames and places them into
|
|
|
|
* the PCM buffer for rendering by the audio device.
|
|
|
|
*
|
|
|
|
* Streams are neither aware of one another nor care about one another. All
|
|
|
|
* streams shall have their own thread (unless it is _really_ efficient to
|
|
|
|
* have a single thread handle a couple minor streams). All coordination of
|
|
|
|
* the streams is done through the stream manager. The clocking is controlled
|
|
|
|
* by and exposed by the stream manager to other streams and implemented at
|
|
|
|
* the PCM level.
|
|
|
|
*
|
|
|
|
* Notes about MPEG files:
|
|
|
|
*
|
|
|
|
* MPEG System Clock is 27MHz - i.e. 27000000 ticks/second.
|
|
|
|
*
|
|
|
|
* FPS is represented in terms of a frame period - this is always an
|
|
|
|
* integer number of 27MHz ticks.
|
|
|
|
*
|
|
|
|
* e.g. 29.97fps (30000/1001) NTSC video has an exact frame period of
|
|
|
|
* 900900 27MHz ticks.
|
|
|
|
*
|
|
|
|
* In libmpeg2, info->sequence->frame_period contains the frame_period.
|
|
|
|
*
|
|
|
|
* Working with Rockbox's 100Hz tick, the common frame rates would need
|
|
|
|
* to be as follows (1):
|
|
|
|
*
|
|
|
|
* FPS | 27Mhz | 100Hz | 44.1KHz | 48KHz
|
|
|
|
* --------|-----------------------------------------------------------
|
|
|
|
* 10* | 2700000 | 10 | 4410 | 4800
|
|
|
|
* 12* | 2250000 | 8.3333 | 3675 | 4000
|
|
|
|
* 15* | 1800000 | 6.6667 | 2940 | 3200
|
|
|
|
* 23.9760 | 1126125 | 4.170833333 | 1839.3375 | 2002
|
|
|
|
* 24 | 1125000 | 4.166667 | 1837.5 | 2000
|
|
|
|
* 25 | 1080000 | 4 | 1764 | 1920
|
|
|
|
* 29.9700 | 900900 | 3.336667 | 1471,47 | 1601.6
|
|
|
|
* 30 | 900000 | 3.333333 | 1470 | 1600
|
|
|
|
*
|
|
|
|
* *Unofficial framerates
|
|
|
|
*
|
|
|
|
* (1) But we don't really care since the audio clock is used anyway and has
|
|
|
|
* very fine resolution ;-)
|
|
|
|
*****************************************************************************/
|
2006-08-07 22:11:07 +00:00
|
|
|
#include "plugin.h"
|
2007-12-29 19:46:35 +00:00
|
|
|
#include "mpegplayer.h"
|
2007-08-13 22:31:11 +00:00
|
|
|
#include "helper.h"
|
2006-08-20 23:12:56 +00:00
|
|
|
#include "mpeg_settings.h"
|
2007-12-29 19:46:35 +00:00
|
|
|
#include "mpeg2.h"
|
2006-08-07 22:11:07 +00:00
|
|
|
#include "video_out.h"
|
2007-12-29 19:46:35 +00:00
|
|
|
#include "stream_thread.h"
|
|
|
|
#include "stream_mgr.h"
|
2006-08-07 22:11:07 +00:00
|
|
|
|
|
|
|
PLUGIN_HEADER
|
2006-11-18 02:18:29 +00:00
|
|
|
PLUGIN_IRAM_DECLARE
|
2006-08-07 22:11:07 +00:00
|
|
|
|
2006-08-09 10:47:22 +00:00
|
|
|
/* button definitions */
|
|
|
|
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
2006-08-20 23:12:56 +00:00
|
|
|
#define MPEG_MENU BUTTON_MODE
|
2006-08-09 10:47:22 +00:00
|
|
|
#define MPEG_STOP BUTTON_OFF
|
|
|
|
#define MPEG_PAUSE BUTTON_ON
|
2007-03-18 17:04:44 +00:00
|
|
|
#define MPEG_VOLDOWN BUTTON_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_UP
|
2008-01-03 17:14:28 +00:00
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
2006-08-07 22:11:07 +00:00
|
|
|
|
2007-07-27 09:57:27 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
2006-08-20 23:12:56 +00:00
|
|
|
#define MPEG_MENU BUTTON_MENU
|
|
|
|
#define MPEG_PAUSE (BUTTON_PLAY | BUTTON_REL)
|
|
|
|
#define MPEG_STOP (BUTTON_PLAY | BUTTON_REPEAT)
|
2007-03-18 17:04:44 +00:00
|
|
|
#define MPEG_VOLDOWN BUTTON_SCROLL_BACK
|
|
|
|
#define MPEG_VOLUP BUTTON_SCROLL_FWD
|
2008-01-03 17:14:28 +00:00
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
2006-08-09 10:47:22 +00:00
|
|
|
|
2007-03-16 23:02:39 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
|
2006-08-20 23:12:56 +00:00
|
|
|
#define MPEG_MENU (BUTTON_REC | BUTTON_REL)
|
2006-08-09 10:47:22 +00:00
|
|
|
#define MPEG_STOP BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE BUTTON_PLAY
|
2007-03-18 17:04:44 +00:00
|
|
|
#define MPEG_VOLDOWN BUTTON_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_UP
|
2008-01-03 17:14:28 +00:00
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
2006-08-09 10:47:22 +00:00
|
|
|
|
2006-08-09 13:25:43 +00:00
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
2006-08-20 23:12:56 +00:00
|
|
|
#define MPEG_MENU BUTTON_MENU
|
2007-05-19 23:38:09 +00:00
|
|
|
#define MPEG_STOP BUTTON_POWER
|
2006-08-09 13:25:43 +00:00
|
|
|
#define MPEG_PAUSE BUTTON_SELECT
|
2007-11-21 05:49:00 +00:00
|
|
|
#define MPEG_PAUSE2 BUTTON_A
|
2007-03-28 23:09:59 +00:00
|
|
|
#define MPEG_VOLDOWN BUTTON_LEFT
|
|
|
|
#define MPEG_VOLUP BUTTON_RIGHT
|
2007-03-18 17:04:44 +00:00
|
|
|
#define MPEG_VOLDOWN2 BUTTON_VOL_DOWN
|
|
|
|
#define MPEG_VOLUP2 BUTTON_VOL_UP
|
2008-01-03 17:14:28 +00:00
|
|
|
#define MPEG_RW BUTTON_UP
|
|
|
|
#define MPEG_FF BUTTON_DOWN
|
2006-08-09 13:25:43 +00:00
|
|
|
|
2006-08-11 08:35:27 +00:00
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
2008-01-03 17:14:28 +00:00
|
|
|
#define MPEG_MENU BUTTON_LEFT
|
2006-08-11 08:35:27 +00:00
|
|
|
#define MPEG_STOP BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE BUTTON_PLAY
|
2007-03-18 17:04:44 +00:00
|
|
|
#define MPEG_VOLDOWN BUTTON_SCROLL_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_SCROLL_UP
|
2008-01-03 17:14:28 +00:00
|
|
|
#define MPEG_RW BUTTON_REW
|
|
|
|
#define MPEG_FF BUTTON_FF
|
2006-08-11 08:35:27 +00:00
|
|
|
|
2006-10-26 13:38:09 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_E200_PAD
|
|
|
|
#define MPEG_MENU BUTTON_SELECT
|
|
|
|
#define MPEG_STOP BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE BUTTON_UP
|
2008-01-10 08:08:31 +00:00
|
|
|
#define MPEG_VOLDOWN BUTTON_SCROLL_BACK
|
|
|
|
#define MPEG_VOLUP BUTTON_SCROLL_FWD
|
2008-01-03 17:14:28 +00:00
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
2006-10-26 13:38:09 +00:00
|
|
|
|
2007-09-20 10:49:48 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_C200_PAD
|
|
|
|
#define MPEG_MENU BUTTON_SELECT
|
|
|
|
#define MPEG_STOP BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE BUTTON_UP
|
|
|
|
#define MPEG_VOLDOWN BUTTON_VOL_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_VOL_UP
|
2008-01-03 17:14:28 +00:00
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
2007-09-20 10:49:48 +00:00
|
|
|
|
2007-10-25 07:44:56 +00:00
|
|
|
#elif CONFIG_KEYPAD == MROBE500_PAD
|
|
|
|
#define MPEG_MENU BUTTON_RC_HEART
|
|
|
|
#define MPEG_STOP BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE BUTTON_TOUCHPAD
|
|
|
|
#define MPEG_VOLDOWN BUTTON_RC_VOL_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_RC_VOL_UP
|
2008-01-03 17:14:28 +00:00
|
|
|
#define MPEG_RW BUTTON_RC_REW
|
|
|
|
#define MPEG_FF BUTTON_RC_FF
|
2007-10-25 07:44:56 +00:00
|
|
|
|
2006-08-09 10:47:22 +00:00
|
|
|
#else
|
|
|
|
#error MPEGPLAYER: Unsupported keypad
|
|
|
|
#endif
|
2006-08-20 23:12:56 +00:00
|
|
|
|
2007-01-01 12:59:32 +00:00
|
|
|
struct plugin_api* rb;
|
|
|
|
|
2007-09-28 11:12:45 +00:00
|
|
|
CACHE_FUNCTION_WRAPPERS(rb);
|
2007-12-29 19:46:35 +00:00
|
|
|
ALIGN_BUFFER_WRAPPER(rb);
|
2007-09-28 11:12:45 +00:00
|
|
|
|
2008-01-03 17:14:28 +00:00
|
|
|
/* One thing we can do here for targets with remotes is having a display
|
|
|
|
* always on the remote instead of always forcing a popup on the main display */
|
|
|
|
|
|
|
|
#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
|
|
|
|
/* 3% of 30min file == 54s step size */
|
|
|
|
#define MIN_FF_REWIND_STEP (TS_SECOND/2)
|
|
|
|
#define WVS_MIN_UPDATE_INTERVAL (HZ/2)
|
|
|
|
|
|
|
|
/* WVS status - same order as icon array */
|
|
|
|
enum wvs_status_enum
|
|
|
|
{
|
|
|
|
WVS_STATUS_STOPPED = 0,
|
|
|
|
WVS_STATUS_PAUSED,
|
|
|
|
WVS_STATUS_PLAYING,
|
|
|
|
WVS_STATUS_FF,
|
|
|
|
WVS_STATUS_RW,
|
|
|
|
WVS_STATUS_COUNT,
|
|
|
|
WVS_STATUS_MASK = 0x7
|
|
|
|
};
|
|
|
|
|
|
|
|
enum wvs_bits
|
2007-07-19 19:32:29 +00:00
|
|
|
{
|
2008-01-07 17:27:08 +00:00
|
|
|
WVS_REFRESH_DEFAULT = 0x0000, /* Only refresh elements when due */
|
|
|
|
/* Refresh the... */
|
|
|
|
WVS_REFRESH_VOLUME = 0x0001, /* ...volume display */
|
|
|
|
WVS_REFRESH_TIME = 0x0002, /* ...time display+progress */
|
|
|
|
WVS_REFRESH_STATUS = 0x0004, /* ...playback status icon */
|
|
|
|
WVS_REFRESH_BACKGROUND = 0x0008, /* ...background (implies ALL) */
|
|
|
|
WVS_REFRESH_VIDEO = 0x0010, /* ...video image upon timeout */
|
|
|
|
WVS_REFRESH_RESUME = 0x0020, /* Resume playback upon timeout */
|
|
|
|
WVS_NODRAW = 0x8000, /* OR bitflag - don't draw anything */
|
|
|
|
WVS_SHOW = 0x4000, /* OR bitflag - show the WVS */
|
|
|
|
WVS_HIDE = 0x0000, /* hide the WVS (aid readability) */
|
|
|
|
WVS_REFRESH_ALL = 0x000f, /* Only immediate graphical elements */
|
2008-01-03 17:14:28 +00:00
|
|
|
};
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Status icons selected according to font height */
|
2008-01-03 17:14:28 +00:00
|
|
|
extern const unsigned char mpegplayer_status_icons_8x8x1[];
|
|
|
|
extern const unsigned char mpegplayer_status_icons_12x12x1[];
|
|
|
|
extern const unsigned char mpegplayer_status_icons_16x16x1[];
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Main border areas that contain WVS elements */
|
2008-01-03 17:14:28 +00:00
|
|
|
#define WVS_BDR_L 2
|
|
|
|
#define WVS_BDR_T 2
|
|
|
|
#define WVS_BDR_R 2
|
|
|
|
#define WVS_BDR_B 2
|
|
|
|
|
|
|
|
struct wvs
|
|
|
|
{
|
|
|
|
long hide_tick;
|
|
|
|
long show_for;
|
|
|
|
long print_tick;
|
|
|
|
long print_delay;
|
|
|
|
long resume_tick;
|
|
|
|
long resume_delay;
|
|
|
|
long next_auto_refresh;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
unsigned fgcolor;
|
|
|
|
unsigned bgcolor;
|
|
|
|
unsigned prog_fillcolor;
|
|
|
|
struct vo_rect update_rect;
|
|
|
|
struct vo_rect prog_rect;
|
|
|
|
struct vo_rect time_rect;
|
|
|
|
struct vo_rect dur_rect;
|
|
|
|
struct vo_rect vol_rect;
|
|
|
|
const unsigned char *icons;
|
|
|
|
struct vo_rect stat_rect;
|
|
|
|
int status;
|
|
|
|
uint32_t curr_time;
|
|
|
|
unsigned auto_refresh;
|
|
|
|
unsigned flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct wvs wvs;
|
|
|
|
|
|
|
|
static void wvs_show(unsigned show);
|
|
|
|
|
|
|
|
#ifdef LCD_LANDSCAPE
|
|
|
|
#define _X (x + wvs.x)
|
|
|
|
#define _Y (y + wvs.y)
|
|
|
|
#define _W width
|
|
|
|
#define _H height
|
|
|
|
#else
|
|
|
|
#define _X (LCD_WIDTH - (y + wvs.y) - height)
|
|
|
|
#define _Y (x + wvs.x)
|
|
|
|
#define _W height
|
|
|
|
#define _H width
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Blend two colors in 0-100% (0-255) mix of c2 into c1 */
|
2008-01-03 17:14:28 +00:00
|
|
|
static unsigned draw_blendcolor(unsigned c1, unsigned c2, unsigned char amount)
|
|
|
|
{
|
|
|
|
int r1 = RGB_UNPACK_RED(c1);
|
|
|
|
int g1 = RGB_UNPACK_GREEN(c1);
|
|
|
|
int b1 = RGB_UNPACK_BLUE(c1);
|
|
|
|
|
|
|
|
int r2 = RGB_UNPACK_RED(c2);
|
|
|
|
int g2 = RGB_UNPACK_GREEN(c2);
|
|
|
|
int b2 = RGB_UNPACK_BLUE(c2);
|
|
|
|
|
|
|
|
return LCD_RGBPACK(amount*(r2 - r1) / 255 + r1,
|
|
|
|
amount*(g2 - g1) / 255 + g1,
|
|
|
|
amount*(b2 - b1) / 255 + b1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Drawing functions that operate rotated on LCD_PORTRAIT displays -
|
|
|
|
* most are just wrappers of lcd_* functions with transforms applied.
|
|
|
|
* The origin is the upper-left corner of the WVS area */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void draw_update_rect(int x, int y, int width, int height)
|
|
|
|
{
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(update_rect)(_X, _Y, _W, _H);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_clear_area(int x, int y, int width, int height)
|
|
|
|
{
|
2008-01-09 22:19:25 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-01-03 17:14:28 +00:00
|
|
|
rb->screen_clear_area(rb->screens[SCREEN_MAIN], _X, _Y, _W, _H);
|
2008-01-09 22:19:25 +00:00
|
|
|
#else
|
|
|
|
int oldmode = grey_get_drawmode();
|
|
|
|
grey_set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
|
|
|
|
grey_fillrect(_X, _Y, _W, _H);
|
|
|
|
grey_set_drawmode(oldmode);
|
|
|
|
#endif
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_clear_area_rect(const struct vo_rect *rc)
|
|
|
|
{
|
|
|
|
int x = rc->l;
|
|
|
|
int y = rc->t;
|
|
|
|
int width = rc->r - rc->l;
|
|
|
|
int height = rc->b - rc->t;
|
2008-01-09 22:19:25 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-01-03 17:14:28 +00:00
|
|
|
rb->screen_clear_area(rb->screens[SCREEN_MAIN], _X, _Y, _W, _H);
|
2008-01-09 22:19:25 +00:00
|
|
|
#else
|
|
|
|
int oldmode = grey_get_drawmode();
|
|
|
|
grey_set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID);
|
|
|
|
grey_fillrect(_X, _Y, _W, _H);
|
|
|
|
grey_set_drawmode(oldmode);
|
|
|
|
#endif
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
static void draw_fillrect(int x, int y, int width, int height)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(fillrect)(_X, _Y, _W, _H);
|
|
|
|
}
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
static void draw_hline(int x1, int x2, int y)
|
|
|
|
{
|
2008-01-03 17:14:28 +00:00
|
|
|
#ifdef LCD_LANDSCAPE
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(hline)(x1 + wvs.x, x2 + wvs.x, y + wvs.y);
|
|
|
|
#else
|
|
|
|
y = LCD_WIDTH - (y + wvs.y) - 1;
|
|
|
|
lcd_(vline)(y, x1 + wvs.x, x2 + wvs.x);
|
2008-01-03 17:14:28 +00:00
|
|
|
#endif
|
2008-01-09 22:19:25 +00:00
|
|
|
}
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
static void draw_vline(int x, int y1, int y2)
|
|
|
|
{
|
|
|
|
#ifdef LCD_LANDSCAPE
|
|
|
|
lcd_(vline)(x + wvs.x, y1 + wvs.y, y2 + wvs.y);
|
|
|
|
#else
|
|
|
|
y1 = LCD_WIDTH - (y1 + wvs.y) - 1;
|
|
|
|
y2 = LCD_WIDTH - (y2 + wvs.y) - 1;
|
|
|
|
lcd_(hline)(y1, y2, x + wvs.x);
|
2008-01-03 17:14:28 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
static void draw_scrollbar_draw(int x, int y, int width, int height,
|
|
|
|
uint32_t min, uint32_t max, uint32_t val)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2008-01-09 22:19:25 +00:00
|
|
|
unsigned oldfg = lcd_(get_foreground)();
|
|
|
|
|
|
|
|
draw_hline(x + 1, x + width - 2, y);
|
|
|
|
draw_hline(x + 1, x + width - 2, y + height - 1);
|
|
|
|
draw_vline(x, y + 1, y + height - 2);
|
|
|
|
draw_vline(x + width - 1, y + 1, y + height - 2);
|
|
|
|
|
|
|
|
val = muldiv_uint32(width - 2, val, max - min);
|
|
|
|
val = MIN(val, (uint32_t)(width - 2));
|
|
|
|
|
|
|
|
draw_fillrect(x + 1, y + 1, val, height - 2);
|
|
|
|
|
|
|
|
lcd_(set_foreground)(wvs.prog_fillcolor);
|
|
|
|
|
|
|
|
draw_fillrect(x + 1 + val, y + 1, width - 2 - val, height - 2);
|
|
|
|
|
|
|
|
lcd_(set_foreground)(oldfg);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
static void draw_scrollbar_draw_rect(const struct vo_rect *rc, int min,
|
|
|
|
int max, int val)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2008-01-09 22:19:25 +00:00
|
|
|
draw_scrollbar_draw(rc->l, rc->t, rc->r - rc->l, rc->b - rc->t,
|
|
|
|
min, max, val);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef LCD_PORTRAIT
|
|
|
|
/* Portrait displays need rotated text rendering */
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Limited function that only renders in DRMODE_FG and uses absolute screen
|
|
|
|
* coordinates */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void draw_oriented_mono_bitmap_part(const unsigned char *src,
|
|
|
|
int src_x, int src_y,
|
|
|
|
int stride, int x, int y,
|
|
|
|
int width, int height)
|
|
|
|
{
|
|
|
|
const unsigned char *src_end;
|
|
|
|
fb_data *dst, *dst_end;
|
|
|
|
unsigned fg_pattern, bg_pattern;
|
|
|
|
|
|
|
|
if (x + width > SCREEN_WIDTH)
|
|
|
|
width = SCREEN_WIDTH - x; /* Clip right */
|
|
|
|
if (x < 0)
|
|
|
|
width += x, x = 0; /* Clip left */
|
|
|
|
if (width <= 0)
|
|
|
|
return; /* nothing left to do */
|
|
|
|
|
|
|
|
if (y + height > SCREEN_HEIGHT)
|
|
|
|
height = SCREEN_HEIGHT - y; /* Clip bottom */
|
|
|
|
if (y < 0)
|
|
|
|
height += y, y = 0; /* Clip top */
|
|
|
|
if (height <= 0)
|
|
|
|
return; /* nothing left to do */
|
|
|
|
|
|
|
|
fg_pattern = rb->lcd_get_foreground();
|
|
|
|
bg_pattern = rb->lcd_get_background();
|
|
|
|
|
|
|
|
src += stride * (src_y >> 3) + src_x; /* move starting point */
|
|
|
|
src_y &= 7;
|
|
|
|
src_end = src + width;
|
|
|
|
|
|
|
|
dst = rb->lcd_framebuffer + (LCD_WIDTH - y) + x*LCD_WIDTH;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
const unsigned char *src_col = src++;
|
|
|
|
unsigned data = *src_col >> src_y;
|
|
|
|
int numbits = 8 - src_y;
|
|
|
|
|
|
|
|
fb_data *dst_col = dst;
|
|
|
|
dst_end = dst_col - height;
|
|
|
|
dst += LCD_WIDTH;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
dst_col--;
|
|
|
|
|
|
|
|
if (data & 1)
|
|
|
|
*dst_col = fg_pattern;
|
|
|
|
#if 0
|
|
|
|
else
|
|
|
|
*dst_col = bg_pattern;
|
|
|
|
#endif
|
|
|
|
data >>= 1;
|
|
|
|
if (--numbits == 0) {
|
|
|
|
src_col += stride;
|
|
|
|
data = *src_col;
|
|
|
|
numbits = 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (dst_col > dst_end);
|
|
|
|
}
|
|
|
|
while (src < src_end);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_putsxy_oriented(int x, int y, const char *str)
|
|
|
|
{
|
|
|
|
unsigned short ch;
|
|
|
|
unsigned short *ucs;
|
|
|
|
int ofs = MIN(x, 0);
|
|
|
|
struct font* pf = rb->font_get(FONT_UI);
|
|
|
|
|
|
|
|
ucs = rb->bidi_l2v(str, 1);
|
|
|
|
|
|
|
|
x += wvs.x;
|
|
|
|
y += wvs.y;
|
|
|
|
|
|
|
|
while ((ch = *ucs++) != 0 && x < SCREEN_WIDTH)
|
|
|
|
{
|
|
|
|
int width;
|
|
|
|
const unsigned char *bits;
|
|
|
|
|
|
|
|
/* get proportional width and glyph bits */
|
|
|
|
width = rb->font_get_width(pf, ch);
|
|
|
|
|
|
|
|
if (ofs > width) {
|
|
|
|
ofs -= width;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bits = rb->font_get_bits(pf, ch);
|
|
|
|
|
|
|
|
draw_oriented_mono_bitmap_part(bits, ofs, 0, width, x, y,
|
|
|
|
width - ofs, pf->height);
|
|
|
|
|
|
|
|
x += width - ofs;
|
|
|
|
ofs = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
static void draw_oriented_mono_bitmap_part(const unsigned char *src,
|
|
|
|
int src_x, int src_y,
|
|
|
|
int stride, int x, int y,
|
|
|
|
int width, int height)
|
|
|
|
{
|
2008-01-09 22:19:25 +00:00
|
|
|
int mode = lcd_(get_drawmode)();
|
|
|
|
lcd_(set_drawmode)(DRMODE_FG);
|
|
|
|
lcd_(mono_bitmap_part)(src, src_x, src_y, stride, x, y, width, height);
|
|
|
|
lcd_(set_drawmode)(mode);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_putsxy_oriented(int x, int y, const char *str)
|
|
|
|
{
|
2008-01-09 22:19:25 +00:00
|
|
|
int mode = lcd_(get_drawmode)();
|
|
|
|
lcd_(set_drawmode)(DRMODE_FG);
|
|
|
|
lcd_(putsxy)(x + wvs.x, y + wvs.y, str);
|
|
|
|
lcd_(set_drawmode)(mode);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
#endif /* LCD_PORTRAIT */
|
|
|
|
|
|
|
|
|
|
|
|
static void wvs_text_init(void)
|
|
|
|
{
|
|
|
|
struct hms hms;
|
|
|
|
char buf[32];
|
|
|
|
int phys;
|
|
|
|
int spc_width;
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(setfont)(FONT_UI);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
wvs.x = 0;
|
|
|
|
wvs.width = SCREEN_WIDTH;
|
|
|
|
|
|
|
|
vo_rect_clear(&wvs.time_rect);
|
|
|
|
vo_rect_clear(&wvs.stat_rect);
|
|
|
|
vo_rect_clear(&wvs.prog_rect);
|
|
|
|
vo_rect_clear(&wvs.vol_rect);
|
|
|
|
|
|
|
|
ts_to_hms(stream_get_duration(), &hms);
|
|
|
|
hms_format(buf, sizeof (buf), &hms);
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(getstringsize)(buf, &wvs.time_rect.r, &wvs.time_rect.b);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
/* Choose well-sized bitmap images relative to font height */
|
|
|
|
if (wvs.time_rect.b < 12) {
|
|
|
|
wvs.icons = mpegplayer_status_icons_8x8x1;
|
|
|
|
wvs.stat_rect.r = wvs.stat_rect.b = 8;
|
|
|
|
} else if (wvs.time_rect.b < 16) {
|
|
|
|
wvs.icons = mpegplayer_status_icons_12x12x1;
|
|
|
|
wvs.stat_rect.r = wvs.stat_rect.b = 12;
|
|
|
|
} else {
|
|
|
|
wvs.icons = mpegplayer_status_icons_16x16x1;
|
|
|
|
wvs.stat_rect.r = wvs.stat_rect.b = 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wvs.stat_rect.b < wvs.time_rect.b) {
|
|
|
|
vo_rect_offset(&wvs.stat_rect, 0,
|
|
|
|
(wvs.time_rect.b - wvs.stat_rect.b) / 2 + WVS_BDR_T);
|
|
|
|
vo_rect_offset(&wvs.time_rect, WVS_BDR_L, WVS_BDR_T);
|
|
|
|
} else {
|
|
|
|
vo_rect_offset(&wvs.time_rect, WVS_BDR_L,
|
|
|
|
wvs.stat_rect.b - wvs.time_rect.b + WVS_BDR_T);
|
|
|
|
vo_rect_offset(&wvs.stat_rect, 0, WVS_BDR_T);
|
|
|
|
}
|
|
|
|
|
|
|
|
wvs.dur_rect = wvs.time_rect;
|
|
|
|
|
|
|
|
phys = rb->sound_val2phys(SOUND_VOLUME, rb->sound_min(SOUND_VOLUME));
|
|
|
|
rb->snprintf(buf, sizeof(buf), "%d%s", phys,
|
|
|
|
rb->sound_unit(SOUND_VOLUME));
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(getstringsize)(" ", &spc_width, NULL);
|
|
|
|
lcd_(getstringsize)(buf, &wvs.vol_rect.r, &wvs.vol_rect.b);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
wvs.prog_rect.r = SCREEN_WIDTH - WVS_BDR_L - spc_width -
|
|
|
|
wvs.vol_rect.r - WVS_BDR_R;
|
|
|
|
wvs.prog_rect.b = 3*wvs.stat_rect.b / 4;
|
|
|
|
vo_rect_offset(&wvs.prog_rect, wvs.time_rect.l,
|
|
|
|
wvs.time_rect.b);
|
|
|
|
|
|
|
|
vo_rect_offset(&wvs.stat_rect,
|
|
|
|
(wvs.prog_rect.r + wvs.prog_rect.l - wvs.stat_rect.r) / 2,
|
|
|
|
0);
|
|
|
|
|
|
|
|
vo_rect_offset(&wvs.dur_rect,
|
|
|
|
wvs.prog_rect.r - wvs.dur_rect.r, 0);
|
|
|
|
|
|
|
|
vo_rect_offset(&wvs.vol_rect, wvs.prog_rect.r + spc_width,
|
|
|
|
(wvs.prog_rect.b + wvs.prog_rect.t - wvs.vol_rect.b) / 2);
|
|
|
|
|
|
|
|
wvs.height = WVS_BDR_T + MAX(wvs.prog_rect.b, wvs.vol_rect.b) -
|
|
|
|
MIN(wvs.time_rect.t, wvs.stat_rect.t) + WVS_BDR_B;
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs.height = ALIGN_UP(wvs.height, 2);
|
|
|
|
#endif
|
|
|
|
wvs.y = SCREEN_HEIGHT - wvs.height;
|
2007-07-19 19:32:29 +00:00
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(setfont)(FONT_SYSFIXED);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void wvs_init(void)
|
|
|
|
{
|
|
|
|
wvs.flags = 0;
|
|
|
|
wvs.show_for = HZ*4;
|
|
|
|
wvs.print_delay = 75*HZ/100;
|
|
|
|
wvs.resume_delay = HZ/2;
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
wvs.bgcolor = LCD_RGBPACK(0x73, 0x75, 0xbd);
|
|
|
|
wvs.fgcolor = LCD_WHITE;
|
|
|
|
wvs.prog_fillcolor = LCD_BLACK;
|
|
|
|
#else
|
2008-01-09 22:19:25 +00:00
|
|
|
wvs.bgcolor = GREY_LIGHTGRAY;
|
|
|
|
wvs.fgcolor = GREY_BLACK;
|
|
|
|
wvs.prog_fillcolor = GREY_WHITE;
|
2008-01-03 17:14:28 +00:00
|
|
|
#endif
|
|
|
|
wvs.curr_time = 0;
|
|
|
|
wvs.status = WVS_STATUS_STOPPED;
|
|
|
|
wvs.auto_refresh = WVS_REFRESH_TIME;
|
|
|
|
wvs.next_auto_refresh = *rb->current_tick;
|
|
|
|
wvs_text_init();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wvs_schedule_refresh(unsigned refresh)
|
|
|
|
{
|
|
|
|
long tick = *rb->current_tick;
|
|
|
|
|
|
|
|
if (refresh & WVS_REFRESH_VIDEO)
|
|
|
|
wvs.print_tick = tick + wvs.print_delay;
|
|
|
|
|
|
|
|
if (refresh & WVS_REFRESH_RESUME)
|
|
|
|
wvs.resume_tick = tick + wvs.resume_delay;
|
|
|
|
|
|
|
|
wvs.auto_refresh |= refresh;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wvs_cancel_refresh(unsigned refresh)
|
|
|
|
{
|
|
|
|
wvs.auto_refresh &= ~refresh;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Refresh the background area */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void wvs_refresh_background(void)
|
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
struct hms hms;
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
unsigned bg = lcd_(get_background)();
|
|
|
|
lcd_(set_drawmode)(DRMODE_SOLID | DRMODE_INVERSEVID);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Draw a "raised" area for our graphics */
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(set_background)(draw_blendcolor(bg, DRAW_WHITE, 192));
|
2008-01-03 17:14:28 +00:00
|
|
|
draw_hline(0, wvs.width, 0);
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(set_background)(draw_blendcolor(bg, DRAW_WHITE, 80));
|
2008-01-03 17:14:28 +00:00
|
|
|
draw_hline(0, wvs.width, 1);
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(set_background)(draw_blendcolor(bg, DRAW_BLACK, 48));
|
2008-01-03 17:14:28 +00:00
|
|
|
draw_hline(0, wvs.width, wvs.height-2);
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(set_background)(draw_blendcolor(bg, DRAW_BLACK, 128));
|
2008-01-03 17:14:28 +00:00
|
|
|
draw_hline(0, wvs.width, wvs.height-1);
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(set_background)(bg);
|
2008-01-03 17:14:28 +00:00
|
|
|
draw_clear_area(0, 2, wvs.width, wvs.height - 4);
|
|
|
|
#else
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Give contrast with the main background */
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(set_background)(GREY_WHITE);
|
2008-01-03 17:14:28 +00:00
|
|
|
draw_hline(0, wvs.width, 0);
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(set_background)(GREY_DARKGRAY);
|
|
|
|
draw_hline(0, wvs.width, wvs.height-1);
|
|
|
|
|
|
|
|
lcd_(set_background)(bg);
|
|
|
|
draw_clear_area(0, 1, wvs.width, wvs.height - 2);
|
2008-01-03 17:14:28 +00:00
|
|
|
#endif
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
vo_rect_set_ext(&wvs.update_rect, 0, 0, wvs.width, wvs.height);
|
|
|
|
lcd_(set_drawmode)(DRMODE_SOLID);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
if (stream_get_duration() != INVALID_TIMESTAMP) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Draw the movie duration */
|
2008-01-03 17:14:28 +00:00
|
|
|
ts_to_hms(stream_get_duration(), &hms);
|
|
|
|
hms_format(buf, sizeof (buf), &hms);
|
|
|
|
draw_putsxy_oriented(wvs.dur_rect.l, wvs.dur_rect.t, buf);
|
|
|
|
}
|
2008-01-07 17:27:08 +00:00
|
|
|
/* else don't know the duration */
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Refresh the current time display + the progress bar */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void wvs_refresh_time(void)
|
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
struct hms hms;
|
|
|
|
|
|
|
|
uint32_t duration = stream_get_duration();
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
draw_scrollbar_draw_rect(&wvs.prog_rect, 0, duration,
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs.curr_time);
|
|
|
|
|
|
|
|
ts_to_hms(wvs.curr_time, &hms);
|
|
|
|
hms_format(buf, sizeof (buf), &hms);
|
|
|
|
|
|
|
|
draw_clear_area_rect(&wvs.time_rect);
|
|
|
|
draw_putsxy_oriented(wvs.time_rect.l, wvs.time_rect.t, buf);
|
|
|
|
|
|
|
|
vo_rect_union(&wvs.update_rect, &wvs.update_rect,
|
|
|
|
&wvs.prog_rect);
|
|
|
|
vo_rect_union(&wvs.update_rect, &wvs.update_rect,
|
|
|
|
&wvs.time_rect);
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Refresh the volume display area */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void wvs_refresh_volume(void)
|
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
int width;
|
|
|
|
|
|
|
|
int volume = rb->global_settings->volume;
|
|
|
|
rb->snprintf(buf, sizeof (buf), "%d%s",
|
|
|
|
rb->sound_val2phys(SOUND_VOLUME, volume),
|
|
|
|
rb->sound_unit(SOUND_VOLUME));
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(getstringsize)(buf, &width, NULL);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
/* Right-justified */
|
|
|
|
draw_clear_area_rect(&wvs.vol_rect);
|
|
|
|
draw_putsxy_oriented(wvs.vol_rect.r - width, wvs.vol_rect.t, buf);
|
|
|
|
|
|
|
|
vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.vol_rect);
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Refresh the status icon */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void wvs_refresh_status(void)
|
|
|
|
{
|
|
|
|
int icon_size = wvs.stat_rect.r - wvs.stat_rect.l;
|
|
|
|
|
|
|
|
draw_clear_area_rect(&wvs.stat_rect);
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
/* Draw status icon with a drop shadow */
|
2008-01-09 22:19:25 +00:00
|
|
|
unsigned oldfg = lcd_(get_foreground)();
|
2008-01-03 17:14:28 +00:00
|
|
|
int i = 1;
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(set_foreground)(draw_blendcolor(lcd_(get_background)(),
|
|
|
|
DRAW_BLACK, 96));
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
draw_oriented_mono_bitmap_part(wvs.icons,
|
|
|
|
icon_size*wvs.status,
|
|
|
|
0,
|
|
|
|
icon_size*WVS_STATUS_COUNT,
|
|
|
|
wvs.stat_rect.l + wvs.x + i,
|
|
|
|
wvs.stat_rect.t + wvs.y + i,
|
|
|
|
icon_size, icon_size);
|
|
|
|
|
|
|
|
if (--i < 0)
|
|
|
|
break;
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(set_foreground)(oldfg);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.stat_rect);
|
|
|
|
#else
|
|
|
|
draw_oriented_mono_bitmap_part(wvs.icons,
|
|
|
|
icon_size*wvs.status,
|
|
|
|
0,
|
|
|
|
icon_size*WVS_STATUS_COUNT,
|
|
|
|
wvs.stat_rect.l + wvs.x,
|
|
|
|
wvs.stat_rect.t + wvs.y,
|
|
|
|
icon_size, icon_size);
|
2008-01-09 22:19:25 +00:00
|
|
|
vo_rect_union(&wvs.update_rect, &wvs.update_rect, &wvs.stat_rect);
|
2008-01-03 17:14:28 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Update the current status which determines which icon is displayed */
|
2008-01-03 17:14:28 +00:00
|
|
|
static bool wvs_update_status(void)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
switch (stream_status())
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
status = WVS_STATUS_STOPPED;
|
|
|
|
break;
|
|
|
|
case STREAM_PAUSED:
|
2008-01-07 17:27:08 +00:00
|
|
|
/* If paused with a pending resume, coerce it to WVS_STATUS_PLAYING */
|
2008-01-03 17:14:28 +00:00
|
|
|
status = (wvs.auto_refresh & WVS_REFRESH_RESUME) ?
|
|
|
|
WVS_STATUS_PLAYING : WVS_STATUS_PAUSED;
|
|
|
|
break;
|
|
|
|
case STREAM_PLAYING:
|
|
|
|
status = WVS_STATUS_PLAYING;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status != wvs.status) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* A refresh is needed */
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs.status = status;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Update the current time that will be displayed */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void wvs_update_time(void)
|
|
|
|
{
|
|
|
|
uint32_t start;
|
|
|
|
wvs.curr_time = stream_get_seek_time(&start);
|
|
|
|
wvs.curr_time -= start;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Refresh various parts of the WVS - showing it if it is hidden */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void wvs_refresh(int hint)
|
|
|
|
{
|
|
|
|
long tick;
|
|
|
|
unsigned oldbg, oldfg;
|
|
|
|
|
|
|
|
tick = *rb->current_tick;
|
|
|
|
|
|
|
|
if (hint == WVS_REFRESH_DEFAULT) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* The default which forces no updates */
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Redraw the current or possibly extract a new video frame */
|
2008-01-03 17:14:28 +00:00
|
|
|
if ((wvs.auto_refresh & WVS_REFRESH_VIDEO) &&
|
|
|
|
TIME_AFTER(tick, wvs.print_tick)) {
|
|
|
|
wvs.auto_refresh &= ~WVS_REFRESH_VIDEO;
|
|
|
|
stream_draw_frame(false);
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Restart playback if the timout was reached */
|
2008-01-03 17:14:28 +00:00
|
|
|
if ((wvs.auto_refresh & WVS_REFRESH_RESUME) &&
|
|
|
|
TIME_AFTER(tick, wvs.resume_tick)) {
|
|
|
|
wvs.auto_refresh &= ~(WVS_REFRESH_RESUME | WVS_REFRESH_VIDEO);
|
|
|
|
stream_resume();
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* If not visible, return */
|
2008-01-03 17:14:28 +00:00
|
|
|
if (!(wvs.flags & WVS_SHOW))
|
|
|
|
return;
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Hide if the visibility duration was reached */
|
2008-01-03 17:14:28 +00:00
|
|
|
if (TIME_AFTER(tick, wvs.hide_tick)) {
|
|
|
|
wvs_show(WVS_HIDE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* A forced update of some region */
|
|
|
|
|
|
|
|
/* Show if currently invisible */
|
2008-01-03 17:14:28 +00:00
|
|
|
if (!(wvs.flags & WVS_SHOW)) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Avoid call back into this function - it will be drawn */
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_show(WVS_SHOW | WVS_NODRAW);
|
|
|
|
hint = WVS_REFRESH_ALL;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Move back timeouts for frame print and hide */
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs.print_tick = tick + wvs.print_delay;
|
|
|
|
wvs.hide_tick = tick + wvs.show_for;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TIME_AFTER(tick, wvs.next_auto_refresh)) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Refresh whatever graphical elements are due automatically */
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs.next_auto_refresh = tick + WVS_MIN_UPDATE_INTERVAL;
|
|
|
|
|
|
|
|
if (wvs.auto_refresh & WVS_REFRESH_STATUS) {
|
|
|
|
if (wvs_update_status())
|
|
|
|
hint |= WVS_REFRESH_STATUS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wvs.auto_refresh & WVS_REFRESH_TIME) {
|
|
|
|
wvs_update_time();
|
|
|
|
hint |= WVS_REFRESH_TIME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hint == 0)
|
2008-01-07 17:27:08 +00:00
|
|
|
return; /* No drawing needed */
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Set basic drawing params that are used. Elements that perform variations
|
|
|
|
* will restore them. */
|
2008-01-09 22:19:25 +00:00
|
|
|
oldfg = lcd_(get_foreground)();
|
|
|
|
oldbg = lcd_(get_background)();
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(setfont)(FONT_UI);
|
|
|
|
lcd_(set_foreground)(wvs.fgcolor);
|
|
|
|
lcd_(set_background)(wvs.bgcolor);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
vo_rect_clear(&wvs.update_rect);
|
|
|
|
|
|
|
|
if (hint & WVS_REFRESH_BACKGROUND) {
|
|
|
|
wvs_refresh_background();
|
|
|
|
hint |= WVS_REFRESH_ALL; /* Requires a redraw of everything */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hint & WVS_REFRESH_TIME) {
|
|
|
|
wvs_refresh_time();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hint & WVS_REFRESH_VOLUME) {
|
|
|
|
wvs_refresh_volume();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hint & WVS_REFRESH_STATUS) {
|
|
|
|
wvs_refresh_status();
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Go back to defaults */
|
2008-01-09 22:19:25 +00:00
|
|
|
lcd_(setfont)(FONT_SYSFIXED);
|
|
|
|
lcd_(set_foreground)(oldfg);
|
|
|
|
lcd_(set_background)(oldbg);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Update the dirty rectangle */
|
2008-01-03 17:14:28 +00:00
|
|
|
vo_lock();
|
|
|
|
|
|
|
|
draw_update_rect(wvs.update_rect.l,
|
|
|
|
wvs.update_rect.t,
|
|
|
|
wvs.update_rect.r - wvs.update_rect.l,
|
|
|
|
wvs.update_rect.b - wvs.update_rect.t);
|
|
|
|
|
|
|
|
vo_unlock();
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Show/Hide the WVS */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void wvs_show(unsigned show)
|
|
|
|
{
|
|
|
|
if (((show ^ wvs.flags) & WVS_SHOW) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (show & WVS_SHOW) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Clip away the part of video that is covered */
|
2008-01-03 17:14:28 +00:00
|
|
|
struct vo_rect rc = { 0, 0, SCREEN_WIDTH, wvs.y };
|
|
|
|
|
|
|
|
wvs.flags |= WVS_SHOW;
|
|
|
|
|
|
|
|
stream_vo_set_clip(&rc);
|
|
|
|
|
|
|
|
if (!(show & WVS_NODRAW))
|
|
|
|
wvs_refresh(WVS_REFRESH_ALL);
|
|
|
|
} else {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Uncover clipped video area and redraw it */
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs.flags &= ~WVS_SHOW;
|
|
|
|
|
|
|
|
stream_vo_set_clip(NULL);
|
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-01-03 17:14:28 +00:00
|
|
|
draw_clear_area(0, 0, wvs.width, wvs.height);
|
2008-01-09 22:19:25 +00:00
|
|
|
#endif
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
if (!(show & WVS_NODRAW)) {
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
vo_lock();
|
|
|
|
draw_update_rect(0, 0, wvs.width, wvs.height);
|
|
|
|
vo_unlock();
|
|
|
|
#endif
|
|
|
|
stream_draw_frame(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Set the current status - update screen if specified */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void wvs_set_status(int status)
|
|
|
|
{
|
|
|
|
bool draw = (status & WVS_NODRAW) == 0;
|
|
|
|
|
|
|
|
status &= WVS_STATUS_MASK;
|
|
|
|
|
|
|
|
if (wvs.status != status) {
|
|
|
|
|
|
|
|
wvs.status = status;
|
|
|
|
|
|
|
|
if (draw)
|
|
|
|
wvs_refresh(WVS_REFRESH_STATUS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle Fast-forward/Rewind keys using WPS settings (and some nicked code ;) */
|
|
|
|
static uint32_t wvs_ff_rw(int btn, unsigned refresh)
|
|
|
|
{
|
|
|
|
unsigned int step = TS_SECOND*rb->global_settings->ff_rewind_min_step;
|
|
|
|
const long ff_rw_accel = rb->global_settings->ff_rewind_accel;
|
|
|
|
long accel_tick = *rb->current_tick + ff_rw_accel*HZ;
|
|
|
|
uint32_t start;
|
|
|
|
uint32_t time = stream_get_seek_time(&start);
|
|
|
|
const uint32_t duration = stream_get_duration();
|
|
|
|
unsigned int max_step = 0;
|
|
|
|
uint32_t ff_rw_count = 0;
|
|
|
|
unsigned status = wvs.status;
|
|
|
|
|
|
|
|
wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME |
|
|
|
|
WVS_REFRESH_TIME);
|
|
|
|
|
|
|
|
time -= start; /* Absolute clock => stream-relative */
|
|
|
|
|
|
|
|
switch (btn)
|
|
|
|
{
|
|
|
|
case MPEG_FF:
|
|
|
|
wvs_set_status(WVS_STATUS_FF);
|
|
|
|
break;
|
|
|
|
case MPEG_RW:
|
|
|
|
wvs_set_status(WVS_STATUS_RW);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
btn = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
btn |= BUTTON_REPEAT;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
long tick = *rb->current_tick;
|
|
|
|
stream_keep_disk_active();
|
|
|
|
|
|
|
|
switch (btn)
|
|
|
|
{
|
|
|
|
case BUTTON_NONE:
|
|
|
|
wvs_refresh(WVS_REFRESH_DEFAULT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MPEG_FF | BUTTON_REPEAT:
|
|
|
|
case MPEG_RW | BUTTON_REPEAT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MPEG_FF | BUTTON_REL:
|
|
|
|
case MPEG_RW | BUTTON_REL:
|
|
|
|
if (wvs.status == WVS_STATUS_FF)
|
|
|
|
time += ff_rw_count;
|
|
|
|
else if (wvs.status == WVS_STATUS_RW)
|
|
|
|
time -= ff_rw_count;
|
|
|
|
|
|
|
|
/* Fall-through */
|
|
|
|
case -1:
|
|
|
|
default:
|
|
|
|
wvs_schedule_refresh(refresh);
|
|
|
|
wvs_set_status(status);
|
|
|
|
wvs_schedule_refresh(WVS_REFRESH_TIME);
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wvs.status == WVS_STATUS_FF) {
|
|
|
|
/* fast forwarding, calc max step relative to end */
|
|
|
|
max_step = muldiv_uint32(duration - (time + ff_rw_count),
|
|
|
|
FF_REWIND_MAX_PERCENT, 100);
|
|
|
|
} else {
|
|
|
|
/* rewinding, calc max step relative to start */
|
|
|
|
max_step = muldiv_uint32(time - ff_rw_count,
|
|
|
|
FF_REWIND_MAX_PERCENT, 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
max_step = MAX(max_step, MIN_FF_REWIND_STEP);
|
|
|
|
|
|
|
|
if (step > max_step)
|
|
|
|
step = max_step;
|
|
|
|
|
|
|
|
ff_rw_count += step;
|
|
|
|
|
|
|
|
if (ff_rw_accel != 0 && TIME_AFTER(tick, accel_tick)) {
|
|
|
|
step *= 2;
|
|
|
|
accel_tick = tick + ff_rw_accel*HZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wvs.status == WVS_STATUS_FF) {
|
|
|
|
if (duration - time <= ff_rw_count)
|
|
|
|
ff_rw_count = duration - time;
|
|
|
|
|
|
|
|
wvs.curr_time = time + ff_rw_count;
|
|
|
|
} else {
|
|
|
|
if (time <= ff_rw_count)
|
|
|
|
ff_rw_count = time;
|
|
|
|
|
|
|
|
wvs.curr_time = time - ff_rw_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
wvs_refresh(WVS_REFRESH_TIME);
|
|
|
|
|
|
|
|
btn = rb->button_get_w_tmo(WVS_MIN_UPDATE_INTERVAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wvs_status(void)
|
|
|
|
{
|
|
|
|
int status = stream_status();
|
|
|
|
|
|
|
|
/* Coerce to STREAM_PLAYING if paused with a pending resume */
|
|
|
|
if (status == STREAM_PAUSED) {
|
|
|
|
if (wvs.auto_refresh & WVS_REFRESH_RESUME)
|
|
|
|
status = STREAM_PLAYING;
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Change the current audio volume by a specified amount */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void wvs_set_volume(int delta)
|
|
|
|
{
|
|
|
|
int vol = rb->global_settings->volume;
|
|
|
|
int limit;
|
|
|
|
|
|
|
|
vol += delta;
|
|
|
|
|
|
|
|
if (delta < 0) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Volume down - clip to lower limit */
|
2008-01-03 17:14:28 +00:00
|
|
|
limit = rb->sound_min(SOUND_VOLUME);
|
|
|
|
if (vol < limit)
|
|
|
|
vol = limit;
|
|
|
|
} else {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Volume up - clip to upper limit */
|
2008-01-03 17:14:28 +00:00
|
|
|
limit = rb->sound_max(SOUND_VOLUME);
|
|
|
|
if (vol > limit)
|
|
|
|
vol = limit;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Sync the global settings */
|
2008-01-03 17:14:28 +00:00
|
|
|
if (vol != rb->global_settings->volume) {
|
|
|
|
rb->sound_set(SOUND_VOLUME, vol);
|
|
|
|
rb->global_settings->volume = vol;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Update the volume display */
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_refresh(WVS_REFRESH_VOLUME);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wvs_play(uint32_t time)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME);
|
|
|
|
|
|
|
|
retval = stream_seek(time, SEEK_SET);
|
|
|
|
|
|
|
|
if (retval >= STREAM_OK) {
|
|
|
|
stream_show_vo(true);
|
|
|
|
retval = stream_play();
|
|
|
|
|
|
|
|
if (retval >= STREAM_OK)
|
|
|
|
wvs_set_status(WVS_STATUS_PLAYING | WVS_NODRAW);
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Halt playback - pause engine and return logical state */
|
2008-01-03 17:14:28 +00:00
|
|
|
static int wvs_halt(void)
|
|
|
|
{
|
|
|
|
int status = stream_pause();
|
|
|
|
|
|
|
|
/* Coerce to STREAM_PLAYING if paused with a pending resume */
|
|
|
|
if (status == STREAM_PAUSED) {
|
|
|
|
if (wvs.auto_refresh & WVS_REFRESH_RESUME)
|
|
|
|
status = STREAM_PLAYING;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Cancel some auto refreshes - caller will restart them if desired */
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Pause playback if playing */
|
2008-01-03 17:14:28 +00:00
|
|
|
static int wvs_pause(void)
|
|
|
|
{
|
|
|
|
unsigned refresh = wvs.auto_refresh;
|
|
|
|
int status = wvs_halt();
|
|
|
|
|
|
|
|
if (status == STREAM_PLAYING && (refresh & WVS_REFRESH_RESUME)) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Resume pending - change to a still video frame update */
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_schedule_refresh(WVS_REFRESH_VIDEO);
|
|
|
|
}
|
|
|
|
|
|
|
|
wvs_set_status(WVS_STATUS_PAUSED);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Resume playback if halted or paused */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void wvs_resume(void)
|
|
|
|
{
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Cancel video and resume auto refresh - the resyc when starting playback
|
|
|
|
* will perform those tasks */
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME);
|
|
|
|
wvs_set_status(WVS_STATUS_PLAYING);
|
|
|
|
stream_resume();
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Stop playback - remember the resume point if not already stopped */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void wvs_stop(void)
|
|
|
|
{
|
|
|
|
wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME);
|
|
|
|
wvs_show(WVS_HIDE | WVS_NODRAW);
|
|
|
|
|
|
|
|
if (stream_stop() != STREAM_STOPPED)
|
|
|
|
settings.resume_time = stream_get_resume_time();
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Perform a seek if seeking is possible for this stream - if playing, a delay
|
|
|
|
* will be inserted before restarting in case the user decides to seek again */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void wvs_seek(int btn)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
unsigned refresh;
|
|
|
|
uint32_t time;
|
|
|
|
|
|
|
|
if (!stream_can_seek())
|
|
|
|
return;
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Halt playback - not strictly nescessary but nice */
|
2008-01-03 17:14:28 +00:00
|
|
|
status = wvs_halt();
|
|
|
|
|
|
|
|
if (status == STREAM_STOPPED)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wvs_show(WVS_SHOW);
|
|
|
|
|
|
|
|
if (status == STREAM_PLAYING)
|
|
|
|
refresh = WVS_REFRESH_RESUME; /* delay resume if playing */
|
|
|
|
else
|
|
|
|
refresh = WVS_REFRESH_VIDEO; /* refresh if paused */
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Obtain a new playback point */
|
2008-01-03 17:14:28 +00:00
|
|
|
time = wvs_ff_rw(btn, refresh);
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Tell engine to resume at that time */
|
2008-01-03 17:14:28 +00:00
|
|
|
stream_seek(time, SEEK_SET);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void button_loop(void)
|
|
|
|
{
|
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
2007-12-29 19:46:35 +00:00
|
|
|
rb->lcd_clear_display();
|
|
|
|
rb->lcd_update();
|
2007-07-19 19:32:29 +00:00
|
|
|
|
2008-01-03 17:14:28 +00:00
|
|
|
/* Turn off backlight timeout */
|
|
|
|
/* backlight control in lib/helper.c */
|
|
|
|
backlight_force_on(rb);
|
|
|
|
|
|
|
|
wvs_init();
|
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
/* Start playback at the specified starting time */
|
2008-01-03 17:14:28 +00:00
|
|
|
if (wvs_play(settings.resume_time) < STREAM_OK) {
|
2007-12-29 19:46:35 +00:00
|
|
|
rb->splash(HZ*2, "Playback failed");
|
2008-01-03 17:14:28 +00:00
|
|
|
return;
|
2007-12-29 19:46:35 +00:00
|
|
|
}
|
2007-07-19 19:32:29 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
/* Gently poll the video player for EOS and handle UI */
|
|
|
|
while (stream_status() != STREAM_STOPPED)
|
2007-07-19 19:32:29 +00:00
|
|
|
{
|
2008-01-03 17:14:28 +00:00
|
|
|
int button = rb->button_get_w_tmo(WVS_MIN_UPDATE_INTERVAL);
|
2007-12-29 19:46:35 +00:00
|
|
|
|
2008-01-09 14:26:19 +00:00
|
|
|
/* Make sure Rockbox doesn't turn off the player because of
|
|
|
|
too little activity */
|
|
|
|
rb->reset_poweroff_timer();
|
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
switch (button)
|
2007-07-19 19:32:29 +00:00
|
|
|
{
|
2007-12-29 19:46:35 +00:00
|
|
|
case BUTTON_NONE:
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
wvs_refresh(WVS_REFRESH_DEFAULT);
|
2007-07-19 19:32:29 +00:00
|
|
|
continue;
|
2008-01-03 17:14:28 +00:00
|
|
|
} /* BUTTON_NONE: */
|
2006-08-20 23:12:56 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
case MPEG_VOLUP:
|
|
|
|
case MPEG_VOLUP|BUTTON_REPEAT:
|
|
|
|
#ifdef MPEG_VOLUP2
|
|
|
|
case MPEG_VOLUP2:
|
|
|
|
case MPEG_VOLUP2|BUTTON_REPEAT:
|
2007-04-10 14:18:30 +00:00
|
|
|
#endif
|
|
|
|
{
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_set_volume(+1);
|
2007-12-29 19:46:35 +00:00
|
|
|
break;
|
|
|
|
} /* MPEG_VOLUP*: */
|
2007-10-09 20:42:20 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
case MPEG_VOLDOWN:
|
|
|
|
case MPEG_VOLDOWN|BUTTON_REPEAT:
|
|
|
|
#ifdef MPEG_VOLDOWN2
|
|
|
|
case MPEG_VOLDOWN2:
|
|
|
|
case MPEG_VOLDOWN2|BUTTON_REPEAT:
|
|
|
|
#endif
|
2007-01-01 12:59:32 +00:00
|
|
|
{
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_set_volume(-1);
|
2007-12-29 19:46:35 +00:00
|
|
|
break;
|
|
|
|
} /* MPEG_VOLDOWN*: */
|
2006-08-20 23:12:56 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
case MPEG_MENU:
|
2007-01-01 12:59:32 +00:00
|
|
|
{
|
2008-01-03 17:14:28 +00:00
|
|
|
int state = wvs_halt(); /* save previous state */
|
2007-12-29 19:46:35 +00:00
|
|
|
int result;
|
2006-08-20 23:12:56 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
/* Hide video output */
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_show(WVS_HIDE | WVS_NODRAW);
|
2007-12-29 19:46:35 +00:00
|
|
|
stream_show_vo(false);
|
|
|
|
backlight_use_settings(rb);
|
2007-10-09 20:42:20 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
result = mpeg_menu();
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
/* The menu can change the font, so restore */
|
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
switch (result)
|
2007-01-01 12:59:32 +00:00
|
|
|
{
|
2007-12-29 19:46:35 +00:00
|
|
|
case MPEG_MENU_QUIT:
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_stop();
|
2007-12-29 19:46:35 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* If not stopped, show video again */
|
2008-01-03 17:14:28 +00:00
|
|
|
if (state != STREAM_STOPPED) {
|
|
|
|
wvs_show(WVS_SHOW);
|
2007-12-29 19:46:35 +00:00
|
|
|
stream_show_vo(true);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
2007-12-29 19:46:35 +00:00
|
|
|
|
|
|
|
/* If stream was playing, restart it */
|
|
|
|
if (state == STREAM_PLAYING) {
|
|
|
|
backlight_force_on(rb);
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_resume();
|
2007-12-29 19:46:35 +00:00
|
|
|
}
|
2007-04-14 02:46:15 +00:00
|
|
|
break;
|
2007-01-01 12:59:32 +00:00
|
|
|
}
|
2007-12-29 19:46:35 +00:00
|
|
|
break;
|
|
|
|
} /* MPEG_MENU: */
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
case MPEG_STOP:
|
2007-04-10 14:18:30 +00:00
|
|
|
{
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_stop();
|
2007-12-29 19:46:35 +00:00
|
|
|
break;
|
|
|
|
} /* MPEG_STOP: */
|
2007-03-26 19:37:48 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
case MPEG_PAUSE:
|
|
|
|
#ifdef MPEG_PAUSE2
|
|
|
|
case MPEG_PAUSE2:
|
|
|
|
#endif
|
2007-04-10 14:18:30 +00:00
|
|
|
{
|
2008-01-03 17:14:28 +00:00
|
|
|
int status = wvs_status();
|
|
|
|
|
|
|
|
if (status == STREAM_PLAYING) {
|
2007-12-29 19:46:35 +00:00
|
|
|
/* Playing => Paused */
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_pause();
|
2007-12-29 19:46:35 +00:00
|
|
|
backlight_use_settings(rb);
|
2007-01-01 12:59:32 +00:00
|
|
|
}
|
2008-01-03 17:14:28 +00:00
|
|
|
else if (status == STREAM_PAUSED) {
|
2007-12-29 19:46:35 +00:00
|
|
|
/* Paused => Playing */
|
|
|
|
backlight_force_on(rb);
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_resume();
|
2007-03-25 18:05:14 +00:00
|
|
|
}
|
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
break;
|
|
|
|
} /* MPEG_PAUSE*: */
|
|
|
|
|
2008-01-03 17:14:28 +00:00
|
|
|
case MPEG_RW:
|
|
|
|
case MPEG_FF:
|
|
|
|
{
|
|
|
|
wvs_seek(button);
|
|
|
|
break;
|
|
|
|
} /* MPEG_RW: MPEG_FF: */
|
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
case SYS_POWEROFF:
|
|
|
|
case SYS_USB_CONNECTED:
|
|
|
|
/* Stop and get the resume time before closing the file early */
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_stop();
|
2007-12-29 19:46:35 +00:00
|
|
|
stream_close();
|
2008-01-09 14:26:19 +00:00
|
|
|
save_settings(); /* Save settings (if they have changed) */
|
2007-12-29 19:46:35 +00:00
|
|
|
/* Fall-through */
|
|
|
|
default:
|
|
|
|
rb->default_event_handler(button);
|
|
|
|
break;
|
2007-01-01 12:59:32 +00:00
|
|
|
}
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
rb->yield();
|
2007-04-10 14:18:30 +00:00
|
|
|
} /* end while */
|
2007-01-01 12:59:32 +00:00
|
|
|
|
2008-01-03 17:14:28 +00:00
|
|
|
wvs_stop();
|
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
rb->lcd_setfont(FONT_UI);
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2008-01-03 17:14:28 +00:00
|
|
|
/* Turn on backlight timeout (revert to settings) */
|
|
|
|
backlight_use_settings(rb);
|
2007-04-10 14:18:30 +00:00
|
|
|
}
|
2007-03-22 09:18:46 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
2007-04-10 14:18:30 +00:00
|
|
|
{
|
2007-12-29 19:46:35 +00:00
|
|
|
int status = PLUGIN_ERROR; /* assume failure */
|
|
|
|
int result;
|
|
|
|
int err;
|
|
|
|
const char *errstring;
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
if (parameter == NULL) {
|
|
|
|
/* No file = GTFO */
|
|
|
|
api->splash(HZ*2, "No File");
|
|
|
|
return PLUGIN_ERROR;
|
|
|
|
}
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
/* Disable all talking before initializing IRAM */
|
|
|
|
api->talk_disable(true);
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
/* Initialize IRAM - stops audio and voice as well */
|
|
|
|
PLUGIN_IRAM_INIT(api)
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
rb = api;
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
rb->lcd_set_backdrop(NULL);
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
rb->lcd_set_background(LCD_BLACK);
|
|
|
|
#endif
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
rb->lcd_clear_display();
|
|
|
|
rb->lcd_update();
|
2007-01-01 12:59:32 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
if (stream_init() < STREAM_OK) {
|
|
|
|
DEBUGF("Could not initialize streams\n");
|
|
|
|
} else {
|
|
|
|
rb->splash(0, "Loading...");
|
|
|
|
init_settings((char*)parameter);
|
2007-04-16 03:34:56 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
err = stream_open((char *)parameter);
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
if (err >= STREAM_OK) {
|
|
|
|
/* start menu */
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
rb->lcd_update();
|
|
|
|
result = mpeg_start_menu(stream_get_duration());
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
if (result != MPEG_START_QUIT) {
|
|
|
|
/* Enter button loop and process UI */
|
2008-01-03 17:14:28 +00:00
|
|
|
button_loop();
|
2007-12-29 19:46:35 +00:00
|
|
|
}
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
stream_close();
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
rb->lcd_clear_display();
|
|
|
|
rb->lcd_update();
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
save_settings(); /* Save settings (if they have changed) */
|
|
|
|
status = PLUGIN_OK;
|
|
|
|
} else {
|
|
|
|
DEBUGF("Could not open %s\n", (char*)parameter);
|
|
|
|
switch (err)
|
|
|
|
{
|
|
|
|
case STREAM_UNSUPPORTED:
|
|
|
|
errstring = "Unsupported format";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
errstring = "Error opening file: %d";
|
|
|
|
}
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
rb->splash(HZ*2, errstring, err);
|
2007-03-25 18:05:14 +00:00
|
|
|
}
|
2007-10-22 05:57:38 +00:00
|
|
|
}
|
2007-01-01 12:59:32 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
stream_exit();
|
2007-06-10 02:10:47 +00:00
|
|
|
|
2007-10-19 15:31:42 +00:00
|
|
|
rb->talk_disable(false);
|
2007-04-10 14:18:30 +00:00
|
|
|
return status;
|
2006-08-07 22:11:07 +00:00
|
|
|
}
|