Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
9ede4c5f
Commit
9ede4c5f
authored
Feb 22, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{output,mixer}/winmm: convert to C++
parent
214a5269
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
57 deletions
+68
-57
Makefile.am
Makefile.am
+2
-2
OutputList.cxx
src/OutputList.cxx
+1
-1
WinmmMixerPlugin.cxx
src/mixer/WinmmMixerPlugin.cxx
+12
-9
WinmmOutputPlugin.cxx
src/output/WinmmOutputPlugin.cxx
+44
-40
WinmmOutputPlugin.hxx
src/output/WinmmOutputPlugin.hxx
+9
-5
No files found.
Makefile.am
View file @
9ede4c5f
...
...
@@ -903,8 +903,8 @@ endif
if
ENABLE_WINMM_OUTPUT
liboutput_plugins_a_SOURCES
+=
\
src/output/
winmm_output_plugin.c src/output/winmm_output_plugin.h
libmixer_plugins_a_SOURCES
+=
src/mixer/
winmm_mixer_plugin.c
src/output/
WinmmOutputPlugin.cxx src/output/WinmmOutputPlugin.hxx
libmixer_plugins_a_SOURCES
+=
src/mixer/
WinmmMixerPlugin.cxx
endif
...
...
src/OutputList.cxx
View file @
9ede4c5f
...
...
@@ -37,7 +37,7 @@
#include "output/RoarOutputPlugin.hxx"
#include "output/shout_output_plugin.h"
#include "output/solaris_output_plugin.h"
#include "output/
winmm_output_plugin.h
"
#include "output/
WinmmOutputPlugin.hxx
"
const
struct
audio_output_plugin
*
const
audio_output_plugins
[]
=
{
#ifdef HAVE_SHOUT
...
...
src/mixer/
winmm_mixer_plugin.c
→
src/mixer/
WinmmMixerPlugin.cxx
View file @
9ede4c5f
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -20,7 +20,7 @@
#include "config.h"
#include "mixer_api.h"
#include "output_api.h"
#include "output/
winmm_output_plugin.h
"
#include "output/
WinmmOutputPlugin.hxx
"
#include <mmsystem.h>
...
...
@@ -33,7 +33,7 @@
struct
winmm_mixer
{
struct
mixer
base
;
struct
winmm_o
utput
*
output
;
WinmmO
utput
*
output
;
};
static
inline
GQuark
...
...
@@ -59,11 +59,11 @@ static struct mixer *
winmm_mixer_init
(
void
*
ao
,
G_GNUC_UNUSED
const
struct
config_param
*
param
,
G_GNUC_UNUSED
GError
**
error_r
)
{
assert
(
ao
!=
NULL
);
assert
(
ao
!=
nullptr
);
struct
winmm_mixer
*
wm
=
g_new
(
struct
winmm_mixer
,
1
);
mixer_init
(
&
wm
->
base
,
&
winmm_mixer_plugin
);
wm
->
output
=
(
struct
winmm_o
utput
*
)
ao
;
wm
->
output
=
(
WinmmO
utput
*
)
ao
;
return
&
wm
->
base
;
}
...
...
@@ -109,8 +109,11 @@ winmm_mixer_set_volume(struct mixer *mixer, unsigned volume, GError **error_r)
}
const
struct
mixer_plugin
winmm_mixer_plugin
=
{
.
init
=
winmm_mixer_init
,
.
finish
=
winmm_mixer_finish
,
.
get_volume
=
winmm_mixer_get_volume
,
.
set_volume
=
winmm_mixer_set_volume
,
winmm_mixer_init
,
winmm_mixer_finish
,
nullptr
,
nullptr
,
winmm_mixer_get_volume
,
winmm_mixer_set_volume
,
false
,
};
src/output/
winmm_output_plugin.c
→
src/output/
WinmmOutputPlugin.cxx
View file @
9ede4c5f
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,11 +18,10 @@
*/
#include "config.h"
#include "
winmm_output_plugin.h
"
#include "
WinmmOutputPlugin.hxx
"
#include "output_api.h"
#include "pcm_buffer.h"
#include "mixer_list.h"
#include "winmm_output_plugin.h"
#include <stdlib.h>
#include <string.h>
...
...
@@ -30,13 +29,13 @@
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "winmm_output"
struct
winmm_b
uffer
{
struct
WinmmB
uffer
{
struct
pcm_buffer
buffer
;
WAVEHDR
hdr
;
};
struct
winmm_o
utput
{
struct
WinmmO
utput
{
struct
audio_output
base
;
UINT
device_id
;
...
...
@@ -48,7 +47,7 @@ struct winmm_output {
*/
HANDLE
event
;
struct
winmm_b
uffer
buffers
[
8
];
WinmmB
uffer
buffers
[
8
];
unsigned
next_buffer
;
};
...
...
@@ -62,7 +61,7 @@ winmm_output_quark(void)
}
HWAVEOUT
winmm_output_get_handle
(
struct
winmm_output
*
output
)
winmm_output_get_handle
(
WinmmOutput
*
output
)
{
return
output
->
handle
;
}
...
...
@@ -77,7 +76,7 @@ static bool
get_device_id
(
const
char
*
device_name
,
UINT
*
device_id
,
GError
**
error_r
)
{
/* if device is not specified use wave mapper */
if
(
device_name
==
NULL
)
{
if
(
device_name
==
nullptr
)
{
*
device_id
=
WAVE_MAPPER
;
return
true
;
}
...
...
@@ -117,17 +116,17 @@ fail:
static
struct
audio_output
*
winmm_output_init
(
const
struct
config_param
*
param
,
GError
**
error_r
)
{
struct
winmm_output
*
wo
=
g_new
(
struct
winmm_output
,
1
);
WinmmOutput
*
wo
=
new
WinmmOutput
(
);
if
(
!
ao_base_init
(
&
wo
->
base
,
&
winmm_output_plugin
,
param
,
error_r
))
{
g_free
(
wo
);
return
NULL
;
return
nullptr
;
}
const
char
*
device
=
config_get_block_string
(
param
,
"device"
,
NULL
);
const
char
*
device
=
config_get_block_string
(
param
,
"device"
,
nullptr
);
if
(
!
get_device_id
(
device
,
&
wo
->
device_id
,
error_r
))
{
ao_base_finish
(
&
wo
->
base
);
g_free
(
wo
);
return
NULL
;
return
nullptr
;
}
return
&
wo
->
base
;
...
...
@@ -136,20 +135,20 @@ winmm_output_init(const struct config_param *param, GError **error_r)
static
void
winmm_output_finish
(
struct
audio_output
*
ao
)
{
struct
winmm_output
*
wo
=
(
struct
winmm_o
utput
*
)
ao
;
WinmmOutput
*
wo
=
(
WinmmO
utput
*
)
ao
;
ao_base_finish
(
&
wo
->
base
);
g_free
(
wo
)
;
delete
wo
;
}
static
bool
winmm_output_open
(
struct
audio_output
*
ao
,
struct
audio_format
*
audio_format
,
GError
**
error_r
)
{
struct
winmm_output
*
wo
=
(
struct
winmm_o
utput
*
)
ao
;
WinmmOutput
*
wo
=
(
WinmmO
utput
*
)
ao
;
wo
->
event
=
CreateEvent
(
NULL
,
false
,
false
,
NULL
);
if
(
wo
->
event
==
NULL
)
{
wo
->
event
=
CreateEvent
(
nullptr
,
false
,
false
,
nullptr
);
if
(
wo
->
event
==
nullptr
)
{
g_set_error
(
error_r
,
winmm_output_quark
(),
0
,
"CreateEvent() failed"
);
return
false
;
...
...
@@ -203,7 +202,7 @@ winmm_output_open(struct audio_output *ao, struct audio_format *audio_format,
static
void
winmm_output_close
(
struct
audio_output
*
ao
)
{
struct
winmm_output
*
wo
=
(
struct
winmm_o
utput
*
)
ao
;
WinmmOutput
*
wo
=
(
WinmmO
utput
*
)
ao
;
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
wo
->
buffers
);
++
i
)
pcm_buffer_deinit
(
&
wo
->
buffers
[
i
].
buffer
);
...
...
@@ -217,17 +216,17 @@ winmm_output_close(struct audio_output *ao)
* Copy data into a buffer, and prepare the wave header.
*/
static
bool
winmm_set_buffer
(
struct
winmm_output
*
wo
,
struct
winmm_b
uffer
*
buffer
,
winmm_set_buffer
(
WinmmOutput
*
wo
,
WinmmB
uffer
*
buffer
,
const
void
*
data
,
size_t
size
,
GError
**
error_r
)
{
void
*
dest
=
pcm_buffer_get
(
&
buffer
->
buffer
,
size
);
assert
(
dest
!=
NULL
);
assert
(
dest
!=
nullptr
);
memcpy
(
dest
,
data
,
size
);
memset
(
&
buffer
->
hdr
,
0
,
sizeof
(
buffer
->
hdr
));
buffer
->
hdr
.
lpData
=
dest
;
buffer
->
hdr
.
lpData
=
(
LPSTR
)
dest
;
buffer
->
hdr
.
dwBufferLength
=
size
;
MMRESULT
result
=
waveOutPrepareHeader
(
wo
->
handle
,
&
buffer
->
hdr
,
...
...
@@ -245,7 +244,7 @@ winmm_set_buffer(struct winmm_output *wo, struct winmm_buffer *buffer,
* Wait until the buffer is finished.
*/
static
bool
winmm_drain_buffer
(
struct
winmm_output
*
wo
,
struct
winmm_b
uffer
*
buffer
,
winmm_drain_buffer
(
WinmmOutput
*
wo
,
WinmmB
uffer
*
buffer
,
GError
**
error_r
)
{
if
((
buffer
->
hdr
.
dwFlags
&
WHDR_DONE
)
==
WHDR_DONE
)
...
...
@@ -272,10 +271,10 @@ winmm_drain_buffer(struct winmm_output *wo, struct winmm_buffer *buffer,
static
size_t
winmm_output_play
(
struct
audio_output
*
ao
,
const
void
*
chunk
,
size_t
size
,
GError
**
error_r
)
{
struct
winmm_output
*
wo
=
(
struct
winmm_o
utput
*
)
ao
;
WinmmOutput
*
wo
=
(
WinmmO
utput
*
)
ao
;
/* get the next buffer from the ring and prepare it */
struct
winmm_b
uffer
*
buffer
=
&
wo
->
buffers
[
wo
->
next_buffer
];
WinmmB
uffer
*
buffer
=
&
wo
->
buffers
[
wo
->
next_buffer
];
if
(
!
winmm_drain_buffer
(
wo
,
buffer
,
error_r
)
||
!
winmm_set_buffer
(
wo
,
buffer
,
chunk
,
size
,
error_r
))
return
0
;
...
...
@@ -299,7 +298,7 @@ winmm_output_play(struct audio_output *ao, const void *chunk, size_t size, GErro
}
static
bool
winmm_drain_all_buffers
(
struct
winmm_o
utput
*
wo
,
GError
**
error_r
)
winmm_drain_all_buffers
(
WinmmO
utput
*
wo
,
GError
**
error_r
)
{
for
(
unsigned
i
=
wo
->
next_buffer
;
i
<
G_N_ELEMENTS
(
wo
->
buffers
);
++
i
)
if
(
!
winmm_drain_buffer
(
wo
,
&
wo
->
buffers
[
i
],
error_r
))
...
...
@@ -313,12 +312,12 @@ winmm_drain_all_buffers(struct winmm_output *wo, GError **error_r)
}
static
void
winmm_stop
(
struct
winmm_o
utput
*
wo
)
winmm_stop
(
WinmmO
utput
*
wo
)
{
waveOutReset
(
wo
->
handle
);
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
wo
->
buffers
);
++
i
)
{
struct
winmm_b
uffer
*
buffer
=
&
wo
->
buffers
[
i
];
WinmmB
uffer
*
buffer
=
&
wo
->
buffers
[
i
];
waveOutUnprepareHeader
(
wo
->
handle
,
&
buffer
->
hdr
,
sizeof
(
buffer
->
hdr
));
}
...
...
@@ -327,29 +326,34 @@ winmm_stop(struct winmm_output *wo)
static
void
winmm_output_drain
(
struct
audio_output
*
ao
)
{
struct
winmm_output
*
wo
=
(
struct
winmm_o
utput
*
)
ao
;
WinmmOutput
*
wo
=
(
WinmmO
utput
*
)
ao
;
if
(
!
winmm_drain_all_buffers
(
wo
,
NULL
))
if
(
!
winmm_drain_all_buffers
(
wo
,
nullptr
))
winmm_stop
(
wo
);
}
static
void
winmm_output_cancel
(
struct
audio_output
*
ao
)
{
struct
winmm_output
*
wo
=
(
struct
winmm_o
utput
*
)
ao
;
WinmmOutput
*
wo
=
(
WinmmO
utput
*
)
ao
;
winmm_stop
(
wo
);
}
const
struct
audio_output_plugin
winmm_output_plugin
=
{
.
name
=
"winmm"
,
.
test_default_device
=
winmm_output_test_default_device
,
.
init
=
winmm_output_init
,
.
finish
=
winmm_output_finish
,
.
open
=
winmm_output_open
,
.
close
=
winmm_output_close
,
.
play
=
winmm_output_play
,
.
drain
=
winmm_output_drain
,
.
cancel
=
winmm_output_cancel
,
.
mixer_plugin
=
&
winmm_mixer_plugin
,
"winmm"
,
winmm_output_test_default_device
,
winmm_output_init
,
winmm_output_finish
,
nullptr
,
nullptr
,
winmm_output_open
,
winmm_output_close
,
nullptr
,
nullptr
,
winmm_output_play
,
winmm_output_drain
,
winmm_output_cancel
,
nullptr
,
&
winmm_mixer_plugin
,
};
src/output/
winmm_output_plugin.h
→
src/output/
WinmmOutputPlugin.hxx
View file @
9ede4c5f
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -17,21 +17,25 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_WINMM_OUTPUT_PLUGIN_H
#define MPD_WINMM_OUTPUT_PLUGIN_H
#ifndef MPD_WINMM_OUTPUT_PLUGIN_H
XX
#define MPD_WINMM_OUTPUT_PLUGIN_H
XX
#include "check.h"
#ifdef ENABLE_WINMM_OUTPUT
#include "gcc.h"
#include <windows.h>
#include <mmsystem.h>
struct
winmm_o
utput
;
struct
WinmmO
utput
;
extern
const
struct
audio_output_plugin
winmm_output_plugin
;
HWAVEOUT
winmm_output_get_handle
(
struct
winmm_output
*
);
gcc_pure
HWAVEOUT
winmm_output_get_handle
(
WinmmOutput
*
);
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment