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
422cf5f1
Commit
422cf5f1
authored
4 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v0.22.x'
parents
ef1acb4e
637cf8a0
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
140 additions
and
72 deletions
+140
-72
meson.build
meson.build
+1
-1
WasapiOutputPlugin.cxx
src/output/plugins/WasapiOutputPlugin.cxx
+3
-3
meson.build
src/output/plugins/meson.build
+1
-0
WindowsFuture.hxx
src/thread/WindowsFuture.hxx
+1
-1
ComWorker.cxx
src/win32/ComWorker.cxx
+2
-9
ComWorker.hxx
src/win32/ComWorker.hxx
+6
-7
HResult.cxx
src/win32/HResult.cxx
+57
-0
HResult.hxx
src/win32/HResult.hxx
+3
-32
WinEvent.cxx
src/win32/WinEvent.cxx
+28
-0
WinEvent.hxx
src/win32/WinEvent.hxx
+6
-7
meson.build
src/win32/meson.build
+19
-0
TestLookupFile.cxx
test/TestLookupFile.cxx
+10
-10
run_convert.cxx
test/run_convert.cxx
+3
-2
No files found.
meson.build
View file @
422cf5f1
...
...
@@ -311,7 +311,6 @@ sources = [
if is_windows
sources += [
'src/win32/Win32Main.cxx',
'src/win32/ComWorker.cxx',
]
endif
...
...
@@ -349,6 +348,7 @@ subdir('src/system')
subdir('src/thread')
subdir('src/net')
subdir('src/event')
subdir('src/win32')
subdir('src/apple')
...
...
This diff is collapsed.
Click to expand it.
src/output/plugins/WasapiOutputPlugin.cxx
View file @
422cf5f1
...
...
@@ -155,7 +155,7 @@ public:
void
Finish
()
noexcept
{
return
SetStatus
(
Status
::
FINISH
);
}
void
Play
()
noexcept
{
return
SetStatus
(
Status
::
PLAY
);
}
void
Pause
()
noexcept
{
return
SetStatus
(
Status
::
PAUSE
);
}
void
WaitDataPoped
()
noexcept
{
data_poped
.
Wait
(
INFINITE
);
}
void
WaitDataPoped
()
noexcept
{
data_poped
.
Wait
();
}
void
CheckException
()
{
if
(
error
.
occur
.
load
())
{
auto
err
=
std
::
exchange
(
error
.
ptr
,
nullptr
);
...
...
@@ -269,7 +269,7 @@ void WasapiOutputThread::Work() noexcept {
COM
com
{
true
};
while
(
true
)
{
try
{
event
.
Wait
(
INFINITE
);
event
.
Wait
();
Status
current_state
=
status
.
load
();
if
(
current_state
==
Status
::
FINISH
)
{
...
...
@@ -322,7 +322,7 @@ void WasapiOutputThread::Work() noexcept {
}
catch
(...)
{
error
.
ptr
=
std
::
current_exception
();
error
.
occur
.
store
(
true
);
error
.
thrown
.
Wait
(
INFINITE
);
error
.
thrown
.
Wait
();
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/output/plugins/meson.build
View file @
422cf5f1
...
...
@@ -159,6 +159,7 @@ if is_windows
wasapi_dep = [
c_compiler.find_library('ksuser', required: true),
c_compiler.find_library('ole32', required: true),
win32_dep,
]
else
wasapi_dep = dependency('', required: false)
...
...
This diff is collapsed.
Click to expand it.
src/thread/WindowsFuture.hxx
View file @
422cf5f1
...
...
@@ -22,7 +22,7 @@
#include "CriticalSection.hxx"
#include "WindowsCond.hxx"
#include <atomic>
#include <memory>
#include <variant>
...
...
This diff is collapsed.
Click to expand it.
src/win32/ComWorker.cxx
View file @
422cf5f1
...
...
@@ -16,27 +16,20 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "ComWorker.hxx"
#include "
Log
.hxx"
#include "
Com
.hxx"
#include "thread/Name.hxx"
#include "util/Domain.hxx"
#include "win32/Com.hxx"
namespace
{
static
constexpr
Domain
com_worker_domain
(
"com_worker"
);
}
Mutex
COMWorker
::
mutex
;
unsigned
int
COMWorker
::
reference_count
=
0
;
std
::
optional
<
COMWorker
::
COMWorkerThread
>
COMWorker
::
thread
;
void
COMWorker
::
COMWorkerThread
::
Work
()
noexcept
{
FormatDebug
(
com_worker_domain
,
"Working thread started"
);
SetThreadName
(
"COM Worker"
);
COM
com
{
true
};
while
(
true
)
{
if
(
!
running_flag
.
test_and_set
())
{
FormatDebug
(
com_worker_domain
,
"Working thread ended"
);
return
;
}
while
(
!
spsc_buffer
.
empty
())
{
...
...
This diff is collapsed.
Click to expand it.
src/win32/ComWorker.hxx
View file @
422cf5f1
/*
* Copyright 2020 The Music Player Daemon Project
* Copyright 2020
-2021
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -20,16 +20,15 @@
#ifndef MPD_WIN32_COM_WORKER_HXX
#define MPD_WIN32_COM_WORKER_HXX
#include "WinEvent.hxx"
#include "thread/Future.hxx"
#include "thread/Mutex.hxx"
#include "thread/Thread.hxx"
#include <boost/lockfree/spsc_queue.hpp>
#include <condition_variable>
#include <mutex>
#include <optional>
#include "thread/Future.hxx"
#include "thread/Mutex.hxx"
#include "thread/Thread.hxx"
#include "win32/WinEvent.hxx"
#include <objbase.h>
#include <windows.h>
// Worker thread for all COM operation
...
...
This diff is collapsed.
Click to expand it.
src/win32/HResult.cxx
0 → 100644
View file @
422cf5f1
/*
* Copyright 2020-2021 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "HResult.hxx"
#include <cassert>
#include <cstdarg>
#include <cstdio>
#include <memory>
std
::
string
HResultCategory
::
message
(
int
Errcode
)
const
{
const
auto
msg
=
HRESULTToString
(
Errcode
);
if
(
!
msg
.
empty
())
return
std
::
string
(
msg
);
char
buffer
[
11
];
// "0x12345678\0"
int
size
=
snprintf
(
buffer
,
sizeof
(
buffer
),
"0x%1x"
,
Errcode
);
assert
(
2
<=
size
&&
size
<=
10
);
return
std
::
string
(
buffer
,
size
);
}
std
::
system_error
FormatHResultError
(
HRESULT
result
,
const
char
*
fmt
,
...)
noexcept
{
std
::
va_list
args1
,
args2
;
va_start
(
args1
,
fmt
);
va_copy
(
args2
,
args1
);
const
int
size
=
vsnprintf
(
nullptr
,
0
,
fmt
,
args1
);
va_end
(
args1
);
assert
(
size
>=
0
);
auto
buffer
=
std
::
make_unique
<
char
[]
>
(
size
+
1
);
vsprintf
(
buffer
.
get
(),
fmt
,
args2
);
va_end
(
args2
);
return
std
::
system_error
(
std
::
error_code
(
result
,
hresult_category
()),
std
::
string
(
buffer
.
get
(),
size
));
}
This diff is collapsed.
Click to expand it.
src/win32/HResult.hxx
View file @
422cf5f1
...
...
@@ -22,13 +22,8 @@
#include "util/Compiler.h"
#include <cassert>
#include <cstdarg>
#include <cstdio>
#include <stdexcept>
#include <string_view>
#include <system_error>
#include <vector>
#include <audiopolicy.h>
...
...
@@ -69,16 +64,7 @@ static inline const std::error_category &hresult_category() noexcept;
class
HResultCategory
:
public
std
::
error_category
{
public
:
const
char
*
name
()
const
noexcept
override
{
return
"HRESULT"
;
}
std
::
string
message
(
int
Errcode
)
const
override
{
const
auto
msg
=
HRESULTToString
(
Errcode
);
if
(
!
msg
.
empty
())
{
return
std
::
string
(
msg
);
}
char
buffer
[
11
];
// "0x12345678\0"
int
size
=
snprintf
(
buffer
,
sizeof
(
buffer
),
"0x%1x"
,
Errcode
);
assert
(
2
<=
size
&&
size
<=
10
);
return
std
::
string
(
buffer
,
size
);
}
std
::
string
message
(
int
Errcode
)
const
override
;
std
::
error_condition
default_error_condition
(
int
code
)
const
noexcept
override
{
return
std
::
error_condition
(
code
,
hresult_category
());
}
...
...
@@ -88,22 +74,7 @@ static inline const std::error_category &hresult_category() noexcept {
return
hresult_category_instance
;
}
gcc_printf
(
2
,
3
)
static
inline
std
::
runtime_error
FormatHResultError
(
HRESULT
result
,
const
char
*
fmt
,
...)
noexcept
{
std
::
va_list
args1
,
args2
;
va_start
(
args1
,
fmt
);
va_copy
(
args2
,
args1
);
const
int
size
=
vsnprintf
(
nullptr
,
0
,
fmt
,
args1
);
va_end
(
args1
);
assert
(
size
>=
0
);
auto
buffer
=
std
::
make_unique
<
char
[]
>
(
size
+
1
);
vsprintf
(
buffer
.
get
(),
fmt
,
args2
);
va_end
(
args2
);
return
std
::
system_error
(
std
::
error_code
(
result
,
hresult_category
()),
std
::
string
(
buffer
.
get
(),
size
));
}
gcc_printf
(
2
,
3
)
std
::
system_error
FormatHResultError
(
HRESULT
result
,
const
char
*
fmt
,
...)
noexcept
;
#endif
This diff is collapsed.
Click to expand it.
src/win32/WinEvent.cxx
0 → 100644
View file @
422cf5f1
/*
* Copyright 2020-2021 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "WinEvent.hxx"
#include "system/Error.hxx"
WinEvent
::
WinEvent
()
:
event
(
CreateEventW
(
nullptr
,
false
,
false
,
nullptr
))
{
if
(
!
event
)
throw
FormatLastError
(
"Error creating events"
);
}
This diff is collapsed.
Click to expand it.
src/win32/WinEvent.hxx
View file @
422cf5f1
...
...
@@ -20,7 +20,6 @@
#ifndef MPD_WIN32_WINEVENT_HXX
#define MPD_WIN32_WINEVENT_HXX
#include "system/Error.hxx"
#include <windows.h>
// RAII for Windows unnamed event object
...
...
@@ -28,11 +27,11 @@
class
WinEvent
{
public
:
WinEvent
()
:
event
(
CreateEventW
(
nullptr
,
false
,
false
,
nullptr
))
{
if
(
!
event
)
{
throw
FormatLastError
(
"Error creating events"
);
}
}
/**
* Throws on error.
*/
WinEvent
();
~
WinEvent
()
noexcept
{
CloseHandle
(
event
);
}
WinEvent
(
WinEvent
&&
)
=
delete
;
WinEvent
(
const
WinEvent
&
)
=
delete
;
...
...
@@ -41,7 +40,7 @@ public:
HANDLE
handle
()
noexcept
{
return
event
;
}
DWORD
Wait
(
DWORD
milliseconds
)
noexcept
{
DWORD
Wait
(
DWORD
milliseconds
=
INFINITE
)
noexcept
{
return
WaitForSingleObject
(
event
,
milliseconds
);
}
...
...
This diff is collapsed.
Click to expand it.
src/win32/meson.build
0 → 100644
View file @
422cf5f1
if not is_windows
win32_dep = dependency('', required: false)
subdir_done()
endif
win32 = static_library(
'win32',
'ComWorker.cxx',
'HResult.cxx',
'WinEvent.cxx',
include_directories: inc,
)
win32_dep = declare_dependency(
link_with: win32,
dependencies: [
thread_dep,
],
)
This diff is collapsed.
Click to expand it.
test/TestLookupFile.cxx
View file @
422cf5f1
...
...
@@ -8,23 +8,23 @@
TEST
(
ArchiveTest
,
Lookup
)
{
EXPECT_THROW
(
LookupFile
(
Path
::
FromFS
(
""
)),
std
::
system_error
);
EXPECT_THROW
(
LookupFile
(
Path
::
FromFS
(
PATH_LITERAL
(
""
)
)),
std
::
system_error
);
EXPECT_FALSE
(
LookupFile
(
Path
::
FromFS
(
"."
)));
EXPECT_FALSE
(
LookupFile
(
Path
::
FromFS
(
PATH_LITERAL
(
"."
)
)));
EXPECT_FALSE
(
LookupFile
(
Path
::
FromFS
(
"config.h"
)));
EXPECT_FALSE
(
LookupFile
(
Path
::
FromFS
(
PATH_LITERAL
(
"config.h"
)
)));
EXPECT_THROW
(
LookupFile
(
Path
::
FromFS
(
"src/foo/bar"
)),
std
::
system_error
);
EXPECT_THROW
(
LookupFile
(
Path
::
FromFS
(
PATH_LITERAL
(
"src/foo/bar"
)
)),
std
::
system_error
);
fclose
(
fopen
(
"dummy"
,
"w"
));
auto
result
=
LookupFile
(
Path
::
FromFS
(
"dummy/foo/bar"
));
auto
result
=
LookupFile
(
Path
::
FromFS
(
PATH_LITERAL
(
"dummy/foo/bar"
)
));
EXPECT_TRUE
(
result
);
EXPECT_STREQ
(
result
.
archive
.
c_str
(),
"dummy"
);
EXPECT_STREQ
(
result
.
inside
.
c_str
(),
"foo/bar"
);
EXPECT_STREQ
(
result
.
archive
.
c_str
(),
PATH_LITERAL
(
"dummy"
)
);
EXPECT_STREQ
(
result
.
inside
.
c_str
(),
PATH_LITERAL
(
"foo/bar"
)
);
result
=
LookupFile
(
Path
::
FromFS
(
"config.h/foo/bar"
));
result
=
LookupFile
(
Path
::
FromFS
(
PATH_LITERAL
(
"config.h/foo/bar"
)
));
EXPECT_TRUE
(
result
);
EXPECT_STREQ
(
result
.
archive
.
c_str
(),
"config.h"
);
EXPECT_STREQ
(
result
.
inside
.
c_str
(),
"foo/bar"
);
EXPECT_STREQ
(
result
.
archive
.
c_str
(),
PATH_LITERAL
(
"config.h"
)
);
EXPECT_STREQ
(
result
.
inside
.
c_str
(),
PATH_LITERAL
(
"foo/bar"
)
);
}
This diff is collapsed.
Click to expand it.
test/run_convert.cxx
View file @
422cf5f1
...
...
@@ -28,6 +28,7 @@
#include "pcm/AudioFormat.hxx"
#include "pcm/Convert.hxx"
#include "fs/Path.hxx"
#include "fs/NarrowPath.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StaticFifoBuffer.hxx"
#include "util/OptionDef.hxx"
...
...
@@ -47,7 +48,7 @@
struct
CommandLine
{
AudioFormat
in_audio_format
,
out_audio_format
;
Path
config_path
=
nullptr
;
FromNarrowPath
config_path
;
bool
verbose
=
false
;
};
...
...
@@ -71,7 +72,7 @@ ParseCommandLine(int argc, char **argv)
while
(
auto
o
=
option_parser
.
Next
())
{
switch
(
Option
(
o
.
index
))
{
case
OPTION_CONFIG
:
c
.
config_path
=
Path
::
FromFS
(
o
.
value
)
;
c
.
config_path
=
o
.
value
;
break
;
case
OPTION_VERBOSE
:
...
...
This diff is collapsed.
Click to expand it.
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