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
66d90dd4
Commit
66d90dd4
authored
Dec 15, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/*: use fprintf(stderr,...) and Log() instead of g_printerr()
Avoid GLib.
parent
d5dfe7d4
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
115 deletions
+59
-115
read_conf.cxx
test/read_conf.cxx
+9
-23
run_convert.cxx
test/run_convert.cxx
+10
-25
run_decoder.cxx
test/run_decoder.cxx
+15
-26
run_encoder.cxx
test/run_encoder.cxx
+16
-21
run_input.cxx
test/run_input.cxx
+6
-18
run_normalize.cxx
test/run_normalize.cxx
+3
-2
No files found.
test/read_conf.cxx
View file @
66d90dd4
...
...
@@ -21,40 +21,26 @@
#include "ConfigGlobal.hxx"
#include "fs/Path.hxx"
#include "util/Error.hxx"
#include <glib.h>
#include "Log.hxx"
#include <assert.h>
static
void
my_log_func
(
gcc_unused
const
gchar
*
log_domain
,
GLogLevelFlags
log_level
,
const
gchar
*
message
,
gcc_unused
gpointer
user_data
)
{
if
(
log_level
>
G_LOG_LEVEL_WARNING
)
return
;
g_printerr
(
"%s
\n
"
,
message
);
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
3
)
{
g_printerr
(
"Usage: read_conf FILE SETTING
\n
"
);
return
1
;
fprintf
(
stderr
,
"Usage: read_conf FILE SETTING
\n
"
);
return
EXIT_FAILURE
;
}
const
Path
config_path
=
Path
::
FromFS
(
argv
[
1
]);
const
char
*
name
=
argv
[
2
];
g_log_set_default_handler
(
my_log_func
,
NULL
);
config_global_init
();
Error
error
;
if
(
!
ReadConfigFile
(
config_path
,
error
))
{
g_printerr
(
"%s:"
,
error
.
GetMessage
()
);
return
1
;
LogError
(
error
);
return
EXIT_FAILURE
;
}
ConfigOption
option
=
ParseConfigOptionName
(
name
);
...
...
@@ -63,11 +49,11 @@ int main(int argc, char **argv)
:
nullptr
;
int
ret
;
if
(
value
!=
NULL
)
{
g_print
(
"%s
\n
"
,
value
);
ret
=
0
;
printf
(
"%s
\n
"
,
value
);
ret
=
EXIT_SUCCESS
;
}
else
{
g_printerr
(
"No such setting: %s
\n
"
,
name
);
ret
=
2
;
fprintf
(
stderr
,
"No such setting: %s
\n
"
,
name
);
ret
=
EXIT_FAILURE
;
}
config_global_finish
();
...
...
test/run_convert.cxx
View file @
66d90dd4
...
...
@@ -30,25 +30,14 @@
#include "ConfigGlobal.hxx"
#include "util/FifoBuffer.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
#include "stdbin.h"
#include <glib.h>
#include <assert.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
static
void
my_log_func
(
const
gchar
*
log_domain
,
gcc_unused
GLogLevelFlags
log_level
,
const
gchar
*
message
,
gcc_unused
gpointer
user_data
)
{
if
(
log_domain
!=
NULL
)
g_printerr
(
"%s: %s
\n
"
,
log_domain
,
message
);
else
g_printerr
(
"%s
\n
"
,
message
);
}
const
char
*
config_get_string
(
gcc_unused
enum
ConfigOption
option
,
const
char
*
default_value
)
...
...
@@ -62,26 +51,23 @@ int main(int argc, char **argv)
const
void
*
output
;
if
(
argc
!=
3
)
{
g_printerr
(
"Usage: run_convert IN_FORMAT OUT_FORMAT <IN >OUT
\n
"
);
fprintf
(
stderr
,
"Usage: run_convert IN_FORMAT OUT_FORMAT <IN >OUT
\n
"
);
return
1
;
}
g_log_set_default_handler
(
my_log_func
,
NULL
);
Error
error
;
if
(
!
audio_format_parse
(
in_audio_format
,
argv
[
1
],
false
,
error
))
{
g_printerr
(
"Failed to parse audio format: %s
\n
"
,
error
.
GetMessage
());
return
1
;
LogError
(
error
,
"Failed to parse audio format"
);
return
EXIT_FAILURE
;
}
AudioFormat
out_audio_format_mask
;
if
(
!
audio_format_parse
(
out_audio_format_mask
,
argv
[
2
],
true
,
error
))
{
g_printerr
(
"Failed to parse audio format: %s
\n
"
,
error
.
GetMessage
());
return
1
;
LogError
(
error
,
"Failed to parse audio format"
);
return
EXIT_FAILURE
;
}
out_audio_format
=
in_audio_format
;
...
...
@@ -91,8 +77,7 @@ int main(int argc, char **argv)
PcmConvert
state
;
if
(
!
state
.
Open
(
in_audio_format
,
out_audio_format_mask
,
error
))
{
g_printerr
(
"Failed to open PcmConvert: %s
\n
"
,
error
.
GetMessage
());
LogError
(
error
,
"Failed to open PcmConvert"
);
return
EXIT_FAILURE
;
}
...
...
@@ -124,8 +109,8 @@ int main(int argc, char **argv)
&
length
,
error
);
if
(
output
==
NULL
)
{
state
.
Close
();
g_printerr
(
"Failed to convert: %s
\n
"
,
error
.
GetMessage
()
);
return
2
;
LogError
(
error
,
"Failed to convert"
);
return
EXIT_FAILURE
;
}
gcc_unused
ssize_t
ignored
=
write
(
1
,
output
,
length
);
...
...
test/run_decoder.cxx
View file @
66d90dd4
...
...
@@ -36,16 +36,7 @@
#include <assert.h>
#include <unistd.h>
#include <stdlib.h>
static
void
my_log_func
(
const
gchar
*
log_domain
,
gcc_unused
GLogLevelFlags
log_level
,
const
gchar
*
message
,
gcc_unused
gpointer
user_data
)
{
if
(
log_domain
!=
NULL
)
g_printerr
(
"%s: %s
\n
"
,
log_domain
,
message
);
else
g_printerr
(
"%s
\n
"
,
message
);
}
#include <stdio.h>
struct
Decoder
{
const
char
*
uri
;
...
...
@@ -66,7 +57,7 @@ decoder_initialized(Decoder &decoder,
assert
(
!
decoder
.
initialized
);
assert
(
audio_format
.
IsValid
());
g_printerr
(
"audio_format=%s duration=%f
\n
"
,
fprintf
(
stderr
,
"audio_format=%s duration=%f
\n
"
,
audio_format_to_string
(
audio_format
,
&
af_string
),
duration
);
...
...
@@ -167,12 +158,12 @@ decoder_replay_gain(gcc_unused Decoder &decoder,
{
const
ReplayGainTuple
*
tuple
=
&
rgi
->
tuples
[
REPLAY_GAIN_ALBUM
];
if
(
tuple
->
IsDefined
())
g_printerr
(
"replay_gain[album]: gain=%f peak=%f
\n
"
,
fprintf
(
stderr
,
"replay_gain[album]: gain=%f peak=%f
\n
"
,
tuple
->
gain
,
tuple
->
peak
);
tuple
=
&
rgi
->
tuples
[
REPLAY_GAIN_TRACK
];
if
(
tuple
->
IsDefined
())
g_printerr
(
"replay_gain[track]: gain=%f peak=%f
\n
"
,
fprintf
(
stderr
,
"replay_gain[track]: gain=%f peak=%f
\n
"
,
tuple
->
gain
,
tuple
->
peak
);
}
...
...
@@ -186,8 +177,8 @@ int main(int argc, char **argv)
const
char
*
decoder_name
;
if
(
argc
!=
3
)
{
g_printerr
(
"Usage: run_decoder DECODER URI >OUT
\n
"
);
return
1
;
fprintf
(
stderr
,
"Usage: run_decoder DECODER URI >OUT
\n
"
);
return
EXIT_FAILURE
;
}
Decoder
decoder
;
...
...
@@ -200,23 +191,21 @@ int main(int argc, char **argv)
#endif
#endif
g_log_set_default_handler
(
my_log_func
,
NULL
);
io_thread_init
();
io_thread_start
();
Error
error
;
if
(
!
input_stream_global_init
(
error
))
{
LogError
(
error
);
return
2
;
return
EXIT_FAILURE
;
}
decoder_plugin_init_all
();
decoder
.
plugin
=
decoder_plugin_from_name
(
decoder_name
);
if
(
decoder
.
plugin
==
NULL
)
{
g_printerr
(
"No such decoder: %s
\n
"
,
decoder_name
);
return
1
;
fprintf
(
stderr
,
"No such decoder: %s
\n
"
,
decoder_name
);
return
EXIT_FAILURE
;
}
decoder
.
initialized
=
false
;
...
...
@@ -233,17 +222,17 @@ int main(int argc, char **argv)
if
(
error
.
IsDefined
())
LogError
(
error
);
else
g_printerr
(
"InputStream::Open() failed
\n
"
);
fprintf
(
stderr
,
"InputStream::Open() failed
\n
"
);
return
1
;
return
EXIT_FAILURE
;
}
decoder
.
plugin
->
StreamDecode
(
decoder
,
*
is
);
is
->
Close
();
}
else
{
g_printerr
(
"Decoder plugin is not usable
\n
"
);
return
1
;
fprintf
(
stderr
,
"Decoder plugin is not usable
\n
"
);
return
EXIT_FAILURE
;
}
decoder_plugin_deinit_all
();
...
...
@@ -251,8 +240,8 @@ int main(int argc, char **argv)
io_thread_deinit
();
if
(
!
decoder
.
initialized
)
{
g_printerr
(
"Decoding failed
\n
"
);
return
1
;
fprintf
(
stderr
,
"Decoding failed
\n
"
);
return
EXIT_FAILURE
;
}
return
0
;
...
...
test/run_encoder.cxx
View file @
66d90dd4
...
...
@@ -24,10 +24,9 @@
#include "AudioParser.hxx"
#include "ConfigData.hxx"
#include "util/Error.hxx"
#include "Log.hxx"
#include "stdbin.h"
#include <glib.h>
#include <stddef.h>
#include <unistd.h>
...
...
@@ -50,8 +49,9 @@ int main(int argc, char **argv)
/* parse command line */
if
(
argc
>
3
)
{
g_printerr
(
"Usage: run_encoder [ENCODER] [FORMAT] <IN >OUT
\n
"
);
return
1
;
fprintf
(
stderr
,
"Usage: run_encoder [ENCODER] [FORMAT] <IN >OUT
\n
"
);
return
EXIT_FAILURE
;
}
if
(
argc
>
1
)
...
...
@@ -63,8 +63,8 @@ int main(int argc, char **argv)
const
auto
plugin
=
encoder_plugin_get
(
encoder_name
);
if
(
plugin
==
NULL
)
{
g_printerr
(
"No such encoder: %s
\n
"
,
encoder_name
);
return
1
;
fprintf
(
stderr
,
"No such encoder: %s
\n
"
,
encoder_name
);
return
EXIT_FAILURE
;
}
config_param
param
;
...
...
@@ -73,9 +73,8 @@ int main(int argc, char **argv)
Error
error
;
const
auto
encoder
=
encoder_init
(
*
plugin
,
param
,
error
);
if
(
encoder
==
NULL
)
{
g_printerr
(
"Failed to initialize encoder: %s
\n
"
,
error
.
GetMessage
());
return
1
;
LogError
(
error
,
"Failed to initialize encoder"
);
return
EXIT_FAILURE
;
}
/* open the encoder */
...
...
@@ -83,16 +82,14 @@ int main(int argc, char **argv)
AudioFormat
audio_format
(
44100
,
SampleFormat
::
S16
,
2
);
if
(
argc
>
2
)
{
if
(
!
audio_format_parse
(
audio_format
,
argv
[
2
],
false
,
error
))
{
g_printerr
(
"Failed to parse audio format: %s
\n
"
,
error
.
GetMessage
());
return
1
;
LogError
(
error
,
"Failed to parse audio format"
);
return
EXIT_FAILURE
;
}
}
if
(
!
encoder_open
(
encoder
,
audio_format
,
error
))
{
g_printerr
(
"Failed to open encoder: %s
\n
"
,
error
.
GetMessage
());
return
1
;
LogError
(
error
,
"Failed to open encoder"
);
return
EXIT_FAILURE
;
}
encoder_to_stdout
(
*
encoder
);
...
...
@@ -102,18 +99,16 @@ int main(int argc, char **argv)
ssize_t
nbytes
;
while
((
nbytes
=
read
(
0
,
buffer
,
sizeof
(
buffer
)))
>
0
)
{
if
(
!
encoder_write
(
encoder
,
buffer
,
nbytes
,
error
))
{
g_printerr
(
"encoder_write() failed: %s
\n
"
,
error
.
GetMessage
());
return
1
;
LogError
(
error
,
"encoder_write() failed"
);
return
EXIT_FAILURE
;
}
encoder_to_stdout
(
*
encoder
);
}
if
(
!
encoder_end
(
encoder
,
error
))
{
g_printerr
(
"encoder_flush() failed: %s
\n
"
,
error
.
GetMessage
());
return
1
;
LogError
(
error
,
"encoder_flush() failed"
);
return
EXIT_FAILURE
;
}
encoder_to_stdout
(
*
encoder
);
...
...
test/run_input.cxx
View file @
66d90dd4
...
...
@@ -40,16 +40,6 @@
#include <unistd.h>
#include <stdlib.h>
static
void
my_log_func
(
const
gchar
*
log_domain
,
gcc_unused
GLogLevelFlags
log_level
,
const
gchar
*
message
,
gcc_unused
gpointer
user_data
)
{
if
(
log_domain
!=
NULL
)
g_printerr
(
"%s: %s
\n
"
,
log_domain
,
message
);
else
g_printerr
(
"%s
\n
"
,
message
);
}
static
int
dump_input_stream
(
InputStream
*
is
)
{
...
...
@@ -73,14 +63,14 @@ dump_input_stream(InputStream *is)
/* print meta data */
if
(
!
is
->
mime
.
empty
())
g_printerr
(
"MIME type: %s
\n
"
,
is
->
mime
.
c_str
());
fprintf
(
stderr
,
"MIME type: %s
\n
"
,
is
->
mime
.
c_str
());
/* read data and tags from the stream */
while
(
!
is
->
IsEOF
())
{
Tag
*
tag
=
is
->
ReadTag
();
if
(
tag
!=
NULL
)
{
g_printerr
(
"Received a tag:
\n
"
);
fprintf
(
stderr
,
"Received a tag:
\n
"
);
tag_save
(
stderr
,
*
tag
);
delete
tag
;
}
...
...
@@ -116,8 +106,8 @@ int main(int argc, char **argv)
int
ret
;
if
(
argc
!=
2
)
{
g_printerr
(
"Usage: run_input URI
\n
"
);
return
1
;
fprintf
(
stderr
,
"Usage: run_input URI
\n
"
);
return
EXIT_FAILURE
;
}
/* initialize GLib */
...
...
@@ -128,8 +118,6 @@ int main(int argc, char **argv)
#endif
#endif
g_log_set_default_handler
(
my_log_func
,
NULL
);
/* initialize MPD */
config_global_init
();
...
...
@@ -159,8 +147,8 @@ int main(int argc, char **argv)
if
(
error
.
IsDefined
())
LogError
(
error
);
else
g_printerr
(
"input_stream::Open() failed
\n
"
);
ret
=
2
;
fprintf
(
stderr
,
"input_stream::Open() failed
\n
"
);
ret
=
EXIT_FAILURE
;
}
/* deinitialize everything */
...
...
test/run_normalize.cxx
View file @
66d90dd4
...
...
@@ -33,6 +33,7 @@
#include <glib.h>
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
...
...
@@ -43,7 +44,7 @@ int main(int argc, char **argv)
ssize_t
nbytes
;
if
(
argc
>
2
)
{
g_printerr
(
"Usage: run_normalize [FORMAT] <IN >OUT
\n
"
);
fprintf
(
stderr
,
"Usage: run_normalize [FORMAT] <IN >OUT
\n
"
);
return
1
;
}
...
...
@@ -51,7 +52,7 @@ int main(int argc, char **argv)
if
(
argc
>
1
)
{
Error
error
;
if
(
!
audio_format_parse
(
audio_format
,
argv
[
1
],
false
,
error
))
{
g_printerr
(
"Failed to parse audio format: %s
\n
"
,
fprintf
(
stderr
,
"Failed to parse audio format: %s
\n
"
,
error
.
GetMessage
());
return
1
;
}
...
...
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