Skip to content
Snippets Groups Projects
Commit f831d6e8 authored by yanmorin's avatar yanmorin
Browse files

Remove segfault with float and mic/speaker < 100

parent 479ff3e6
No related branches found
No related tags found
No related merge requests found
...@@ -92,9 +92,9 @@ RingBuffer::Put(void* buffer, int toCopy, unsigned short volume) { ...@@ -92,9 +92,9 @@ RingBuffer::Put(void* buffer, int toCopy, unsigned short volume) {
// put the data inside the buffer. // put the data inside the buffer.
if (volume!=100) { if (volume!=100) {
SFLDataFormat* src16 = (SFLDataFormat*)src; SFLDataFormat* start = (SFLDataFormat*)src;
int int16len = (block >> 1); int nbSample = block / sizeof(SFLDataFormat);
for (int i=0; i < int16len; i++) { src16[i] = src16[i] * volume / 100; } for (int i=0; i<nbSample; i++) { start[i] = start[i] * volume / 100; }
} }
// bcopy(src, dest, len) // bcopy(src, dest, len)
//fprintf(stderr, "has %d put %d\t", len, block); //fprintf(stderr, "has %d put %d\t", len, block);
...@@ -143,8 +143,8 @@ RingBuffer::Get(void *buffer, int toCopy, unsigned short volume) { ...@@ -143,8 +143,8 @@ RingBuffer::Get(void *buffer, int toCopy, unsigned short volume) {
if(volume!=100) { if(volume!=100) {
SFLDataFormat* start = (SFLDataFormat*)(mBuffer + mStart); SFLDataFormat* start = (SFLDataFormat*)(mBuffer + mStart);
int int16len = (block >> 1); int nbSample = block / sizeof(SFLDataFormat);
for (int i=0; i<int16len; i++) { start[i] = start[i] * volume / 100; } for (int i=0; i<nbSample; i++) { start[i] = start[i] * volume / 100; }
} }
// bcopy(src, dest, len) // bcopy(src, dest, len)
bcopy (mBuffer + mStart, dest, block); bcopy (mBuffer + mStart, dest, block);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment