diff --git a/sflphone-common/src/audio/audiorecord.cpp b/sflphone-common/src/audio/audiorecord.cpp index 125339fe8c0f9e0a5187cc7b863f025b1ca310a7..06d97d0b30d0ee58919e957e3f243245a880ae1e 100644 --- a/sflphone-common/src/audio/audiorecord.cpp +++ b/sflphone-common/src/audio/audiorecord.cpp @@ -471,9 +471,7 @@ void AudioRecord::recMicData (SFLDataFormat* buffer, int nSamples) void AudioRecord::recData (SFLDataFormat* buffer, int nSamples) { - if (recordingEnabled_) { - - _debug("Recording enabled"); + if (recordingEnabled_) { if (fp == 0) { _debug ("AudioRecord: Can't record data, a file has not yet been opened!"); @@ -488,7 +486,6 @@ void AudioRecord::recData (SFLDataFormat* buffer, int nSamples) else { fflush (fp); byteCounter_ += (unsigned long) (nSamples*sizeof (SFLDataFormat)); - _debug("AudioRecord: wrote %d bytes", byteCounter_); } } } diff --git a/sflphone-common/src/audio/audiorecorder.cpp b/sflphone-common/src/audio/audiorecorder.cpp index 420572729a08895af497e7f0d4841854a67a9ab9..bb846e022b3a728c3bca022514583d0e84e30663 100644 --- a/sflphone-common/src/audio/audiorecorder.cpp +++ b/sflphone-common/src/audio/audiorecorder.cpp @@ -31,13 +31,26 @@ #include "audiorecorder.h" #include "mainbuffer.h" -AudioRecorder::AudioRecorder (AudioRecord *arec, MainBuffer *mb) - : Thread(), recorderId("recorder_id") +int AudioRecorder::count = 0; + +AudioRecorder::AudioRecorder (AudioRecord *arec, MainBuffer *mb) : Thread() { setCancel (cancelDeferred); + ++count; + + std::string id("processid_"); + + // convert count into string + std::string s; + std::stringstream out; + out << count; + s = out.str(); + + recorderId = id.append(s); + arecord = arec; - mbuffer = mb; + mbuffer = mb; } @@ -55,18 +68,12 @@ void AudioRecorder::run (void) int availBytes = mbuffer->availForGet(recorderId); - _debug("Audiorecord: avail for get (before) %d", availBytes); - if(availBytes > 0) { int got = mbuffer->getData(buffer, availBytes, 100, recorderId); - _debug("Audiorecord: audio get from main buffer %d", got); - int availBytesAfter = mbuffer->availForGet(recorderId); - _debug("Audiorecord: avail for get (after) %d", availBytesAfter); - arecord->recData(buffer, availBytes/sizeof(SFLDataFormat)); } diff --git a/sflphone-common/src/audio/audiorecorder.h b/sflphone-common/src/audio/audiorecorder.h index a6ea97146e421346603ffe4f242802482fdfa976..b1c15f3a489a49fa058b320cb81caa8153e93208 100644 --- a/sflphone-common/src/audio/audiorecorder.h +++ b/sflphone-common/src/audio/audiorecorder.h @@ -44,6 +44,8 @@ class AudioRecorder : public ost::Thread { ~AudioRecorder(void){ terminate(); } + static int count; + std::string getRecorderID() { return recorderId; } virtual void run(); diff --git a/sflphone-common/src/audio/mainbuffer.cpp b/sflphone-common/src/audio/mainbuffer.cpp index 91e0d238d850ce61b14d3fe563156c084a498263..2ccc1f8d6e7ee6409bcb4a223e4a42f4f9bca1ab 100644 --- a/sflphone-common/src/audio/mainbuffer.cpp +++ b/sflphone-common/src/audio/mainbuffer.cpp @@ -255,23 +255,33 @@ void MainBuffer::unBindCallID (CallID call_id1, CallID call_id2) } } -void MainBuffer::unBindHalfDuplexOut(CallID call_id, CallID process_id) +void MainBuffer::unBindHalfDuplexOut(CallID process_id, CallID call_id) { removeCallIDfromSet(process_id, call_id); - RingBuffer* ringbuffer; - - ringbuffer = getRingBuffer(process_id); + RingBuffer* ringbuffer = getRingBuffer(call_id); if(ringbuffer) { - ringbuffer->removeReadPointer(call_id); + ringbuffer->removeReadPointer(process_id); if(ringbuffer->getNbReadPointer() == 0) { - removeCallIDSet(process_id); - removeRingBuffer(process_id); + removeCallIDSet(call_id); + removeRingBuffer(call_id); } } + else { + _debug("Error: did not found ringbuffer %s", process_id.c_str()); + removeCallIDSet(process_id); + } + + + CallIDSet* callid_set = getCallIDSet(process_id); + if(callid_set) { + if(callid_set->empty()) + removeCallIDSet(process_id); + } + } @@ -387,9 +397,7 @@ int MainBuffer::getData (void *buffer, int toCopy, unsigned short volume, CallID return 0; } else { - for (int k = 0; k < nbSmplToCopy; k++) { - ( (SFLDataFormat*) (buffer)) [k] = 0; - } + memset(buffer, 0, nbSmplToCopy*sizeof(SFLDataFormat*)); int size = 0; diff --git a/sflphone-common/src/conference.cpp b/sflphone-common/src/conference.cpp index b32629acb63eeef8ef6e7be3601f7e8119cf4a96..20219fc5921f19a641dc3a6829dd57245eec68fb 100644 --- a/sflphone-common/src/conference.cpp +++ b/sflphone-common/src/conference.cpp @@ -162,23 +162,45 @@ ParticipantSet Conference::getParticipantList() bool Conference::setRecording() { - bool recordStatus = Recordable::recAudio.setRecording(); + bool recordStatus = Recordable::recAudio.isRecording(); - if(!recordStatus) - return false; + Recordable::recAudio.setRecording(); - MainBuffer *mbuffer = Manager::instance().getMainBuffer(); + // start recording + if(!recordStatus){ - ParticipantSet::iterator iter = _participants.begin(); + MainBuffer *mbuffer = Manager::instance().getMainBuffer(); - CallID process_id = Recordable::recorder.getRecorderID(); + ParticipantSet::iterator iter = _participants.begin(); - while(iter != _participants.end()) { + CallID process_id = Recordable::recorder.getRecorderID(); + + while(iter != _participants.end()) { mbuffer->bindHalfDuplexOut(process_id, *iter); iter++; + } + + mbuffer->bindHalfDuplexOut(process_id); + + } + // stop recording + else { + + MainBuffer *mbuffer = Manager::instance().getMainBuffer(); + + ParticipantSet::iterator iter = _participants.begin(); + + CallID process_id = Recordable::recorder.getRecorderID(); + + while(iter != _participants.end()) { + mbuffer->unBindHalfDuplexOut(process_id, *iter); + iter++; + } + + mbuffer->unBindHalfDuplexOut(process_id); + } - mbuffer->bindHalfDuplexOut(process_id); Recordable::recorder.start();