diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-07-27 12:25:15 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-07-27 12:25:15 -0600 |
commit | dc388b2bd44718d09d2f9e817c50702ad6ffdd55 (patch) | |
tree | d06b7ee48a9c3fb512fe8e7d8f00a7b28dd903a6 | |
parent | 707f46add8f3687009950c5337230a86173c094e (diff) | |
download | nuttx-dc388b2bd44718d09d2f9e817c50702ad6ffdd55.tar.gz nuttx-dc388b2bd44718d09d2f9e817c50702ad6ffdd55.tar.bz2 nuttx-dc388b2bd44718d09d2f9e817c50702ad6ffdd55.zip |
NxWM::CMediaPlayer: successive presses on fast forward or rewind button now increase the subsampling, wrapping back to 2X when the maximum of 16x is reached.
-rw-r--r-- | NxWidgets/nxwm/include/cmediaplayer.hxx | 11 | ||||
-rw-r--r-- | NxWidgets/nxwm/src/cmediaplayer.cxx | 53 |
2 files changed, 47 insertions, 17 deletions
diff --git a/NxWidgets/nxwm/include/cmediaplayer.hxx b/NxWidgets/nxwm/include/cmediaplayer.hxx index ea1133f98..fc71c0b25 100644 --- a/NxWidgets/nxwm/include/cmediaplayer.hxx +++ b/NxWidgets/nxwm/include/cmediaplayer.hxx @@ -2,7 +2,9 @@ * NxWidgets/nxwm/include/cmediaplayer.hxx * * Copyright (C) 2013 Ken Pettit. All rights reserved. + * Copyright (C) 2014 Gregory Nutt. All rights reserved. * Author: Ken Pettit <pettitkd@gmail.com> + * Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -93,8 +95,8 @@ namespace NxWM * STAGED | STAGED | STOPPED | PLAYING | X | X | X | * PLAYING | X | X | X | PAUSED |FFORWARD2 | REWIND2 | * PAUSED | STAGED | STOPPED | PLAYING | X |FFORWARD1 | REWIND1 | - * FFORWARD1| X | X | PAUSED | X | PAUSED | REWIND1 | - * REWIND1 | X | X | PAUSED | X |FFORWARD1 | PAUSED | + * FFORWARD1| X | X | PAUSED | X |FFORWARD1 | REWIND1 | + * REWIND1 | X | X | PAUSED | X |FFORWARD1 | REWIND1 | * FFORWARD2| X | X | X | PLAYING | PLAYING | REWIND1 | * REWIND2 | X | X | X | PLAYING |FFORWARD1 | PLAYING | * ---------+----------+----------+----------+----------+----------+----------+ @@ -152,11 +154,14 @@ namespace NxWM enum EMediaPlayerState m_prevState; /**< Media player previous state */ enum EPendingRelease m_pending; /**< Pending image release event */ NXWidgets::CNxString m_filePath; /**< The full path to the selected file */ - unsigned int m_fileIndex; /**< Last selected text box selection */ + int m_fileIndex; /**< Last selected text box selection */ bool m_fileReady; /**< True: Ready to play */ #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME uint8_t m_level; /**< Current volume level, range 0-100 */ #endif +#ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD + uint8_t m_subSample; /**< Current FFFORWARD subsampling */ +#endif /** * Media player geometry. diff --git a/NxWidgets/nxwm/src/cmediaplayer.cxx b/NxWidgets/nxwm/src/cmediaplayer.cxx index cd76e5a9c..ad63e13cd 100644 --- a/NxWidgets/nxwm/src/cmediaplayer.cxx +++ b/NxWidgets/nxwm/src/cmediaplayer.cxx @@ -137,6 +137,9 @@ CMediaPlayer::CMediaPlayer(CTaskbar *taskbar, CApplicationWindow *window) #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME m_level = 0; #endif +#ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD + m_subSample = AUDIO_SUBSAMPLE_NONE; +#endif m_fileReady = false; // Add our personalized window label @@ -1504,13 +1507,22 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e) if (m_state == MPLAYER_FREWIND) { - // Yes.. then revert to the previous play/pause state - // REVISIT: Or just increase rewind speed? + // Yes.. then just increase rewind rate (by specifying a + // higher level of sub-sampling) + + if (m_subSample >= AUDIO_SUBSAMPLE_MAX) + { + m_subSample = AUDIO_SUBSAMPLE_MIN; + } + else + { + m_subSample++; + } - int ret = nxplayer_cancel_motion(m_player, m_prevState == MPLAYER_PAUSED); + int ret = nxplayer_rewind(m_player, m_subSample); if (ret < 0) { - dbg("ERROR: nxplayer_cancel_motion failed: %d\n", ret); + dbg("ERROR: nxplayer_rewind failed: %d\n", ret); } else { @@ -1522,9 +1534,11 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e) else if (m_state != MPLAYER_STOPPED && m_state != MPLAYER_STAGED) { - // Start rewinding + // Start rewinding at the minimum rate + + m_subSample = AUDIO_SUBSAMPLE_MIN; - int ret = nxplayer_rewind(m_player, SUBSAMPLE_4X); + int ret = nxplayer_rewind(m_player, m_subSample); if (ret < 0) { dbg("ERROR: nxplayer_rewind failed: %d\n", ret); @@ -1546,17 +1560,22 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e) if (m_state == MPLAYER_FFORWARD) { - // Yes.. then revert to the previous play/pause state - // REVISIT: Or just increase fast forward speed? + // Yes.. then just increase fast forward rate (by specifying a + // level level of sub-sampling) - int ret = nxplayer_cancel_motion(m_player, m_prevState == MPLAYER_PAUSED); - if (ret < 0) + if (m_subSample >= AUDIO_SUBSAMPLE_MAX) { - dbg("ERROR: nxplayer_cancel_motion failed: %d\n", ret); + m_subSample = AUDIO_SUBSAMPLE_MIN; } else { - setMediaPlayerState(m_prevState); + m_subSample++; + } + + int ret = nxplayer_fforward(m_player, m_subSample); + if (ret < 0) + { + dbg("ERROR: nxplayer_fforward failed: %d\n", ret); } } @@ -1564,9 +1583,11 @@ void CMediaPlayer::handleActionEvent(const NXWidgets::CWidgetEventArgs &e) else if (m_state != MPLAYER_STOPPED && m_state != MPLAYER_STAGED) { - // Start fast forwarding + // Start fast forwarding at the minimum rate + + m_subSample = AUDIO_SUBSAMPLE_MIN; - int ret = nxplayer_fforward(m_player, SUBSAMPLE_4X); + int ret = nxplayer_fforward(m_player, m_subSample); if (ret < 0) { dbg("ERROR: nxplayer_fforward failed: %d\n", ret); @@ -1663,6 +1684,8 @@ void CMediaPlayer::handleReleaseEvent(const NXWidgets::CWidgetEventArgs &e) // In these states, stop the fast motion action and return to the // previous state + m_subSample = AUDIO_SUBSAMPLE_NONE; + int ret = nxplayer_cancel_motion(m_player, m_prevState == MPLAYER_PAUSED); if (ret < 0) { @@ -1714,6 +1737,8 @@ void CMediaPlayer::handleReleaseEvent(const NXWidgets::CWidgetEventArgs &e) // Otherwise, we must be fast forwarding or rewinding. In these // cases, stop the action and return to the previous state + m_subSample = AUDIO_SUBSAMPLE_NONE; + int ret = nxplayer_cancel_motion(m_player, m_prevState == MPLAYER_PAUSED); if (ret < 0) { |