diff --git a/sflphone-common/src/audio/alsa/alsalayer.cpp b/sflphone-common/src/audio/alsa/alsalayer.cpp index ec30bad9ec8bdbdcf6a35b6429179d5ed8586ecf..2fdd6d0e117645ab45a95a88070c4ffcefb5d7e3 100644 --- a/sflphone-common/src/audio/alsa/alsalayer.cpp +++ b/sflphone-common/src/audio/alsa/alsalayer.cpp @@ -860,7 +860,11 @@ void AlsaLayer::audioCallback (void) memset (out, 0, toGet); if (out) { - _urgentRingBuffer.Get (out, toGet, spkrVolume); + _urgentRingBuffer.Get (out, toGet); + if (spkrVolume!=100) + for (int i=0; i<toGet / sizeof (SFLDataFormat); i++) + out[i] = out[i] * spkrVolume / 100; + write (out, toGet, _PlaybackHandle); free (out); } diff --git a/sflphone-common/src/audio/mainbuffer.cpp b/sflphone-common/src/audio/mainbuffer.cpp index 9145ee71f46480f24e898aebfea1b5c38e20918d..e3520aecdb0bd2795f946c92c016326580c8d3c5 100644 --- a/sflphone-common/src/audio/mainbuffer.cpp +++ b/sflphone-common/src/audio/mainbuffer.cpp @@ -391,7 +391,7 @@ int MainBuffer::getDataByID (void *buffer, int toCopy, std::string call_id, std: return 0; } - return ring_buffer->Get (buffer, toCopy, 100, reader_id); + return ring_buffer->Get (buffer, toCopy, reader_id); } diff --git a/sflphone-common/src/audio/ringbuffer.cpp b/sflphone-common/src/audio/ringbuffer.cpp index 2b15ef80b36f55a5b189e1f215f3ea17cd414348..21b313c5b80d34526ab084ee827c436baf8bed72 100644 --- a/sflphone-common/src/audio/ringbuffer.cpp +++ b/sflphone-common/src/audio/ringbuffer.cpp @@ -288,7 +288,7 @@ RingBuffer::AvailForGet (std::string call_id) // Get will move 'toCopy' bytes from the internal FIFO to 'buffer' int -RingBuffer::Get (void *buffer, int toCopy, unsigned short volume, std::string call_id) +RingBuffer::Get (void *buffer, int toCopy, std::string call_id) { if (getNbReadPointer() == 0) @@ -315,7 +315,6 @@ RingBuffer::Get (void *buffer, int toCopy, unsigned short volume, std::string ca int mStart = getReadPointer (call_id); - //fprintf(stderr, "G"); while (toCopy) { block = toCopy; @@ -323,16 +322,6 @@ RingBuffer::Get (void *buffer, int toCopy, unsigned short volume, std::string ca block = mBufferSize - mStart; } - if (volume!=100) { - SFLDataFormat* start = (SFLDataFormat*) (mBuffer + mStart); - int nbSample = block / sizeof (SFLDataFormat); - - for (int i=0; i<nbSample; i++) { - start[i] = start[i] * volume / 100; - } - } - - // bcopy(src, dest, len) bcopy (mBuffer + mStart, dest, block); dest += block; diff --git a/sflphone-common/src/audio/ringbuffer.h b/sflphone-common/src/audio/ringbuffer.h index 8b84e94418212005a45c590095956f05c9927bac..a6933a34d4d6745ba28ca6eba86b6f25355534a2 100644 --- a/sflphone-common/src/audio/ringbuffer.h +++ b/sflphone-common/src/audio/ringbuffer.h @@ -121,10 +121,9 @@ class RingBuffer * Get data in the ring buffer * @param buffer Data to copied * @param toCopy Number of bytes to copy - * @param volume The volume * @return int Number of bytes copied */ - int Get (void* buffer, int toCopy, unsigned short volume = 100, std::string call_id = default_id); + int Get (void* buffer, int toCopy, std::string call_id = default_id); /** * Discard data from the buffer diff --git a/sflphone-common/test/mainbuffertest.cpp b/sflphone-common/test/mainbuffertest.cpp index 35bb618c8137caaa969b02844644d0360fa134fc..05958fe473981f12ed3b41c8a4d597e1b4b2a887 100644 --- a/sflphone-common/test/mainbuffertest.cpp +++ b/sflphone-common/test/mainbuffertest.cpp @@ -388,7 +388,7 @@ void MainBufferTest::testRingBufferNonDefaultID() CPPUNIT_ASSERT (test_ring_buffer->AvailForGet (test_id) == 2*sizeof (int)); CPPUNIT_ASSERT (test_ring_buffer->getLen (test_id) == 2*sizeof (int)); - CPPUNIT_ASSERT (test_ring_buffer->Get (&testget, sizeof (int), 100, test_id) == sizeof (int)); + CPPUNIT_ASSERT (test_ring_buffer->Get (&testget, sizeof (int), test_id) == sizeof (int)); CPPUNIT_ASSERT (test_ring_buffer->AvailForGet (test_id) == sizeof (int)); CPPUNIT_ASSERT (test_ring_buffer->getLen (test_id) == sizeof (int)); CPPUNIT_ASSERT (testget == testint1); @@ -1120,13 +1120,13 @@ void MainBufferTest::testRingBufferSeveralPointers() CPPUNIT_ASSERT (test_ring_buffer->AvailForGet (test_pointer2) == 4*sizeof (int)); - CPPUNIT_ASSERT (test_ring_buffer->Get (&testoutput, sizeof (int), 100, test_pointer1) == sizeof (int)); + CPPUNIT_ASSERT (test_ring_buffer->Get (&testoutput, sizeof (int), test_pointer1) == sizeof (int)); CPPUNIT_ASSERT (testoutput == testint1); CPPUNIT_ASSERT (test_ring_buffer->AvailForPut() == initPutLen - 4* (int) sizeof (int)); CPPUNIT_ASSERT (test_ring_buffer->AvailForGet (test_pointer1) == 3*sizeof (int)); CPPUNIT_ASSERT (test_ring_buffer->AvailForGet (test_pointer2) == 4*sizeof (int)); - CPPUNIT_ASSERT (test_ring_buffer->Get (&testoutput, sizeof (int), 100, test_pointer2) == sizeof (int)); + CPPUNIT_ASSERT (test_ring_buffer->Get (&testoutput, sizeof (int), test_pointer2) == sizeof (int)); CPPUNIT_ASSERT (testoutput == testint1); CPPUNIT_ASSERT (test_ring_buffer->AvailForPut() == initPutLen - 3* (int) sizeof (int)); CPPUNIT_ASSERT (test_ring_buffer->AvailForGet (test_pointer1) == 3*sizeof (int));