From: bruceperens Date: Tue, 22 Apr 2014 04:12:40 +0000 (+0000) Subject: Receive works correctly with keying. Audio start() and stop() seems to work X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=ac306126e3c660e8fbbcf132c4fc2800f0c11c69;p=freetel-svn-tracking.git Receive works correctly with keying. Audio start() and stop() seems to work correctly so far. git-svn-id: https://svn.code.sf.net/p/freetel/code@1545 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/freedv-server/source/platform/linux/audio_in_alsa.cpp b/freedv-server/source/platform/linux/audio_in_alsa.cpp index b5af2f3e..76de58f6 100644 --- a/freedv-server/source/platform/linux/audio_in_alsa.cpp +++ b/freedv-server/source/platform/linux/audio_in_alsa.cpp @@ -201,6 +201,7 @@ namespace FreeDV { void AudioInALSA::start() { + std::cerr << "Input start " << parameters << std::endl; snd_pcm_drop(handle); snd_pcm_prepare(handle); snd_pcm_start(handle); @@ -210,7 +211,11 @@ namespace FreeDV { void AudioInALSA::stop() { + std::cerr << "Input stop " << parameters << std::endl; snd_pcm_drop(handle); + snd_pcm_prepare(handle); + snd_pcm_pause(handle, 1); + started = false; } static bool diff --git a/freedv-server/source/platform/linux/audio_out_alsa.cpp b/freedv-server/source/platform/linux/audio_out_alsa.cpp index 3589f154..f061e9f4 100644 --- a/freedv-server/source/platform/linux/audio_out_alsa.cpp +++ b/freedv-server/source/platform/linux/audio_out_alsa.cpp @@ -210,13 +210,16 @@ namespace FreeDV { { snd_pcm_drop(handle); snd_pcm_prepare(handle); - started = true; + snd_pcm_pause(handle, 1); } void AudioOutALSA::stop() { snd_pcm_drop(handle); + snd_pcm_prepare(handle); + snd_pcm_pause(handle, 1); + started = false; } static bool diff --git a/freedv-server/source/platform/linux/evdev.cpp b/freedv-server/source/platform/linux/evdev.cpp index 89fc8284..dd663570 100644 --- a/freedv-server/source/platform/linux/evdev.cpp +++ b/freedv-server/source/platform/linux/evdev.cpp @@ -199,6 +199,7 @@ namespace FreeDV { { if ( length >= 0 ) { array[0].fd = fd; + array[0].events = POLLIN|POLLERR|POLLNVAL; return 1; } else diff --git a/freedv-server/source/run.cpp b/freedv-server/source/run.cpp index 8b8bc787..49e92798 100644 --- a/freedv-server/source/run.cpp +++ b/freedv-server/source/run.cpp @@ -5,10 +5,11 @@ /// #include "drivers.h" +#include +#include #include #include #include -#include // Start of Transmit: // Make the delay at start of transmit and end of transmit adjustable. @@ -129,29 +130,13 @@ namespace FreeDV { bool Run::drain_digital() { - static bool done = false; - if ( !done ) { - done = true; - return false; - } - else { - done = false; - return true; - } + return true; } bool Run::drain_ssb() { - static bool done = false; - if ( !done ) { - done = true; - return false; - } - else { - done = false; - return true; - } + return true; } void @@ -298,16 +283,26 @@ namespace FreeDV { // we'll catch up. un_key(); start_receive(); + i->receiver->start(); + i->loudspeaker->start(); if ( !add_poll_device(i->receiver) ) add_poll_device(i->loudspeaker); for ( ; ; ) { for ( int j = 0; j < poll_fd_count; j++ ) { poll_fds[j].revents = 0; - poll_fds[j].events = POLLIN; } - const int result = IODevice::poll(poll_fds, poll_fd_count, 1000); + int result = 0; + + if ( poll_fd_count > poll_fd_base ) + result = IODevice::poll(poll_fds, poll_fd_count, 1000); + else { + struct timespec request; + request.tv_sec = 0; + request.tv_nsec = AudioFrameDuration * 100000; + nanosleep(&request, 0); + } if ( result < 0 ) do_throw(result, "Poll"); @@ -388,6 +383,14 @@ namespace FreeDV { break; case UnKey: if ( ptt_digital || ptt_ssb ) { + // Reset polling from the Drain operation. + poll_fd_count = poll_fd_base; + + i->microphone->start(); + // Start polling the transmitter devices. + if ( !add_poll_device(i->microphone) ) + add_poll_device(i->transmitter); + if ( ptt_digital ) { state = TransmitDigital; start_transmit_digital(); @@ -411,7 +414,6 @@ namespace FreeDV { // Start polling the receiver devices. if ( !add_poll_device(i->receiver) ) add_poll_device(i->loudspeaker); - } break; }