Skip to content
Snippets Groups Projects
Commit d8aebd60 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Restore mic adjust volume on ALSA layer

parent 5220536b
No related branches found
No related tags found
No related merge requests found
......@@ -143,6 +143,7 @@ AlsaLayer::getMic(void *buffer, int toCopy)
if( _CaptureHandle )
{
res = read( buffer, toCopy );
adjustVolume( buffer , toCopy , SFL_PCM_CAPTURE );
}
return res ;
}
......@@ -651,3 +652,23 @@ void AlsaLayer::audioCallback (void)
//_debug("AL: Nb sample: %d char, [0]=%f [1]=%f [2]=%f\n", toPut, in[0], in[1], in[2]);
//_micRingBuffer.Put(in, toPut, micVolume);
}
void* AlsaLayer::adjustVolume( void* buffer , int len, int stream )
{
int vol, i, size;
SFLDataFormat *src = NULL;
(stream == SFL_PCM_PLAYBACK)? vol = _manager->getSpkrVolume() : vol = _manager->getMicVolume();
src = (SFLDataFormat*) buffer;
if( vol != 100 )
{
size = len / sizeof(SFLDataFormat);
for( i = 0 ; i < size ; i++ ){
src[i] = src[i] * vol / 100 ;
}
}
return src ;
}
......@@ -220,6 +220,8 @@ class AlsaLayer : public AudioLayer {
*/
int read( void* buffer, int toCopy);
/**
* Recover from XRUN state for capture
* ALSA Library API
......@@ -232,6 +234,8 @@ class AlsaLayer : public AudioLayer {
*/
void handle_xrun_playback( void );
void* adjustVolume( void* buffer , int len, int stream );
/**
* Handles to manipulate playback stream
* ALSA Library API
......
......@@ -142,7 +142,6 @@ PulseLayer::createStreams( pa_context* c )
record = new AudioStream(c, CAPTURE_STREAM, CAPTURE_STREAM_NAME , _manager->getMicVolume());
pa_stream_set_read_callback( record->pulseStream() , audioCallback, this);
//pa_stream_set_underflow_callback( record->pulseStream() , underflow , this);
//cache = new AudioStream(c, UPLOAD_STREAM, "Cache samples", _manager->getSpkrVolume());
pa_threaded_mainloop_signal(m , 0);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment