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
7918785c
Commit
7918785c
authored
Nov 25, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output: use GLib instead of log.h/util.h
parent
0277921e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
38 deletions
+39
-38
audio.c
src/audio.c
+18
-19
output_api.h
src/output_api.h
+0
-1
output_init.c
src/output_init.c
+16
-15
output_thread.c
src/output_thread.c
+5
-3
No files found.
src/audio.c
View file @
7918785c
...
@@ -21,7 +21,6 @@
...
@@ -21,7 +21,6 @@
#include "output_api.h"
#include "output_api.h"
#include "output_control.h"
#include "output_control.h"
#include "output_internal.h"
#include "output_internal.h"
#include "log.h"
#include "path.h"
#include "path.h"
#include "client.h"
#include "client.h"
#include "idle.h"
#include "idle.h"
...
@@ -73,21 +72,21 @@ void initAudioDriver(void)
...
@@ -73,21 +72,21 @@ void initAudioDriver(void)
if
(
!
audio_output_init
(
output
,
param
))
{
if
(
!
audio_output_init
(
output
,
param
))
{
if
(
param
)
if
(
param
)
{
{
FATAL
(
"problems configuring output device "
g_error
(
"problems configuring output device "
"defined at line %i
\n
"
,
param
->
line
);
"defined at line %i
\n
"
,
param
->
line
);
}
}
else
else
{
{
FATAL
(
"No audio_output specified and unable to "
g_error
(
"No audio_output specified and unable to "
"detect a default audio output device
\n
"
);
"detect a default audio output device
\n
"
);
}
}
}
}
/* require output names to be unique: */
/* require output names to be unique: */
for
(
j
=
0
;
j
<
i
;
j
++
)
{
for
(
j
=
0
;
j
<
i
;
j
++
)
{
if
(
!
strcmp
(
output
->
name
,
audioOutputArray
[
j
].
name
))
{
if
(
!
strcmp
(
output
->
name
,
audioOutputArray
[
j
].
name
))
{
FATAL
(
"output devices with identical "
g_error
(
"output devices with identical "
"names: %s
\n
"
,
output
->
name
);
"names: %s
\n
"
,
output
->
name
);
}
}
}
}
}
}
...
@@ -109,8 +108,8 @@ void initAudioConfig(void)
...
@@ -109,8 +108,8 @@ void initAudioConfig(void)
return
;
return
;
if
(
0
!=
parseAudioConfig
(
&
configured_audio_format
,
param
->
value
))
{
if
(
0
!=
parseAudioConfig
(
&
configured_audio_format
,
param
->
value
))
{
FATAL
(
"error parsing
\"
%s
\"
at line %i
\n
"
,
g_error
(
"error parsing
\"
%s
\"
at line %i
\n
"
,
CONF_AUDIO_OUTPUT_FORMAT
,
param
->
line
);
CONF_AUDIO_OUTPUT_FORMAT
,
param
->
line
);
}
}
}
}
...
@@ -123,34 +122,34 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
...
@@ -123,34 +122,34 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
audioFormat
->
sample_rate
=
strtol
(
conf
,
&
test
,
10
);
audioFormat
->
sample_rate
=
strtol
(
conf
,
&
test
,
10
);
if
(
*
test
!=
':'
)
{
if
(
*
test
!=
':'
)
{
ERROR
(
"error parsing audio output format: %s
\n
"
,
conf
);
g_warning
(
"error parsing audio output format: %s
\n
"
,
conf
);
return
-
1
;
return
-
1
;
}
}
if
(
audioFormat
->
sample_rate
<=
0
)
{
if
(
audioFormat
->
sample_rate
<=
0
)
{
ERROR
(
"sample rate %u is not >= 0
\n
"
,
g_warning
(
"sample rate %u is not >= 0
\n
"
,
audioFormat
->
sample_rate
);
audioFormat
->
sample_rate
);
return
-
1
;
return
-
1
;
}
}
audioFormat
->
bits
=
(
uint8_t
)
strtoul
(
test
+
1
,
&
test
,
10
);
audioFormat
->
bits
=
(
uint8_t
)
strtoul
(
test
+
1
,
&
test
,
10
);
if
(
*
test
!=
':'
)
{
if
(
*
test
!=
':'
)
{
ERROR
(
"error parsing audio output format: %s
\n
"
,
conf
);
g_warning
(
"error parsing audio output format: %s
\n
"
,
conf
);
return
-
1
;
return
-
1
;
}
}
if
(
audioFormat
->
bits
!=
16
&&
audioFormat
->
bits
!=
24
&&
if
(
audioFormat
->
bits
!=
16
&&
audioFormat
->
bits
!=
24
&&
audioFormat
->
bits
!=
8
)
{
audioFormat
->
bits
!=
8
)
{
ERROR
(
"bits %u can not be used for audio output
\n
"
,
g_warning
(
"bits %u can not be used for audio output
\n
"
,
audioFormat
->
bits
);
audioFormat
->
bits
);
return
-
1
;
return
-
1
;
}
}
audioFormat
->
channels
=
(
uint8_t
)
strtoul
(
test
+
1
,
&
test
,
10
);
audioFormat
->
channels
=
(
uint8_t
)
strtoul
(
test
+
1
,
&
test
,
10
);
if
(
*
test
!=
'\0'
)
{
if
(
*
test
!=
'\0'
)
{
ERROR
(
"error parsing audio output format: %s
\n
"
,
conf
);
g_warning
(
"error parsing audio output format: %s
\n
"
,
conf
);
return
-
1
;
return
-
1
;
}
}
...
@@ -159,8 +158,8 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
...
@@ -159,8 +158,8 @@ int parseAudioConfig(struct audio_format *audioFormat, char *conf)
case
2
:
case
2
:
break
;
break
;
default:
default:
ERROR
(
"channels %i
can not be used for audio output
\n
"
,
g_warning
(
"channels %u
can not be used for audio output
\n
"
,
(
int
)
audioFormat
->
channels
);
audioFormat
->
channels
);
return
-
1
;
return
-
1
;
}
}
...
@@ -418,7 +417,7 @@ void readAudioDevicesState(FILE *fp)
...
@@ -418,7 +417,7 @@ void readAudioDevicesState(FILE *fp)
continue
;
continue
;
errline:
errline:
/* nonfatal */
/* nonfatal */
ERROR
(
"invalid line in state_file: %s
\n
"
,
buffer
);
g_warning
(
"invalid line in state_file: %s
\n
"
,
buffer
);
}
}
}
}
src/output_api.h
View file @
7918785c
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
#include "audio_format.h"
#include "audio_format.h"
#include "tag.h"
#include "tag.h"
#include "conf.h"
#include "conf.h"
#include "log.h"
#include <stdbool.h>
#include <stdbool.h>
...
...
src/output_init.c
View file @
7918785c
...
@@ -20,9 +20,10 @@
...
@@ -20,9 +20,10 @@
#include "output_api.h"
#include "output_api.h"
#include "output_internal.h"
#include "output_internal.h"
#include "output_list.h"
#include "output_list.h"
#include "log.h"
#include "audio.h"
#include "audio.h"
#include <glib.h>
#define AUDIO_OUTPUT_TYPE "type"
#define AUDIO_OUTPUT_TYPE "type"
#define AUDIO_OUTPUT_NAME "name"
#define AUDIO_OUTPUT_NAME "name"
#define AUDIO_OUTPUT_FORMAT "format"
#define AUDIO_OUTPUT_FORMAT "format"
...
@@ -30,9 +31,9 @@
...
@@ -30,9 +31,9 @@
#define getBlockParam(name, str, force) { \
#define getBlockParam(name, str, force) { \
bp = getBlockParam(param, name); \
bp = getBlockParam(param, name); \
if(force && bp == NULL) { \
if(force && bp == NULL) { \
FATAL
("couldn't find parameter \"%s\" in audio output " \
g_error
("couldn't find parameter \"%s\" in audio output " \
"definition beginning at %i\n",
\
"definition beginning at %i\n",
\
name, param->line);
\
name, param->line);
\
} \
} \
if(bp) str = bp->value; \
if(bp) str = bp->value; \
}
}
...
@@ -53,30 +54,30 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
...
@@ -53,30 +54,30 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
plugin
=
audio_output_plugin_get
(
type
);
plugin
=
audio_output_plugin_get
(
type
);
if
(
plugin
==
NULL
)
{
if
(
plugin
==
NULL
)
{
FATAL
(
"couldn't find audio output plugin for type "
g_error
(
"couldn't find audio output plugin for type "
"
\"
%s
\"
at line %i
\n
"
,
type
,
param
->
line
);
"
\"
%s
\"
at line %i
\n
"
,
type
,
param
->
line
);
}
}
}
else
{
}
else
{
unsigned
i
;
unsigned
i
;
WARNING
(
"No
\"
%s
\"
defined in config file
\n
"
,
g_warning
(
"No
\"
%s
\"
defined in config file
\n
"
,
CONF_AUDIO_OUTPUT
);
CONF_AUDIO_OUTPUT
);
WARNING
(
"Attempt to detect audio output device
\n
"
);
g_warning
(
"Attempt to detect audio output device
\n
"
);
audio_output_plugins_for_each
(
plugin
,
i
)
{
audio_output_plugins_for_each
(
plugin
,
i
)
{
if
(
plugin
->
test_default_device
)
{
if
(
plugin
->
test_default_device
)
{
WARNING
(
"Attempting to detect a %s audio "
g_warning
(
"Attempting to detect a %s audio "
"device
\n
"
,
plugin
->
name
);
"device
\n
"
,
plugin
->
name
);
if
(
plugin
->
test_default_device
())
{
if
(
plugin
->
test_default_device
())
{
WARNING
(
"Successfully detected a %s "
g_warning
(
"Successfully detected a %s "
"audio device
\n
"
,
plugin
->
name
);
"audio device
\n
"
,
plugin
->
name
);
break
;
break
;
}
}
}
}
}
}
if
(
plugin
==
NULL
)
{
if
(
plugin
==
NULL
)
{
WARNING
(
"Unable to detect an audio device
\n
"
);
g_warning
(
"Unable to detect an audio device
\n
"
);
return
0
;
return
0
;
}
}
...
@@ -96,7 +97,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
...
@@ -96,7 +97,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
if
(
format
)
{
if
(
format
)
{
if
(
0
!=
parseAudioConfig
(
&
ao
->
reqAudioFormat
,
format
))
{
if
(
0
!=
parseAudioConfig
(
&
ao
->
reqAudioFormat
,
format
))
{
FATAL
(
"error parsing format at line %i
\n
"
,
bp
->
line
);
g_error
(
"error parsing format at line %i
\n
"
,
bp
->
line
);
}
}
}
else
}
else
audio_format_clear
(
&
ao
->
reqAudioFormat
);
audio_format_clear
(
&
ao
->
reqAudioFormat
);
...
...
src/output_thread.c
View file @
7918785c
...
@@ -19,9 +19,11 @@
...
@@ -19,9 +19,11 @@
#include "output_thread.h"
#include "output_thread.h"
#include "output_api.h"
#include "output_api.h"
#include "output_internal.h"
#include "output_internal.h"
#include "utils.h"
#include <glib.h>
#include <assert.h>
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
enum
{
enum
{
/** after a failure, wait this number of seconds before
/** after a failure, wait this number of seconds before
...
@@ -46,7 +48,7 @@ static void convertAudioFormat(struct audio_output *audioOutput,
...
@@ -46,7 +48,7 @@ static void convertAudioFormat(struct audio_output *audioOutput,
if
(
size
>
audioOutput
->
convBufferLen
)
{
if
(
size
>
audioOutput
->
convBufferLen
)
{
if
(
audioOutput
->
convBuffer
!=
NULL
)
if
(
audioOutput
->
convBuffer
!=
NULL
)
free
(
audioOutput
->
convBuffer
);
free
(
audioOutput
->
convBuffer
);
audioOutput
->
convBuffer
=
x
malloc
(
size
);
audioOutput
->
convBuffer
=
g_
malloc
(
size
);
audioOutput
->
convBufferLen
=
size
;
audioOutput
->
convBufferLen
=
size
;
}
}
...
@@ -164,5 +166,5 @@ void audio_output_thread_start(struct audio_output *ao)
...
@@ -164,5 +166,5 @@ void audio_output_thread_start(struct audio_output *ao)
pthread_attr_init
(
&
attr
);
pthread_attr_init
(
&
attr
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
if
(
pthread_create
(
&
ao
->
thread
,
&
attr
,
audio_output_task
,
ao
))
if
(
pthread_create
(
&
ao
->
thread
,
&
attr
,
audio_output_task
,
ao
))
FATAL
(
"Failed to spawn output task: %s
\n
"
,
strerror
(
errno
));
g_error
(
"Failed to spawn output task: %s
\n
"
,
strerror
(
errno
));
}
}
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