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
74af4e4c
Commit
74af4e4c
authored
Feb 25, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fifo: no CamelCase
Renamed types, functions and variables.
parent
ee7cf9c9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
44 deletions
+51
-44
fifo_plugin.c
src/output/fifo_plugin.c
+49
-42
output_list.c
src/output_list.c
+2
-2
No files found.
src/output/fifo_plugin.c
View file @
74af4e4c
...
@@ -34,19 +34,19 @@
...
@@ -34,19 +34,19 @@
#define FIFO_BUFFER_SIZE 65536
/* pipe capacity on Linux >= 2.6.11 */
#define FIFO_BUFFER_SIZE 65536
/* pipe capacity on Linux >= 2.6.11 */
typedef
struct
_FifoD
ata
{
struct
fifo_d
ata
{
char
*
path
;
char
*
path
;
int
input
;
int
input
;
int
output
;
int
output
;
int
created
;
int
created
;
Timer
*
timer
;
Timer
*
timer
;
}
FifoData
;
};
static
FifoData
*
newFifoData
(
void
)
static
struct
fifo_data
*
fifo_data_new
(
void
)
{
{
FifoD
ata
*
ret
;
struct
fifo_d
ata
*
ret
;
ret
=
g_new
(
FifoD
ata
,
1
);
ret
=
g_new
(
struct
fifo_d
ata
,
1
);
ret
->
path
=
NULL
;
ret
->
path
=
NULL
;
ret
->
input
=
-
1
;
ret
->
input
=
-
1
;
...
@@ -56,13 +56,13 @@ static FifoData *newFifoData(void)
...
@@ -56,13 +56,13 @@ static FifoData *newFifoData(void)
return
ret
;
return
ret
;
}
}
static
void
f
reeFifoData
(
FifoD
ata
*
fd
)
static
void
f
ifo_data_free
(
struct
fifo_d
ata
*
fd
)
{
{
g_free
(
fd
->
path
);
g_free
(
fd
->
path
);
g_free
(
fd
);
g_free
(
fd
);
}
}
static
void
removeFifo
(
FifoD
ata
*
fd
)
static
void
fifo_delete
(
struct
fifo_d
ata
*
fd
)
{
{
g_debug
(
"Removing FIFO
\"
%s
\"
"
,
fd
->
path
);
g_debug
(
"Removing FIFO
\"
%s
\"
"
,
fd
->
path
);
...
@@ -75,7 +75,8 @@ static void removeFifo(FifoData *fd)
...
@@ -75,7 +75,8 @@ static void removeFifo(FifoData *fd)
fd
->
created
=
0
;
fd
->
created
=
0
;
}
}
static
void
closeFifo
(
FifoData
*
fd
)
static
void
fifo_close
(
struct
fifo_data
*
fd
)
{
{
struct
stat
st
;
struct
stat
st
;
...
@@ -90,10 +91,11 @@ static void closeFifo(FifoData *fd)
...
@@ -90,10 +91,11 @@ static void closeFifo(FifoData *fd)
}
}
if
(
fd
->
created
&&
(
stat
(
fd
->
path
,
&
st
)
==
0
))
if
(
fd
->
created
&&
(
stat
(
fd
->
path
,
&
st
)
==
0
))
removeFifo
(
fd
);
fifo_delete
(
fd
);
}
}
static
int
makeFifo
(
FifoData
*
fd
)
static
int
fifo_make
(
struct
fifo_data
*
fd
)
{
{
if
(
mkfifo
(
fd
->
path
,
0666
)
<
0
)
{
if
(
mkfifo
(
fd
->
path
,
0666
)
<
0
)
{
g_warning
(
"Couldn't create FIFO
\"
%s
\"
: %s"
,
g_warning
(
"Couldn't create FIFO
\"
%s
\"
: %s"
,
...
@@ -106,14 +108,15 @@ static int makeFifo(FifoData *fd)
...
@@ -106,14 +108,15 @@ static int makeFifo(FifoData *fd)
return
0
;
return
0
;
}
}
static
int
checkFifo
(
FifoData
*
fd
)
static
int
fifo_check
(
struct
fifo_data
*
fd
)
{
{
struct
stat
st
;
struct
stat
st
;
if
(
stat
(
fd
->
path
,
&
st
)
<
0
)
{
if
(
stat
(
fd
->
path
,
&
st
)
<
0
)
{
if
(
errno
==
ENOENT
)
{
if
(
errno
==
ENOENT
)
{
/* Path doesn't exist */
/* Path doesn't exist */
return
makeFifo
(
fd
);
return
fifo_make
(
fd
);
}
}
g_warning
(
"Failed to stat FIFO
\"
%s
\"
: %s"
,
g_warning
(
"Failed to stat FIFO
\"
%s
\"
: %s"
,
...
@@ -130,16 +133,17 @@ static int checkFifo(FifoData *fd)
...
@@ -130,16 +133,17 @@ static int checkFifo(FifoData *fd)
return
0
;
return
0
;
}
}
static
bool
openFifo
(
FifoData
*
fd
)
static
bool
fifo_open
(
struct
fifo_data
*
fd
)
{
{
if
(
checkFifo
(
fd
)
<
0
)
if
(
fifo_check
(
fd
)
<
0
)
return
false
;
return
false
;
fd
->
input
=
open
(
fd
->
path
,
O_RDONLY
|
O_NONBLOCK
);
fd
->
input
=
open
(
fd
->
path
,
O_RDONLY
|
O_NONBLOCK
);
if
(
fd
->
input
<
0
)
{
if
(
fd
->
input
<
0
)
{
g_warning
(
"Could not open FIFO
\"
%s
\"
for reading: %s"
,
g_warning
(
"Could not open FIFO
\"
%s
\"
for reading: %s"
,
fd
->
path
,
strerror
(
errno
));
fd
->
path
,
strerror
(
errno
));
closeFifo
(
fd
);
fifo_close
(
fd
);
return
false
;
return
false
;
}
}
...
@@ -147,7 +151,7 @@ static bool openFifo(FifoData *fd)
...
@@ -147,7 +151,7 @@ static bool openFifo(FifoData *fd)
if
(
fd
->
output
<
0
)
{
if
(
fd
->
output
<
0
)
{
g_warning
(
"Could not open FIFO
\"
%s
\"
for writing: %s"
,
g_warning
(
"Could not open FIFO
\"
%s
\"
for writing: %s"
,
fd
->
path
,
strerror
(
errno
));
fd
->
path
,
strerror
(
errno
));
closeFifo
(
fd
);
fifo_close
(
fd
);
return
false
;
return
false
;
}
}
...
@@ -155,10 +159,10 @@ static bool openFifo(FifoData *fd)
...
@@ -155,10 +159,10 @@ static bool openFifo(FifoData *fd)
}
}
static
void
*
static
void
*
fifo_
initDriver
(
G_GNUC_UNUSED
const
struct
audio_format
*
audio_format
,
fifo_
output_init
(
G_GNUC_UNUSED
const
struct
audio_format
*
audio_format
,
const
struct
config_param
*
param
)
const
struct
config_param
*
param
)
{
{
FifoD
ata
*
fd
;
struct
fifo_d
ata
*
fd
;
char
*
value
,
*
path
;
char
*
value
,
*
path
;
value
=
config_dup_block_string
(
param
,
"path"
,
NULL
);
value
=
config_dup_block_string
(
param
,
"path"
,
NULL
);
...
@@ -173,45 +177,48 @@ fifo_initDriver(G_GNUC_UNUSED const struct audio_format *audio_format,
...
@@ -173,45 +177,48 @@ fifo_initDriver(G_GNUC_UNUSED const struct audio_format *audio_format,
"at line %i"
,
param
->
line
);
"at line %i"
,
param
->
line
);
}
}
fd
=
newFifoData
();
fd
=
fifo_data_new
();
fd
->
path
=
path
;
fd
->
path
=
path
;
if
(
!
openFifo
(
fd
))
{
if
(
!
fifo_open
(
fd
))
{
f
reeFifoData
(
fd
);
f
ifo_data_free
(
fd
);
return
NULL
;
return
NULL
;
}
}
return
fd
;
return
fd
;
}
}
static
void
fifo_finishDriver
(
void
*
data
)
static
void
fifo_output_finish
(
void
*
data
)
{
{
FifoData
*
fd
=
(
FifoD
ata
*
)
data
;
struct
fifo_data
*
fd
=
(
struct
fifo_d
ata
*
)
data
;
closeFifo
(
fd
);
fifo_close
(
fd
);
f
reeFifoData
(
fd
);
f
ifo_data_free
(
fd
);
}
}
static
bool
fifo_openDevice
(
void
*
data
,
static
bool
struct
audio_format
*
audio_format
)
fifo_output_open
(
void
*
data
,
struct
audio_format
*
audio_format
)
{
{
FifoData
*
fd
=
(
FifoD
ata
*
)
data
;
struct
fifo_data
*
fd
=
(
struct
fifo_d
ata
*
)
data
;
fd
->
timer
=
timer_new
(
audio_format
);
fd
->
timer
=
timer_new
(
audio_format
);
return
true
;
return
true
;
}
}
static
void
fifo_closeDevice
(
void
*
data
)
static
void
fifo_output_close
(
void
*
data
)
{
{
FifoData
*
fd
=
(
FifoD
ata
*
)
data
;
struct
fifo_data
*
fd
=
(
struct
fifo_d
ata
*
)
data
;
timer_free
(
fd
->
timer
);
timer_free
(
fd
->
timer
);
}
}
static
void
fifo_dropBufferedAudio
(
void
*
data
)
static
void
fifo_output_cancel
(
void
*
data
)
{
{
FifoData
*
fd
=
(
FifoD
ata
*
)
data
;
struct
fifo_data
*
fd
=
(
struct
fifo_d
ata
*
)
data
;
char
buf
[
FIFO_BUFFER_SIZE
];
char
buf
[
FIFO_BUFFER_SIZE
];
int
bytes
=
1
;
int
bytes
=
1
;
...
@@ -227,9 +234,9 @@ static void fifo_dropBufferedAudio(void *data)
...
@@ -227,9 +234,9 @@ static void fifo_dropBufferedAudio(void *data)
}
}
static
size_t
static
size_t
fifo_
playAudio
(
void
*
data
,
const
void
*
chunk
,
size_t
size
)
fifo_
output_play
(
void
*
data
,
const
void
*
chunk
,
size_t
size
)
{
{
FifoData
*
fd
=
(
FifoD
ata
*
)
data
;
struct
fifo_data
*
fd
=
(
struct
fifo_d
ata
*
)
data
;
ssize_t
bytes
;
ssize_t
bytes
;
if
(
!
fd
->
timer
->
started
)
if
(
!
fd
->
timer
->
started
)
...
@@ -248,7 +255,7 @@ fifo_playAudio(void *data, const void *chunk, size_t size)
...
@@ -248,7 +255,7 @@ fifo_playAudio(void *data, const void *chunk, size_t size)
switch
(
errno
)
{
switch
(
errno
)
{
case
EAGAIN
:
case
EAGAIN
:
/* The pipe is full, so empty it */
/* The pipe is full, so empty it */
fifo_
dropBufferedAudio
(
fd
);
fifo_
output_cancel
(
fd
);
continue
;
continue
;
case
EINTR
:
case
EINTR
:
continue
;
continue
;
...
@@ -261,12 +268,12 @@ fifo_playAudio(void *data, const void *chunk, size_t size)
...
@@ -261,12 +268,12 @@ fifo_playAudio(void *data, const void *chunk, size_t size)
}
}
}
}
const
struct
audio_output_plugin
fifo
P
lugin
=
{
const
struct
audio_output_plugin
fifo
_output_p
lugin
=
{
.
name
=
"fifo"
,
.
name
=
"fifo"
,
.
init
=
fifo_
initDriver
,
.
init
=
fifo_
output_init
,
.
finish
=
fifo_
finishDriver
,
.
finish
=
fifo_
output_finish
,
.
open
=
fifo_o
penDevice
,
.
open
=
fifo_o
utput_open
,
.
play
=
fifo_playAudio
,
.
close
=
fifo_output_close
,
.
cancel
=
fifo_dropBufferedAudio
,
.
play
=
fifo_output_play
,
.
c
lose
=
fifo_closeDevice
,
.
c
ancel
=
fifo_output_cancel
,
};
};
src/output_list.c
View file @
74af4e4c
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
extern
const
struct
audio_output_plugin
shoutPlugin
;
extern
const
struct
audio_output_plugin
shoutPlugin
;
extern
const
struct
audio_output_plugin
null_output_plugin
;
extern
const
struct
audio_output_plugin
null_output_plugin
;
extern
const
struct
audio_output_plugin
fifo
P
lugin
;
extern
const
struct
audio_output_plugin
fifo
_output_p
lugin
;
extern
const
struct
audio_output_plugin
alsaPlugin
;
extern
const
struct
audio_output_plugin
alsaPlugin
;
extern
const
struct
audio_output_plugin
ao_output_plugin
;
extern
const
struct
audio_output_plugin
ao_output_plugin
;
extern
const
struct
audio_output_plugin
ossPlugin
;
extern
const
struct
audio_output_plugin
ossPlugin
;
...
@@ -37,7 +37,7 @@ const struct audio_output_plugin *audio_output_plugins[] = {
...
@@ -37,7 +37,7 @@ const struct audio_output_plugin *audio_output_plugins[] = {
#endif
#endif
&
null_output_plugin
,
&
null_output_plugin
,
#ifdef HAVE_FIFO
#ifdef HAVE_FIFO
&
fifo
P
lugin
,
&
fifo
_output_p
lugin
,
#endif
#endif
#ifdef HAVE_ALSA
#ifdef HAVE_ALSA
&
alsaPlugin
,
&
alsaPlugin
,
...
...
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