summaryrefslogtreecommitdiff
path: root/drumgizmo/output
diff options
context:
space:
mode:
Diffstat (limited to 'drumgizmo/output')
-rw-r--r--drumgizmo/output/oss.cc12
-rw-r--r--drumgizmo/output/oss.h1
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;
};