Commit 6b6d9e64 authored by Max Kellermann's avatar Max Kellermann

decoder/pcm: convert to C++

parent f016a99f
...@@ -68,7 +68,6 @@ mpd_headers = \ ...@@ -68,7 +68,6 @@ mpd_headers = \
src/gerror.h \ src/gerror.h \
src/glib_compat.h \ src/glib_compat.h \
src/gcc.h \ src/gcc.h \
src/decoder/pcm_decoder_plugin.h \
src/input_stream.h \ src/input_stream.h \
src/TextInputStream.hxx \ src/TextInputStream.hxx \
src/ls.h \ src/ls.h \
...@@ -447,7 +446,8 @@ endif ...@@ -447,7 +446,8 @@ endif
# decoder plugins # decoder plugins
libdecoder_plugins_a_SOURCES = \ libdecoder_plugins_a_SOURCES = \
src/decoder/pcm_decoder_plugin.c \ src/decoder/PcmDecoderPlugin.cxx \
src/decoder/PcmDecoderPlugin.hxx \
src/decoder/DsdiffDecoderPlugin.cxx \ src/decoder/DsdiffDecoderPlugin.cxx \
src/decoder/DsdiffDecoderPlugin.hxx \ src/decoder/DsdiffDecoderPlugin.hxx \
src/decoder/DsfDecoderPlugin.cxx \ src/decoder/DsfDecoderPlugin.cxx \
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "conf.h" #include "conf.h"
#include "mpd_error.h" #include "mpd_error.h"
#include "decoder/AudiofileDecoderPlugin.hxx" #include "decoder/AudiofileDecoderPlugin.hxx"
#include "decoder/pcm_decoder_plugin.h" #include "decoder/PcmDecoderPlugin.hxx"
#include "decoder/DsdiffDecoderPlugin.hxx" #include "decoder/DsdiffDecoderPlugin.hxx"
#include "decoder/DsfDecoderPlugin.hxx" #include "decoder/DsfDecoderPlugin.hxx"
#include "decoder/FlacDecoderPlugin.h" #include "decoder/FlacDecoderPlugin.h"
......
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -18,9 +18,12 @@ ...@@ -18,9 +18,12 @@
*/ */
#include "config.h" #include "config.h"
#include "decoder/pcm_decoder_plugin.h" #include "decoder/PcmDecoderPlugin.hxx"
#include "decoder_api.h" #include "decoder_api.h"
extern "C" {
#include "util/byte_reverse.h" #include "util/byte_reverse.h"
}
#include <glib.h> #include <glib.h>
#include <unistd.h> #include <unistd.h>
...@@ -32,17 +35,17 @@ ...@@ -32,17 +35,17 @@
static void static void
pcm_stream_decode(struct decoder *decoder, struct input_stream *is) pcm_stream_decode(struct decoder *decoder, struct input_stream *is)
{ {
static const struct audio_format audio_format = { static constexpr struct audio_format audio_format = {
.sample_rate = 44100, 44100,
.format = SAMPLE_FORMAT_S16, SAMPLE_FORMAT_S16,
.channels = 2, 2,
}; };
const char *const mime = input_stream_get_mime_type(is); const char *const mime = input_stream_get_mime_type(is);
const bool reverse_endian = mime != NULL && const bool reverse_endian = mime != nullptr &&
strcmp(mime, "audio/x-mpd-cdda-pcm-reverse") == 0; strcmp(mime, "audio/x-mpd-cdda-pcm-reverse") == 0;
GError *error = NULL; GError *error = nullptr;
enum decoder_command cmd; enum decoder_command cmd;
double time_to_size = audio_format_time_to_size(&audio_format); double time_to_size = audio_format_time_to_size(&audio_format);
...@@ -98,11 +101,18 @@ static const char *const pcm_mime_types[] = { ...@@ -98,11 +101,18 @@ static const char *const pcm_mime_types[] = {
/* same as above, but with reverse byte order */ /* same as above, but with reverse byte order */
"audio/x-mpd-cdda-pcm-reverse", "audio/x-mpd-cdda-pcm-reverse",
NULL nullptr
}; };
const struct decoder_plugin pcm_decoder_plugin = { const struct decoder_plugin pcm_decoder_plugin = {
.name = "pcm", "pcm",
.stream_decode = pcm_stream_decode, nullptr,
.mime_types = pcm_mime_types, nullptr,
pcm_stream_decode,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
pcm_mime_types,
}; };
/* /*
* Copyright (C) 2003-2011 The Music Player Daemon Project * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org * http://www.musicpd.org
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
* which does not need a decoder. * which does not need a decoder.
*/ */
#ifndef MPD_DECODER_PCM_H #ifndef MPD_DECODER_PCM_HXX
#define MPD_DECODER_PCM_H #define MPD_DECODER_PCM_HXX
extern const struct decoder_plugin pcm_decoder_plugin; extern const struct decoder_plugin pcm_decoder_plugin;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment