aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/oss.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-11-28 12:51:46 +0100
committerSven Gothel <[email protected]>2023-11-28 12:51:46 +0100
commit1aaf4f070011490bcece50394b9b32dfa593fd9e (patch)
tree17d68284e401a35eea3d3a574d986d446a60763a /alc/backends/oss.cpp
parent6e7cee4fa9a8af03f28ca26cd89f8357390dfc90 (diff)
parent571b546f35eead77ce109f8d4dd6c3de3199d573 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'alc/backends/oss.cpp')
-rw-r--r--alc/backends/oss.cpp42
1 files changed, 19 insertions, 23 deletions
diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp
index 6d4fa261..87d3ba35 100644
--- a/alc/backends/oss.cpp
+++ b/alc/backends/oss.cpp
@@ -31,27 +31,23 @@
#include <algorithm>
#include <atomic>
#include <cerrno>
-#include <cstdio>
#include <cstring>
#include <exception>
#include <functional>
#include <memory>
-#include <new>
#include <string>
#include <thread>
#include <utility>
+#include <vector>
-#include "albyte.h"
#include "alc/alconfig.h"
#include "almalloc.h"
#include "alnumeric.h"
-#include "aloptional.h"
+#include "althrd_setname.h"
#include "core/device.h"
#include "core/helpers.h"
#include "core/logging.h"
#include "ringbuffer.h"
-#include "threads.h"
-#include "vector.h"
#include <sys/soundcard.h>
@@ -92,22 +88,22 @@ struct DevMap {
std::string device_name;
};
-al::vector<DevMap> PlaybackDevices;
-al::vector<DevMap> CaptureDevices;
+std::vector<DevMap> PlaybackDevices;
+std::vector<DevMap> CaptureDevices;
#ifdef ALC_OSS_COMPAT
#define DSP_CAP_OUTPUT 0x00020000
#define DSP_CAP_INPUT 0x00010000
-void ALCossListPopulate(al::vector<DevMap> &devlist, int type)
+void ALCossListPopulate(std::vector<DevMap> &devlist, int type)
{
devlist.emplace_back(DevMap{DefaultName, (type==DSP_CAP_INPUT) ? DefaultCapture : DefaultPlayback});
}
#else
-void ALCossListAppend(al::vector<DevMap> &list, al::span<const char> handle, al::span<const char> path)
+void ALCossListAppend(std::vector<DevMap> &list, al::span<const char> handle, al::span<const char> path)
{
#ifdef ALC_OSS_DEVNODE_TRUC
for(size_t i{0};i < path.size();++i)
@@ -152,7 +148,7 @@ void ALCossListAppend(al::vector<DevMap> &list, al::span<const char> handle, al:
TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str());
}
-void ALCossListPopulate(al::vector<DevMap> &devlist, int type_flag)
+void ALCossListPopulate(std::vector<DevMap> &devlist, int type_flag)
{
int fd{open("/dev/mixer", O_RDONLY)};
if(fd < 0)
@@ -231,14 +227,14 @@ struct OSSPlayback final : public BackendBase {
int mixerProc();
- void open(const char *name) override;
+ void open(std::string_view name) override;
bool reset() override;
void start() override;
void stop() override;
int mFd{-1};
- al::vector<al::byte> mMixData;
+ std::vector<std::byte> mMixData;
std::atomic<bool> mKillNow{true};
std::thread mThread;
@@ -284,7 +280,7 @@ int OSSPlayback::mixerProc()
continue;
}
- al::byte *write_ptr{mMixData.data()};
+ std::byte *write_ptr{mMixData.data()};
size_t to_write{mMixData.size()};
mDevice->renderSamples(write_ptr, static_cast<uint>(to_write/frame_size), frame_step);
while(to_write > 0 && !mKillNow.load(std::memory_order_acquire))
@@ -308,10 +304,10 @@ int OSSPlayback::mixerProc()
}
-void OSSPlayback::open(const char *name)
+void OSSPlayback::open(std::string_view name)
{
const char *devname{DefaultPlayback.c_str()};
- if(!name)
+ if(name.empty())
name = DefaultName;
else
{
@@ -324,7 +320,7 @@ void OSSPlayback::open(const char *name)
);
if(iter == PlaybackDevices.cend())
throw al::backend_exception{al::backend_error::NoDevice,
- "Device name \"%s\" not found", name};
+ "Device name \"%.*s\" not found", static_cast<int>(name.length()), name.data()};
devname = iter->device_name.c_str();
}
@@ -447,10 +443,10 @@ struct OSScapture final : public BackendBase {
int recordProc();
- void open(const char *name) override;
+ void open(std::string_view name) override;
void start() override;
void stop() override;
- void captureSamples(al::byte *buffer, uint samples) override;
+ void captureSamples(std::byte *buffer, uint samples) override;
uint availableSamples() override;
int mFd{-1};
@@ -516,10 +512,10 @@ int OSScapture::recordProc()
}
-void OSScapture::open(const char *name)
+void OSScapture::open(std::string_view name)
{
const char *devname{DefaultCapture.c_str()};
- if(!name)
+ if(name.empty())
name = DefaultName;
else
{
@@ -532,7 +528,7 @@ void OSScapture::open(const char *name)
);
if(iter == CaptureDevices.cend())
throw al::backend_exception{al::backend_error::NoDevice,
- "Device name \"%s\" not found", name};
+ "Device name \"%.*s\" not found", static_cast<int>(name.length()), name.data()};
devname = iter->device_name.c_str();
}
@@ -620,7 +616,7 @@ void OSScapture::stop()
ERR("Error resetting device: %s\n", strerror(errno));
}
-void OSScapture::captureSamples(al::byte *buffer, uint samples)
+void OSScapture::captureSamples(std::byte *buffer, uint samples)
{ mRing->read(buffer, samples); }
uint OSScapture::availableSamples()