diff options
Diffstat (limited to 'drumgizmo/output/oss.cc')
-rw-r--r-- | drumgizmo/output/oss.cc | 12 |
1 files changed, 11 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 |