summaryrefslogtreecommitdiffstats
path: root/client/record_channel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/record_channel.cpp')
-rw-r--r--client/record_channel.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/client/record_channel.cpp b/client/record_channel.cpp
index 738f98fd..04760311 100644
--- a/client/record_channel.cpp
+++ b/client/record_channel.cpp
@@ -101,14 +101,7 @@ RecordChannel::~RecordChannel(void)
_messages.pop_front();
delete mes;
}
- delete _wave_recorder;
-
- if (_celt_encoder) {
- celt051_encoder_destroy(_celt_encoder);
- }
- if (_celt_mode) {
- celt051_mode_destroy(_celt_mode);
- }
+ clear();
}
bool RecordChannel::abort(void)
@@ -128,6 +121,11 @@ void RecordChannel::on_connect()
post_message(message);
}
+void RecordChannel::on_disconnect()
+{
+ clear();
+}
+
void RecordChannel::send_start_mark()
{
Message* message = new Message(SPICE_MSGC_RECORD_START_MARK);
@@ -177,6 +175,23 @@ void RecordChannel::handle_start(RedPeer::InMessage* message)
_wave_recorder->start();
}
+void RecordChannel::clear()
+{
+ if (_wave_recorder) {
+ _wave_recorder->stop();
+ delete _wave_recorder;
+ _wave_recorder = NULL;
+ }
+ if (_celt_encoder) {
+ celt051_encoder_destroy(_celt_encoder);
+ _celt_encoder = NULL;
+ }
+ if (_celt_mode) {
+ celt051_mode_destroy(_celt_mode);
+ _celt_mode = NULL;
+ }
+}
+
void RecordChannel::handle_stop(RedPeer::InMessage* message)
{
RecordHandler* handler = static_cast<RecordHandler*>(get_message_handler());
@@ -186,13 +201,7 @@ void RecordChannel::handle_stop(RedPeer::InMessage* message)
return;
}
ASSERT(_celt_mode && _celt_encoder);
- _wave_recorder->stop();
- celt051_encoder_destroy(_celt_encoder);
- _celt_encoder = NULL;
- celt051_mode_destroy(_celt_mode);
- _celt_mode = NULL;
- delete _wave_recorder;
- _wave_recorder = NULL;
+ clear();
}
RecordSamplesMessage* RecordChannel::get_message()