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
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
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"
|
2008-11-20 11:27:31 +00:00
|
|
|
#include "lib/helper.h"
|
2006-08-20 23:12:56 +00:00
|
|
|
#include "mpeg_settings.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
|
|
|
|
2010-08-24 14:30:46 +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
|
2010-01-13 12:55:52 +00:00
|
|
|
|
2008-01-27 00:18:29 +00:00
|
|
|
#define MPEG_RC_MENU BUTTON_RC_DSP
|
|
|
|
#define MPEG_RC_STOP (BUTTON_RC_PLAY | BUTTON_REPEAT)
|
|
|
|
#define MPEG_RC_PAUSE (BUTTON_RC_PLAY | BUTTON_REL)
|
|
|
|
#define MPEG_RC_VOLDOWN BUTTON_RC_VOL_DOWN
|
|
|
|
#define MPEG_RC_VOLUP BUTTON_RC_VOL_UP
|
|
|
|
#define MPEG_RC_RW BUTTON_RC_REW
|
|
|
|
#define MPEG_RC_FF BUTTON_RC_FF
|
2006-08-09 13:25:43 +00:00
|
|
|
|
2008-05-02 00:38:11 +00:00
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
|
|
|
|
#define MPEG_MENU BUTTON_MENU
|
|
|
|
#define MPEG_STOP BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE BUTTON_SELECT
|
|
|
|
#define MPEG_PAUSE2 BUTTON_PLAY
|
|
|
|
#define MPEG_VOLDOWN BUTTON_LEFT
|
|
|
|
#define MPEG_VOLUP BUTTON_RIGHT
|
|
|
|
#define MPEG_VOLDOWN2 BUTTON_VOL_DOWN
|
|
|
|
#define MPEG_VOLUP2 BUTTON_VOL_UP
|
|
|
|
#define MPEG_RW BUTTON_UP
|
2010-05-07 11:47:54 +00:00
|
|
|
#define MPEG_RW2 BUTTON_PREV
|
2008-05-02 00:38:11 +00:00
|
|
|
#define MPEG_FF BUTTON_DOWN
|
2010-05-07 11:47:54 +00:00
|
|
|
#define MPEG_FF2 BUTTON_NEXT
|
2010-05-07 13:06:42 +00:00
|
|
|
#define MPEG_SHOW_OSD BUTTON_BACK
|
2010-01-13 12:55:52 +00:00
|
|
|
|
2009-02-03 10:55:30 +00:00
|
|
|
#define MPEG_RC_MENU BUTTON_RC_DSP
|
|
|
|
#define MPEG_RC_STOP (BUTTON_RC_PLAY | BUTTON_REPEAT)
|
|
|
|
#define MPEG_RC_PAUSE (BUTTON_RC_PLAY | BUTTON_REL)
|
|
|
|
#define MPEG_RC_VOLDOWN BUTTON_RC_VOL_DOWN
|
|
|
|
#define MPEG_RC_VOLUP BUTTON_RC_VOL_UP
|
|
|
|
#define MPEG_RC_RW BUTTON_RC_REW
|
|
|
|
#define MPEG_RC_FF BUTTON_RC_FF
|
2008-05-02 00:38:11 +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
|
|
|
|
2009-05-13 08:27:36 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_E200_PAD
|
2006-10-26 13:38:09 +00:00
|
|
|
#define MPEG_MENU BUTTON_SELECT
|
|
|
|
#define MPEG_STOP BUTTON_POWER
|
2009-07-08 17:15:42 +00:00
|
|
|
#define MPEG_PAUSE BUTTON_RIGHT
|
2008-01-10 08:08:31 +00:00
|
|
|
#define MPEG_VOLDOWN BUTTON_SCROLL_BACK
|
|
|
|
#define MPEG_VOLUP BUTTON_SCROLL_FWD
|
2009-07-08 17:15:42 +00:00
|
|
|
#define MPEG_RW BUTTON_UP
|
|
|
|
#define MPEG_FF BUTTON_DOWN
|
2006-10-26 13:38:09 +00:00
|
|
|
|
2009-05-13 08:27:36 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_FUZE_PAD
|
|
|
|
#define MPEG_MENU BUTTON_SELECT
|
|
|
|
#define MPEG_STOP (BUTTON_HOME|BUTTON_REPEAT)
|
|
|
|
#define MPEG_PAUSE BUTTON_UP
|
|
|
|
#define MPEG_VOLDOWN BUTTON_SCROLL_BACK
|
|
|
|
#define MPEG_VOLUP BUTTON_SCROLL_FWD
|
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
|
|
|
|
|
|
|
|
2008-12-12 19:50:49 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_C200_PAD || \
|
|
|
|
CONFIG_KEYPAD == SANSA_CLIP_PAD || \
|
|
|
|
CONFIG_KEYPAD == SANSA_M200_PAD
|
2007-09-20 10:49:48 +00:00
|
|
|
#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_STOP BUTTON_POWER
|
2009-05-06 04:03:13 +00:00
|
|
|
|
|
|
|
#define MPEG_RC_MENU BUTTON_RC_HEART
|
|
|
|
#define MPEG_RC_STOP BUTTON_RC_DOWN
|
|
|
|
#define MPEG_RC_PAUSE BUTTON_RC_PLAY
|
|
|
|
#define MPEG_RC_VOLDOWN BUTTON_RC_VOL_DOWN
|
|
|
|
#define MPEG_RC_VOLUP BUTTON_RC_VOL_UP
|
|
|
|
#define MPEG_RC_RW BUTTON_RC_REW
|
|
|
|
#define MPEG_RC_FF BUTTON_RC_FF
|
2007-10-25 07:44:56 +00:00
|
|
|
|
2008-03-01 22:55:09 +00:00
|
|
|
#elif CONFIG_KEYPAD == MROBE100_PAD
|
|
|
|
#define MPEG_MENU BUTTON_MENU
|
|
|
|
#define MPEG_STOP BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE BUTTON_PLAY
|
|
|
|
#define MPEG_VOLDOWN BUTTON_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_UP
|
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
|
|
|
|
2008-03-25 23:21:36 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
|
|
|
|
#define MPEG_MENU BUTTON_RC_MENU
|
|
|
|
#define MPEG_STOP BUTTON_RC_REC
|
|
|
|
#define MPEG_PAUSE BUTTON_RC_PLAY
|
|
|
|
#define MPEG_VOLDOWN BUTTON_RC_VOL_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_RC_VOL_UP
|
|
|
|
#define MPEG_RW BUTTON_RC_REW
|
|
|
|
#define MPEG_FF BUTTON_RC_FF
|
|
|
|
|
2009-12-15 20:51:41 +00:00
|
|
|
#elif CONFIG_KEYPAD == COWON_D2_PAD
|
2008-04-27 15:30:19 +00:00
|
|
|
#define MPEG_MENU (BUTTON_MENU|BUTTON_REL)
|
|
|
|
//#define MPEG_STOP BUTTON_POWER
|
2008-03-22 22:03:34 +00:00
|
|
|
#define MPEG_VOLDOWN BUTTON_MINUS
|
|
|
|
#define MPEG_VOLUP BUTTON_PLUS
|
|
|
|
|
2008-10-07 16:38:28 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO67_PAD
|
|
|
|
#define MPEG_MENU BUTTON_MENU
|
|
|
|
#define MPEG_STOP BUTTON_STOP
|
|
|
|
#define MPEG_PAUSE BUTTON_PLAY
|
|
|
|
#define MPEG_VOLDOWN BUTTON_VOLDOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_VOLUP
|
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
|
|
|
|
2008-12-04 21:28:56 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
|
|
|
|
#define MPEG_MENU BUTTON_MENU
|
|
|
|
#define MPEG_STOP BUTTON_BACK
|
2008-12-08 09:51:42 +00:00
|
|
|
#define MPEG_PAUSE BUTTON_PLAY
|
2008-12-04 21:28:56 +00:00
|
|
|
#define MPEG_VOLDOWN BUTTON_UP
|
|
|
|
#define MPEG_VOLUP BUTTON_DOWN
|
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
|
|
|
|
2009-01-24 22:41:55 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
|
|
|
|
#define MPEG_MENU BUTTON_MENU
|
|
|
|
#define MPEG_STOP BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE BUTTON_SELECT
|
|
|
|
#define MPEG_VOLDOWN BUTTON_VOL_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_VOL_UP
|
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
|
|
|
|
2010-11-03 02:45:53 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
|
|
|
|
#define MPEG_MENU BUTTON_MENU
|
|
|
|
#define MPEG_STOP BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE BUTTON_PLAY
|
|
|
|
#define MPEG_VOLDOWN BUTTON_VOL_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_VOL_UP
|
|
|
|
#define MPEG_RW BUTTON_PREV
|
|
|
|
#define MPEG_FF BUTTON_NEXT
|
|
|
|
|
2009-12-07 18:23:25 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
|
|
|
|
#define MPEG_MENU BUTTON_MENU
|
|
|
|
#define MPEG_STOP BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE BUTTON_PLAY
|
|
|
|
#define MPEG_VOLDOWN BUTTON_VOL_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_VOL_UP
|
|
|
|
#define MPEG_RW BUTTON_UP
|
|
|
|
#define MPEG_FF BUTTON_DOWN
|
|
|
|
|
2009-04-07 23:41:44 +00:00
|
|
|
#elif CONFIG_KEYPAD == ONDAVX747_PAD
|
|
|
|
#define MPEG_MENU (BUTTON_MENU|BUTTON_REL)
|
|
|
|
//#define MPEG_STOP BUTTON_POWER
|
|
|
|
#define MPEG_VOLDOWN BUTTON_VOL_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_VOL_UP
|
|
|
|
|
2009-08-31 21:11:32 +00:00
|
|
|
#elif CONFIG_KEYPAD == ONDAVX777_PAD
|
|
|
|
#define MPEG_MENU BUTTON_POWER
|
|
|
|
|
2009-08-04 03:08:32 +00:00
|
|
|
#elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
|
|
|
|
#define MPEG_MENU BUTTON_LEFT
|
|
|
|
#define MPEG_STOP BUTTON_RIGHT
|
|
|
|
#define MPEG_PAUSE BUTTON_PLAY
|
|
|
|
#define MPEG_VOLDOWN BUTTON_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_UP
|
|
|
|
#define MPEG_RW BUTTON_REW
|
|
|
|
#define MPEG_FF BUTTON_FFWD
|
|
|
|
|
2010-02-14 21:56:53 +00:00
|
|
|
#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
|
|
|
|
#define MPEG_MENU BUTTON_MENU
|
|
|
|
#define MPEG_STOP BUTTON_REC
|
|
|
|
#define MPEG_PAUSE BUTTON_PLAY
|
|
|
|
#define MPEG_VOLDOWN BUTTON_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_UP
|
|
|
|
#define MPEG_RW BUTTON_PREV
|
|
|
|
#define MPEG_FF BUTTON_NEXT
|
|
|
|
|
2010-04-26 21:40:00 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD200_PAD
|
2010-11-02 10:44:34 +00:00
|
|
|
#define MPEG_MENU BUTTON_FUNC
|
2010-04-26 21:40:00 +00:00
|
|
|
#define MPEG_PAUSE (BUTTON_PLAY | BUTTON_REL)
|
|
|
|
#define MPEG_STOP (BUTTON_PLAY | BUTTON_REPEAT)
|
|
|
|
#define MPEG_VOLDOWN BUTTON_VOL_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_VOL_UP
|
2010-11-02 10:44:34 +00:00
|
|
|
#define MPEG_RW BUTTON_REW
|
|
|
|
#define MPEG_FF BUTTON_FF
|
2010-04-26 21:40:00 +00:00
|
|
|
|
2010-11-30 10:52:14 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD300_PAD
|
|
|
|
#define MPEG_MENU BUTTON_MENU
|
|
|
|
#define MPEG_PAUSE (BUTTON_PLAY | BUTTON_REL)
|
|
|
|
#define MPEG_STOP (BUTTON_PLAY | BUTTON_REPEAT)
|
|
|
|
#define MPEG_VOLDOWN BUTTON_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_UP
|
|
|
|
#define MPEG_RW BUTTON_REW
|
|
|
|
#define MPEG_FF BUTTON_FF
|
|
|
|
|
2011-10-02 17:35:25 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD
|
|
|
|
#define MPEG_MENU BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE (BUTTON_PLAYPAUSE | BUTTON_REL)
|
|
|
|
#define MPEG_STOP (BUTTON_PLAYPAUSE | BUTTON_REPEAT)
|
|
|
|
#define MPEG_VOLDOWN BUTTON_VOL_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_VOL_UP
|
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
|
|
|
|
2011-11-16 14:08:01 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_CONNECT_PAD
|
|
|
|
#define MPEG_MENU BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE (BUTTON_SELECT | BUTTON_REL)
|
|
|
|
#define MPEG_STOP (BUTTON_SELECT | BUTTON_REPEAT)
|
|
|
|
#define MPEG_VOLDOWN BUTTON_VOL_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_VOL_UP
|
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
|
|
|
|
Initial commit of the Samsung YP-R0 port.
This port is a hybrid native/RaaA port. It runs on a embedded linux system,
but is the only application. It therefore can implement lots of stuff that
native targets also implement, while leveraging the underlying linux kernel.
The port is quite advanced. User interface, audio playback, plugins work
mostly fine. Missing is e.g. power mangement and USB (see SamsungYPR0 wiki page).
Included in utils/ypr0tools are scripts and programs required to generate
a patched firmware. The patched firmware has the rootfs modified to load
Rockbox. It includes a early/safe USB mode.
This port needs a new toolchain, one that includes glibc headers and libraries.
rockboxdev.sh can generate it, but e.g. codesourcey and distro packages may
also work.
Most of the initial effort is done by Lorenzo Miori and others (on ABI),
including reverse engineering and patching of the original firmware,
initial drivers, and more. Big thanks to you.
Flyspray: FS#12348
Author: Lorenzo Miori, myself
Merry christmas to ypr0 owners! :)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31415 a1c6a512-1295-4272-9138-f99709370657
2011-12-24 11:56:46 +00:00
|
|
|
#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
|
|
|
|
#define MPEG_MENU BUTTON_MENU
|
|
|
|
#define MPEG_PAUSE BUTTON_SELECT
|
|
|
|
#define MPEG_STOP BUTTON_POWER
|
|
|
|
#define MPEG_VOLDOWN BUTTON_DOWN
|
|
|
|
#define MPEG_VOLUP BUTTON_UP
|
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
|
|
|
|
2012-03-23 18:32:50 +00:00
|
|
|
#elif CONFIG_KEYPAD == HM60X_PAD
|
|
|
|
#define MPEG_MENU BUTTON_POWER
|
|
|
|
#define MPEG_PAUSE BUTTON_SELECT
|
|
|
|
#define MPEG_STOP (BUTTON_SELECT | BUTTON_POWER)
|
|
|
|
#define MPEG_VOLDOWN (BUTTON_POWER | BUTTON_DOWN)
|
|
|
|
#define MPEG_VOLUP (BUTTON_POWER | BUTTON_UP)
|
|
|
|
#define MPEG_RW BUTTON_LEFT
|
|
|
|
#define MPEG_FF BUTTON_RIGHT
|
|
|
|
|
2006-08-09 10:47:22 +00:00
|
|
|
#else
|
2008-03-01 22:55:09 +00:00
|
|
|
#error No keymap defined!
|
2006-08-09 10:47:22 +00:00
|
|
|
#endif
|
2006-08-20 23:12:56 +00:00
|
|
|
|
2008-08-23 09:46:38 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2008-04-27 15:30:19 +00:00
|
|
|
#ifndef MPEG_MENU
|
|
|
|
#define MPEG_MENU (BUTTON_TOPRIGHT|BUTTON_REL)
|
|
|
|
#endif
|
|
|
|
#ifndef MPEG_STOP
|
|
|
|
#define MPEG_STOP BUTTON_TOPLEFT
|
|
|
|
#endif
|
|
|
|
#ifndef MPEG_PAUSE
|
|
|
|
#define MPEG_PAUSE BUTTON_CENTER
|
|
|
|
#endif
|
|
|
|
#ifndef MPEG_VOLDOWN
|
2009-05-06 04:03:13 +00:00
|
|
|
#define MPEG_VOLDOWN BUTTON_BOTTOMMIDDLE
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
#ifndef MPEG_VOLUP
|
2009-05-06 04:03:13 +00:00
|
|
|
#define MPEG_VOLUP BUTTON_TOPMIDDLE
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
#ifndef MPEG_RW
|
|
|
|
#define MPEG_RW BUTTON_MIDLEFT
|
|
|
|
#endif
|
|
|
|
#ifndef MPEG_FF
|
|
|
|
#define MPEG_FF BUTTON_MIDRIGHT
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
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 */
|
|
|
|
|
2010-01-13 12:55:52 +00:00
|
|
|
#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
|
2008-01-03 17:14:28 +00:00
|
|
|
/* 3% of 30min file == 54s step size */
|
|
|
|
#define MIN_FF_REWIND_STEP (TS_SECOND/2)
|
2010-05-07 13:33:44 +00:00
|
|
|
#define OSD_MIN_UPDATE_INTERVAL (HZ/2)
|
2011-01-03 16:41:19 +00:00
|
|
|
#define FPS_UPDATE_INTERVAL (HZ) /* Get new FPS reading each second */
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-11-26 12:32:00 +00:00
|
|
|
enum video_action
|
|
|
|
{
|
|
|
|
VIDEO_STOP = 0,
|
|
|
|
VIDEO_PREV,
|
|
|
|
VIDEO_NEXT,
|
2011-07-08 22:31:15 +00:00
|
|
|
VIDEO_ACTION_MANUAL = 0x8000, /* Flag that says user did it */
|
2010-11-26 12:32:00 +00:00
|
|
|
};
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
/* OSD status - same order as icon array */
|
|
|
|
enum osd_status_enum
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
OSD_STATUS_STOPPED = 0,
|
|
|
|
OSD_STATUS_PAUSED,
|
|
|
|
OSD_STATUS_PLAYING,
|
|
|
|
OSD_STATUS_FF,
|
|
|
|
OSD_STATUS_RW,
|
|
|
|
OSD_STATUS_COUNT,
|
|
|
|
OSD_STATUS_MASK = 0x7
|
2008-01-03 17:14:28 +00:00
|
|
|
};
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
enum osd_bits
|
2007-07-19 19:32:29 +00:00
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
OSD_REFRESH_DEFAULT = 0x0000, /* Only refresh elements when due */
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Refresh the... */
|
2010-05-07 13:33:44 +00:00
|
|
|
OSD_REFRESH_VOLUME = 0x0001, /* ...volume display */
|
|
|
|
OSD_REFRESH_TIME = 0x0002, /* ...time display+progress */
|
|
|
|
OSD_REFRESH_STATUS = 0x0004, /* ...playback status icon */
|
|
|
|
OSD_REFRESH_BACKGROUND = 0x0008, /* ...background (implies ALL) */
|
|
|
|
OSD_REFRESH_VIDEO = 0x0010, /* ...video image upon timeout */
|
|
|
|
OSD_REFRESH_RESUME = 0x0020, /* Resume playback upon timeout */
|
|
|
|
OSD_NODRAW = 0x8000, /* OR bitflag - don't draw anything */
|
|
|
|
OSD_SHOW = 0x4000, /* OR bitflag - show the OSD */
|
2010-12-22 11:20:07 +00:00
|
|
|
#ifdef HAVE_HEADPHONE_DETECTION
|
|
|
|
OSD_HP_PAUSE = 0x2000, /* OR bitflag - headphones caused pause */
|
|
|
|
#endif
|
2010-05-07 13:33:44 +00:00
|
|
|
OSD_HIDE = 0x0000, /* hide the OSD (aid readability) */
|
|
|
|
OSD_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[];
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
/* Main border areas that contain OSD elements */
|
|
|
|
#define OSD_BDR_L 2
|
|
|
|
#define OSD_BDR_T 2
|
|
|
|
#define OSD_BDR_R 2
|
|
|
|
#define OSD_BDR_B 2
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
struct osd
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
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;
|
2011-01-03 16:41:19 +00:00
|
|
|
int font;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fps
|
|
|
|
{
|
|
|
|
/* FPS Display */
|
|
|
|
struct vo_rect rect; /* OSD coordinates */
|
|
|
|
int pf_x; /* Screen coordinates */
|
|
|
|
int pf_y;
|
|
|
|
int pf_width;
|
|
|
|
int pf_height;
|
|
|
|
long update_tick; /* When to next update FPS reading */
|
|
|
|
#define FPS_FORMAT "%d.%02d"
|
|
|
|
#define FPS_DIMSTR "999.99" /* For establishing rect size */
|
|
|
|
#define FPS_BUFSIZE sizeof("999.99")
|
2008-01-03 17:14:28 +00:00
|
|
|
};
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
static struct osd osd;
|
2011-01-03 16:41:19 +00:00
|
|
|
static struct fps fps NOCACHEBSS_ATTR; /* Accessed on other processor */
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_show(unsigned show);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
#ifdef LCD_LANDSCAPE
|
2010-05-07 13:33:44 +00:00
|
|
|
#define _X (x + osd.x)
|
|
|
|
#define _Y (y + osd.y)
|
2008-01-03 17:14:28 +00:00
|
|
|
#define _W width
|
|
|
|
#define _H height
|
|
|
|
#else
|
2010-05-07 13:33:44 +00:00
|
|
|
#define _X (LCD_WIDTH - (y + osd.y) - height)
|
|
|
|
#define _Y (x + osd.x)
|
2008-01-03 17:14:28 +00:00
|
|
|
#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.
|
2010-05-07 13:33:44 +00:00
|
|
|
* The origin is the upper-left corner of the OSD area */
|
2008-01-03 17:14:28 +00:00
|
|
|
static void draw_update_rect(int x, int y, int width, int height)
|
|
|
|
{
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_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)
|
|
|
|
{
|
2010-01-13 12:55:52 +00:00
|
|
|
draw_clear_area(rc->l, rc->t, rc->r - rc->l, rc->b - rc->t);
|
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
|
|
|
{
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_fillrect(_X, _Y, _W, _H);
|
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_hline(int x1, int x2, int y)
|
|
|
|
{
|
2008-01-03 17:14:28 +00:00
|
|
|
#ifdef LCD_LANDSCAPE
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_hline(x1 + osd.x, x2 + osd.x, y + osd.y);
|
2008-01-09 22:19:25 +00:00
|
|
|
#else
|
2010-05-07 13:33:44 +00:00
|
|
|
y = LCD_WIDTH - (y + osd.y) - 1;
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_vline(y, x1 + osd.x, x2 + osd.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
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_vline(x + osd.x, y1 + osd.y, y2 + osd.y);
|
2008-01-09 22:19:25 +00:00
|
|
|
#else
|
2010-05-07 13:33:44 +00:00
|
|
|
y1 = LCD_WIDTH - (y1 + osd.y) - 1;
|
|
|
|
y2 = LCD_WIDTH - (y2 + osd.y) - 1;
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_hline(y1, y2, x + osd.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
|
|
|
{
|
2010-06-04 08:43:32 +00:00
|
|
|
unsigned oldfg = mylcd_get_foreground();
|
2008-01-09 22:19:25 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_foreground(osd.prog_fillcolor);
|
2008-01-09 22:19:25 +00:00
|
|
|
|
|
|
|
draw_fillrect(x + 1 + val, y + 1, width - 2 - val, height - 2);
|
|
|
|
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_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
|
|
|
}
|
|
|
|
|
2011-01-03 16:41:19 +00:00
|
|
|
static void draw_setfont(int font)
|
|
|
|
{
|
|
|
|
osd.font = font;
|
|
|
|
mylcd_setfont(font);
|
|
|
|
}
|
|
|
|
|
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;
|
2011-05-08 21:06:38 +00:00
|
|
|
unsigned fg_pattern;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
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 */
|
|
|
|
|
2011-05-08 21:06:38 +00:00
|
|
|
fg_pattern = rb->lcd_get_foreground();
|
|
|
|
/*bg_pattern =*/ rb->lcd_get_background();
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
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;
|
2010-01-13 12:55:52 +00:00
|
|
|
do
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2010-01-13 12:55:52 +00:00
|
|
|
do
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2011-03-05 18:36:51 +00:00
|
|
|
/* draw alpha bitmap for anti-alias font */
|
|
|
|
#define ALPHA_COLOR_FONT_DEPTH 2
|
|
|
|
#define ALPHA_COLOR_LOOKUP_SHIFT (1 << ALPHA_COLOR_FONT_DEPTH)
|
|
|
|
#define ALPHA_COLOR_LOOKUP_SIZE ((1 << ALPHA_COLOR_LOOKUP_SHIFT) - 1)
|
|
|
|
#define ALPHA_COLOR_PIXEL_PER_BYTE (8 >> ALPHA_COLOR_FONT_DEPTH)
|
|
|
|
#define ALPHA_COLOR_PIXEL_PER_WORD (32 >> ALPHA_COLOR_FONT_DEPTH)
|
|
|
|
#ifdef CPU_ARM
|
|
|
|
#define BLEND_INIT do {} while (0)
|
|
|
|
#define BLEND_START(acc, color, alpha) \
|
|
|
|
asm volatile("mul %0, %1, %2" : "=&r" (acc) : "r" (color), "r" (alpha))
|
|
|
|
#define BLEND_CONT(acc, color, alpha) \
|
|
|
|
asm volatile("mla %0, %1, %2, %0" : "+&r" (acc) : "r" (color), "r" (alpha))
|
|
|
|
#define BLEND_OUT(acc) do {} while (0)
|
|
|
|
#elif defined(CPU_COLDFIRE)
|
|
|
|
#define ALPHA_BITMAP_READ_WORDS
|
|
|
|
#define BLEND_INIT coldfire_set_macsr(EMAC_UNSIGNED)
|
|
|
|
#define BLEND_START(acc, color, alpha) \
|
|
|
|
asm volatile("mac.l %0, %1, %%acc0" :: "%d" (color), "d" (alpha))
|
|
|
|
#define BLEND_CONT BLEND_START
|
|
|
|
#define BLEND_OUT(acc) asm volatile("movclr.l %%acc0, %0" : "=d" (acc))
|
|
|
|
#else
|
|
|
|
#define BLEND_INIT do {} while (0)
|
|
|
|
#define BLEND_START(acc, color, alpha) ((acc) = (color) * (alpha))
|
|
|
|
#define BLEND_CONT(acc, color, alpha) ((acc) += (color) * (alpha))
|
|
|
|
#define BLEND_OUT(acc) do {} while (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Blend the given two colors */
|
|
|
|
static inline unsigned blend_two_colors(unsigned c1, unsigned c2, unsigned a)
|
|
|
|
{
|
|
|
|
a += a >> (ALPHA_COLOR_LOOKUP_SHIFT - 1);
|
|
|
|
#if (LCD_PIXELFORMAT == RGB565SWAPPED)
|
|
|
|
c1 = swap16(c1);
|
|
|
|
c2 = swap16(c2);
|
|
|
|
#endif
|
|
|
|
unsigned c1l = (c1 | (c1 << 16)) & 0x07e0f81f;
|
|
|
|
unsigned c2l = (c2 | (c2 << 16)) & 0x07e0f81f;
|
|
|
|
unsigned p;
|
|
|
|
BLEND_START(p, c1l, a);
|
|
|
|
BLEND_CONT(p, c2l, ALPHA_COLOR_LOOKUP_SIZE + 1 - a);
|
|
|
|
BLEND_OUT(p);
|
|
|
|
p = (p >> ALPHA_COLOR_LOOKUP_SHIFT) & 0x07e0f81f;
|
|
|
|
p |= (p >> 16);
|
|
|
|
#if (LCD_PIXELFORMAT == RGB565SWAPPED)
|
|
|
|
return swap16(p);
|
|
|
|
#else
|
|
|
|
return p;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_oriented_alpha_bitmap_part(const unsigned char *src,
|
|
|
|
int src_x, int src_y,
|
|
|
|
int stride, int x, int y,
|
|
|
|
int width, int height)
|
|
|
|
{
|
|
|
|
fb_data *dst, *dst_start;
|
2011-05-08 21:06:38 +00:00
|
|
|
unsigned fg_pattern;
|
2011-03-05 18:36:51 +00:00
|
|
|
|
|
|
|
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 */
|
|
|
|
|
|
|
|
/* initialize blending */
|
|
|
|
BLEND_INIT;
|
|
|
|
|
2011-05-08 21:06:38 +00:00
|
|
|
fg_pattern = rb->lcd_get_foreground();
|
|
|
|
/*bg_pattern=*/ rb->lcd_get_background();
|
2011-03-05 18:36:51 +00:00
|
|
|
|
|
|
|
dst_start = rb->lcd_framebuffer + (LCD_WIDTH - y - 1) + x*LCD_WIDTH;
|
|
|
|
int col, row = height;
|
|
|
|
unsigned data, pixels;
|
|
|
|
unsigned skip_end = (stride - width);
|
|
|
|
unsigned skip_start = src_y * stride + src_x;
|
|
|
|
|
|
|
|
#ifdef ALPHA_BITMAP_READ_WORDS
|
|
|
|
uint32_t *src_w = (uint32_t *)((uintptr_t)src & ~3);
|
|
|
|
skip_start += ALPHA_COLOR_PIXEL_PER_BYTE * ((uintptr_t)src & 3);
|
|
|
|
src_w += skip_start / ALPHA_COLOR_PIXEL_PER_WORD;
|
|
|
|
data = letoh32(*src_w++);
|
|
|
|
#else
|
|
|
|
src += skip_start / ALPHA_COLOR_PIXEL_PER_BYTE;
|
|
|
|
data = *src;
|
|
|
|
#endif
|
|
|
|
pixels = skip_start % ALPHA_COLOR_PIXEL_PER_WORD;
|
|
|
|
data >>= pixels * ALPHA_COLOR_LOOKUP_SHIFT;
|
|
|
|
#ifdef ALPHA_BITMAP_READ_WORDS
|
|
|
|
pixels = 8 - pixels;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
col = width;
|
|
|
|
dst = dst_start--;
|
|
|
|
#ifdef ALPHA_BITMAP_READ_WORDS
|
|
|
|
#define UPDATE_SRC_ALPHA do { \
|
|
|
|
if (--pixels) \
|
|
|
|
data >>= ALPHA_COLOR_LOOKUP_SHIFT; \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
data = letoh32(*src_w++); \
|
|
|
|
pixels = ALPHA_COLOR_PIXEL_PER_WORD; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#elif ALPHA_COLOR_PIXEL_PER_BYTE == 2
|
|
|
|
#define UPDATE_SRC_ALPHA do { \
|
|
|
|
if (pixels ^= 1) \
|
|
|
|
data >>= ALPHA_COLOR_LOOKUP_SHIFT; \
|
|
|
|
else \
|
|
|
|
data = *(++src); \
|
|
|
|
} while (0)
|
|
|
|
#else
|
|
|
|
#define UPDATE_SRC_ALPHA do { \
|
|
|
|
if (pixels = (++pixels % ALPHA_COLOR_PIXEL_PER_BYTE)) \
|
|
|
|
data >>= ALPHA_COLOR_LOOKUP_SHIFT; \
|
|
|
|
else \
|
|
|
|
data = *(++src); \
|
|
|
|
} while (0)
|
|
|
|
#endif
|
|
|
|
do
|
|
|
|
{
|
|
|
|
*dst=blend_two_colors(*dst, fg_pattern,
|
|
|
|
data & ALPHA_COLOR_LOOKUP_SIZE );
|
|
|
|
dst += LCD_WIDTH;
|
|
|
|
UPDATE_SRC_ALPHA;
|
|
|
|
}
|
|
|
|
while (--col);
|
|
|
|
#ifdef ALPHA_BITMAP_READ_WORDS
|
|
|
|
if (skip_end < pixels)
|
|
|
|
{
|
|
|
|
pixels -= skip_end;
|
|
|
|
data >>= skip_end * ALPHA_COLOR_LOOKUP_SHIFT;
|
|
|
|
} else {
|
|
|
|
pixels = skip_end - pixels;
|
|
|
|
src_w += pixels / ALPHA_COLOR_PIXEL_PER_WORD;
|
|
|
|
pixels %= ALPHA_COLOR_PIXEL_PER_WORD;
|
|
|
|
data = letoh32(*src_w++);
|
|
|
|
data >>= pixels * ALPHA_COLOR_LOOKUP_SHIFT;
|
|
|
|
pixels = 8 - pixels;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (skip_end)
|
|
|
|
{
|
|
|
|
pixels += skip_end;
|
|
|
|
if (pixels >= ALPHA_COLOR_PIXEL_PER_BYTE)
|
|
|
|
{
|
|
|
|
src += pixels / ALPHA_COLOR_PIXEL_PER_BYTE;
|
|
|
|
pixels %= ALPHA_COLOR_PIXEL_PER_BYTE;
|
|
|
|
data = *src;
|
|
|
|
data >>= pixels * ALPHA_COLOR_LOOKUP_SHIFT;
|
|
|
|
} else
|
|
|
|
data >>= skip_end * ALPHA_COLOR_LOOKUP_SHIFT;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
} while (--row);
|
|
|
|
}
|
|
|
|
|
2008-01-03 17:14:28 +00:00
|
|
|
static void draw_putsxy_oriented(int x, int y, const char *str)
|
|
|
|
{
|
|
|
|
unsigned short ch;
|
|
|
|
unsigned short *ucs;
|
|
|
|
int ofs = MIN(x, 0);
|
2011-01-03 16:41:19 +00:00
|
|
|
struct font* pf = rb->font_get(osd.font);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
ucs = rb->bidi_l2v(str, 1);
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
x += osd.x;
|
|
|
|
y += osd.y;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2011-03-05 18:36:51 +00:00
|
|
|
if (pf->depth)
|
|
|
|
draw_oriented_alpha_bitmap_part(bits, ofs, 0, width, x, y,
|
|
|
|
width - ofs, pf->height);
|
|
|
|
else
|
|
|
|
draw_oriented_mono_bitmap_part(bits, ofs, 0, width, x, y,
|
|
|
|
width - ofs, pf->height);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2010-06-04 08:43:32 +00:00
|
|
|
int mode = mylcd_get_drawmode();
|
|
|
|
mylcd_set_drawmode(DRMODE_FG);
|
|
|
|
mylcd_mono_bitmap_part(src, src_x, src_y, stride, x, y, width, height);
|
|
|
|
mylcd_set_drawmode(mode);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_putsxy_oriented(int x, int y, const char *str)
|
|
|
|
{
|
2010-06-04 08:43:32 +00:00
|
|
|
int mode = mylcd_get_drawmode();
|
|
|
|
mylcd_set_drawmode(DRMODE_FG);
|
|
|
|
mylcd_putsxy(x + osd.x, y + osd.y, str);
|
|
|
|
mylcd_set_drawmode(mode);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
#endif /* LCD_PORTRAIT */
|
|
|
|
|
2011-01-03 16:41:19 +00:00
|
|
|
/** FPS Display **/
|
|
|
|
|
|
|
|
/* Post-frame callback (on video thread) - update the FPS rectangle from the
|
|
|
|
* framebuffer */
|
|
|
|
static void fps_post_frame_callback(void)
|
|
|
|
{
|
|
|
|
vo_lock();
|
|
|
|
mylcd_update_rect(fps.pf_x, fps.pf_y,
|
|
|
|
fps.pf_width, fps.pf_height);
|
|
|
|
vo_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up to have the callback only update the intersection of the video
|
|
|
|
* rectangle and the FPS text rectangle - if they don't intersect, then
|
|
|
|
* the callback is set to NULL */
|
|
|
|
static void fps_update_post_frame_callback(void)
|
|
|
|
{
|
|
|
|
void (*cb)(void) = NULL;
|
|
|
|
|
|
|
|
if (settings.showfps) {
|
|
|
|
struct vo_rect cliprect;
|
|
|
|
|
|
|
|
if (stream_vo_get_clip(&cliprect)) {
|
|
|
|
/* Oriented screen coordinates -> OSD coordinates */
|
|
|
|
vo_rect_offset(&cliprect, -osd.x, -osd.y);
|
|
|
|
|
|
|
|
if (vo_rect_intersect(&cliprect, &cliprect, &fps.rect)) {
|
|
|
|
int x = cliprect.l;
|
|
|
|
int y = cliprect.t;
|
|
|
|
int width = cliprect.r - cliprect.l;
|
|
|
|
int height = cliprect.b - cliprect.t;
|
|
|
|
|
|
|
|
/* OSD coordinates -> framebuffer coordinates */
|
|
|
|
fps.pf_x = _X;
|
|
|
|
fps.pf_y = _Y;
|
|
|
|
fps.pf_width = _W;
|
|
|
|
fps.pf_height = _H;
|
|
|
|
|
|
|
|
cb = fps_post_frame_callback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stream_set_callback(VIDEO_SET_POST_FRAME_CALLBACK, cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Refresh the FPS display */
|
|
|
|
static void fps_refresh(void)
|
|
|
|
{
|
|
|
|
char str[FPS_BUFSIZE];
|
|
|
|
struct video_output_stats stats;
|
|
|
|
int w, h, sw;
|
|
|
|
long tick;
|
|
|
|
|
|
|
|
tick = *rb->current_tick;
|
|
|
|
|
|
|
|
if (TIME_BEFORE(tick, fps.update_tick))
|
|
|
|
return;
|
|
|
|
|
|
|
|
fps.update_tick = tick + FPS_UPDATE_INTERVAL;
|
|
|
|
|
|
|
|
stream_video_stats(&stats);
|
|
|
|
|
|
|
|
rb->snprintf(str, FPS_BUFSIZE, FPS_FORMAT,
|
|
|
|
stats.fps / 100, stats.fps % 100);
|
|
|
|
|
|
|
|
w = fps.rect.r - fps.rect.l;
|
|
|
|
h = fps.rect.b - fps.rect.t;
|
|
|
|
|
|
|
|
draw_clear_area(fps.rect.l, fps.rect.t, w, h);
|
|
|
|
mylcd_getstringsize(str, &sw, NULL);
|
|
|
|
draw_putsxy_oriented(fps.rect.r - sw, fps.rect.t, str);
|
|
|
|
|
|
|
|
vo_lock();
|
|
|
|
draw_update_rect(fps.rect.l, fps.rect.t, w, h);
|
|
|
|
vo_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the FPS display */
|
|
|
|
static void fps_init(void)
|
|
|
|
{
|
|
|
|
fps.update_tick = *rb->current_tick;
|
|
|
|
fps.rect.l = fps.rect.t = 0;
|
|
|
|
mylcd_getstringsize(FPS_DIMSTR, &fps.rect.r, &fps.rect.b);
|
|
|
|
vo_rect_offset(&fps.rect, -osd.x, -osd.y);
|
|
|
|
fps_update_post_frame_callback();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** OSD **/
|
|
|
|
|
2009-03-17 02:43:47 +00:00
|
|
|
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
2008-05-28 10:17:16 +00:00
|
|
|
/* So we can refresh the overlay */
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_lcd_enable_hook(void* param)
|
2008-05-28 10:17:16 +00:00
|
|
|
{
|
2009-10-20 21:54:59 +00:00
|
|
|
(void)param;
|
2008-05-28 10:17:16 +00:00
|
|
|
rb->queue_post(rb->button_queue, LCD_ENABLE_EVENT_1, 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_backlight_on_video_mode(bool video_on)
|
2008-05-18 00:14:34 +00:00
|
|
|
{
|
|
|
|
if (video_on) {
|
|
|
|
/* Turn off backlight timeout */
|
2011-01-24 12:29:16 +00:00
|
|
|
backlight_ignore_timeout();
|
2009-03-17 02:43:47 +00:00
|
|
|
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
2010-05-07 13:33:44 +00:00
|
|
|
rb->remove_event(LCD_EVENT_ACTIVATION, osd_lcd_enable_hook);
|
2008-05-28 10:17:16 +00:00
|
|
|
#endif
|
2008-05-18 00:14:34 +00:00
|
|
|
} else {
|
2009-03-17 02:43:47 +00:00
|
|
|
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
2010-05-07 13:33:44 +00:00
|
|
|
rb->add_event(LCD_EVENT_ACTIVATION, false, osd_lcd_enable_hook);
|
2008-05-28 10:17:16 +00:00
|
|
|
#endif
|
2008-05-18 00:14:34 +00:00
|
|
|
/* Revert to user's backlight settings */
|
2009-01-16 10:34:40 +00:00
|
|
|
backlight_use_settings();
|
2008-05-18 00:14:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_backlight_brightness_video_mode(bool video_on)
|
2008-05-18 00:14:34 +00:00
|
|
|
{
|
|
|
|
if (settings.backlight_brightness < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mpeg_backlight_update_brightness(
|
|
|
|
video_on ? settings.backlight_brightness : -1);
|
|
|
|
}
|
|
|
|
#else
|
2010-05-07 13:33:44 +00:00
|
|
|
#define osd_backlight_brightness_video_mode(video_on)
|
2008-05-18 00:14:34 +00:00
|
|
|
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_text_init(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
struct hms hms;
|
|
|
|
char buf[32];
|
|
|
|
int phys;
|
|
|
|
int spc_width;
|
|
|
|
|
2011-01-03 16:41:19 +00:00
|
|
|
draw_setfont(FONT_UI);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.x = 0;
|
|
|
|
osd.width = SCREEN_WIDTH;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
vo_rect_clear(&osd.time_rect);
|
|
|
|
vo_rect_clear(&osd.stat_rect);
|
|
|
|
vo_rect_clear(&osd.prog_rect);
|
|
|
|
vo_rect_clear(&osd.vol_rect);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
ts_to_hms(stream_get_duration(), &hms);
|
|
|
|
hms_format(buf, sizeof (buf), &hms);
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_getstringsize(buf, &osd.time_rect.r, &osd.time_rect.b);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
/* Choose well-sized bitmap images relative to font height */
|
2010-05-07 13:33:44 +00:00
|
|
|
if (osd.time_rect.b < 12) {
|
|
|
|
osd.icons = mpegplayer_status_icons_8x8x1;
|
|
|
|
osd.stat_rect.r = osd.stat_rect.b = 8;
|
|
|
|
} else if (osd.time_rect.b < 16) {
|
|
|
|
osd.icons = mpegplayer_status_icons_12x12x1;
|
|
|
|
osd.stat_rect.r = osd.stat_rect.b = 12;
|
2008-01-03 17:14:28 +00:00
|
|
|
} else {
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.icons = mpegplayer_status_icons_16x16x1;
|
|
|
|
osd.stat_rect.r = osd.stat_rect.b = 16;
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (osd.stat_rect.b < osd.time_rect.b) {
|
|
|
|
vo_rect_offset(&osd.stat_rect, 0,
|
|
|
|
(osd.time_rect.b - osd.stat_rect.b) / 2 + OSD_BDR_T);
|
|
|
|
vo_rect_offset(&osd.time_rect, OSD_BDR_L, OSD_BDR_T);
|
2008-01-03 17:14:28 +00:00
|
|
|
} else {
|
2010-05-07 13:33:44 +00:00
|
|
|
vo_rect_offset(&osd.time_rect, OSD_BDR_L,
|
|
|
|
osd.stat_rect.b - osd.time_rect.b + OSD_BDR_T);
|
|
|
|
vo_rect_offset(&osd.stat_rect, 0, OSD_BDR_T);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.dur_rect = osd.time_rect;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
phys = rb->sound_val2phys(SOUND_VOLUME, rb->sound_min(SOUND_VOLUME));
|
|
|
|
rb->snprintf(buf, sizeof(buf), "%d%s", phys,
|
|
|
|
rb->sound_unit(SOUND_VOLUME));
|
|
|
|
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_getstringsize(" ", &spc_width, NULL);
|
|
|
|
mylcd_getstringsize(buf, &osd.vol_rect.r, &osd.vol_rect.b);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.prog_rect.r = SCREEN_WIDTH - OSD_BDR_L - spc_width -
|
|
|
|
osd.vol_rect.r - OSD_BDR_R;
|
|
|
|
osd.prog_rect.b = 3*osd.stat_rect.b / 4;
|
|
|
|
vo_rect_offset(&osd.prog_rect, osd.time_rect.l,
|
|
|
|
osd.time_rect.b);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
vo_rect_offset(&osd.stat_rect,
|
|
|
|
(osd.prog_rect.r + osd.prog_rect.l - osd.stat_rect.r) / 2,
|
2008-01-03 17:14:28 +00:00
|
|
|
0);
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
vo_rect_offset(&osd.dur_rect,
|
|
|
|
osd.prog_rect.r - osd.dur_rect.r, 0);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
vo_rect_offset(&osd.vol_rect, osd.prog_rect.r + spc_width,
|
|
|
|
(osd.prog_rect.b + osd.prog_rect.t - osd.vol_rect.b) / 2);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.height = OSD_BDR_T + MAX(osd.prog_rect.b, osd.vol_rect.b) -
|
|
|
|
MIN(osd.time_rect.t, osd.stat_rect.t) + OSD_BDR_B;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2008-01-09 22:19:25 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.height = ALIGN_UP(osd.height, 2);
|
2008-01-03 17:14:28 +00:00
|
|
|
#endif
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.y = SCREEN_HEIGHT - osd.height;
|
2007-07-19 19:32:29 +00:00
|
|
|
|
2011-01-03 16:41:19 +00:00
|
|
|
draw_setfont(FONT_SYSFIXED);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_init(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.flags = 0;
|
|
|
|
osd.show_for = HZ*4;
|
|
|
|
osd.print_delay = 75*HZ/100;
|
|
|
|
osd.resume_delay = HZ/2;
|
2008-01-03 17:14:28 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.bgcolor = LCD_RGBPACK(0x73, 0x75, 0xbd);
|
|
|
|
osd.fgcolor = LCD_WHITE;
|
|
|
|
osd.prog_fillcolor = LCD_BLACK;
|
2008-01-03 17:14:28 +00:00
|
|
|
#else
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.bgcolor = GREY_LIGHTGRAY;
|
|
|
|
osd.fgcolor = GREY_BLACK;
|
|
|
|
osd.prog_fillcolor = GREY_WHITE;
|
2008-01-03 17:14:28 +00:00
|
|
|
#endif
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.curr_time = 0;
|
|
|
|
osd.status = OSD_STATUS_STOPPED;
|
|
|
|
osd.auto_refresh = OSD_REFRESH_TIME;
|
|
|
|
osd.next_auto_refresh = *rb->current_tick;
|
|
|
|
osd_text_init();
|
2011-01-03 16:41:19 +00:00
|
|
|
fps_init();
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
#ifdef HAVE_HEADPHONE_DETECTION
|
|
|
|
static void osd_set_hp_pause_flag(bool set)
|
|
|
|
{
|
|
|
|
if (set)
|
|
|
|
osd.flags |= OSD_HP_PAUSE;
|
|
|
|
else
|
|
|
|
osd.flags &= ~OSD_HP_PAUSE;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define osd_set_hp_pause_flag(set)
|
|
|
|
#endif /* HAVE_HEADPHONE_DETECTION */
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_schedule_refresh(unsigned refresh)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
long tick = *rb->current_tick;
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (refresh & OSD_REFRESH_VIDEO)
|
|
|
|
osd.print_tick = tick + osd.print_delay;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (refresh & OSD_REFRESH_RESUME)
|
|
|
|
osd.resume_tick = tick + osd.resume_delay;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.auto_refresh |= refresh;
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_cancel_refresh(unsigned refresh)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.auto_refresh &= ~refresh;
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Refresh the background area */
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_refresh_background(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
struct hms hms;
|
|
|
|
|
2010-06-04 08:43:32 +00:00
|
|
|
unsigned bg = mylcd_get_background();
|
|
|
|
mylcd_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 */
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_background(draw_blendcolor(bg, MYLCD_WHITE, 192));
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_hline(0, osd.width, 0);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_background(draw_blendcolor(bg, MYLCD_WHITE, 80));
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_hline(0, osd.width, 1);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_background(draw_blendcolor(bg, MYLCD_BLACK, 48));
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_hline(0, osd.width, osd.height-2);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_background(draw_blendcolor(bg, MYLCD_BLACK, 128));
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_hline(0, osd.width, osd.height-1);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_background(bg);
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_clear_area(0, 2, osd.width, osd.height - 4);
|
2008-01-03 17:14:28 +00:00
|
|
|
#else
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Give contrast with the main background */
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_background(MYLCD_WHITE);
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_hline(0, osd.width, 0);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_background(MYLCD_DARKGRAY);
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_hline(0, osd.width, osd.height-1);
|
2008-01-09 22:19:25 +00:00
|
|
|
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_background(bg);
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_clear_area(0, 1, osd.width, osd.height - 2);
|
2008-01-03 17:14:28 +00:00
|
|
|
#endif
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
vo_rect_set_ext(&osd.update_rect, 0, 0, osd.width, osd.height);
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_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);
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_putsxy_oriented(osd.dur_rect.l, osd.dur_rect.t, buf);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
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 */
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_refresh_time(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
struct hms hms;
|
|
|
|
|
|
|
|
uint32_t duration = stream_get_duration();
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_scrollbar_draw_rect(&osd.prog_rect, 0, duration,
|
|
|
|
osd.curr_time);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
ts_to_hms(osd.curr_time, &hms);
|
2008-01-03 17:14:28 +00:00
|
|
|
hms_format(buf, sizeof (buf), &hms);
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_clear_area_rect(&osd.time_rect);
|
|
|
|
draw_putsxy_oriented(osd.time_rect.l, osd.time_rect.t, buf);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
vo_rect_union(&osd.update_rect, &osd.update_rect,
|
|
|
|
&osd.prog_rect);
|
|
|
|
vo_rect_union(&osd.update_rect, &osd.update_rect,
|
|
|
|
&osd.time_rect);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Refresh the volume display area */
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_refresh_volume(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
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));
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_getstringsize(buf, &width, NULL);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
/* Right-justified */
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_clear_area_rect(&osd.vol_rect);
|
|
|
|
draw_putsxy_oriented(osd.vol_rect.r - width, osd.vol_rect.t, buf);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
vo_rect_union(&osd.update_rect, &osd.update_rect, &osd.vol_rect);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Refresh the status icon */
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_refresh_status(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
int icon_size = osd.stat_rect.r - osd.stat_rect.l;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_clear_area_rect(&osd.stat_rect);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
/* Draw status icon with a drop shadow */
|
2010-06-04 08:43:32 +00:00
|
|
|
unsigned oldfg = mylcd_get_foreground();
|
2008-01-03 17:14:28 +00:00
|
|
|
int i = 1;
|
|
|
|
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_foreground(draw_blendcolor(mylcd_get_background(),
|
|
|
|
MYLCD_BLACK, 96));
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_oriented_mono_bitmap_part(osd.icons,
|
|
|
|
icon_size*osd.status,
|
2008-01-03 17:14:28 +00:00
|
|
|
0,
|
2010-05-07 13:33:44 +00:00
|
|
|
icon_size*OSD_STATUS_COUNT,
|
|
|
|
osd.stat_rect.l + osd.x + i,
|
|
|
|
osd.stat_rect.t + osd.y + i,
|
2008-01-03 17:14:28 +00:00
|
|
|
icon_size, icon_size);
|
|
|
|
|
|
|
|
if (--i < 0)
|
|
|
|
break;
|
|
|
|
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_foreground(oldfg);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
vo_rect_union(&osd.update_rect, &osd.update_rect, &osd.stat_rect);
|
2008-01-03 17:14:28 +00:00
|
|
|
#else
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_oriented_mono_bitmap_part(osd.icons,
|
|
|
|
icon_size*osd.status,
|
2008-01-03 17:14:28 +00:00
|
|
|
0,
|
2010-05-07 13:33:44 +00:00
|
|
|
icon_size*OSD_STATUS_COUNT,
|
|
|
|
osd.stat_rect.l + osd.x,
|
|
|
|
osd.stat_rect.t + osd.y,
|
2008-01-03 17:14:28 +00:00
|
|
|
icon_size, icon_size);
|
2010-05-07 13:33:44 +00:00
|
|
|
vo_rect_union(&osd.update_rect, &osd.update_rect, &osd.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 */
|
2010-05-07 13:33:44 +00:00
|
|
|
static bool osd_update_status(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
switch (stream_status())
|
|
|
|
{
|
|
|
|
default:
|
2010-05-07 13:33:44 +00:00
|
|
|
status = OSD_STATUS_STOPPED;
|
2008-01-03 17:14:28 +00:00
|
|
|
break;
|
|
|
|
case STREAM_PAUSED:
|
2010-05-07 13:33:44 +00:00
|
|
|
/* If paused with a pending resume, coerce it to OSD_STATUS_PLAYING */
|
|
|
|
status = (osd.auto_refresh & OSD_REFRESH_RESUME) ?
|
|
|
|
OSD_STATUS_PLAYING : OSD_STATUS_PAUSED;
|
2008-01-03 17:14:28 +00:00
|
|
|
break;
|
|
|
|
case STREAM_PLAYING:
|
2010-05-07 13:33:44 +00:00
|
|
|
status = OSD_STATUS_PLAYING;
|
2008-01-03 17:14:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (status != osd.status) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* A refresh is needed */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.status = status;
|
2008-01-03 17:14:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Update the current time that will be displayed */
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_update_time(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
uint32_t start;
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.curr_time = stream_get_seek_time(&start);
|
|
|
|
osd.curr_time -= start;
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
/* Refresh various parts of the OSD - showing it if it is hidden */
|
|
|
|
static void osd_refresh(int hint)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
long tick;
|
|
|
|
unsigned oldbg, oldfg;
|
|
|
|
|
|
|
|
tick = *rb->current_tick;
|
|
|
|
|
2011-01-03 16:41:19 +00:00
|
|
|
if (settings.showfps)
|
|
|
|
fps_refresh();
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (hint == OSD_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-12 05:45:38 +00:00
|
|
|
/* Make sure Rockbox doesn't turn off the player because of
|
|
|
|
too little activity */
|
2010-05-07 13:33:44 +00:00
|
|
|
if (osd.status == OSD_STATUS_PLAYING)
|
2008-01-12 05:45:38 +00:00
|
|
|
rb->reset_poweroff_timer();
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Redraw the current or possibly extract a new video frame */
|
2010-05-07 13:33:44 +00:00
|
|
|
if ((osd.auto_refresh & OSD_REFRESH_VIDEO) &&
|
|
|
|
TIME_AFTER(tick, osd.print_tick)) {
|
|
|
|
osd.auto_refresh &= ~OSD_REFRESH_VIDEO;
|
2008-01-03 17:14:28 +00:00
|
|
|
stream_draw_frame(false);
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Restart playback if the timout was reached */
|
2010-05-07 13:33:44 +00:00
|
|
|
if ((osd.auto_refresh & OSD_REFRESH_RESUME) &&
|
|
|
|
TIME_AFTER(tick, osd.resume_tick)) {
|
|
|
|
osd.auto_refresh &= ~(OSD_REFRESH_RESUME | OSD_REFRESH_VIDEO);
|
2008-01-03 17:14:28 +00:00
|
|
|
stream_resume();
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* If not visible, return */
|
2010-05-07 13:33:44 +00:00
|
|
|
if (!(osd.flags & OSD_SHOW))
|
2008-01-03 17:14:28 +00:00
|
|
|
return;
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Hide if the visibility duration was reached */
|
2010-05-07 13:33:44 +00:00
|
|
|
if (TIME_AFTER(tick, osd.hide_tick)) {
|
|
|
|
osd_show(OSD_HIDE);
|
2008-01-03 17:14:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* A forced update of some region */
|
|
|
|
|
|
|
|
/* Show if currently invisible */
|
2010-05-07 13:33:44 +00:00
|
|
|
if (!(osd.flags & OSD_SHOW)) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Avoid call back into this function - it will be drawn */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_show(OSD_SHOW | OSD_NODRAW);
|
|
|
|
hint = OSD_REFRESH_ALL;
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Move back timeouts for frame print and hide */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.print_tick = tick + osd.print_delay;
|
|
|
|
osd.hide_tick = tick + osd.show_for;
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (TIME_AFTER(tick, osd.next_auto_refresh)) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Refresh whatever graphical elements are due automatically */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.next_auto_refresh = tick + OSD_MIN_UPDATE_INTERVAL;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (osd.auto_refresh & OSD_REFRESH_STATUS) {
|
|
|
|
if (osd_update_status())
|
|
|
|
hint |= OSD_REFRESH_STATUS;
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (osd.auto_refresh & OSD_REFRESH_TIME) {
|
|
|
|
osd_update_time();
|
|
|
|
hint |= OSD_REFRESH_TIME;
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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. */
|
2010-06-04 08:43:32 +00:00
|
|
|
oldfg = mylcd_get_foreground();
|
|
|
|
oldbg = mylcd_get_background();
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2011-01-03 16:41:19 +00:00
|
|
|
draw_setfont(FONT_UI);
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_foreground(osd.fgcolor);
|
|
|
|
mylcd_set_background(osd.bgcolor);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
vo_rect_clear(&osd.update_rect);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (hint & OSD_REFRESH_BACKGROUND) {
|
|
|
|
osd_refresh_background();
|
|
|
|
hint |= OSD_REFRESH_ALL; /* Requires a redraw of everything */
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (hint & OSD_REFRESH_TIME) {
|
|
|
|
osd_refresh_time();
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (hint & OSD_REFRESH_VOLUME) {
|
|
|
|
osd_refresh_volume();
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (hint & OSD_REFRESH_STATUS) {
|
|
|
|
osd_refresh_status();
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Go back to defaults */
|
2011-01-03 16:41:19 +00:00
|
|
|
draw_setfont(FONT_SYSFIXED);
|
2010-06-04 08:43:32 +00:00
|
|
|
mylcd_set_foreground(oldfg);
|
|
|
|
mylcd_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();
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_update_rect(osd.update_rect.l,
|
|
|
|
osd.update_rect.t,
|
|
|
|
osd.update_rect.r - osd.update_rect.l,
|
|
|
|
osd.update_rect.b - osd.update_rect.t);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
vo_unlock();
|
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
/* Show/Hide the OSD */
|
|
|
|
static void osd_show(unsigned show)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
if (((show ^ osd.flags) & OSD_SHOW) == 0)
|
2008-01-27 21:45:15 +00:00
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
if (show & OSD_SHOW) {
|
|
|
|
osd.hide_tick = *rb->current_tick + osd.show_for;
|
2008-01-27 21:45:15 +00:00
|
|
|
}
|
2008-01-03 17:14:28 +00:00
|
|
|
return;
|
2008-01-27 21:45:15 +00:00
|
|
|
}
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (show & OSD_SHOW) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Clip away the part of video that is covered */
|
2010-05-07 13:33:44 +00:00
|
|
|
struct vo_rect rc = { 0, 0, SCREEN_WIDTH, osd.y };
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.flags |= OSD_SHOW;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (osd.status != OSD_STATUS_PLAYING) {
|
2008-05-18 00:14:34 +00:00
|
|
|
/* Not playing - set brightness to mpegplayer setting */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_backlight_brightness_video_mode(true);
|
2008-05-18 00:14:34 +00:00
|
|
|
}
|
|
|
|
|
2008-01-03 17:14:28 +00:00
|
|
|
stream_vo_set_clip(&rc);
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (!(show & OSD_NODRAW))
|
|
|
|
osd_refresh(OSD_REFRESH_ALL);
|
2008-01-03 17:14:28 +00:00
|
|
|
} else {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Uncover clipped video area and redraw it */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.flags &= ~OSD_SHOW;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_clear_area(0, 0, osd.width, osd.height);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (!(show & OSD_NODRAW)) {
|
2008-01-03 17:14:28 +00:00
|
|
|
vo_lock();
|
2010-05-07 13:33:44 +00:00
|
|
|
draw_update_rect(0, 0, osd.width, osd.height);
|
2008-01-03 17:14:28 +00:00
|
|
|
vo_unlock();
|
2008-01-11 00:46:09 +00:00
|
|
|
|
2008-01-12 05:45:38 +00:00
|
|
|
stream_vo_set_clip(NULL);
|
2008-01-03 17:14:28 +00:00
|
|
|
stream_draw_frame(false);
|
2008-01-12 05:45:38 +00:00
|
|
|
} else {
|
|
|
|
stream_vo_set_clip(NULL);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
2008-05-18 00:14:34 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (osd.status != OSD_STATUS_PLAYING) {
|
2008-05-18 00:14:34 +00:00
|
|
|
/* Not playing - restore backlight brightness */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_backlight_brightness_video_mode(false);
|
2008-05-18 00:14:34 +00:00
|
|
|
}
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Set the current status - update screen if specified */
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_set_status(int status)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
bool draw = (status & OSD_NODRAW) == 0;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
status &= OSD_STATUS_MASK;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (osd.status != status) {
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd.status = status;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
if (draw)
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_refresh(OSD_REFRESH_STATUS);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-27 21:45:15 +00:00
|
|
|
/* Get the current status value */
|
2010-05-07 13:33:44 +00:00
|
|
|
static int osd_get_status(void)
|
2008-01-27 21:45:15 +00:00
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
return osd.status & OSD_STATUS_MASK;
|
2008-01-27 21:45:15 +00:00
|
|
|
}
|
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
/* Handle Fast-forward/Rewind keys using WPS settings (and some nicked code ;)
|
|
|
|
* Returns last button code
|
|
|
|
*/
|
|
|
|
static int osd_ff_rw(int btn, unsigned refresh, uint32_t *new_time)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
unsigned int step = TS_SECOND*rb->global_settings->ff_rewind_min_step;
|
2008-06-28 17:55:53 +00:00
|
|
|
const long ff_rw_accel = (rb->global_settings->ff_rewind_accel + 3);
|
2008-01-03 17:14:28 +00:00
|
|
|
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;
|
2010-05-07 13:33:44 +00:00
|
|
|
unsigned status = osd.status;
|
2010-12-22 11:20:07 +00:00
|
|
|
int new_btn;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_cancel_refresh(OSD_REFRESH_VIDEO | OSD_REFRESH_RESUME |
|
|
|
|
OSD_REFRESH_TIME);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
time -= start; /* Absolute clock => stream-relative */
|
|
|
|
|
|
|
|
switch (btn)
|
|
|
|
{
|
|
|
|
case MPEG_FF:
|
2010-05-07 11:47:54 +00:00
|
|
|
#ifdef MPEG_FF2
|
|
|
|
case MPEG_FF2:
|
|
|
|
#endif
|
2008-01-27 00:18:29 +00:00
|
|
|
#ifdef MPEG_RC_FF
|
|
|
|
case MPEG_RC_FF:
|
|
|
|
#endif
|
2010-12-22 11:20:07 +00:00
|
|
|
osd_set_status(OSD_STATUS_FF);
|
|
|
|
new_btn = btn | BUTTON_REPEAT; /* simplify code below */
|
2008-01-03 17:14:28 +00:00
|
|
|
break;
|
|
|
|
case MPEG_RW:
|
2010-05-07 11:47:54 +00:00
|
|
|
#ifdef MPEG_RW2
|
|
|
|
case MPEG_RW2:
|
|
|
|
#endif
|
2008-01-27 00:18:29 +00:00
|
|
|
#ifdef MPEG_RC_RW
|
|
|
|
case MPEG_RC_RW:
|
|
|
|
#endif
|
2010-12-22 11:20:07 +00:00
|
|
|
osd_set_status(OSD_STATUS_RW);
|
|
|
|
new_btn = btn | BUTTON_REPEAT; /* simplify code below */
|
2008-01-03 17:14:28 +00:00
|
|
|
break;
|
|
|
|
default:
|
2010-12-22 11:20:07 +00:00
|
|
|
new_btn = BUTTON_NONE; /* Fail tests below but still do proper exit */
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
stream_keep_disk_active();
|
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
if (new_btn == (btn | BUTTON_REPEAT)) {
|
|
|
|
if (osd.status == OSD_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);
|
|
|
|
}
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
max_step = MAX(max_step, MIN_FF_REWIND_STEP);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
if (step > max_step)
|
|
|
|
step = max_step;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
ff_rw_count += step;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
/* smooth seeking by multiplying step by: 1 + (2 ^ -accel) */
|
|
|
|
step += step >> ff_rw_accel;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
if (osd.status == OSD_STATUS_FF) {
|
|
|
|
if (duration - time <= ff_rw_count)
|
|
|
|
ff_rw_count = duration - time;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
osd.curr_time = time + ff_rw_count;
|
|
|
|
} else {
|
|
|
|
if (time <= ff_rw_count)
|
|
|
|
ff_rw_count = time;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
osd.curr_time = time - ff_rw_count;
|
|
|
|
}
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
osd_refresh(OSD_REFRESH_TIME);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
new_btn = mpeg_button_get(TIMEOUT_BLOCK);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
2010-12-22 11:20:07 +00:00
|
|
|
else {
|
|
|
|
if (new_btn == (btn | BUTTON_REL)) {
|
|
|
|
if (osd.status == OSD_STATUS_FF)
|
|
|
|
time += ff_rw_count;
|
|
|
|
else if (osd.status == OSD_STATUS_RW)
|
|
|
|
time -= ff_rw_count;
|
|
|
|
}
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
*new_time = time;
|
|
|
|
|
|
|
|
osd_schedule_refresh(refresh);
|
|
|
|
osd_set_status(status);
|
|
|
|
osd_schedule_refresh(OSD_REFRESH_TIME);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
return new_btn;
|
|
|
|
}
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
/* Return adjusted STREAM_* status */
|
|
|
|
static int osd_stream_status(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
int status = stream_status();
|
|
|
|
|
|
|
|
/* Coerce to STREAM_PLAYING if paused with a pending resume */
|
|
|
|
if (status == STREAM_PAUSED) {
|
2010-05-07 13:33:44 +00:00
|
|
|
if (osd.auto_refresh & OSD_REFRESH_RESUME)
|
2008-01-03 17:14:28 +00:00
|
|
|
status = STREAM_PLAYING;
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Change the current audio volume by a specified amount */
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_set_volume(int delta)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
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 */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_refresh(OSD_REFRESH_VOLUME);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2008-01-27 21:45:15 +00:00
|
|
|
/* Begin playback at the specified time */
|
2010-05-07 13:33:44 +00:00
|
|
|
static int osd_play(uint32_t time)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
osd_set_hp_pause_flag(false);
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_cancel_refresh(OSD_REFRESH_VIDEO | OSD_REFRESH_RESUME);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
retval = stream_seek(time, SEEK_SET);
|
|
|
|
|
|
|
|
if (retval >= STREAM_OK) {
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_backlight_on_video_mode(true);
|
|
|
|
osd_backlight_brightness_video_mode(true);
|
2008-01-03 17:14:28 +00:00
|
|
|
stream_show_vo(true);
|
2011-01-03 16:41:19 +00:00
|
|
|
|
2008-01-03 17:14:28 +00:00
|
|
|
retval = stream_play();
|
|
|
|
|
|
|
|
if (retval >= STREAM_OK)
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_set_status(OSD_STATUS_PLAYING | OSD_NODRAW);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Halt playback - pause engine and return logical state */
|
2010-05-07 13:33:44 +00:00
|
|
|
static int osd_halt(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
int status = stream_pause();
|
|
|
|
|
|
|
|
/* Coerce to STREAM_PLAYING if paused with a pending resume */
|
|
|
|
if (status == STREAM_PAUSED) {
|
2010-05-07 13:33:44 +00:00
|
|
|
if (osd_get_status() == OSD_STATUS_PLAYING)
|
2008-01-03 17:14:28 +00:00
|
|
|
status = STREAM_PLAYING;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Cancel some auto refreshes - caller will restart them if desired */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_cancel_refresh(OSD_REFRESH_VIDEO | OSD_REFRESH_RESUME);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2008-05-18 00:14:34 +00:00
|
|
|
/* No backlight fiddling here - callers does the right thing */
|
|
|
|
|
2008-01-03 17:14:28 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Pause playback if playing */
|
2010-05-07 13:33:44 +00:00
|
|
|
static int osd_pause(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
unsigned refresh = osd.auto_refresh;
|
|
|
|
int status = osd_halt();
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
osd_set_hp_pause_flag(false);
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
if (status == STREAM_PLAYING && (refresh & OSD_REFRESH_RESUME)) {
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Resume pending - change to a still video frame update */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_schedule_refresh(OSD_REFRESH_VIDEO);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_set_status(OSD_STATUS_PAUSED);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_backlight_on_video_mode(false);
|
|
|
|
/* Leave brightness alone and restore it when OSD is hidden */
|
2008-05-18 00:14:34 +00:00
|
|
|
|
2011-05-13 22:51:10 +00:00
|
|
|
if (stream_can_seek() && rb->global_settings->pause_rewind) {
|
|
|
|
stream_seek(-rb->global_settings->pause_rewind*TS_SECOND,
|
|
|
|
SEEK_CUR);
|
|
|
|
osd_schedule_refresh(OSD_REFRESH_VIDEO);
|
|
|
|
/* Update time display now */
|
|
|
|
osd_update_time();
|
|
|
|
osd_refresh(OSD_REFRESH_TIME);
|
|
|
|
}
|
|
|
|
|
2008-01-03 17:14:28 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2008-01-07 17:27:08 +00:00
|
|
|
/* Resume playback if halted or paused */
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_resume(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2008-05-18 00:14:34 +00:00
|
|
|
/* Cancel video and resume auto refresh - the resyc when starting
|
|
|
|
* playback will perform those tasks */
|
2010-12-22 11:20:07 +00:00
|
|
|
osd_set_hp_pause_flag(false);
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_backlight_on_video_mode(true);
|
|
|
|
osd_backlight_brightness_video_mode(true);
|
|
|
|
osd_cancel_refresh(OSD_REFRESH_VIDEO | OSD_REFRESH_RESUME);
|
|
|
|
osd_set_status(OSD_STATUS_PLAYING);
|
2008-01-03 17:14:28 +00:00
|
|
|
stream_resume();
|
|
|
|
}
|
|
|
|
|
2008-01-12 05:45:38 +00:00
|
|
|
/* Stop playback - remember the resume point if not closed */
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_stop(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2008-01-12 05:45:38 +00:00
|
|
|
uint32_t resume_time;
|
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
osd_set_hp_pause_flag(false);
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_cancel_refresh(OSD_REFRESH_VIDEO | OSD_REFRESH_RESUME);
|
|
|
|
osd_set_status(OSD_STATUS_STOPPED | OSD_NODRAW);
|
2010-11-26 12:32:00 +00:00
|
|
|
osd_show(OSD_HIDE);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2008-01-12 05:45:38 +00:00
|
|
|
stream_stop();
|
|
|
|
|
|
|
|
resume_time = stream_get_resume_time();
|
|
|
|
|
|
|
|
if (resume_time != INVALID_TIMESTAMP)
|
|
|
|
settings.resume_time = resume_time;
|
2008-05-18 00:14:34 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_backlight_on_video_mode(false);
|
|
|
|
osd_backlight_brightness_video_mode(false);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
/* Perform a seek by button if seeking is possible for this stream.
|
|
|
|
*
|
|
|
|
* A delay will be inserted before restarting in case the user decides to
|
|
|
|
* seek again soon after.
|
|
|
|
*
|
|
|
|
* Returns last button code
|
|
|
|
*/
|
|
|
|
static int osd_seek_btn(int btn)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
int status;
|
2010-12-22 11:20:07 +00:00
|
|
|
unsigned refresh = 0;
|
2008-01-03 17:14:28 +00:00
|
|
|
uint32_t time;
|
|
|
|
|
|
|
|
if (!stream_can_seek())
|
2010-12-22 11:20:07 +00:00
|
|
|
return true;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
/* Halt playback - not strictly necessary but nice when doing
|
|
|
|
* buttons */
|
2010-05-07 13:33:44 +00:00
|
|
|
status = osd_halt();
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
if (status == STREAM_STOPPED)
|
2010-12-22 11:20:07 +00:00
|
|
|
return true;
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_show(OSD_SHOW);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
/* Obtain a new playback point according to the buttons */
|
2008-01-03 17:14:28 +00:00
|
|
|
if (status == STREAM_PLAYING)
|
2010-05-07 13:33:44 +00:00
|
|
|
refresh = OSD_REFRESH_RESUME; /* delay resume if playing */
|
2008-01-03 17:14:28 +00:00
|
|
|
else
|
2010-05-07 13:33:44 +00:00
|
|
|
refresh = OSD_REFRESH_VIDEO; /* refresh if paused */
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
btn = osd_ff_rw(btn, refresh, &time);
|
2008-01-03 17:14:28 +00:00
|
|
|
|
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);
|
2010-12-22 11:20:07 +00:00
|
|
|
|
|
|
|
return btn;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform a seek by time if seeking is possible for this stream
|
|
|
|
*
|
|
|
|
* If playing, the seeking is immediate, otherise a delay is added to showing
|
|
|
|
* a still if paused in case the user does another seek soon after.
|
|
|
|
*
|
|
|
|
* If seeking isn't possible, a time of zero performs a skip to the
|
|
|
|
* beginning.
|
|
|
|
*/
|
|
|
|
static void osd_seek_time(uint32_t time)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
unsigned refresh = 0;
|
|
|
|
|
|
|
|
if (!stream_can_seek() && time != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
stream_wait_status();
|
|
|
|
status = osd_stream_status();
|
|
|
|
|
|
|
|
if (status == STREAM_STOPPED)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (status == STREAM_PLAYING) /* merely preserve resume */
|
|
|
|
refresh = osd.auto_refresh & OSD_REFRESH_RESUME;
|
|
|
|
else
|
|
|
|
refresh = OSD_REFRESH_VIDEO; /* refresh if paused */
|
|
|
|
|
|
|
|
/* Cancel print or resume if pending */
|
|
|
|
osd_cancel_refresh(OSD_REFRESH_VIDEO | OSD_REFRESH_RESUME);
|
|
|
|
|
|
|
|
/* Tell engine to seek to the given time - no state change */
|
|
|
|
stream_seek(time, SEEK_SET);
|
|
|
|
|
|
|
|
osd_update_time();
|
|
|
|
osd_refresh(OSD_REFRESH_TIME);
|
|
|
|
osd_schedule_refresh(refresh);
|
2008-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 21:20:53 +00:00
|
|
|
/* Has this file one of the supported extensions? */
|
2010-11-26 12:32:00 +00:00
|
|
|
static bool is_videofile(const char* file)
|
|
|
|
{
|
2010-12-18 21:20:53 +00:00
|
|
|
static const char * const extensions[] =
|
|
|
|
{
|
|
|
|
/* Should match apps/plugins/viewers.config */
|
|
|
|
"mpg", "mpeg", "mpv", "m2v"
|
|
|
|
};
|
|
|
|
|
2010-11-26 12:32:00 +00:00
|
|
|
const char* ext = rb->strrchr(file, '.');
|
2010-12-18 21:20:53 +00:00
|
|
|
int i;
|
2010-11-26 12:32:00 +00:00
|
|
|
|
2010-12-18 21:20:53 +00:00
|
|
|
if (!ext)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
for (i = ARRAYLEN(extensions) - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
if (!rb->strcasecmp(ext + 1, extensions[i]))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i >= 0;
|
2010-11-26 12:32:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* deliver the next/previous video file in the current directory.
|
2010-12-22 11:20:07 +00:00
|
|
|
returns false if there is none. */
|
2010-11-26 12:32:00 +00:00
|
|
|
static bool get_videofile(int direction, char* videofile, size_t bufsize)
|
|
|
|
{
|
|
|
|
struct tree_context *tree = rb->tree_get_context();
|
2011-08-30 14:01:45 +00:00
|
|
|
struct entry *dircache = rb->tree_get_entries(tree);
|
2010-11-26 12:32:00 +00:00
|
|
|
int i, step, end, found = 0;
|
|
|
|
char *videoname = rb->strrchr(videofile, '/') + 1;
|
|
|
|
size_t rest = bufsize - (videoname - videofile) - 1;
|
|
|
|
|
|
|
|
if (direction == VIDEO_NEXT) {
|
|
|
|
i = 0;
|
|
|
|
step = 1;
|
|
|
|
end = tree->filesindir;
|
|
|
|
} else {
|
|
|
|
i = tree->filesindir-1;
|
|
|
|
step = -1;
|
|
|
|
end = -1;
|
|
|
|
}
|
|
|
|
for (; i != end; i += step)
|
|
|
|
{
|
|
|
|
const char* name = dircache[i].name;
|
|
|
|
if (!rb->strcmp(name, videoname)) {
|
|
|
|
found = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (found && rb->strlen(name) <= rest &&
|
|
|
|
!(dircache[i].attr & ATTR_DIRECTORY) && is_videofile(name))
|
|
|
|
{
|
|
|
|
rb->strcpy(videoname, name);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-27 21:45:15 +00:00
|
|
|
#ifdef HAVE_HEADPHONE_DETECTION
|
|
|
|
/* Handle SYS_PHONE_PLUGGED/UNPLUGGED */
|
2010-05-07 13:33:44 +00:00
|
|
|
static void osd_handle_phone_plug(bool inserted)
|
2008-01-27 21:45:15 +00:00
|
|
|
{
|
|
|
|
if (rb->global_settings->unplug_mode == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Wait for any incomplete state transition to complete first */
|
|
|
|
stream_wait_status();
|
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
int status = osd_stream_status();
|
2008-01-27 21:45:15 +00:00
|
|
|
|
|
|
|
if (inserted) {
|
|
|
|
if (rb->global_settings->unplug_mode > 1) {
|
2010-12-22 11:20:07 +00:00
|
|
|
if (status == STREAM_PAUSED &&
|
|
|
|
(osd.flags & OSD_HP_PAUSE)) {
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_resume();
|
2008-01-27 21:45:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (status == STREAM_PLAYING) {
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_pause();
|
2008-01-27 21:45:15 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
osd_set_hp_pause_flag(true);
|
2008-01-27 21:45:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-11-26 12:32:00 +00:00
|
|
|
static int button_loop(void)
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2010-11-26 12:32:00 +00:00
|
|
|
int next_action = (settings.play_mode == 0) ? VIDEO_STOP : VIDEO_NEXT;
|
|
|
|
|
2008-01-03 17:14:28 +00:00
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
2010-01-21 12:14:18 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
rb->lcd_set_background(LCD_BLACK);
|
|
|
|
#endif
|
2007-12-29 19:46:35 +00:00
|
|
|
rb->lcd_clear_display();
|
|
|
|
rb->lcd_update();
|
2007-07-19 19:32:29 +00:00
|
|
|
|
2009-08-27 14:24:58 +00:00
|
|
|
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_YUV)
|
|
|
|
rb->lcd_set_mode(LCD_MODE_YUV);
|
2009-04-01 05:17:20 +00:00
|
|
|
#endif
|
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_init();
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
/* Start playback at the specified starting time */
|
2010-05-07 13:33:44 +00:00
|
|
|
if (osd_play(settings.resume_time) < STREAM_OK) {
|
2007-12-29 19:46:35 +00:00
|
|
|
rb->splash(HZ*2, "Playback failed");
|
2010-11-26 12:32:00 +00:00
|
|
|
return VIDEO_STOP;
|
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
|
|
|
{
|
2010-12-22 11:20:07 +00:00
|
|
|
int button = mpeg_button_get(OSD_MIN_UPDATE_INTERVAL/2);
|
2008-01-09 14:26:19 +00:00
|
|
|
|
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
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_refresh(OSD_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
|
|
|
|
2009-03-17 02:43:47 +00:00
|
|
|
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
2008-05-28 10:17:16 +00:00
|
|
|
case LCD_ENABLE_EVENT_1:
|
|
|
|
{
|
|
|
|
/* Draw the current frame if prepared already */
|
|
|
|
stream_draw_frame(true);
|
|
|
|
break;
|
|
|
|
} /* LCD_ENABLE_EVENT_1: */
|
|
|
|
#endif
|
|
|
|
|
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:
|
2008-01-27 00:18:29 +00:00
|
|
|
#endif
|
|
|
|
#ifdef MPEG_RC_VOLUP
|
|
|
|
case MPEG_RC_VOLUP:
|
|
|
|
case MPEG_RC_VOLUP|BUTTON_REPEAT:
|
2007-04-10 14:18:30 +00:00
|
|
|
#endif
|
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_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:
|
2008-01-27 00:18:29 +00:00
|
|
|
#endif
|
|
|
|
#ifdef MPEG_RC_VOLDOWN
|
|
|
|
case MPEG_RC_VOLDOWN:
|
|
|
|
case MPEG_RC_VOLDOWN|BUTTON_REPEAT:
|
2007-12-29 19:46:35 +00:00
|
|
|
#endif
|
2007-01-01 12:59:32 +00:00
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_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:
|
2008-01-27 00:18:29 +00:00
|
|
|
#ifdef MPEG_RC_MENU
|
|
|
|
case MPEG_RC_MENU:
|
|
|
|
#endif
|
2007-01-01 12:59:32 +00:00
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
int state = osd_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 */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_show(OSD_HIDE | OSD_NODRAW);
|
2007-12-29 19:46:35 +00:00
|
|
|
stream_show_vo(false);
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_backlight_brightness_video_mode(false);
|
2007-10-09 20:42:20 +00:00
|
|
|
|
2009-08-27 14:24:58 +00:00
|
|
|
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_YUV)
|
|
|
|
rb->lcd_set_mode(LCD_MODE_RGB565);
|
2009-04-01 05:17:20 +00:00
|
|
|
#endif
|
|
|
|
|
2009-08-27 14:24:58 +00:00
|
|
|
result = mpeg_menu();
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2010-11-26 12:32:00 +00:00
|
|
|
next_action = (settings.play_mode == 0) ? VIDEO_STOP : VIDEO_NEXT;
|
|
|
|
|
2011-01-03 16:41:19 +00:00
|
|
|
fps_update_post_frame_callback();
|
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
/* The menu can change the font, so restore */
|
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
2010-01-13 12:55:52 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
rb->lcd_set_background(LCD_BLACK);
|
|
|
|
#endif
|
2010-01-21 12:14:18 +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
|
|
|
switch (result)
|
2007-01-01 12:59:32 +00:00
|
|
|
{
|
2007-12-29 19:46:35 +00:00
|
|
|
case MPEG_MENU_QUIT:
|
2010-11-26 12:32:00 +00:00
|
|
|
next_action = VIDEO_STOP;
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_stop();
|
2007-12-29 19:46:35 +00:00
|
|
|
break;
|
2008-01-12 05:45:38 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
default:
|
2009-08-27 14:24:58 +00:00
|
|
|
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_YUV)
|
|
|
|
rb->lcd_set_mode(LCD_MODE_YUV);
|
2009-04-01 05:17:20 +00:00
|
|
|
#endif
|
2007-12-29 19:46:35 +00:00
|
|
|
/* If not stopped, show video again */
|
2008-01-03 17:14:28 +00:00
|
|
|
if (state != STREAM_STOPPED) {
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_show(OSD_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) {
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_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
|
|
|
|
2010-05-07 13:06:42 +00:00
|
|
|
#ifdef MPEG_SHOW_OSD
|
|
|
|
case MPEG_SHOW_OSD:
|
|
|
|
case MPEG_SHOW_OSD | BUTTON_REPEAT:
|
|
|
|
/* Show if not visible */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_show(OSD_SHOW);
|
2010-05-07 13:06:42 +00:00
|
|
|
/* Make sure it refreshes */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_refresh(OSD_REFRESH_DEFAULT);
|
2010-05-07 13:06:42 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
case MPEG_STOP:
|
2008-01-27 00:18:29 +00:00
|
|
|
#ifdef MPEG_RC_STOP
|
|
|
|
case MPEG_RC_STOP:
|
|
|
|
#endif
|
2008-01-12 05:45:38 +00:00
|
|
|
case ACTION_STD_CANCEL:
|
2007-04-10 14:18:30 +00:00
|
|
|
{
|
2010-12-22 11:20:07 +00:00
|
|
|
cancel_playback:
|
2010-11-26 12:32:00 +00:00
|
|
|
next_action = VIDEO_STOP;
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_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:
|
2008-01-27 00:18:29 +00:00
|
|
|
#endif
|
|
|
|
#ifdef MPEG_RC_PAUSE
|
|
|
|
case MPEG_RC_PAUSE:
|
2007-12-29 19:46:35 +00:00
|
|
|
#endif
|
2007-04-10 14:18:30 +00:00
|
|
|
{
|
2010-12-22 11:20:07 +00:00
|
|
|
int status = osd_stream_status();
|
2008-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
if (status == STREAM_PLAYING) {
|
2007-12-29 19:46:35 +00:00
|
|
|
/* Playing => Paused */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_pause();
|
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 */
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_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:
|
2010-05-07 11:47:54 +00:00
|
|
|
#ifdef MPEG_RW2
|
|
|
|
case MPEG_RW2:
|
|
|
|
#endif
|
2010-12-22 11:20:07 +00:00
|
|
|
#ifdef MPEG_RC_RW
|
|
|
|
case MPEG_RC_RW:
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
int old_button = button;
|
|
|
|
|
|
|
|
/* If button has been released: skip to next/previous file */
|
|
|
|
button = mpeg_button_get(OSD_MIN_UPDATE_INTERVAL);
|
|
|
|
|
|
|
|
if ((old_button | BUTTON_REL) == button) {
|
|
|
|
/* Check current playback position */
|
|
|
|
osd_update_time();
|
|
|
|
|
|
|
|
if (settings.play_mode == 0 || osd.curr_time >= 3*TS_SECOND) {
|
|
|
|
/* Start the current video from the beginning */
|
|
|
|
osd_seek_time(0*TS_SECOND);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Release within 3 seconds of start: skip to previous
|
|
|
|
* file */
|
|
|
|
osd_stop();
|
2011-07-08 22:31:15 +00:00
|
|
|
next_action = VIDEO_PREV | VIDEO_ACTION_MANUAL;
|
2010-12-22 11:20:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((button & ~BUTTON_REPEAT) == old_button) {
|
|
|
|
button = osd_seek_btn(old_button);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (button == ACTION_STD_CANCEL)
|
|
|
|
goto cancel_playback; /* jump to stop handling above */
|
|
|
|
|
|
|
|
rb->default_event_handler(button);
|
|
|
|
break;
|
|
|
|
} /* MPEG_RW: */
|
|
|
|
|
|
|
|
case MPEG_FF:
|
2010-05-07 11:47:54 +00:00
|
|
|
#ifdef MPEG_FF2
|
|
|
|
case MPEG_FF2:
|
|
|
|
#endif
|
2010-12-22 11:20:07 +00:00
|
|
|
#ifdef MPEG_RC_FF
|
2008-01-27 00:18:29 +00:00
|
|
|
case MPEG_RC_FF:
|
|
|
|
#endif
|
2008-01-03 17:14:28 +00:00
|
|
|
{
|
2010-11-26 12:32:00 +00:00
|
|
|
int old_button = button;
|
2010-12-22 11:20:07 +00:00
|
|
|
|
2010-11-26 12:32:00 +00:00
|
|
|
if (settings.play_mode != 0)
|
2010-12-22 11:20:07 +00:00
|
|
|
button = mpeg_button_get(OSD_MIN_UPDATE_INTERVAL);
|
|
|
|
|
|
|
|
if ((old_button | BUTTON_REL) == button) {
|
|
|
|
/* If button has been released: skip to next file */
|
2010-11-26 12:32:00 +00:00
|
|
|
osd_stop();
|
2011-07-08 22:31:15 +00:00
|
|
|
next_action = VIDEO_NEXT | VIDEO_ACTION_MANUAL;
|
2010-11-26 12:32:00 +00:00
|
|
|
}
|
2010-12-22 11:20:07 +00:00
|
|
|
else if ((button & ~BUTTON_REPEAT) == old_button) {
|
|
|
|
button = osd_seek_btn(old_button);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (button == ACTION_STD_CANCEL)
|
|
|
|
goto cancel_playback; /* jump to stop handling above */
|
|
|
|
|
|
|
|
rb->default_event_handler(button);
|
2008-01-03 17:14:28 +00:00
|
|
|
break;
|
2010-12-22 11:20:07 +00:00
|
|
|
} /* MPEG_FF: */
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2008-01-27 21:45:15 +00:00
|
|
|
#ifdef HAVE_HEADPHONE_DETECTION
|
|
|
|
case SYS_PHONE_PLUGGED:
|
|
|
|
case SYS_PHONE_UNPLUGGED:
|
|
|
|
{
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_handle_phone_plug(button == SYS_PHONE_PLUGGED);
|
2008-01-27 21:45:15 +00:00
|
|
|
break;
|
|
|
|
} /* SYS_PHONE_*: */
|
|
|
|
#endif
|
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
default:
|
2008-01-12 05:45:38 +00:00
|
|
|
{
|
2010-12-22 11:20:07 +00:00
|
|
|
osd_refresh(OSD_REFRESH_DEFAULT);
|
2007-12-29 19:46:35 +00:00
|
|
|
rb->default_event_handler(button);
|
|
|
|
break;
|
2008-01-12 05:45:38 +00:00
|
|
|
} /* default: */
|
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
|
|
|
|
2010-05-07 13:33:44 +00:00
|
|
|
osd_stop();
|
2008-01-03 17:14:28 +00:00
|
|
|
|
2009-03-17 02:43:47 +00:00
|
|
|
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
|
2008-05-28 11:44:06 +00:00
|
|
|
/* Be sure hook is removed before exiting since the stop will put it
|
|
|
|
* back because of the backlight restore. */
|
2010-05-07 13:33:44 +00:00
|
|
|
rb->remove_event(LCD_EVENT_ACTIVATION, osd_lcd_enable_hook);
|
2008-05-28 11:44:06 +00:00
|
|
|
#endif
|
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
rb->lcd_setfont(FONT_UI);
|
2010-11-26 12:32:00 +00:00
|
|
|
|
|
|
|
return next_action;
|
2007-04-10 14:18:30 +00:00
|
|
|
}
|
2007-03-22 09:18:46 +00:00
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
2007-04-10 14:18:30 +00:00
|
|
|
{
|
2010-11-26 12:32:00 +00:00
|
|
|
static char videofile[MAX_PATH];
|
2010-12-19 03:28:43 +00:00
|
|
|
int status = PLUGIN_OK; /* assume success */
|
2010-11-26 12:32:00 +00:00
|
|
|
bool quit = false;
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
if (parameter == NULL) {
|
|
|
|
/* No file = GTFO */
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->splash(HZ*2, "No File");
|
2007-12-29 19:46:35 +00:00
|
|
|
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 */
|
2009-01-16 10:34:40 +00:00
|
|
|
rb->talk_disable(true);
|
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
|
|
|
|
2010-11-26 12:32:00 +00:00
|
|
|
rb->strcpy(videofile, (const char*) parameter);
|
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
if (stream_init() < STREAM_OK) {
|
2010-12-19 03:28:43 +00:00
|
|
|
/* Fatal because this should not fail */
|
2007-12-29 19:46:35 +00:00
|
|
|
DEBUGF("Could not initialize streams\n");
|
2010-12-19 03:28:43 +00:00
|
|
|
status = PLUGIN_ERROR;
|
2007-12-29 19:46:35 +00:00
|
|
|
} else {
|
2010-12-22 11:20:07 +00:00
|
|
|
int next_action = VIDEO_STOP;
|
|
|
|
bool get_videofile_says = true;
|
|
|
|
|
2010-11-26 12:32:00 +00:00
|
|
|
while (!quit)
|
|
|
|
{
|
|
|
|
init_settings(videofile);
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2011-07-08 22:31:15 +00:00
|
|
|
int result = stream_open(videofile);
|
|
|
|
bool manual_skip = false;
|
2010-12-22 11:20:07 +00:00
|
|
|
|
|
|
|
if (result >= STREAM_OK) {
|
2010-11-26 12:32:00 +00:00
|
|
|
/* start menu */
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
rb->lcd_update();
|
|
|
|
result = mpeg_start_menu(stream_get_duration());
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
next_action = VIDEO_STOP;
|
2010-11-26 12:32:00 +00:00
|
|
|
if (result != MPEG_START_QUIT) {
|
|
|
|
/* Enter button loop and process UI */
|
|
|
|
next_action = button_loop();
|
2011-07-08 22:31:15 +00:00
|
|
|
manual_skip = next_action & VIDEO_ACTION_MANUAL;
|
|
|
|
next_action &= ~VIDEO_ACTION_MANUAL;
|
2010-11-26 12:32:00 +00:00
|
|
|
}
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2010-11-26 12:32:00 +00:00
|
|
|
stream_close();
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2010-11-26 12:32:00 +00:00
|
|
|
rb->lcd_clear_display();
|
|
|
|
rb->lcd_update();
|
2007-04-10 14:18:30 +00:00
|
|
|
|
2010-11-26 12:32:00 +00:00
|
|
|
save_settings();
|
|
|
|
} else {
|
2010-12-19 03:28:43 +00:00
|
|
|
/* Problem with file; display message about it - not
|
|
|
|
* considered a plugin error */
|
2010-12-22 11:20:07 +00:00
|
|
|
long tick;
|
|
|
|
const char *errstring;
|
|
|
|
|
2010-11-26 12:32:00 +00:00
|
|
|
DEBUGF("Could not open %s\n", videofile);
|
2010-12-22 11:20:07 +00:00
|
|
|
switch (result)
|
2010-11-26 12:32:00 +00:00
|
|
|
{
|
|
|
|
case STREAM_UNSUPPORTED:
|
|
|
|
errstring = "Unsupported format";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
errstring = "Error opening file: %d";
|
|
|
|
}
|
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
tick = *rb->current_tick + HZ*2;
|
2010-12-19 03:28:43 +00:00
|
|
|
|
2010-12-22 11:20:07 +00:00
|
|
|
rb->splashf(0, errstring, result);
|
|
|
|
|
|
|
|
/* Be sure it doesn't get stuck in an unbreakable loop of bad
|
|
|
|
* files, just in case! Otherwise, keep searching in the
|
|
|
|
* chosen direction until a good one is found. */
|
|
|
|
while (!quit && TIME_BEFORE(*rb->current_tick, tick))
|
|
|
|
{
|
|
|
|
int button = mpeg_button_get(HZ*2);
|
|
|
|
|
|
|
|
switch (button)
|
|
|
|
{
|
|
|
|
case MPEG_STOP:
|
|
|
|
case ACTION_STD_CANCEL:
|
|
|
|
/* Abort the search and exit */
|
|
|
|
next_action = VIDEO_STOP;
|
|
|
|
quit = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BUTTON_NONE:
|
|
|
|
if (settings.play_mode != 0) {
|
|
|
|
if (next_action == VIDEO_STOP) {
|
|
|
|
/* Default to next file */
|
|
|
|
next_action = VIDEO_NEXT;
|
|
|
|
}
|
|
|
|
else if (next_action == VIDEO_PREV &&
|
|
|
|
!get_videofile_says) {
|
|
|
|
/* Was first file already; avoid endlessly
|
|
|
|
* retrying it */
|
|
|
|
next_action = VIDEO_STOP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
rb->default_event_handler(button);
|
|
|
|
} /* switch */
|
|
|
|
} /* while */
|
2010-11-26 12:32:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* return value of button_loop says, what's next */
|
|
|
|
switch (next_action)
|
|
|
|
{
|
|
|
|
case VIDEO_NEXT:
|
2007-12-29 19:46:35 +00:00
|
|
|
{
|
2010-12-22 11:20:07 +00:00
|
|
|
get_videofile_says = get_videofile(VIDEO_NEXT, videofile,
|
|
|
|
sizeof(videofile));
|
|
|
|
/* quit after finished the last videofile */
|
|
|
|
quit = !get_videofile_says;
|
2011-07-08 22:31:15 +00:00
|
|
|
|
|
|
|
if (manual_skip)
|
|
|
|
{
|
|
|
|
rb->system_sound_play(get_videofile_says ?
|
|
|
|
SOUND_TRACK_SKIP : SOUND_TRACK_NO_MORE);
|
|
|
|
}
|
|
|
|
|
2007-12-29 19:46:35 +00:00
|
|
|
break;
|
2010-11-26 12:32:00 +00:00
|
|
|
}
|
|
|
|
case VIDEO_PREV:
|
|
|
|
{
|
2010-12-22 11:20:07 +00:00
|
|
|
get_videofile_says = get_videofile(VIDEO_PREV, videofile,
|
|
|
|
sizeof(videofile));
|
2010-11-26 12:32:00 +00:00
|
|
|
/* if there is no previous file, play the same videofile */
|
2011-07-08 22:31:15 +00:00
|
|
|
|
|
|
|
if (manual_skip)
|
|
|
|
{
|
|
|
|
rb->system_sound_play(get_videofile_says ?
|
|
|
|
SOUND_TRACK_SKIP : SOUND_TRACK_NO_MORE);
|
|
|
|
}
|
|
|
|
|
2010-11-26 12:32:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case VIDEO_STOP:
|
|
|
|
{
|
|
|
|
quit = true;
|
|
|
|
break;
|
|
|
|
}
|
2007-12-29 19:46:35 +00:00
|
|
|
}
|
2010-12-22 11:20:07 +00:00
|
|
|
} /* while */
|
2007-10-22 05:57:38 +00:00
|
|
|
}
|
2010-01-13 12:55:52 +00:00
|
|
|
|
2009-08-27 14:24:58 +00:00
|
|
|
#if defined(HAVE_LCD_MODES) && (HAVE_LCD_MODES & LCD_MODE_YUV)
|
|
|
|
rb->lcd_set_mode(LCD_MODE_RGB565);
|
2009-04-01 05:17:20 +00:00
|
|
|
#endif
|
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);
|
2010-12-22 11:20:07 +00:00
|
|
|
|
|
|
|
/* Actually handle delayed processing of system events of interest
|
|
|
|
* that were captured in other button loops */
|
|
|
|
mpeg_sysevent_handle();
|
|
|
|
|
2007-04-10 14:18:30 +00:00
|
|
|
return status;
|
2006-08-07 22:11:07 +00:00
|
|
|
}
|