Skip to content
Snippets Groups Projects
Commit 063badd0 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#1962] Use snd_pcm_avail_update to get number of byte to copy for ringtone

parent 3873a0e8
Branches
Tags
No related merge requests found
...@@ -845,11 +845,12 @@ void AlsaLayer::audioCallback (void) ...@@ -845,11 +845,12 @@ void AlsaLayer::audioCallback (void)
spkrVolume = _manager->getSpkrVolume(); spkrVolume = _manager->getSpkrVolume();
micVolume = _manager->getMicVolume(); micVolume = _manager->getMicVolume();
tone = _manager->getTelephoneTone();
file_tone = _manager->getTelephoneFile();
// AvailForGet tell the number of chars inside the buffer // AvailForGet tell the number of chars inside the buffer
// framePerBuffer are the number of data for one channel (left) // framePerBuffer are the number of data for one channel (left)
urgentAvailBytes = _urgentRingBuffer.AvailForGet(); urgentAvailBytes = _urgentRingBuffer.AvailForGet();
tone = _manager->getTelephoneTone();
file_tone = _manager->getTelephoneFile();
toGet = framesPerBufferAlsa; toGet = framesPerBufferAlsa;
maxBytes = toGet * sizeof (SFLDataFormat); maxBytes = toGet * sizeof (SFLDataFormat);
...@@ -973,18 +974,24 @@ void AlsaLayer::audioCallback (void) ...@@ -973,18 +974,24 @@ void AlsaLayer::audioCallback (void)
if (file_tone && _RingtoneHandle) { if (file_tone && _RingtoneHandle) {
out = (SFLDataFormat *) malloc (maxBytes); int ringtoneAvailSmpl = snd_pcm_avail_update(_RingtoneHandle);
file_tone->getNext (out, toGet, spkrVolume); int ringtoneAvailBytes = ringtoneAvailSmpl*sizeof(SFLDataFormat);
write (out, maxBytes, _RingtoneHandle);
out = (SFLDataFormat *) malloc(ringtoneAvailBytes);
file_tone->getNext (out, ringtoneAvailSmpl, spkrVolume);
write (out, ringtoneAvailBytes, _RingtoneHandle);
free (out); free (out);
out = NULL; out = NULL;
} else if (_RingtoneHandle) { } else if (_RingtoneHandle) {
out = (SFLDataFormat *) malloc ( maxBytes); int ringtoneAvailSmpl = snd_pcm_avail_update(_RingtoneHandle);
memset(out, 0, maxBytes); int ringtoneAvailBytes = ringtoneAvailSmpl*sizeof(SFLDataFormat);
write(out, maxBytes, _RingtoneHandle);
out = (SFLDataFormat *) malloc(ringtoneAvailBytes);
memset(out, 0, ringtoneAvailBytes);
write(out, ringtoneAvailBytes, _RingtoneHandle);
free(out); free(out);
out = NULL; out = NULL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment