kwave  18.07.70
Kwave::RecordController Class Reference

#include <RecordController.h>

Inheritance diagram for Kwave::RecordController:
Inheritance graph
Collaboration diagram for Kwave::RecordController:
Collaboration graph

Public Slots

void setInitialized (bool initialized)
 
void setEmpty (bool empty)
 
void enablePrerecording (bool enable)
 
void actionReset ()
 
void actionStop ()
 
void actionPause ()
 
void actionStart ()
 
void deviceRecordStarted ()
 
void deviceBufferFull ()
 
void deviceTriggerReached ()
 
void deviceRecordStopped (int)
 
void enableTrigger (bool enable)
 

Signals

void stateChanged (Kwave::RecordState state)
 
void sigReset (bool &accepted)
 
void sigStartRecord ()
 
void sigStopRecord (int errorcode)
 

Public Member Functions

 RecordController ()
 
virtual ~RecordController ()
 
const char * stateName (const Kwave::RecordState state)
 

Private Attributes

Kwave::RecordState m_state
 
Kwave::RecordState m_next_state
 
bool m_trigger_set
 
bool m_enable_prerecording
 
bool m_empty
 

Detailed Description

Definition at line 29 of file RecordController.h.

Constructor & Destructor Documentation

◆ RecordController()

Kwave::RecordController::RecordController ( )

Constructor

Definition at line 24 of file RecordController.cpp.

◆ ~RecordController()

Kwave::RecordController::~RecordController ( )
virtual

Destructor

Definition at line 35 of file RecordController.cpp.

36 {
37 }

Member Function Documentation

◆ actionPause

void Kwave::RecordController::actionPause ( )
slot

Pause the recording

Definition at line 115 of file RecordController.cpp.

References m_state, Kwave::REC_BUFFERING, Kwave::REC_DONE, Kwave::REC_EMPTY, Kwave::REC_PAUSED, Kwave::REC_PRERECORDING, Kwave::REC_RECORDING, Kwave::REC_UNINITIALIZED, Kwave::REC_WAITING_FOR_TRIGGER, stateChanged(), and stateName().

116 {
117  switch (m_state) {
119  case Kwave::REC_EMPTY:
120  case Kwave::REC_DONE:
121  // what do you want ?
122  break;
126  // this should never happen
127  qWarning("RecordController::actionPause(): "
128  "state = %s ???", stateName(m_state));
129  break;
131  // pause recording
133  break;
134  case Kwave::REC_PAUSED:
135  // continue recording
137  break;
138  }
139 }
const char * stateName(const Kwave::RecordState state)
void stateChanged(Kwave::RecordState state)
Kwave::RecordState m_state
Here is the call graph for this function:

◆ actionReset

void Kwave::RecordController::actionReset ( )
slot

Clear all recorded data and prepare for new recording

Definition at line 64 of file RecordController.cpp.

References m_next_state, m_state, Kwave::REC_BUFFERING, Kwave::REC_DONE, Kwave::REC_EMPTY, Kwave::REC_PAUSED, Kwave::REC_PRERECORDING, Kwave::REC_RECORDING, Kwave::REC_UNINITIALIZED, Kwave::REC_WAITING_FOR_TRIGGER, sigReset(), and stateChanged().

65 {
66  switch (m_state) {
68  // already empty, nothing to do
69  break;
71 #if 0
72  // fall back to REC_WAITING_FOR_TRIGGER
75  break;
76 #endif
77  case Kwave::REC_EMPTY:
81  case Kwave::REC_PAUSED:
82  case Kwave::REC_DONE:
83  bool accepted = true;
84  emit sigReset(accepted);
85  if (accepted) emit stateChanged(m_state = Kwave::REC_EMPTY);
86  break;
87  }
88 }
void sigReset(bool &accepted)
void stateChanged(Kwave::RecordState state)
Kwave::RecordState m_state
Kwave::RecordState m_next_state

◆ actionStart

void Kwave::RecordController::actionStart ( )
slot

Start the recording

Definition at line 142 of file RecordController.cpp.

References m_next_state, m_state, Kwave::REC_BUFFERING, Kwave::REC_DONE, Kwave::REC_EMPTY, Kwave::REC_PAUSED, Kwave::REC_PRERECORDING, Kwave::REC_RECORDING, Kwave::REC_UNINITIALIZED, Kwave::REC_WAITING_FOR_TRIGGER, sigStartRecord(), and stateChanged().

Referenced by Kwave::RecordPlugin::setup().

143 {
144  switch (m_state) {
146  break; // impossible
147  case Kwave::REC_EMPTY:
148  case Kwave::REC_DONE:
149  // interpret this as manual trigger
150  emit sigStartRecord();
151  break;
155  // interpret as "trigger now"
158  break;
159  case Kwave::REC_PAUSED:
160  // interpret this as "continue"
162  emit sigStartRecord();
163  break;
165  // already recording...
167  break;
168  }
169 }
void stateChanged(Kwave::RecordState state)
Kwave::RecordState m_state
Kwave::RecordState m_next_state
Here is the caller graph for this function:

◆ actionStop

void Kwave::RecordController::actionStop ( )
slot

Stop the recording

Definition at line 91 of file RecordController.cpp.

References m_next_state, m_state, Kwave::REC_BUFFERING, Kwave::REC_DONE, Kwave::REC_EMPTY, Kwave::REC_PAUSED, Kwave::REC_PRERECORDING, Kwave::REC_RECORDING, Kwave::REC_UNINITIALIZED, Kwave::REC_WAITING_FOR_TRIGGER, and sigStopRecord().

Referenced by Kwave::RecordPlugin::processBuffer().

92 {
93  switch (m_state) {
95  case Kwave::REC_EMPTY:
96  case Kwave::REC_DONE:
97  // already stopped, nothing to do
98  break;
102  // abort, change to REC_EMPTY
103  emit sigStopRecord(0);
104  break;
106  case Kwave::REC_PAUSED:
107  // abort, change to REC_DONE
109  emit sigStopRecord(0);
110  break;
111  }
112 }
void sigStopRecord(int errorcode)
Kwave::RecordState m_state
Kwave::RecordState m_next_state
Here is the caller graph for this function:

◆ deviceBufferFull

void Kwave::RecordController::deviceBufferFull ( )
slot

The device buffer contains data

Definition at line 196 of file RecordController.cpp.

References m_enable_prerecording, m_next_state, m_state, m_trigger_set, Kwave::REC_BUFFERING, Kwave::REC_DONE, Kwave::REC_EMPTY, Kwave::REC_PAUSED, Kwave::REC_PRERECORDING, Kwave::REC_RECORDING, Kwave::REC_UNINITIALIZED, Kwave::REC_WAITING_FOR_TRIGGER, stateChanged(), and stateName().

Referenced by Kwave::RecordPlugin::processBuffer().

197 {
198  switch (m_state) {
200  break; // impossible
201  case Kwave::REC_EMPTY:
202  // we are only "recording" for updating the level
203  // meters and other effects -> no state change
204  break;
208  // this should never happen
209  qWarning("RecordController::deviceBufferFull(): "
210  "state = %s ???", stateName(m_state));
211  break;
212  case Kwave::REC_PAUSED: /* == buffering again after pause */
213  // -> will change to "REC_BUFFERING" soon...
214  break;
216  if (m_enable_prerecording) {
217  // prerecording was set
219  } else if (m_trigger_set) {
220  // trigger was set
222  } else {
223  // default: just start recording
226  }
227  emit stateChanged(m_state);
228  break;
229  case Kwave::REC_DONE:
230  // might occur when the buffer content is flushed
231  // after a stop
232  break;
233  }
234 }
const char * stateName(const Kwave::RecordState state)
void stateChanged(Kwave::RecordState state)
Kwave::RecordState m_state
Kwave::RecordState m_next_state
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deviceRecordStarted

void Kwave::RecordController::deviceRecordStarted ( )
slot

The device has started recording

Definition at line 172 of file RecordController.cpp.

References m_empty, m_next_state, m_state, Kwave::REC_BUFFERING, Kwave::REC_DONE, Kwave::REC_EMPTY, Kwave::REC_PAUSED, Kwave::REC_PRERECORDING, Kwave::REC_RECORDING, Kwave::REC_UNINITIALIZED, Kwave::REC_WAITING_FOR_TRIGGER, stateChanged(), and stateName().

Referenced by Kwave::RecordPlugin::startRecording().

173 {
174  switch (m_state) {
176  break; // impossible
177  case Kwave::REC_EMPTY:
178  case Kwave::REC_PAUSED:
179  case Kwave::REC_DONE:
180  // continue, pre-recording or trigger
183  break;
188  // this should never happen
189  qWarning("RecordController::deviceRecordStarted(): "
190  "state = %s ???", stateName(m_state));
191  break;
192  }
193 }
const char * stateName(const Kwave::RecordState state)
void stateChanged(Kwave::RecordState state)
Kwave::RecordState m_state
Kwave::RecordState m_next_state
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deviceRecordStopped

void Kwave::RecordController::deviceRecordStopped ( int  )
slot

The device has stopped recording

Definition at line 275 of file RecordController.cpp.

References m_empty, m_next_state, m_state, Kwave::REC_BUFFERING, Kwave::REC_DONE, Kwave::REC_EMPTY, Kwave::REC_PAUSED, Kwave::REC_PRERECORDING, Kwave::REC_RECORDING, Kwave::REC_UNINITIALIZED, Kwave::REC_WAITING_FOR_TRIGGER, stateChanged(), and stateName().

276 {
277  switch (m_state) {
279  case Kwave::REC_EMPTY:
280  case Kwave::REC_DONE:
281  // this could happen when an abort occurs during buffering
282  emit stateChanged(m_state);
283  break;
287  // abort, no real data produced
288  if (m_empty) {
290  } else {
292  }
293  break;
295  // recording -> pause or done
296  switch (m_next_state) {
297  case Kwave::REC_EMPTY:
298  // something went wrong when starting the recorder
299  if (m_empty) {
301  } else {
303  }
304  break;
305  case Kwave::REC_PAUSED:
307  break;
308  case Kwave::REC_DONE:
310  break;
311  default:
312  qWarning("RecordController::deviceRecordStopped(): "
313  "next state = %s ???", stateName(m_next_state));
314  }
315  break;
316  case Kwave::REC_PAUSED:
317  // pause -> done
319  break;
320  }
321 }
const char * stateName(const Kwave::RecordState state)
void stateChanged(Kwave::RecordState state)
Kwave::RecordState m_state
Kwave::RecordState m_next_state
Here is the call graph for this function:

◆ deviceTriggerReached

void Kwave::RecordController::deviceTriggerReached ( )
slot

The record trigger has been reached

Definition at line 243 of file RecordController.cpp.

References m_enable_prerecording, m_next_state, m_state, m_trigger_set, Kwave::REC_BUFFERING, Kwave::REC_DONE, Kwave::REC_EMPTY, Kwave::REC_PAUSED, Kwave::REC_PRERECORDING, Kwave::REC_RECORDING, Kwave::REC_UNINITIALIZED, Kwave::REC_WAITING_FOR_TRIGGER, stateChanged(), and stateName().

Referenced by Kwave::RecordPlugin::processBuffer().

244 {
245  switch (m_state) {
247  case Kwave::REC_EMPTY:
250  case Kwave::REC_PAUSED:
251  case Kwave::REC_DONE:
252  // this should never happen
253  qWarning("RecordController::deviceTriggerReached(): "
254  "state = %s ???", stateName(m_state));
255  break;
258  Q_ASSERT(m_trigger_set);
259  if ((m_enable_prerecording) &&
261  {
262  // prerecording was set
264  } else {
265  // default: just start recording
268  }
269  emit stateChanged(m_state);
270  break;
271  }
272 }
const char * stateName(const Kwave::RecordState state)
void stateChanged(Kwave::RecordState state)
Kwave::RecordState m_state
Kwave::RecordState m_next_state
Here is the call graph for this function:
Here is the caller graph for this function:

◆ enablePrerecording

void Kwave::RecordController::enablePrerecording ( bool  enable)
slot

Enable the prerecording. Has to be called before any status change to enable/disable the prerecording mode

Parameters
enableif true, enable prerecording

Definition at line 58 of file RecordController.cpp.

References m_enable_prerecording.

Referenced by Kwave::RecordPlugin::setup().

59 {
60  m_enable_prerecording = enable;
61 }
Here is the caller graph for this function:

◆ enableTrigger

void Kwave::RecordController::enableTrigger ( bool  enable)
slot

The recording trigger has been enabled/disabled

Definition at line 237 of file RecordController.cpp.

References m_trigger_set.

Referenced by Kwave::RecordPlugin::setup().

238 {
239  m_trigger_set = enable;
240 }
Here is the caller graph for this function:

◆ setEmpty

void Kwave::RecordController::setEmpty ( bool  empty)
slot

Informs the controller whether the signal is empty or not

Parameters
emptyif true, nothing has been recorded

Definition at line 52 of file RecordController.cpp.

References m_empty.

Referenced by Kwave::RecordPlugin::flushPrerecordingQueue(), Kwave::RecordPlugin::processBuffer(), and Kwave::RecordPlugin::resetRecording().

53 {
54  m_empty = empty;
55 }
Here is the caller graph for this function:

◆ setInitialized

void Kwave::RecordController::setInitialized ( bool  initialized)
slot

Informs the controller whether the recording engine has been successfully been initialized or recording cannot be started.

Parameters
initializedif true, recording can be started

Definition at line 40 of file RecordController.cpp.

References m_empty, m_next_state, m_state, Kwave::REC_DONE, Kwave::REC_EMPTY, Kwave::REC_UNINITIALIZED, and stateChanged().

Referenced by Kwave::RecordPlugin::setDevice().

Here is the caller graph for this function:

◆ sigReset

void Kwave::RecordController::sigReset ( bool &  accepted)
signal

All recorded data has to be cleared

Referenced by actionReset().

Here is the caller graph for this function:

◆ sigStartRecord

void Kwave::RecordController::sigStartRecord ( )
signal

Recording should start

Referenced by actionStart().

Here is the caller graph for this function:

◆ sigStopRecord

void Kwave::RecordController::sigStopRecord ( int  errorcode)
signal

Recording should stop

Referenced by actionStop().

Here is the caller graph for this function:

◆ stateChanged

void Kwave::RecordController::stateChanged ( Kwave::RecordState  state)
signal

emitted when the state of the recording changed

Referenced by actionPause(), actionReset(), actionStart(), deviceBufferFull(), deviceRecordStarted(), deviceRecordStopped(), deviceTriggerReached(), and setInitialized().

Here is the caller graph for this function:

◆ stateName()

const char * Kwave::RecordController::stateName ( const Kwave::RecordState  state)

returns the name of a state

Definition at line 324 of file RecordController.cpp.

References Kwave::REC_BUFFERING, Kwave::REC_DONE, Kwave::REC_EMPTY, Kwave::REC_PAUSED, Kwave::REC_PRERECORDING, Kwave::REC_RECORDING, Kwave::REC_UNINITIALIZED, and Kwave::REC_WAITING_FOR_TRIGGER.

Referenced by actionPause(), deviceBufferFull(), deviceRecordStarted(), deviceRecordStopped(), and deviceTriggerReached().

325 {
326  switch (state) {
327  case Kwave::REC_UNINITIALIZED: return "REC_UNINITIALIZED";
328  case Kwave::REC_EMPTY: return "REC_EMPTY";
329  case Kwave::REC_BUFFERING: return "REC_BUFFERING";
330  case Kwave::REC_WAITING_FOR_TRIGGER: return "REC_WAITING_FOR_TRIGGER";
331  case Kwave::REC_PRERECORDING: return "REC_PRERECORDING";
332  case Kwave::REC_RECORDING: return "REC_RECORDING";
333  case Kwave::REC_PAUSED: return "REC_PAUSED";
334  case Kwave::REC_DONE: return "REC_DONE";
335  }
336  return "-INVALID-";
337 }
Here is the caller graph for this function:

Member Data Documentation

◆ m_empty

bool Kwave::RecordController::m_empty
private

if true the current file is empty

Definition at line 125 of file RecordController.h.

Referenced by deviceRecordStarted(), deviceRecordStopped(), setEmpty(), and setInitialized().

◆ m_enable_prerecording

bool Kwave::RecordController::m_enable_prerecording
private

use prerecording

Definition at line 122 of file RecordController.h.

Referenced by deviceBufferFull(), deviceTriggerReached(), and enablePrerecording().

◆ m_next_state

Kwave::RecordState Kwave::RecordController::m_next_state
private

state of the recording engine after finishing the last action, not needed for all state changes.

Definition at line 116 of file RecordController.h.

Referenced by actionReset(), actionStart(), actionStop(), deviceBufferFull(), deviceRecordStarted(), deviceRecordStopped(), deviceTriggerReached(), and setInitialized().

◆ m_state

Kwave::RecordState Kwave::RecordController::m_state
private

◆ m_trigger_set

bool Kwave::RecordController::m_trigger_set
private

use a trigger

Definition at line 119 of file RecordController.h.

Referenced by deviceBufferFull(), deviceTriggerReached(), and enableTrigger().


The documentation for this class was generated from the following files: