Commit 68cafe35 authored by Alexandre Savard's avatar Alexandre Savard

Merge branch 'conference'

parents bd9a899e 59a295d8
......@@ -713,6 +713,8 @@ AlsaLayer::handle_xrun_playback (void)
if (state == SND_PCM_STATE_XRUN) {
stopPlaybackStream ();
preparePlaybackStream ();
_trigger_request = true;
}
}
......@@ -958,8 +960,12 @@ void AlsaLayer::audioCallback (void)
if((tone == 0) && (file_tone == 0)) {
bzero (out, maxNbBytesToGet);
write (out, maxNbBytesToGet);
SFLDataFormat* zeros = (SFLDataFormat*)malloc (framesPerBufferAlsa * sizeof (SFLDataFormat));
bzero (zeros, framesPerBufferAlsa * sizeof (SFLDataFormat));
write (zeros, framesPerBufferAlsa * sizeof (SFLDataFormat));
free (zeros);
}
}
......
......@@ -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 = 32000;
attributes->tlength = 16000;
attributes->prebuf = 1024;
attributes->minreq = 512;
attributes->fragsize = (uint32_t) -1;
attributes->maxlength = 16000;
attributes->tlength = 8192;
attributes->prebuf = 2048; // Pulseaudio will not start if prebuffering is not reached
attributes->minreq = 512; // The server side playback framesize
attributes->fragsize = 1024; // Fragment size at wich we receive an interupt
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) {
......@@ -197,13 +197,14 @@ AudioStream::createStream (pa_context* c)
// attributes->fragsize = (uint32_t)-1;
attributes->maxlength = 32000;
attributes->tlength = 16000;
attributes->prebuf = 1024;
attributes->minreq = 512;
attributes->fragsize = (uint32_t) -1;
attributes->tlength = (uint32_t)-1;
attributes->prebuf = (uint32_t)-1;
attributes->minreq = (uint32_t)-1;
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 );
// pa_stream_connect_record( s , NULL , attributes , PA_STREAM_INTERPOLATE_TIMING );
pa_stream_connect_record( s, NULL, NULL, PA_STREAM_INTERPOLATE_TIMING );
} else if (_streamType == UPLOAD_STREAM) {
pa_stream_connect_upload (s , 1024);
} else {
......
......@@ -57,7 +57,14 @@ 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");
// const pa_timing_info* info = pa_stream_get_timing_info(s);
// _debug(" pa write_index: %l\n", (long)(info->write_index));
// _debug(" pa write_index_corupt (if not 0): %i\n", info->write_index_corrupt);
// _debug(" pa read_index: %l\n", (long)(info->read_index));
// _debug(" pa read_index_corrupt (if not 0): %i\n", info->read_index_corrupt);
// fill in audio buffer twice the prebuffering value to restart playback
SFLDataFormat* out = (SFLDataFormat*) pa_xmalloc (framesPerBuffer*sizeof(SFLDataFormat));
bzero (out, framesPerBuffer*sizeof(SFLDataFormat));
......@@ -347,12 +354,12 @@ void PulseLayer::startStream (void)
assert (context);
}
_urgentRingBuffer.flush();
_mainBuffer.flushAllBuffers();
// Create Streams
connectPulseAudioServer();
_urgentRingBuffer.flushAll();
_mainBuffer.flushAllBuffers();
is_started = true;
}
......@@ -402,18 +409,19 @@ PulseLayer::stopStream (void)
void PulseLayer::underflow (pa_stream* s UNUSED, void* userdata UNUSED)
{
_debug ("PulseLayer::Buffer Underflow\n");
}
// void PulseLayer::underflow (pa_stream* s UNUSED, void* userdata UNUSED)
//{
// _debug ("PulseLayer::Buffer Underflow\n");
//}
/*
void PulseLayer::overflow (pa_stream* s, void* userdata UNUSED)
{
//PulseLayer* pulse = (PulseLayer*) userdata;
pa_stream_drop (s);
pa_stream_trigger (s, NULL, NULL);
}
*/
void PulseLayer::processPlaybackData (void)
......@@ -452,12 +460,21 @@ void PulseLayer::writeToSpeaker (void)
int toGet;
int toPlay;
// const pa_timing_info* info = pa_stream_get_timing_info(s);
// _debug(" pa write_index: %i", info->write_index);
// _debug(" pa write_index_corupt (if not 0): %i" info->write_index_corrupt);
// _debug(" pa read_index: %i", info->read_index);
// _debug(" pa read_index_corrupt (if not 0): %i", info->read_index_corrupt);
SFLDataFormat* out;// = (SFLDataFormat*)pa_xmalloc(framesPerBuffer);
urgentAvailBytes = _urgentRingBuffer.AvailForGet();
if (urgentAvailBytes > 0) {
// _debug("urgentAvailBytes: %i\n", urgentAvailBytes);
toGet = (urgentAvailBytes < (int) (framesPerBuffer * sizeof (SFLDataFormat))) ? urgentAvailBytes : framesPerBuffer * sizeof (SFLDataFormat);
out = (SFLDataFormat*) pa_xmalloc (toGet * sizeof (SFLDataFormat));
_urgentRingBuffer.Get (out, toGet, 100);
......@@ -487,7 +504,7 @@ void PulseLayer::writeToSpeaker (void)
}
}
if (file_tone != 0) {
else if (file_tone != 0) {
if (playback->getStreamState() == PA_STREAM_READY)
{
......@@ -556,11 +573,17 @@ void PulseLayer::writeToSpeaker (void)
if((tone == 0) && (file_tone == 0)) {
// _debug("maxNbBytesToGet: %i\n", maxNbBytesToGet);
bzero (out, maxNbBytesToGet);
pa_stream_write (playback->pulseStream(), out, maxNbBytesToGet, NULL, 0, PA_SEEK_RELATIVE);
SFLDataFormat* zeros = (SFLDataFormat*)pa_xmalloc (framesPerBuffer*sizeof(SFLDataFormat));
bzero (zeros, framesPerBuffer*sizeof(SFLDataFormat));
pa_stream_write(playback->pulseStream(), zeros, framesPerBuffer*sizeof(SFLDataFormat), NULL, 0, PA_SEEK_RELATIVE);
pa_xfree (zeros);
}
}
_urgentRingBuffer.Discard(toGet);
pa_xfree (out);
......
......@@ -1701,7 +1701,7 @@ ManagerImpl::playDtmf (char code, bool isTalking)
// Put buffer to urgentRingBuffer
// put the size in bytes...
// so size * 1 channel (mono) * sizeof (bytes for the data)
audiolayer->flushUrgent();
// audiolayer->flushUrgent();
audiolayer->startStream();
audiolayer->putUrgent (buf, size * sizeof (SFLDataFormat));
......
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