Commit c9fcca77 authored by Julien Bonjean's avatar Julien Bonjean

Merge branch 'master' into jbonjean

parents a22b5955 3d2a5409
......@@ -265,13 +265,12 @@ class AlsaLayer : public AudioLayer {
bool _is_open_capture;
bool _trigger_request;
AudioThread *_audioThread;
AudioThread* _audioThread;
/** Sample rate converter object */
SamplerateConverter * _converter;
int _converterSamplingRate;
SamplerateConverter* _converter;
// Allpass filter to remove DC offset
DcBlocker* dcblocker;
};
......
......@@ -184,11 +184,11 @@ AudioStream::createStream (pa_context* c)
// parameters are defined as number of bytes
// 2048 bytes (1024 int16) is 20 ms at 44100 Hz
if (_streamType == PLAYBACK_STREAM) {
attributes->maxlength = 16000;
attributes->tlength = 2048;
attributes->prebuf = 2048;
attributes->minreq = 1024;
attributes->fragsize = 4096;
attributes->maxlength = 32000;
attributes->tlength = 16000;
attributes->prebuf = 1024;
attributes->minreq = 512;
attributes->fragsize = (uint32_t) -1;
pa_stream_connect_playback( s , NULL , attributes, PA_STREAM_INTERPOLATE_TIMING, &_volume, NULL);
// pa_stream_connect_playback (s , NULL , attributes, PA_STREAM_START_CORKED, &_volume, NULL);
} else if (_streamType == CAPTURE_STREAM) {
......@@ -196,11 +196,11 @@ AudioStream::createStream (pa_context* c)
// attributes->maxlength = 66500;
// attributes->fragsize = (uint32_t)-1;
attributes->maxlength = 16000;
attributes->tlength = 1024;
attributes->maxlength = 32000;
attributes->tlength = 16000;
attributes->prebuf = 1024;
attributes->minreq = 512;
attributes->fragsize = 1024;
attributes->fragsize = (uint32_t) -1;
// pa_stream_connect_record (s , NULL , attributes , PA_STREAM_START_CORKED);
pa_stream_connect_record( s , NULL , attributes , PA_STREAM_INTERPOLATE_TIMING );
......
......@@ -25,7 +25,7 @@ int framesPerBuffer = 2048;
static void playback_callback (pa_stream* s, size_t bytes, void* userdata)
{
_debug("playback_callback\n");
// _debug("playback_callback\n");
assert (s && bytes);
assert (bytes > 0);
......@@ -57,7 +57,16 @@ static void stream_moved_callback(pa_stream *s UNUSED, void *userdata UNUSED)
static void playback_underflow_callback (pa_stream* s, void* userdata UNUSED)
{
_debug ("PulseLayer::Buffer Underflow\n");
SFLDataFormat* out = (SFLDataFormat*) pa_xmalloc (framesPerBuffer*sizeof(SFLDataFormat));
bzero (out, framesPerBuffer*sizeof(SFLDataFormat));
pa_stream_write (s, out, framesPerBuffer*sizeof(SFLDataFormat), NULL, 0, PA_SEEK_RELATIVE);
pa_stream_trigger (s, NULL, NULL);
pa_xfree (out);
}
......@@ -448,7 +457,6 @@ void PulseLayer::writeToSpeaker (void)
if (urgentAvailBytes > 0) {
_debug("Urgent Avail?????????????????????\n");
toGet = (urgentAvailBytes < (int) (framesPerBuffer * sizeof (SFLDataFormat))) ? urgentAvailBytes : framesPerBuffer * sizeof (SFLDataFormat);
out = (SFLDataFormat*) pa_xmalloc (toGet * sizeof (SFLDataFormat));
......@@ -469,7 +477,6 @@ void PulseLayer::writeToSpeaker (void)
if (playback->getStreamState() == PA_STREAM_READY)
{
_debug("Play Tone!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
toGet = framesPerBuffer;
out = (SFLDataFormat*) pa_xmalloc (toGet * sizeof (SFLDataFormat));
......@@ -485,20 +492,13 @@ void PulseLayer::writeToSpeaker (void)
if (playback->getStreamState() == PA_STREAM_READY)
{
_debug("Play File Tone!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
toGet = framesPerBuffer;
toPlay = ( (int) (toGet * sizeof (SFLDataFormat)) > framesPerBuffer) ? framesPerBuffer : toGet * sizeof (SFLDataFormat);
_debug("toPlay: %i\n", toPlay);
toPlay = ( (int) (toGet * sizeof (SFLDataFormat)) > framesPerBuffer * sizeof (SFLDataFormat)) ? framesPerBuffer : toGet * sizeof (SFLDataFormat);
out = (SFLDataFormat*) pa_xmalloc (toPlay);
file_tone->getNext (out, toPlay/2 , 100);
file_tone->getNext(out, toPlay/sizeof(SFLDataFormat), 100);
pa_stream_write (playback->pulseStream(), out, toPlay, NULL, 0, PA_SEEK_RELATIVE);
_debug("ok\n");
pa_xfree (out);
_debug("end of play file\n");
}
} else {
......@@ -554,9 +554,8 @@ void PulseLayer::writeToSpeaker (void)
} else {
if((tone == 0) && (file_tone == 0)) {
_debug("send zeros......................\n");
// _debug("maxNbBytesToGet: %i\n", maxNbBytesToGet);
bzero (out, maxNbBytesToGet);
pa_stream_write (playback->pulseStream(), out, maxNbBytesToGet, NULL, 0, PA_SEEK_RELATIVE);
}
......
......@@ -2030,10 +2030,11 @@ bool ManagerImpl::playATone (Tone::TONEID toneId)
audiolayer = getAudioDriver();
if (audiolayer)
if (audiolayer) {
audiolayer->startStream();
audiolayer->flushUrgent();
audiolayer->flushUrgent();
}
if (_telephoneTone != 0) {
_toneMutex.enterMutex();
......@@ -2168,12 +2169,8 @@ ManagerImpl::ringtone()
_audiofile.start();
_toneMutex.leaveMutex();
if (CHECK_INTERFACE (layer, ALSA)) {
//ringback();
} else {
audiolayer->startStream();
}
audiolayer->startStream();
} else {
ringback();
}
......@@ -2186,7 +2183,7 @@ ManagerImpl::ringtone()
AudioLoop*
ManagerImpl::getTelephoneTone()
{
_debug("ManagerImpl::getTelephoneTone()\n");
// _debug("ManagerImpl::getTelephoneTone()\n");
if (_telephoneTone != 0) {
ost::MutexLock m (_toneMutex);
return _telephoneTone->getCurrentTone();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment