Commit ea419fec authored by Alexandre Savard's avatar Alexandre Savard

[#1962] Instantiate ringtone audio stream in pulseaudio

parent 529b2eff
......@@ -33,8 +33,6 @@
#include "algorithm.h"
#define FRAME_PER_BUFFER 160
/**
* @file audiolayer.h
* @brief Main sound class. Manages the data transfers between the application and the hardware.
......
......@@ -210,6 +210,17 @@ AudioStream::createStream (pa_context* c)
pa_stream_connect_record (s, NULL, attributes, (pa_stream_flags_t) (PA_STREAM_ADJUST_LATENCY|PA_STREAM_AUTO_TIMING_UPDATE));
pa_threaded_mainloop_unlock(_mainloop);
} else if (_streamType == RINGTONE_STREAM) {
attributes->maxlength = (uint32_t) -1;
attributes->tlength = pa_usec_to_bytes(100 * PA_USEC_PER_MSEC, &_sample_spec);
attributes->prebuf = 0;
attributes->minreq = (uint32_t) -1;
pa_threaded_mainloop_lock(_mainloop);
pa_stream_connect_playback(s, NULL, attributes, (pa_stream_flags_t) (PA_STREAM_NOFLAGS), NULL, NULL);
pa_threaded_mainloop_unlock(_mainloop);
} else if (_streamType == UPLOAD_STREAM) {
pa_stream_connect_upload (s , 1024);
} else {
......
......@@ -35,6 +35,7 @@
enum STREAM_TYPE {
PLAYBACK_STREAM,
CAPTURE_STREAM,
RINGTONE_STREAM,
UPLOAD_STREAM
};
......
......@@ -73,8 +73,9 @@ PulseLayer::PulseLayer (ManagerImpl* manager)
: AudioLayer (manager , PULSEAUDIO)
, context (NULL)
, m (NULL)
, playback()
, record()
, playback(NULL)
, record(NULL)
, ringtone(NULL)
{
_urgentRingBuffer.createReadPointer();
dcblocker = new DcBlocker();
......@@ -278,6 +279,18 @@ bool PulseLayer::createStreams (pa_context* c)
// pa_stream_set_moved_callback(record->pulseStream(), stream_moved_callback, this);
delete recordParam;
PulseLayerType * ringtoneParam = new PulseLayerType();
ringtoneParam->context = c;
ringtoneParam->type = RINGTONE_STREAM;
ringtoneParam->description = RINGTONE_STREAM_NAME;
ringtoneParam->volume = _manager->getSpkrVolume();
ringtoneParam->mainloop = m;
ringtone = new AudioStream (ringtoneParam, _audioSampleRate);
ringtone->connectStream();
pa_stream_set_write_callback(ringtone->pulseStream(), playback_callback, this);
delete ringtoneParam;
pa_threaded_mainloop_signal (m , 0);
flushMain();
......
......@@ -31,8 +31,9 @@
#include <stdlib.h>
#define PLAYBACK_STREAM_NAME "SFLphone out"
#define CAPTURE_STREAM_NAME "SFLphone in"
#define PLAYBACK_STREAM_NAME "SFLphone playback"
#define CAPTURE_STREAM_NAME "SFLphone capture"
#define RINGTONE_STREAM_NAME "SFLphone ringtone"
class RingBuffer;
class ManagerImpl;
......@@ -200,6 +201,11 @@ class PulseLayer : public AudioLayer {
*/
AudioStream* record;
/**
* A special stream object to handle specific playback stream for ringtone
*/
AudioStream* ringtone;
/** Sample rate converter object */
SamplerateConverter * _converter;
......
......@@ -1950,7 +1950,7 @@ void ManagerImpl::notificationIncomingCall (void) {
if (audiolayer != 0) {
samplerate = audiolayer->getSampleRate();
frequency << "440/" << FRAME_PER_BUFFER;
frequency << "440/" << 160;
Tone tone(frequency.str(), samplerate);
nbSampling = tone.getSize();
SFLDataFormat buf[nbSampling];
......
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