kwave
18.07.70
|
#include <PlaybackController.h>
Public Slots | |
void | playbackStart () |
void | playbackLoop () |
void | playbackPause () |
void | playbackContinue () |
void | playbackStop () |
void | reload () |
void | seekTo (sample_index_t pos) |
void | seekDone (sample_index_t pos) |
void | updatePlaybackPos (sample_index_t pos) |
void | playbackDone () |
Signals | |
void | sigPlaybackStarted () |
void | sigPlaybackPaused () |
void | sigPlaybackStopped () |
void | sigPlaybackPos (sample_index_t pos) |
void | sigSeekDone (sample_index_t pos) |
void | sigDevicePlaybackDone () |
void | sigDevicePlaybackPos (sample_index_t pos) |
void | sigDeviceSeekDone (sample_index_t pos) |
Public Member Functions | |
PlaybackController (Kwave::SignalManager &signal_manager) | |
virtual | ~PlaybackController () Q_DECL_OVERRIDE |
void | reset () |
bool | loop () const |
bool | running () const |
bool | paused () const |
void | setStartPos (sample_index_t pos) |
void | setEndPos (sample_index_t pos) |
sample_index_t | startPos () const |
sample_index_t | endPos () const |
sample_index_t | currentPos () const |
void | registerPlaybackDeviceFactory (Kwave::PlaybackDeviceFactory *factory) |
void | unregisterPlaybackDeviceFactory (Kwave::PlaybackDeviceFactory *factory) |
virtual Kwave::PlayBackDevice * | createDevice (Kwave::playback_method_t method) |
Kwave::PlayBackDevice * | openDevice (int tracks, const Kwave::PlayBackParam *playback_params) |
void | setDefaultParams (const Kwave::PlayBackParam ¶ms) |
void | checkMethod (Kwave::playback_method_t &method) |
![]() | |
virtual | ~Runnable () |
Protected Member Functions | |
virtual void | run_wrapper (const QVariant ¶ms) Q_DECL_OVERRIDE |
Private Slots | |
void | closeDevice () |
void | trackSelectionChanged () |
Private Member Functions | |
void | startDevicePlayBack () |
void | stopDevicePlayBack () |
Provides a generic interface for classes that can contol playback with start, stop, pause and continue. This class is intended to be used or derived in a class that is able to control a playback device by simply startig or stopping playback and can be easily used by some other part of the program that has nothing to do directly with playback. The playback control functions all start with "playback" and are slots that are intended to be connected to some simple gui elements like toolbar buttons or menu entries.
This class internally manages the logic and handling of the playback position.
Definition at line 53 of file PlaybackController.h.
|
explicit |
Default constructor
Definition at line 42 of file PlaybackController.cpp.
References closeDevice(), Kwave::connect(), m_signal_manager, playbackDone(), sigDevicePlaybackDone(), and trackSelectionChanged().
|
virtual |
Destructor
Definition at line 66 of file PlaybackController.cpp.
References playbackStop().
void Kwave::PlaybackController::checkMethod | ( | Kwave::playback_method_t & | method | ) |
Checks whether a playback method is supported and returns the next best match if not.
method | reference to a playback method, can be modified |
Definition at line 556 of file PlaybackController.cpp.
References DBG, Kwave::TypesMap< IDX, DATA >::findFromData(), m_playback_factories, Kwave::TypesMap< IDX, DATA >::name(), Kwave::PLAYBACK_INVALID, Kwave::PLAYBACK_NONE, and Kwave::PlaybackDeviceFactory::supportedMethods().
Referenced by openDevice(), and Kwave::PlayBackDialog::setMethod().
|
privateslot |
Closes the playback device, deletes the instance of the PlayBackDevice and sets m_device to 0.
Definition at line 542 of file PlaybackController.cpp.
References m_device, and m_lock_device.
Referenced by PlaybackController(), and stopDevicePlayBack().
|
virtual |
Create a playback device matching the given playback method.
method | a playback_method_t (e.g. Pulse, ALSA, OSS...) |
Definition at line 591 of file PlaybackController.cpp.
References Kwave::PlaybackDeviceFactory::createDevice(), m_playback_factories, and Kwave::PlaybackDeviceFactory::supportedMethods().
Referenced by openDevice(), and Kwave::PlayBackDialog::setMethod().
sample_index_t Kwave::PlaybackController::currentPos | ( | ) | const |
returns the current position of the playback pointer
Definition at line 303 of file PlaybackController.cpp.
References m_playback_position.
Referenced by startDevicePlayBack().
sample_index_t Kwave::PlaybackController::endPos | ( | ) | const |
returns the position where the playback ends
Definition at line 297 of file PlaybackController.cpp.
References m_playback_end.
bool Kwave::PlaybackController::loop | ( | ) | const |
returns the loop mode flag
Definition at line 261 of file PlaybackController.cpp.
References m_loop_mode.
Kwave::PlayBackDevice * Kwave::PlaybackController::openDevice | ( | int | tracks, |
const Kwave::PlayBackParam * | playback_params | ||
) |
Creates, opens and initializes a playback device.
tracks | number of tracks, if negative use the setting of playback_params |
playback_params | points to a structure with playback parameters. If null, the default parameters of the current signal will be used |
Definition at line 610 of file PlaybackController.cpp.
References Kwave::PlayBackParam::bits_per_sample, Kwave::PlayBackParam::bufbase, Kwave::PlayBackParam::channels, checkMethod(), createDevice(), Kwave::PlayBackParam::device, Kwave::MessageBox::error(), Kwave::SignalManager::isClosed(), Kwave::SignalManager::isEmpty(), m_playback_params, m_signal_manager, Kwave::PlayBackParam::method, Kwave::PlayBackDevice::open(), Kwave::SignalManager::parentWidget(), Kwave::PLAYBACK_NONE, Kwave::PlayBackParam::rate, Kwave::SignalManager::rate(), and Kwave::SignalManager::selectedTracks().
Referenced by Kwave::PluginManager::openMultiTrackPlayback(), and startDevicePlayBack().
bool Kwave::PlaybackController::paused | ( | ) | const |
returns true if the playback is paused
Definition at line 273 of file PlaybackController.cpp.
References m_paused.
|
slot |
Continues the playback at the position where it has been stopped by the playbackPause() command. If the last playback pointer has become invalid or is not available (less 0), this function will do the same as playbackStart(). This also emits the signal sigPlaybackStarted().
Definition at line 135 of file PlaybackController.cpp.
References m_paused, m_playing, m_reload_mode, playbackStart(), sigPlaybackStarted(), and startDevicePlayBack().
|
slot |
Updates the status if playback is done
Definition at line 207 of file PlaybackController.cpp.
References m_old_first, m_old_last, m_paused, m_playback_position, m_playing, m_reload_mode, sigPlaybackPaused(), sigPlaybackPos(), sigPlaybackStopped(), and startDevicePlayBack().
Referenced by PlaybackController().
|
slot |
(Re-)starts the playback in loop mode (like with playbackStart(). Also emitts sigPlaybackStarted() if playback has successfully been started.
Definition at line 96 of file PlaybackController.cpp.
References m_loop_mode, m_paused, m_playback_position, m_playback_start, m_playing, m_reload_mode, sigPlaybackPos(), sigPlaybackStarted(), sigPlaybackStopped(), startDevicePlayBack(), and stopDevicePlayBack().
|
slot |
Pauses the playback. Causes sigPlaybackDone() to be emitted if the current buffer has played out. The current playback pointer will stay at it's current position.
Definition at line 121 of file PlaybackController.cpp.
References m_paused, m_playing, m_reload_mode, and stopDevicePlayBack().
|
slot |
(Re-)starts the playback. If playback has successfully been started, the signal sigPlaybackStarted() will be emitted.
Definition at line 72 of file PlaybackController.cpp.
References m_loop_mode, m_paused, m_playback_position, m_playback_start, m_playing, m_reload_mode, sigPlaybackPos(), sigPlaybackStarted(), sigPlaybackStopped(), startDevicePlayBack(), and stopDevicePlayBack().
Referenced by Kwave::SignalManager::executeCommand(), and playbackContinue().
|
slot |
Stopps playback / loop. Like playbackPause(), but resets the playback pointer back to the start.
Definition at line 156 of file PlaybackController.cpp.
References m_paused, m_playing, m_reload_mode, sigPlaybackStopped(), and stopDevicePlayBack().
Referenced by Kwave::SignalManager::close(), and ~PlaybackController().
void Kwave::PlaybackController::registerPlaybackDeviceFactory | ( | Kwave::PlaybackDeviceFactory * | factory | ) |
Registers a PlaybackDeviceFactory
Definition at line 672 of file PlaybackController.cpp.
References m_playback_factories.
Referenced by Kwave::PlayBackPlugin::load().
|
slot |
If playback is currently running, it will be paused and then restarted with current track and time selection.
Definition at line 234 of file PlaybackController.cpp.
References m_paused, m_playing, m_reload_mode, and stopDevicePlayBack().
void Kwave::PlaybackController::reset | ( | ) |
resets start, current position, loop, pause and running flag
Definition at line 247 of file PlaybackController.cpp.
References m_loop_mode, m_paused, m_playback_position, m_playback_start, m_playing, m_reload_mode, sigPlaybackPos(), and sigPlaybackStopped().
Referenced by Kwave::SignalManager::close().
|
protectedvirtual |
wrapper for our run() function, called from worker thread
Implements Kwave::Runnable.
Definition at line 399 of file PlaybackController.cpp.
References Kwave::SignalManager::allTracks(), Kwave::WorkerThread::cancel(), Kwave::PlayBackParam::channels, Kwave::SampleReader::eof(), Kwave::FullSnapshot, m_device, m_lock_device, m_lock_playback, m_loop_mode, m_playback_end, m_playback_params, m_playback_position, m_playback_start, m_seek_pos, m_should_seek, m_signal_manager, m_thread, m_track_selection_changed, Kwave::PlayBackParam::rate, Kwave::MultiTrackReader::reset(), SCREEN_REFRESHES_PER_SECOND, Kwave::MultiTrackReader::seek(), seekDone(), Kwave::SignalManager::selectedTracks(), Kwave::WorkerThread::shouldStop(), sigDevicePlaybackDone(), Kwave::MultiTrackReader::skip(), startPos(), Kwave::toUint(), updatePlaybackPos(), and Kwave::PlayBackDevice::write().
bool Kwave::PlaybackController::running | ( | ) | const |
returns true if the playback is running
Definition at line 267 of file PlaybackController.cpp.
References m_playing.
Referenced by Kwave::SignalView::mousePressEvent(), and Kwave::SignalView::mouseReleaseEvent().
|
slot |
Called when the seek has finished
Definition at line 194 of file PlaybackController.cpp.
References sigSeekDone().
Referenced by run_wrapper(), and seekTo().
|
slot |
Seeks to a new position
Definition at line 172 of file PlaybackController.cpp.
References m_lock_playback, m_paused, m_playback_end, m_playback_start, m_seek_pos, m_should_seek, seekDone(), and updatePlaybackPos().
void Kwave::PlaybackController::setDefaultParams | ( | const Kwave::PlayBackParam & | params | ) |
Sets default playback parameters, for use next time playback is started
params | new playback parameters |
Definition at line 665 of file PlaybackController.cpp.
References m_playback_params.
Referenced by Kwave::PlayBackPlugin::load(), and Kwave::PlayBackPlugin::setup().
void Kwave::PlaybackController::setEndPos | ( | sample_index_t | pos | ) |
sets a new end position
Definition at line 285 of file PlaybackController.cpp.
References m_playback_end.
Referenced by startDevicePlayBack().
void Kwave::PlaybackController::setStartPos | ( | sample_index_t | pos | ) |
sets a new start position
Definition at line 279 of file PlaybackController.cpp.
References m_playback_start.
Referenced by startDevicePlayBack().
|
signal |
Signals that playback has stopped (sent from worker thread).
Referenced by PlaybackController(), run_wrapper(), startDevicePlayBack(), and stopDevicePlayBack().
|
signal |
Emits the current playback position (from worker thread)
|
signal |
Emitted after a successful seek operation (from worker thread)
|
signal |
Signals that playback has been paused.
Referenced by playbackDone().
|
signal |
Emits the current position of the playback pointer
Referenced by playbackDone(), playbackLoop(), playbackStart(), reset(), and updatePlaybackPos().
|
signal |
Signals that playback has started.
Referenced by playbackContinue(), playbackLoop(), and playbackStart().
|
signal |
Signals that playback has stopped.
Referenced by playbackDone(), playbackLoop(), playbackStart(), playbackStop(), and reset().
|
signal |
Emits the current position after a seek operation
Referenced by seekDone().
|
private |
Starts playback device (and worker thread)
Definition at line 309 of file PlaybackController.cpp.
References currentPos(), Kwave::Selection::first(), Kwave::Selection::last(), Kwave::SignalManager::length(), m_device, m_lock_device, m_old_first, m_old_last, m_paused, m_playback_params, m_signal_manager, m_thread, openDevice(), Kwave::PlayBackParam::rate, Kwave::SignalManager::rate(), Kwave::SignalManager::selection(), setEndPos(), setStartPos(), sigDevicePlaybackDone(), Kwave::WorkerThread::start(), and updatePlaybackPos().
Referenced by playbackContinue(), playbackDone(), playbackLoop(), and playbackStart().
sample_index_t Kwave::PlaybackController::startPos | ( | ) | const |
returns the position where the playback starts
Definition at line 291 of file PlaybackController.cpp.
References m_playback_start.
Referenced by run_wrapper().
|
private |
Stops the playback device (and worker thread)
Definition at line 381 of file PlaybackController.cpp.
References Kwave::WorkerThread::cancel(), closeDevice(), m_thread, and sigDevicePlaybackDone().
Referenced by playbackLoop(), playbackPause(), playbackStart(), playbackStop(), and reload().
|
privateslot |
updates the mixer matrix if the track selection has changed
Definition at line 392 of file PlaybackController.cpp.
References m_lock_playback, and m_track_selection_changed.
Referenced by PlaybackController().
void Kwave::PlaybackController::unregisterPlaybackDeviceFactory | ( | Kwave::PlaybackDeviceFactory * | factory | ) |
Unregisters a PlaybackDeviceFactory
Definition at line 679 of file PlaybackController.cpp.
References m_playback_factories.
Referenced by Kwave::PlayBackPlugin::unload().
|
slot |
Updates the current playback position
Definition at line 200 of file PlaybackController.cpp.
References m_playback_position, and sigPlaybackPos().
Referenced by run_wrapper(), seekTo(), and startDevicePlayBack().
|
private |
The playback device used for playback
Definition at line 274 of file PlaybackController.h.
Referenced by closeDevice(), run_wrapper(), and startDevicePlayBack().
|
private |
Mutex for locking access to the playback device
Definition at line 277 of file PlaybackController.h.
Referenced by closeDevice(), run_wrapper(), and startDevicePlayBack().
|
private |
Mutex for locking access to members that control the playback loop, like m_should_seek, m_seek_pos and m_mixer
Definition at line 286 of file PlaybackController.h.
Referenced by run_wrapper(), seekTo(), and trackSelectionChanged().
|
private |
if set to true, the playback will be done in loop mode
Definition at line 306 of file PlaybackController.h.
Referenced by loop(), playbackLoop(), playbackStart(), reset(), and run_wrapper().
|
private |
Start of the selection when playback started
Definition at line 324 of file PlaybackController.h.
Referenced by playbackDone(), and startDevicePlayBack().
|
private |
End of the selection when playback started
Definition at line 327 of file PlaybackController.h.
Referenced by playbackDone(), and startDevicePlayBack().
|
private |
if true, playback is only paused and can be continued
Definition at line 309 of file PlaybackController.h.
Referenced by paused(), playbackContinue(), playbackDone(), playbackLoop(), playbackPause(), playbackStart(), playbackStop(), reload(), reset(), seekTo(), and startDevicePlayBack().
|
private |
the end position for playback
Definition at line 321 of file PlaybackController.h.
Referenced by endPos(), run_wrapper(), seekTo(), and setEndPos().
|
private |
list of playback device factories
Definition at line 330 of file PlaybackController.h.
Referenced by checkMethod(), createDevice(), registerPlaybackDeviceFactory(), and unregisterPlaybackDeviceFactory().
|
private |
the parameters used for playback
Definition at line 280 of file PlaybackController.h.
Referenced by openDevice(), run_wrapper(), setDefaultParams(), and startDevicePlayBack().
|
private |
the current play position
Definition at line 315 of file PlaybackController.h.
Referenced by currentPos(), playbackDone(), playbackLoop(), playbackStart(), reset(), run_wrapper(), and updatePlaybackPos().
|
private |
the start position for playback
Definition at line 318 of file PlaybackController.h.
Referenced by playbackLoop(), playbackStart(), reset(), run_wrapper(), seekTo(), setStartPos(), and startPos().
|
private |
is set to true if the playback has been started
Definition at line 312 of file PlaybackController.h.
Referenced by playbackContinue(), playbackDone(), playbackLoop(), playbackPause(), playbackStart(), playbackStop(), reload(), reset(), and running().
|
private |
If true, we are in "reload" mode. In this mode the playback is paused and continued without emitting a sigPlaybackDone. This is useful if playback parameters or signal selection has changed during playback.
Definition at line 303 of file PlaybackController.h.
Referenced by playbackContinue(), playbackDone(), playbackLoop(), playbackPause(), playbackStart(), playbackStop(), reload(), and reset().
|
private |
position to seek to
Definition at line 292 of file PlaybackController.h.
Referenced by run_wrapper(), and seekTo().
|
private |
if true, m_seek_pos is valid and a seek has been requested
Definition at line 289 of file PlaybackController.h.
Referenced by run_wrapper(), and seekTo().
|
private |
Reference to our signal manager
Definition at line 266 of file PlaybackController.h.
Referenced by openDevice(), PlaybackController(), run_wrapper(), and startDevicePlayBack().
|
private |
Thread that executes the run() member function.
Definition at line 271 of file PlaybackController.h.
Referenced by run_wrapper(), startDevicePlayBack(), and stopDevicePlayBack().
|
private |
notification flag, true if the track selection has changed
Definition at line 295 of file PlaybackController.h.
Referenced by run_wrapper(), and trackSelectionChanged().