From: bruceperens Date: Wed, 28 May 2014 21:19:28 +0000 (+0000) Subject: Oops, I broke drain_ssb(). X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=55682cb50d927ded16a0fca42394b4a268cc7655;p=freetel-svn-tracking.git Oops, I broke drain_ssb(). git-svn-id: https://svn.code.sf.net/p/freetel/code@1605 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/freedv-server/source/platform/linux/audio_out_alsa.cpp b/freedv-server/source/platform/linux/audio_out_alsa.cpp index e14daa27..d20d983c 100644 --- a/freedv-server/source/platform/linux/audio_out_alsa.cpp +++ b/freedv-server/source/platform/linux/audio_out_alsa.cpp @@ -161,15 +161,10 @@ namespace FreeDV { } if ( error >= 0 ) - return error; + return error; // This is the normal output. else if ( error == -EPIPE ) { // This is an unlikely condition, but should not be allowed to abort // the program. - // About the only reason this might happen would be a failure of - // real-time schduling, for example a system management interrupt - // outside of the control of the operating system, or a problem with - // the sound hardware or driver. Punt and hope it gets better the next - // time. std::cerr << "ALSA output \"" << parameters << "\": double write underrun." << std::endl; return 0; diff --git a/freedv-server/source/run.cpp b/freedv-server/source/run.cpp index 52231027..bba6642b 100644 --- a/freedv-server/source/run.cpp +++ b/freedv-server/source/run.cpp @@ -143,7 +143,7 @@ namespace FreeDV { if ( final ) { const std::size_t samples_per_frame = i->codec->samples_per_frame(); if ( samples_to_encode < samples_per_frame && samples_to_encode > 0 ) { - const std::size_t fill = samples_per_frame - samples_to_encode; + const std::size_t fill = min(in_fifo.put_space() / 2, (samples_per_frame - samples_to_encode)); const std::size_t bytes = fill * 2; memset(in_fifo.put(bytes), 0, bytes); in_fifo.put_done(bytes); @@ -175,7 +175,7 @@ namespace FreeDV { if ( final && in_fifo.get_available() == 0 ) { const std::size_t bytes_per_frame = i->modem->bytes_per_frame(); if ( bytes_to_modulate < bytes_per_frame && bytes_to_modulate > 0 ) { - const std::size_t fill = bytes_per_frame - bytes_to_modulate; + const std::size_t fill = min(codec_fifo.put_space(), (bytes_per_frame - bytes_to_modulate)); memset(codec_fifo.put(fill), 0, fill); codec_fifo.put_done(fill); bytes_to_modulate += fill; @@ -283,6 +283,12 @@ namespace FreeDV { output_fd_base = -1; } } + + if ( final ) { + if ( in_fifo.get_available() == 0 + && out_fifo.get_available() == 0 ) + return true; + } return false; }