aboutsummaryrefslogtreecommitdiffstats
path: root/src/filter
diff options
context:
space:
mode:
Diffstat (limited to 'src/filter')
-rw-r--r--src/filter/AutoConvertFilterPlugin.cxx21
-rw-r--r--src/filter/ChainFilterPlugin.cxx35
-rw-r--r--src/filter/ConvertFilterPlugin.cxx15
-rw-r--r--src/filter/NormalizeFilterPlugin.cxx10
-rw-r--r--src/filter/NullFilterPlugin.cxx8
-rw-r--r--src/filter/ReplayGainFilterPlugin.cxx29
-rw-r--r--src/filter/RouteFilterPlugin.cxx39
-rw-r--r--src/filter/VolumeFilterPlugin.cxx21
8 files changed, 87 insertions, 91 deletions
diff --git a/src/filter/AutoConvertFilterPlugin.cxx b/src/filter/AutoConvertFilterPlugin.cxx
index 19495acbc..4b5ebff4d 100644
--- a/src/filter/AutoConvertFilterPlugin.cxx
+++ b/src/filter/AutoConvertFilterPlugin.cxx
@@ -46,21 +46,22 @@ public:
delete filter;
}
- virtual AudioFormat Open(AudioFormat &af, GError **error_r);
- virtual void Close();
+ virtual AudioFormat Open(AudioFormat &af, Error &error) override;
+ virtual void Close() override;
virtual const void *FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, GError **error_r);
+ size_t *dest_size_r,
+ Error &error) override;
};
AudioFormat
-AutoConvertFilter::Open(AudioFormat &in_audio_format, GError **error_r)
+AutoConvertFilter::Open(AudioFormat &in_audio_format, Error &error)
{
assert(in_audio_format.IsValid());
/* open the "real" filter */
const AudioFormat child_audio_format = in_audio_format;
- AudioFormat out_audio_format = filter->Open(in_audio_format, error_r);
+ AudioFormat out_audio_format = filter->Open(in_audio_format, error);
if (!out_audio_format.IsDefined())
return out_audio_format;
@@ -70,7 +71,7 @@ AutoConvertFilter::Open(AudioFormat &in_audio_format, GError **error_r)
/* yes - create a convert_filter */
const config_param empty;
- convert = filter_new(&convert_filter_plugin, empty, error_r);
+ convert = filter_new(&convert_filter_plugin, empty, error);
if (convert == nullptr) {
filter->Close();
return AudioFormat::Undefined();
@@ -78,7 +79,7 @@ AutoConvertFilter::Open(AudioFormat &in_audio_format, GError **error_r)
AudioFormat audio_format2 = in_audio_format;
AudioFormat audio_format3 =
- convert->Open(audio_format2, error_r);
+ convert->Open(audio_format2, error);
if (!audio_format3.IsDefined()) {
delete convert;
filter->Close();
@@ -108,15 +109,15 @@ AutoConvertFilter::Close()
const void *
AutoConvertFilter::FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, GError **error_r)
+ size_t *dest_size_r, Error &error)
{
if (convert != nullptr) {
- src = convert->FilterPCM(src, src_size, &src_size, error_r);
+ src = convert->FilterPCM(src, src_size, &src_size, error);
if (src == nullptr)
return nullptr;
}
- return filter->FilterPCM(src, src_size, dest_size_r, error_r);
+ return filter->FilterPCM(src, src_size, dest_size_r, error);
}
Filter *
diff --git a/src/filter/ChainFilterPlugin.cxx b/src/filter/ChainFilterPlugin.cxx
index fbb91795d..a24f533b1 100644
--- a/src/filter/ChainFilterPlugin.cxx
+++ b/src/filter/ChainFilterPlugin.cxx
@@ -24,6 +24,8 @@
#include "FilterInternal.hxx"
#include "FilterRegistry.hxx"
#include "AudioFormat.hxx"
+#include "util/Error.hxx"
+#include "util/Domain.hxx"
#include <glib.h>
@@ -53,10 +55,10 @@ public:
children.emplace_back(name, filter);
}
- virtual AudioFormat Open(AudioFormat &af, GError **error_r) override;
+ virtual AudioFormat Open(AudioFormat &af, Error &error) override;
virtual void Close();
virtual const void *FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, GError **error_r);
+ size_t *dest_size_r, Error &error);
private:
/**
@@ -66,15 +68,11 @@ private:
void CloseUntil(const Filter *until);
};
-static inline GQuark
-filter_quark(void)
-{
- return g_quark_from_static_string("filter");
-}
+static constexpr Domain chain_filter_domain("chain_filter");
static Filter *
chain_filter_init(gcc_unused const config_param &param,
- gcc_unused GError **error_r)
+ gcc_unused Error &error)
{
return new ChainFilter();
}
@@ -99,11 +97,11 @@ ChainFilter::CloseUntil(const Filter *until)
static AudioFormat
chain_open_child(const char *name, Filter *filter,
const AudioFormat &prev_audio_format,
- GError **error_r)
+ Error &error)
{
AudioFormat conv_audio_format = prev_audio_format;
const AudioFormat next_audio_format =
- filter->Open(conv_audio_format, error_r);
+ filter->Open(conv_audio_format, error);
if (!next_audio_format.IsDefined())
return next_audio_format;
@@ -111,10 +109,11 @@ chain_open_child(const char *name, Filter *filter,
struct audio_format_string s;
filter->Close();
- g_set_error(error_r, filter_quark(), 0,
- "Audio format not supported by filter '%s': %s",
- name,
- audio_format_to_string(prev_audio_format, &s));
+
+ error.Format(chain_filter_domain,
+ "Audio format not supported by filter '%s': %s",
+ name,
+ audio_format_to_string(prev_audio_format, &s));
return AudioFormat::Undefined();
}
@@ -122,13 +121,13 @@ chain_open_child(const char *name, Filter *filter,
}
AudioFormat
-ChainFilter::Open(AudioFormat &in_audio_format, GError **error_r)
+ChainFilter::Open(AudioFormat &in_audio_format, Error &error)
{
AudioFormat audio_format = in_audio_format;
for (auto &child : children) {
audio_format = chain_open_child(child.name, child.filter,
- audio_format, error_r);
+ audio_format, error);
if (!audio_format.IsDefined()) {
/* rollback, close all children */
CloseUntil(child.filter);
@@ -149,13 +148,13 @@ ChainFilter::Close()
const void *
ChainFilter::FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, GError **error_r)
+ size_t *dest_size_r, Error &error)
{
for (auto &child : children) {
/* feed the output of the previous filter as input
into the current one */
src = child.filter->FilterPCM(src, src_size, &src_size,
- error_r);
+ error);
if (src == NULL)
return NULL;
}
diff --git a/src/filter/ConvertFilterPlugin.cxx b/src/filter/ConvertFilterPlugin.cxx
index 4dc0d0333..3ef2be719 100644
--- a/src/filter/ConvertFilterPlugin.cxx
+++ b/src/filter/ConvertFilterPlugin.cxx
@@ -56,21 +56,22 @@ public:
out_audio_format = _out_audio_format;
}
- virtual AudioFormat Open(AudioFormat &af, GError **error_r) override;
- virtual void Close();
+ virtual AudioFormat Open(AudioFormat &af, Error &error) override;
+ virtual void Close() override;
virtual const void *FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, GError **error_r);
+ size_t *dest_size_r,
+ Error &error) override;
};
static Filter *
convert_filter_init(gcc_unused const config_param &param,
- gcc_unused GError **error_r)
+ gcc_unused Error &error)
{
return new ConvertFilter();
}
AudioFormat
-ConvertFilter::Open(AudioFormat &audio_format, gcc_unused GError **error_r)
+ConvertFilter::Open(AudioFormat &audio_format, gcc_unused Error &error)
{
assert(audio_format.IsValid());
@@ -91,7 +92,7 @@ ConvertFilter::Close()
const void *
ConvertFilter::FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, GError **error_r)
+ size_t *dest_size_r, Error &error)
{
if (in_audio_format == out_audio_format) {
/* optimized special case: no-op */
@@ -102,7 +103,7 @@ ConvertFilter::FilterPCM(const void *src, size_t src_size,
return state->Convert(in_audio_format,
src, src_size,
out_audio_format, dest_size_r,
- error_r);
+ error);
}
const struct filter_plugin convert_filter_plugin = {
diff --git a/src/filter/NormalizeFilterPlugin.cxx b/src/filter/NormalizeFilterPlugin.cxx
index 63b562fa0..6c4f6b0e5 100644
--- a/src/filter/NormalizeFilterPlugin.cxx
+++ b/src/filter/NormalizeFilterPlugin.cxx
@@ -34,21 +34,21 @@ class NormalizeFilter final : public Filter {
PcmBuffer buffer;
public:
- virtual AudioFormat Open(AudioFormat &af, GError **error_r) override;
+ virtual AudioFormat Open(AudioFormat &af, Error &error) override;
virtual void Close();
virtual const void *FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, GError **error_r);
+ size_t *dest_size_r, Error &error);
};
static Filter *
normalize_filter_init(gcc_unused const config_param &param,
- gcc_unused GError **error_r)
+ gcc_unused Error &error)
{
return new NormalizeFilter();
}
AudioFormat
-NormalizeFilter::Open(AudioFormat &audio_format, gcc_unused GError **error_r)
+NormalizeFilter::Open(AudioFormat &audio_format, gcc_unused Error &error)
{
audio_format.format = SampleFormat::S16;
@@ -66,7 +66,7 @@ NormalizeFilter::Close()
const void *
NormalizeFilter::FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, gcc_unused GError **error_r)
+ size_t *dest_size_r, gcc_unused Error &error)
{
int16_t *dest = (int16_t *)buffer.Get(src_size);
memcpy(dest, src, src_size);
diff --git a/src/filter/NullFilterPlugin.cxx b/src/filter/NullFilterPlugin.cxx
index f76c05d3f..ad585d4b6 100644
--- a/src/filter/NullFilterPlugin.cxx
+++ b/src/filter/NullFilterPlugin.cxx
@@ -34,15 +34,15 @@
class NullFilter final : public Filter {
public:
virtual AudioFormat Open(AudioFormat &af,
- gcc_unused GError **error_r) {
+ gcc_unused Error &error) override {
return af;
}
- virtual void Close() {}
+ virtual void Close() override {}
virtual const void *FilterPCM(const void *src, size_t src_size,
size_t *dest_size_r,
- gcc_unused GError **error_r) {
+ gcc_unused Error &error) override {
*dest_size_r = src_size;
return src;
}
@@ -50,7 +50,7 @@ public:
static Filter *
null_filter_init(gcc_unused const config_param &param,
- gcc_unused GError **error_r)
+ gcc_unused Error &error)
{
return new NullFilter();
}
diff --git a/src/filter/ReplayGainFilterPlugin.cxx b/src/filter/ReplayGainFilterPlugin.cxx
index 446264c6e..0dd8905cb 100644
--- a/src/filter/ReplayGainFilterPlugin.cxx
+++ b/src/filter/ReplayGainFilterPlugin.cxx
@@ -28,6 +28,8 @@
#include "MixerControl.hxx"
#include "pcm/PcmVolume.hxx"
#include "pcm/PcmBuffer.hxx"
+#include "util/Error.hxx"
+#include "util/Domain.hxx"
#include <glib.h>
@@ -114,17 +116,13 @@ public:
*/
void Update();
- virtual AudioFormat Open(AudioFormat &af, GError **error_r) override;
+ virtual AudioFormat Open(AudioFormat &af, Error &error) override;
virtual void Close();
virtual const void *FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, GError **error_r);
+ size_t *dest_size_r, Error &error);
};
-static inline GQuark
-replay_gain_quark(void)
-{
- return g_quark_from_static_string("replay_gain");
-}
+static constexpr Domain replay_gain_domain("replay_gain");
void
ReplayGainFilter::Update()
@@ -145,24 +143,22 @@ ReplayGainFilter::Update()
if (_volume > 100)
_volume = 100;
- GError *error = NULL;
- if (!mixer_set_volume(mixer, _volume, &error)) {
+ Error error;
+ if (!mixer_set_volume(mixer, _volume, error))
g_warning("Failed to update hardware mixer: %s",
- error->message);
- g_error_free(error);
- }
+ error.GetMessage());
}
}
static Filter *
replay_gain_filter_init(gcc_unused const config_param &param,
- gcc_unused GError **error_r)
+ gcc_unused Error &error)
{
return new ReplayGainFilter();
}
AudioFormat
-ReplayGainFilter::Open(AudioFormat &af, gcc_unused GError **error_r)
+ReplayGainFilter::Open(AudioFormat &af, gcc_unused Error &error)
{
format = af;
@@ -177,7 +173,7 @@ ReplayGainFilter::Close()
const void *
ReplayGainFilter::FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, GError **error_r)
+ size_t *dest_size_r, Error &error)
{
*dest_size_r = src_size;
@@ -201,8 +197,7 @@ ReplayGainFilter::FilterPCM(const void *src, size_t src_size,
format.format,
volume);
if (!success) {
- g_set_error(error_r, replay_gain_quark(), 0,
- "pcm_volume() has failed");
+ error.Set(replay_gain_domain, "pcm_volume() has failed");
return NULL;
}
diff --git a/src/filter/RouteFilterPlugin.cxx b/src/filter/RouteFilterPlugin.cxx
index 2c0d60cbe..20ef5e963 100644
--- a/src/filter/RouteFilterPlugin.cxx
+++ b/src/filter/RouteFilterPlugin.cxx
@@ -41,13 +41,16 @@
#include "config.h"
#include "conf.h"
-#include "ConfigQuark.hxx"
+#include "ConfigError.hxx"
#include "AudioFormat.hxx"
#include "CheckAudioFormat.hxx"
#include "FilterPlugin.hxx"
#include "FilterInternal.hxx"
#include "FilterRegistry.hxx"
#include "pcm/PcmBuffer.hxx"
+#include "util/Error.hxx"
+
+#include <glib.h>
#include <assert.h>
#include <string.h>
@@ -118,16 +121,16 @@ public:
* @param filter a route_filter whose min_channels and sources[] to set
* @return true on success, false on error
*/
- bool Configure(const config_param &param, GError **error_r);
+ bool Configure(const config_param &param, Error &error);
- virtual AudioFormat Open(AudioFormat &af, GError **error_r) override;
+ virtual AudioFormat Open(AudioFormat &af, Error &error) override;
virtual void Close();
virtual const void *FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, GError **error_r);
+ size_t *dest_size_r, Error &error);
};
bool
-RouteFilter::Configure(const config_param &param, GError **error_r) {
+RouteFilter::Configure(const config_param &param, Error &error) {
/* TODO:
* With a more clever way of marking "don't copy to output N",
@@ -160,9 +163,9 @@ RouteFilter::Configure(const config_param &param, GError **error_r) {
// Split the a>b string into source and destination
sd = g_strsplit(tokens[c], ">", 2);
if (g_strv_length(sd) != 2) {
- g_set_error(error_r, config_quark(), 1,
- "Invalid copy around %d in routes spec: %s",
- param.line, tokens[c]);
+ error.Format(config_domain,
+ "Invalid copy around %d in routes spec: %s",
+ param.line, tokens[c]);
g_strfreev(sd);
g_strfreev(tokens);
return false;
@@ -183,9 +186,9 @@ RouteFilter::Configure(const config_param &param, GError **error_r) {
if (!audio_valid_channel_count(min_output_channels)) {
g_strfreev(tokens);
- g_set_error(error_r, audio_format_quark(), 0,
- "Invalid number of output channels requested: %d",
- min_output_channels);
+ error.Format(config_domain,
+ "Invalid number of output channels requested: %d",
+ min_output_channels);
return false;
}
@@ -207,9 +210,9 @@ RouteFilter::Configure(const config_param &param, GError **error_r) {
// Split the a>b string into source and destination
sd = g_strsplit(tokens[c], ">", 2);
if (g_strv_length(sd) != 2) {
- g_set_error(error_r, config_quark(), 1,
- "Invalid copy around %d in routes spec: %s",
- param.line, tokens[c]);
+ error.Format(config_domain,
+ "Invalid copy around %d in routes spec: %s",
+ param.line, tokens[c]);
g_strfreev(sd);
g_strfreev(tokens);
return false;
@@ -229,10 +232,10 @@ RouteFilter::Configure(const config_param &param, GError **error_r) {
}
static Filter *
-route_filter_init(const config_param &param, GError **error_r)
+route_filter_init(const config_param &param, Error &error)
{
RouteFilter *filter = new RouteFilter();
- if (!filter->Configure(param, error_r)) {
+ if (!filter->Configure(param, error)) {
delete filter;
return nullptr;
}
@@ -241,7 +244,7 @@ route_filter_init(const config_param &param, GError **error_r)
}
AudioFormat
-RouteFilter::Open(AudioFormat &audio_format, gcc_unused GError **error_r)
+RouteFilter::Open(AudioFormat &audio_format, gcc_unused Error &error)
{
// Copy the input format for later reference
input_format = audio_format;
@@ -266,7 +269,7 @@ RouteFilter::Close()
const void *
RouteFilter::FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, gcc_unused GError **error_r)
+ size_t *dest_size_r, gcc_unused Error &error)
{
size_t number_of_frames = src_size / input_frame_size;
diff --git a/src/filter/VolumeFilterPlugin.cxx b/src/filter/VolumeFilterPlugin.cxx
index 239f0b899..4c51ac599 100644
--- a/src/filter/VolumeFilterPlugin.cxx
+++ b/src/filter/VolumeFilterPlugin.cxx
@@ -26,6 +26,8 @@
#include "pcm/PcmVolume.hxx"
#include "pcm/PcmBuffer.hxx"
#include "AudioFormat.hxx"
+#include "util/Error.hxx"
+#include "util/Domain.hxx"
#include <glib.h>
@@ -58,27 +60,23 @@ public:
volume = _volume;
}
- virtual AudioFormat Open(AudioFormat &af, GError **error_r) override;
+ virtual AudioFormat Open(AudioFormat &af, Error &error) override;
virtual void Close();
virtual const void *FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, GError **error_r);
+ size_t *dest_size_r, Error &error);
};
-static inline GQuark
-volume_quark(void)
-{
- return g_quark_from_static_string("pcm_volume");
-}
+static constexpr Domain volume_domain("pcm_volume");
static Filter *
volume_filter_init(gcc_unused const config_param &param,
- gcc_unused GError **error_r)
+ gcc_unused Error &error)
{
return new VolumeFilter();
}
AudioFormat
-VolumeFilter::Open(AudioFormat &audio_format, gcc_unused GError **error_r)
+VolumeFilter::Open(AudioFormat &audio_format, gcc_unused Error &error)
{
format = audio_format;
@@ -93,7 +91,7 @@ VolumeFilter::Close()
const void *
VolumeFilter::FilterPCM(const void *src, size_t src_size,
- size_t *dest_size_r, GError **error_r)
+ size_t *dest_size_r, Error &error)
{
*dest_size_r = src_size;
@@ -117,8 +115,7 @@ VolumeFilter::FilterPCM(const void *src, size_t src_size,
format.format,
volume);
if (!success) {
- g_set_error(error_r, volume_quark(), 0,
- "pcm_volume() has failed");
+ error.Set(volume_domain, "pcm_volume() has failed");
return NULL;
}