From: bruceperens Date: Tue, 22 Apr 2014 02:03:53 +0000 (+0000) Subject: Implement start/stop for ALSA devices. X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=d5288590a03b7f4ca9bb82df944402d22e73d093;p=freetel-svn-tracking.git Implement start/stop for ALSA devices. git-svn-id: https://svn.code.sf.net/p/freetel/code@1543 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 78abee62..b5af2f3e 100644 --- a/freedv-server/source/platform/linux/audio_in_alsa.cpp +++ b/freedv-server/source/platform/linux/audio_in_alsa.cpp @@ -58,6 +58,17 @@ namespace FreeDV { /// Read audio from the "short" type. virtual std::size_t read16(std::int16_t * array, std::size_t length); + + /// Start the audio device. + /// Input devices: start digitizing samples for the program to + /// subsequently read. + virtual void + start(); + + /// Stop the audio device. + /// Input devices: stop digitizing samples. + virtual void + stop(); }; AudioInALSA::AudioInALSA(const char * p) @@ -151,10 +162,7 @@ namespace FreeDV { int error; if ( !started ) { - snd_pcm_drop(handle); - snd_pcm_prepare(handle); - snd_pcm_start(handle); - started = true; + start(); return AudioFrameSamples; } @@ -190,6 +198,21 @@ namespace FreeDV { do_throw(error, "Get Frames Available for Read"); } + void + AudioInALSA::start() + { + snd_pcm_drop(handle); + snd_pcm_prepare(handle); + snd_pcm_start(handle); + started = true; + } + + void + AudioInALSA::stop() + { + snd_pcm_drop(handle); + } + static bool initializer() { diff --git a/freedv-server/source/platform/linux/audio_out_alsa.cpp b/freedv-server/source/platform/linux/audio_out_alsa.cpp index b22607fc..3589f154 100644 --- a/freedv-server/source/platform/linux/audio_out_alsa.cpp +++ b/freedv-server/source/platform/linux/audio_out_alsa.cpp @@ -54,6 +54,16 @@ namespace FreeDV { virtual std::size_t ready(); + /// Start the audio device. + /// Output devices: prepare for samples to be sent. + virtual void + start(); + + /// Stop the audio device. + /// Output devices: stop playing samples. + virtual void + stop(); + /// Write audio from the "short" type. virtual std::size_t write16(const std::int16_t * array, std::size_t length); @@ -195,6 +205,20 @@ namespace FreeDV { do_throw(error, "Get Frames Available for Write"); } + void + AudioOutALSA::start() + { + snd_pcm_drop(handle); + snd_pcm_prepare(handle); + started = true; + } + + void + AudioOutALSA::stop() + { + snd_pcm_drop(handle); + } + static bool initializer() {