summaryrefslogtreecommitdiffstats
path: root/client/x11
diff options
context:
space:
mode:
authorJeremy White <jwhite@codeweavers.com>2013-11-30 09:19:21 -0600
committerChristophe Fergeau <cfergeau@redhat.com>2014-01-02 12:36:59 +0100
commitce9b714137a767b81f2d3c40b5f3ce0d5cf70fc8 (patch)
treed0d0c87004994d5d037fb63a7c1d588bafe11226 /client/x11
parent4c7c0ef3a70001b1bc9011ef824d3c6fcccd9ca0 (diff)
downloadspice-ce9b714137a767b81f2d3c40b5f3ce0d5cf70fc8.tar.gz
spice-ce9b714137a767b81f2d3c40b5f3ce0d5cf70fc8.tar.xz
spice-ce9b714137a767b81f2d3c40b5f3ce0d5cf70fc8.zip
Add support for the Opus codec
Signed-off-by: Jeremy White <jwhite@codeweavers.com>
Diffstat (limited to 'client/x11')
-rw-r--r--client/x11/platform.cpp10
-rw-r--r--client/x11/playback.cpp13
-rw-r--r--client/x11/playback.h5
-rw-r--r--client/x11/record.cpp15
-rw-r--r--client/x11/record.h7
5 files changed, 30 insertions, 20 deletions
diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index b8563b3f..bb8704c4 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -3433,16 +3433,18 @@ void Platform::reset_cursor_pos()
WaveRecordAbstract* Platform::create_recorder(RecordClient& client,
uint32_t sampels_per_sec,
uint32_t bits_per_sample,
- uint32_t channels)
+ uint32_t channels,
+ uint32_t frame_size)
{
- return new WaveRecorder(client, sampels_per_sec, bits_per_sample, channels);
+ return new WaveRecorder(client, sampels_per_sec, bits_per_sample, channels, frame_size);
}
WavePlaybackAbstract* Platform::create_player(uint32_t sampels_per_sec,
uint32_t bits_per_sample,
- uint32_t channels)
+ uint32_t channels,
+ uint32_t frame_size)
{
- return new WavePlayer(sampels_per_sec, bits_per_sample, channels);
+ return new WavePlayer(sampels_per_sec, bits_per_sample, channels, frame_size);
}
void XPlatform::on_focus_in()
diff --git a/client/x11/playback.cpp b/client/x11/playback.cpp
index 5fa7e182..035d6de8 100644
--- a/client/x11/playback.cpp
+++ b/client/x11/playback.cpp
@@ -24,12 +24,12 @@
#define REING_SIZE_MS 300
-WavePlayer::WavePlayer(uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channels)
+WavePlayer::WavePlayer(uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channels, uint32_t frame_size)
: _pcm (NULL)
, _hw_params (NULL)
, _sw_params (NULL)
{
- if (!init(sampels_per_sec, bits_per_sample, channels)) {
+ if (!init(sampels_per_sec, bits_per_sample, channels, frame_size)) {
cleanup();
THROW("failed");
}
@@ -57,9 +57,9 @@ WavePlayer::~WavePlayer()
bool WavePlayer::init(uint32_t sampels_per_sec,
uint32_t bits_per_sample,
- uint32_t channels)
+ uint32_t channels,
+ uint32_t frame_size)
{
- const int frame_size = WavePlaybackAbstract::FRAME_SIZE;
const char* pcm_device = "default";
snd_pcm_format_t format;
int err;
@@ -75,6 +75,7 @@ bool WavePlayer::init(uint32_t sampels_per_sec,
return false;
}
_sampels_per_ms = sampels_per_sec / 1000;
+ _frame_size = frame_size;
if ((err = snd_pcm_open(&_pcm, pcm_device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0) {
LOG_ERROR("cannot open audio playback device %s %s", pcm_device, snd_strerror(err));
@@ -183,14 +184,14 @@ bool WavePlayer::init(uint32_t sampels_per_sec,
bool WavePlayer::write(uint8_t* frame)
{
- snd_pcm_sframes_t ret = snd_pcm_writei(_pcm, frame, WavePlaybackAbstract::FRAME_SIZE);
+ snd_pcm_sframes_t ret = snd_pcm_writei(_pcm, frame, _frame_size);
if (ret < 0) {
if (ret == -EAGAIN) {
return false;
}
DBG(0, "err %s", snd_strerror(-ret));
if (snd_pcm_recover(_pcm, ret, 1) == 0) {
- snd_pcm_writei(_pcm, frame, WavePlaybackAbstract::FRAME_SIZE);
+ snd_pcm_writei(_pcm, frame, _frame_size);
}
}
return true;
diff --git a/client/x11/playback.h b/client/x11/playback.h
index 27ef9ed7..383f02d3 100644
--- a/client/x11/playback.h
+++ b/client/x11/playback.h
@@ -25,7 +25,7 @@
class WavePlayer: public WavePlaybackAbstract {
public:
- WavePlayer(uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channels);
+ WavePlayer(uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channels, uint32_t frame_size);
virtual ~WavePlayer();
virtual bool write(uint8_t* frame);
@@ -34,7 +34,7 @@ public:
virtual uint32_t get_delay_ms();
private:
- bool init(uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channel);
+ bool init(uint32_t sampels_per_sec, uint32_t bits_per_sample, uint32_t channel, uint32_t frame_size);
void cleanup();
private:
@@ -42,6 +42,7 @@ private:
snd_pcm_hw_params_t* _hw_params;
snd_pcm_sw_params_t* _sw_params;
uint32_t _sampels_per_ms;
+ uint32_t _frame_size;
};
#endif
diff --git a/client/x11/record.cpp b/client/x11/record.cpp
index 535a8c9e..32c0af7f 100644
--- a/client/x11/record.cpp
+++ b/client/x11/record.cpp
@@ -48,18 +48,19 @@ void WaveRecorder::EventTrigger::on_event()
WaveRecorder::WaveRecorder(Platform::RecordClient& client,
uint32_t sampels_per_sec,
uint32_t bits_per_sample,
- uint32_t channels)
+ uint32_t channels,
+ uint32_t frame_size)
: _client (client)
, _pcm (NULL)
, _hw_params (NULL)
, _sw_params (NULL)
, _sample_bytes (bits_per_sample * channels / 8)
- , _frame (new uint8_t[_sample_bytes * WaveRecordAbstract::FRAME_SIZE])
+ , _frame (new uint8_t[_sample_bytes * frame_size])
, _frame_pos (_frame)
- , _frame_end (_frame + _sample_bytes * WaveRecordAbstract::FRAME_SIZE)
+ , _frame_end (_frame + _sample_bytes * frame_size)
, _event_trigger (NULL)
{
- if (!init(sampels_per_sec, bits_per_sample, channels)) {
+ if (!init(sampels_per_sec, bits_per_sample, channels, frame_size)) {
cleanup();
THROW("failed");
}
@@ -93,13 +94,15 @@ void WaveRecorder::cleanup()
bool WaveRecorder::init(uint32_t sampels_per_sec,
uint32_t bits_per_sample,
- uint32_t channels)
+ uint32_t channels,
+ uint32_t frame_size)
{
- const int frame_size = WaveRecordAbstract::FRAME_SIZE;
const char* pcm_device = "default";
snd_pcm_format_t format;
int err;
+ _frame_size = frame_size;
+
switch (bits_per_sample) {
case 8:
format = SND_PCM_FORMAT_S8;
diff --git a/client/x11/record.h b/client/x11/record.h
index 91410962..9470791f 100644
--- a/client/x11/record.h
+++ b/client/x11/record.h
@@ -29,7 +29,8 @@ public:
WaveRecorder(Platform::RecordClient& client,
uint32_t sampels_per_sec,
uint32_t bits_per_sample,
- uint32_t channels);
+ uint32_t channels,
+ uint32_t frame_size);
virtual ~WaveRecorder();
virtual void start();
@@ -39,7 +40,8 @@ public:
private:
bool init(uint32_t sampels_per_sec,
uint32_t bits_per_sample,
- uint32_t channels);
+ uint32_t channels,
+ uint32_t frame_size);
void cleanup();
void on_event();
@@ -49,6 +51,7 @@ private:
snd_pcm_hw_params_t* _hw_params;
snd_pcm_sw_params_t* _sw_params;
uint32_t _sample_bytes;
+ uint32_t _frame_size;
uint8_t* _frame;
uint8_t* _frame_pos;
uint8_t* _frame_end;