decoder/pcm: convert to C++
This commit is contained in:
@ -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
|
|||||||
# 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 @@
|
|||||||
#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"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 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 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#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 @@
|
|||||||
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[] = {
|
|||||||
/* 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,
|
||||||
};
|
};
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 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 @@
|
|||||||
* 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;
|
||||||
|
|
Reference in New Issue
Block a user