Commit 975deca8 authored by Max Kellermann's avatar Max Kellermann

{decoder,player}_thread: convert to C++

parent 3bbb5023
...@@ -72,7 +72,6 @@ mpd_headers = \ ...@@ -72,7 +72,6 @@ mpd_headers = \
src/cmdline.h \ src/cmdline.h \
src/conf.h \ src/conf.h \
src/crossfade.h \ src/crossfade.h \
src/decoder_thread.h \
src/decoder_control.h \ src/decoder_control.h \
src/decoder_plugin.h \ src/decoder_plugin.h \
src/decoder_command.h \ src/decoder_command.h \
...@@ -137,7 +136,6 @@ mpd_headers = \ ...@@ -137,7 +136,6 @@ mpd_headers = \
src/output/httpd_internal.h \ src/output/httpd_internal.h \
src/page.h \ src/page.h \
src/permission.h \ src/permission.h \
src/player_thread.h \
src/player_control.h \ src/player_control.h \
src/playlist.h \ src/playlist.h \
src/playlist_error.h \ src/playlist_error.h \
...@@ -224,7 +222,7 @@ src_mpd_SOURCES = \ ...@@ -224,7 +222,7 @@ src_mpd_SOURCES = \
src/crossfade.c \ src/crossfade.c \
src/cue/cue_parser.c src/cue/cue_parser.h \ src/cue/cue_parser.c src/cue/cue_parser.h \
src/decoder_error.h \ src/decoder_error.h \
src/decoder_thread.c \ src/DecoderThread.cxx src/DecoderThread.hxx \
src/decoder_control.c \ src/decoder_control.c \
src/decoder_api.c \ src/decoder_api.c \
src/decoder_internal.c \ src/decoder_internal.c \
...@@ -291,7 +289,7 @@ src_mpd_SOURCES = \ ...@@ -291,7 +289,7 @@ src_mpd_SOURCES = \
src/mapper.c \ src/mapper.c \
src/page.c \ src/page.c \
src/permission.c \ src/permission.c \
src/player_thread.c \ src/PlayerThread.cxx src/PlayerThread.hxx \
src/player_control.c \ src/player_control.c \
src/playlist.c \ src/playlist.c \
src/playlist_global.c \ src/playlist_global.c \
......
/* /*
* 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,22 +18,23 @@ ...@@ -18,22 +18,23 @@
*/ */
#include "config.h" #include "config.h"
#include "decoder_thread.h" #include "DecoderThread.hxx"
#include "decoder_error.h" #include "decoder_error.h"
#include "decoder_plugin.h"
#include "song.h"
#include "mpd_error.h"
extern "C" {
#include "decoder_control.h" #include "decoder_control.h"
#include "decoder_internal.h" #include "decoder_internal.h"
#include "decoder_list.h" #include "decoder_list.h"
#include "decoder_plugin.h"
#include "decoder_api.h" #include "decoder_api.h"
#include "replay_gain_ape.h" #include "replay_gain_ape.h"
#include "input_stream.h" #include "input_stream.h"
#include "pipe.h"
#include "song.h"
#include "tag.h" #include "tag.h"
#include "mapper.h" #include "mapper.h"
#include "path.h"
#include "uri.h" #include "uri.h"
#include "mpd_error.h" }
#include <glib.h> #include <glib.h>
...@@ -183,12 +184,7 @@ decoder_file_decode(const struct decoder_plugin *plugin, ...@@ -183,12 +184,7 @@ decoder_file_decode(const struct decoder_plugin *plugin,
static inline gpointer static inline gpointer
deconst_plugin(const struct decoder_plugin *plugin) deconst_plugin(const struct decoder_plugin *plugin)
{ {
union { return const_cast<struct decoder_plugin *>(plugin);
const struct decoder_plugin *in;
gpointer out;
} u = { .in = plugin };
return u.out;
} }
/** /**
...@@ -384,11 +380,7 @@ static void ...@@ -384,11 +380,7 @@ static void
decoder_run_song(struct decoder_control *dc, decoder_run_song(struct decoder_control *dc,
const struct song *song, const char *uri) const struct song *song, const char *uri)
{ {
struct decoder decoder = { decoder decoder(dc, dc->start_ms > 0);
.dc = dc,
.initial_seek_pending = dc->start_ms > 0,
.initial_seek_running = false,
};
int ret; int ret;
decoder.timestamp = 0.0; decoder.timestamp = 0.0;
...@@ -477,7 +469,7 @@ decoder_run(struct decoder_control *dc) ...@@ -477,7 +469,7 @@ decoder_run(struct decoder_control *dc)
static gpointer static gpointer
decoder_task(gpointer arg) decoder_task(gpointer arg)
{ {
struct decoder_control *dc = arg; struct decoder_control *dc = (struct decoder_control *)arg;
decoder_lock(dc); decoder_lock(dc);
......
/* /*
* 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 @@ ...@@ -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_DECODER_THREAD_H #ifndef MPD_DECODER_THREAD_HXX
#define MPD_DECODER_THREAD_H #define MPD_DECODER_THREAD_HXX
struct decoder_control; struct decoder_control;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "UpdateGlue.hxx" #include "UpdateGlue.hxx"
#include "chunk.h" #include "chunk.h"
#include "StateFile.hxx" #include "StateFile.hxx"
#include "PlayerThread.hxx"
extern "C" { extern "C" {
#include "daemon.h" #include "daemon.h"
...@@ -33,7 +34,6 @@ extern "C" { ...@@ -33,7 +34,6 @@ extern "C" {
#include "AllCommands.h" #include "AllCommands.h"
#include "playlist.h" #include "playlist.h"
#include "database.h" #include "database.h"
#include "player_thread.h"
#include "listen.h" #include "listen.h"
#include "cmdline.h" #include "cmdline.h"
#include "conf.h" #include "conf.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,23 +18,24 @@ ...@@ -18,23 +18,24 @@
*/ */
#include "config.h" #include "config.h"
#include "player_thread.h" #include "PlayerThread.hxx"
#include "DecoderThread.hxx"
#include "song.h"
#include "Main.hxx"
#include "mpd_error.h"
extern "C" {
#include "player_control.h" #include "player_control.h"
#include "decoder_control.h" #include "decoder_control.h"
#include "decoder_thread.h"
#include "output_all.h" #include "output_all.h"
#include "pcm_volume.h"
#include "path.h"
#include "event_pipe.h" #include "event_pipe.h"
#include "crossfade.h" #include "crossfade.h"
#include "song.h"
#include "tag.h" #include "tag.h"
#include "pipe.h" #include "pipe.h"
#include "chunk.h" #include "chunk.h"
#include "idle.h" #include "idle.h"
#include "Main.hxx"
#include "buffer.h" #include "buffer.h"
#include "mpd_error.h" }
#include <glib.h> #include <glib.h>
...@@ -123,6 +124,20 @@ struct player { ...@@ -123,6 +124,20 @@ struct player {
* precisely. * precisely.
*/ */
float elapsed_time; float elapsed_time;
player(player_control *_pc, decoder_control *_dc)
:pc(_pc), dc(_dc),
buffering(false),
decoder_starting(false),
paused(false),
queued(true),
output_open(false),
song(NULL),
xfade(XFADE_UNKNOWN),
cross_fading(false),
cross_fade_chunks(0),
cross_fade_tag(NULL),
elapsed_time(0.0) {}
}; };
static struct music_buffer *player_buffer; static struct music_buffer *player_buffer;
...@@ -882,21 +897,7 @@ player_song_border(struct player *player) ...@@ -882,21 +897,7 @@ player_song_border(struct player *player)
*/ */
static void do_play(struct player_control *pc, struct decoder_control *dc) static void do_play(struct player_control *pc, struct decoder_control *dc)
{ {
struct player player = { player player(pc, dc);
.pc = pc,
.dc = dc,
.buffering = true,
.decoder_starting = false,
.paused = false,
.queued = true,
.output_open = false,
.song = NULL,
.xfade = XFADE_UNKNOWN,
.cross_fading = false,
.cross_fade_chunks = 0,
.cross_fade_tag = NULL,
.elapsed_time = 0.0,
};
player_unlock(pc); player_unlock(pc);
...@@ -1094,7 +1095,7 @@ static void do_play(struct player_control *pc, struct decoder_control *dc) ...@@ -1094,7 +1095,7 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
static gpointer static gpointer
player_task(gpointer arg) player_task(gpointer arg)
{ {
struct player_control *pc = arg; struct player_control *pc = (struct player_control *)arg;
struct decoder_control *dc = dc_new(pc->cond); struct decoder_control *dc = dc_new(pc->cond);
decoder_thread_start(dc); decoder_thread_start(dc);
......
/* /*
* 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
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
* #music_chunk instances around in #music_pipe objects. * #music_chunk instances around in #music_pipe objects.
*/ */
#ifndef MPD_PLAYER_THREAD_H #ifndef MPD_PLAYER_THREAD_HXX
#define MPD_PLAYER_THREAD_H #define MPD_PLAYER_THREAD_HXX
struct player_control; struct player_control;
......
...@@ -80,6 +80,13 @@ struct decoder { ...@@ -80,6 +80,13 @@ struct decoder {
* has changed since the last check. * has changed since the last check.
*/ */
unsigned replay_gain_serial; unsigned replay_gain_serial;
#ifdef __cplusplus
decoder(decoder_control *_dc, bool _initial_seek_pending)
:dc(_dc),
initial_seek_pending(_initial_seek_pending),
initial_seek_running(false) {}
#endif
}; };
/** /**
......
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