diff options
author | Goran Mekić <meka@tilda.center> | 2017-04-30 11:48:36 +0200 |
---|---|---|
committer | Goran Mekić <meka@tilda.center> | 2017-04-30 12:16:01 +0200 |
commit | a9256048bf2d9ec3ff6004a6dd6bf9e3a3f88294 (patch) | |
tree | c35494c9a7b4379bc811fdf6e21b8e11408ca486 /drumgizmo | |
parent | fc8d2e31e79782e219259a1ab6782a39edc18516 (diff) |
Get OSS buffer size
Diffstat (limited to 'drumgizmo')
-rw-r--r-- | drumgizmo/output/oss.cc | 12 | ||||
-rw-r--r-- | drumgizmo/output/oss.h | 1 |
2 files changed, 12 insertions, 1 deletions
diff --git a/drumgizmo/output/oss.cc b/drumgizmo/output/oss.cc index ee13a84..9815460 100644 --- a/drumgizmo/output/oss.cc +++ b/drumgizmo/output/oss.cc @@ -40,6 +40,7 @@ OSSOutputEngine::OSSOutputEngine() , data{} , max_fragments{4} , fragment_size{8} + , buffer_size{1024} { data.clear(); data.resize(1024 * num_channels); @@ -64,6 +65,15 @@ bool OSSOutputEngine::init(const Channels& channels) exit(-1); } + audio_buf_info info; + if(ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) == -1) + { + std::cerr << "Can not get buffer info: "; + std::cerr << std::strerror(errno) << std::endl; + return false; + } + buffer_size = info.bytes / 4; + tmp = format; if(ioctl(fd, SNDCTL_DSP_SETFMT, &tmp) == -1 || tmp != format) { @@ -195,7 +205,7 @@ void OSSOutputEngine::post(size_t nsamples) std::size_t OSSOutputEngine::getBufferSize() const { - return data.size() / num_channels; + return buffer_size; } std::size_t OSSOutputEngine::getSamplerate() const diff --git a/drumgizmo/output/oss.h b/drumgizmo/output/oss.h index 889021f..1233ec1 100644 --- a/drumgizmo/output/oss.h +++ b/drumgizmo/output/oss.h @@ -54,5 +54,6 @@ private: unsigned int format; unsigned int max_fragments; unsigned int fragment_size; + unsigned int buffer_size; std::vector<std::int32_t> data; }; |