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
7612bf1b
Commit
7612bf1b
authored
Nov 04, 2010
by
Denis Krjuchkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winmm_output: added "device" configuration option
Device can be specified either by magic index (starting with 0) or by device name.
parent
ad56e10e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
2 deletions
+35
-2
winmm_output_plugin.c
src/output/winmm_output_plugin.c
+35
-2
No files found.
src/output/winmm_output_plugin.c
View file @
7612bf1b
...
...
@@ -23,6 +23,8 @@
#include "mixer_list.h"
#include "winmm_output_plugin.h"
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#undef G_LOG_DOMAIN
...
...
@@ -35,6 +37,7 @@ struct winmm_buffer {
};
struct
winmm_output
{
UINT
device_id
;
HWAVEOUT
handle
;
/**
...
...
@@ -68,13 +71,43 @@ winmm_output_test_default_device(void)
return
waveOutGetNumDevs
()
>
0
;
}
static
UINT
get_device_id
(
const
char
*
device_name
)
{
/* if device is not specified use wave mapper */
if
(
device_name
==
NULL
)
return
WAVE_MAPPER
;
/* check for device id */
char
*
endptr
;
UINT
id
=
strtoul
(
device_name
,
&
endptr
,
0
);
if
(
*
endptr
==
0
)
return
id
;
/* check for device name */
for
(
UINT
i
=
0
;
i
<
waveOutGetNumDevs
();
i
++
)
{
WAVEOUTCAPS
caps
;
MMRESULT
result
=
waveOutGetDevCaps
(
i
,
&
caps
,
sizeof
(
caps
));
if
(
result
!=
MMSYSERR_NOERROR
)
continue
;
/* szPname is only 32 chars long, so it is often truncated.
Use partial match to work around this. */
if
(
strstr
(
device_name
,
caps
.
szPname
)
==
device_name
)
return
i
;
}
/* fallback to wave mapper */
return
WAVE_MAPPER
;
}
static
void
*
winmm_output_init
(
G_GNUC_UNUSED
const
struct
audio_format
*
audio_format
,
G_GNUC_UNUSED
const
struct
config_param
*
param
,
G_GNUC_UNUSED
GError
**
error
)
{
struct
winmm_output
*
wo
=
g_new
(
struct
winmm_output
,
1
);
const
char
*
device
=
config_get_block_string
(
param
,
"device"
,
NULL
);
wo
->
device_id
=
get_device_id
(
device
);
return
wo
;
}
...
...
@@ -126,7 +159,7 @@ winmm_output_open(void *data, struct audio_format *audio_format,
format
.
wBitsPerSample
=
audio_format_sample_size
(
audio_format
)
*
8
;
format
.
cbSize
=
0
;
MMRESULT
result
=
waveOutOpen
(
&
wo
->
handle
,
WAVE_MAPPER
,
&
format
,
MMRESULT
result
=
waveOutOpen
(
&
wo
->
handle
,
wo
->
device_id
,
&
format
,
(
DWORD_PTR
)
wo
->
event
,
0
,
CALLBACK_EVENT
);
if
(
result
!=
MMSYSERR_NOERROR
)
{
CloseHandle
(
wo
->
event
);
...
...
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