output/solaris: convert to C++
This commit is contained in:
parent
750b2ad6a8
commit
4aeec4bb60
@ -880,7 +880,7 @@ endif
|
|||||||
|
|
||||||
if ENABLE_SOLARIS_OUTPUT
|
if ENABLE_SOLARIS_OUTPUT
|
||||||
liboutput_plugins_a_SOURCES += \
|
liboutput_plugins_a_SOURCES += \
|
||||||
src/output/solaris_output_plugin.c src/output/solaris_output_plugin.h
|
src/output/SolarisOutputPlugin.cxx src/output/SolarisOutputPlugin.hxx
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ENABLE_WINMM_OUTPUT
|
if ENABLE_WINMM_OUTPUT
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "output/RecorderOutputPlugin.hxx"
|
#include "output/RecorderOutputPlugin.hxx"
|
||||||
#include "output/RoarOutputPlugin.hxx"
|
#include "output/RoarOutputPlugin.hxx"
|
||||||
#include "output/ShoutOutputPlugin.hxx"
|
#include "output/ShoutOutputPlugin.hxx"
|
||||||
#include "output/solaris_output_plugin.h"
|
#include "output/SolarisOutputPlugin.hxx"
|
||||||
#include "output/WinmmOutputPlugin.hxx"
|
#include "output/WinmmOutputPlugin.hxx"
|
||||||
|
|
||||||
const struct audio_output_plugin *const audio_output_plugins[] = {
|
const struct audio_output_plugin *const audio_output_plugins[] = {
|
||||||
|
@ -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,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "solaris_output_plugin.h"
|
#include "SolarisOutputPlugin.hxx"
|
||||||
#include "output_api.h"
|
#include "output_api.h"
|
||||||
#include "fd_util.h"
|
#include "fd_util.h"
|
||||||
|
|
||||||
@ -53,13 +53,22 @@ struct audio_info {
|
|||||||
#undef G_LOG_DOMAIN
|
#undef G_LOG_DOMAIN
|
||||||
#define G_LOG_DOMAIN "solaris_output"
|
#define G_LOG_DOMAIN "solaris_output"
|
||||||
|
|
||||||
struct solaris_output {
|
struct SolarisOutput {
|
||||||
struct audio_output base;
|
struct audio_output base;
|
||||||
|
|
||||||
/* configuration */
|
/* configuration */
|
||||||
const char *device;
|
const char *device;
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
bool Initialize(const config_param *param, GError **error_r) {
|
||||||
|
return ao_base_init(&base, &solaris_output_plugin, param,
|
||||||
|
error_r);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Deinitialize() {
|
||||||
|
ao_base_finish(&base);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,13 +90,12 @@ solaris_output_test_default_device(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
solaris_output_init(const struct config_param *param, GError **error_r)
|
solaris_output_init(const config_param *param, GError **error_r)
|
||||||
{
|
{
|
||||||
struct solaris_output *so = g_new(struct solaris_output, 1);
|
SolarisOutput *so = new SolarisOutput();
|
||||||
|
if (!so->Initialize(param, error_r)) {
|
||||||
if (!ao_base_init(&so->base, &solaris_output_plugin, param, error_r)) {
|
delete so;
|
||||||
g_free(so);
|
return nullptr;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
so->device = config_get_block_string(param, "device", "/dev/audio");
|
so->device = config_get_block_string(param, "device", "/dev/audio");
|
||||||
@ -98,17 +106,17 @@ solaris_output_init(const struct config_param *param, GError **error_r)
|
|||||||
static void
|
static void
|
||||||
solaris_output_finish(struct audio_output *ao)
|
solaris_output_finish(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
struct solaris_output *so = (struct solaris_output *)ao;
|
SolarisOutput *so = (SolarisOutput *)ao;
|
||||||
|
|
||||||
ao_base_finish(&so->base);
|
so->Deinitialize();
|
||||||
g_free(so);
|
delete so;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
solaris_output_open(struct audio_output *ao, struct audio_format *audio_format,
|
solaris_output_open(struct audio_output *ao, struct audio_format *audio_format,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
struct solaris_output *so = (struct solaris_output *)ao;
|
SolarisOutput *so = (SolarisOutput *)ao;
|
||||||
struct audio_info info;
|
struct audio_info info;
|
||||||
int ret, flags;
|
int ret, flags;
|
||||||
|
|
||||||
@ -161,7 +169,7 @@ solaris_output_open(struct audio_output *ao, struct audio_format *audio_format,
|
|||||||
static void
|
static void
|
||||||
solaris_output_close(struct audio_output *ao)
|
solaris_output_close(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
struct solaris_output *so = (struct solaris_output *)ao;
|
SolarisOutput *so = (SolarisOutput *)ao;
|
||||||
|
|
||||||
close(so->fd);
|
close(so->fd);
|
||||||
}
|
}
|
||||||
@ -170,7 +178,7 @@ static size_t
|
|||||||
solaris_output_play(struct audio_output *ao, const void *chunk, size_t size,
|
solaris_output_play(struct audio_output *ao, const void *chunk, size_t size,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
struct solaris_output *so = (struct solaris_output *)ao;
|
SolarisOutput *so = (SolarisOutput *)ao;
|
||||||
ssize_t nbytes;
|
ssize_t nbytes;
|
||||||
|
|
||||||
nbytes = write(so->fd, chunk, size);
|
nbytes = write(so->fd, chunk, size);
|
||||||
@ -186,18 +194,25 @@ solaris_output_play(struct audio_output *ao, const void *chunk, size_t size,
|
|||||||
static void
|
static void
|
||||||
solaris_output_cancel(struct audio_output *ao)
|
solaris_output_cancel(struct audio_output *ao)
|
||||||
{
|
{
|
||||||
struct solaris_output *so = (struct solaris_output *)ao;
|
SolarisOutput *so = (SolarisOutput *)ao;
|
||||||
|
|
||||||
ioctl(so->fd, I_FLUSH);
|
ioctl(so->fd, I_FLUSH);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct audio_output_plugin solaris_output_plugin = {
|
const struct audio_output_plugin solaris_output_plugin = {
|
||||||
.name = "solaris",
|
"solaris",
|
||||||
.test_default_device = solaris_output_test_default_device,
|
solaris_output_test_default_device,
|
||||||
.init = solaris_output_init,
|
solaris_output_init,
|
||||||
.finish = solaris_output_finish,
|
solaris_output_finish,
|
||||||
.open = solaris_output_open,
|
nullptr,
|
||||||
.close = solaris_output_close,
|
nullptr,
|
||||||
.play = solaris_output_play,
|
solaris_output_open,
|
||||||
.cancel = solaris_output_cancel,
|
solaris_output_close,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
solaris_output_play,
|
||||||
|
nullptr,
|
||||||
|
solaris_output_cancel,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
};
|
};
|
@ -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
|
||||||
@ -17,8 +17,8 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MPD_SOLARIS_OUTPUT_PLUGIN_H
|
#ifndef MPD_SOLARIS_OUTPUT_PLUGIN_HXX
|
||||||
#define MPD_SOLARIS_OUTPUT_PLUGIN_H
|
#define MPD_SOLARIS_OUTPUT_PLUGIN_HXX
|
||||||
|
|
||||||
extern const struct audio_output_plugin solaris_output_plugin;
|
extern const struct audio_output_plugin solaris_output_plugin;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user