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

#5765: Fix audio crash for illformated wavefiles

parent ae7c5c3a
No related branches found
No related tags found
No related merge requests found
......@@ -53,6 +53,11 @@ AudioLoop::getNext (SFLDataFormat* output, int nb, short volume)
int block;
int pos = _pos;
if(_size == 0) {
_error("AudioLoop: Error: Audio loop size is 0");
return 0;
}
while (nb) {
block = nb;
......
......@@ -958,27 +958,45 @@ void PulseLayer::ringtoneToSpeaker (void)
if (file_tone) {
if (ringtone->getStreamState() == PA_STREAM_READY) {
if (ringtone->getStreamState() != PA_STREAM_READY) {
_error("PulseAudio: Error: Ringtone stream not in state ready");
return;
}
out = (SFLDataFormat *) pa_xmalloc (writableSize);
if(out == NULL) {
_error("PulseAudio: Error: Could not allocate memory for buffer");
return;
}
out = (SFLDataFormat *) pa_xmalloc (writableSize);
memset (out, 0, writableSize);
memset (out, 0, writableSize);
int copied = file_tone->getNext (out, writableSize/sizeof (SFLDataFormat), 100);
pa_stream_write (ringtone->pulseStream(), out, copied*sizeof (SFLDataFormat), NULL, 0, PA_SEEK_RELATIVE);
int copied = file_tone->getNext (out, writableSize/sizeof (SFLDataFormat), 100);
pa_xfree (out);
if(copied == 0) {
copied = writableSize/sizeof(SFLDataFormat);
}
} else {
if (ringtone->getStreamState() == PA_STREAM_READY) {
pa_stream_write (ringtone->pulseStream(), out, copied*sizeof (SFLDataFormat), NULL, 0, PA_SEEK_RELATIVE);
out = (SFLDataFormat*) pa_xmalloc (writableSize);
memset (out, 0, writableSize);
pa_xfree (out);
} else {
pa_stream_write (ringtone->pulseStream(), out, writableSize, NULL, 0, PA_SEEK_RELATIVE);
if (ringtone->getStreamState() != PA_STREAM_READY) {
_error("PulseAudio: Error: Ringtone stream not in state ready");
return;
}
pa_xfree (out);
out = (SFLDataFormat*) pa_xmalloc (writableSize);
if(out == NULL) {
_error("PulseAudio: Error: Could not allocate memory for buffer");
return;
}
memset (out, 0, writableSize);
pa_stream_write (ringtone->pulseStream(), out, writableSize, NULL, 0, PA_SEEK_RELATIVE);
pa_xfree (out);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment