Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
e8472670
Commit
e8472670
authored
4 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Add initial support for pulseaudio
parent
dfbe0b3c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xpdev/Common.gmake
+7
-0
7 additions, 0 deletions
src/xpdev/Common.gmake
src/xpdev/xpbeep.c
+84
-0
84 additions, 0 deletions
src/xpdev/xpbeep.c
with
91 additions
and
0 deletions
src/xpdev/Common.gmake
+
7
−
0
View file @
e8472670
...
...
@@ -124,6 +124,13 @@ ifdef USE_SDL_AUDIO
endif
endif
ifndef NO_PULSEAUDIO
ifeq ($(shell command -v pkg-config > /dev/null && pkg-config --exists libpulse && echo 'YES' ; fi),YES)
XPDEV_CFLAGS += -DWITH_PULSEAUDIO
XPDEV_MT_CFLAGS += -DWITH_PULSEAUDIO
endif
endif
ifdef STATIC
STATIC_SDL := true
endif
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/xpbeep.c
+
84
−
0
View file @
e8472670
...
...
@@ -53,6 +53,10 @@
#include
<portaudio.h>
#endif
#ifdef WITH_PULSEAUDIO
#include
<pulse/simple.h>
#endif
#ifdef WITH_SDL_AUDIO
#include
"sdlfuncs.h"
#endif
...
...
@@ -86,6 +90,9 @@ static BOOL sdl_device_open_failed=FALSE;
#ifdef WITH_PORTAUDIO
static
BOOL
portaudio_device_open_failed
=
FALSE
;
#endif
#ifdef WITH_PULSEAUDIO
static
BOOL
pulseaudio_device_open_failed
=
FALSE
;
#endif
enum
{
SOUND_DEVICE_CLOSED
...
...
@@ -94,11 +101,23 @@ enum {
,
SOUND_DEVICE_OSS
,
SOUND_DEVICE_SDL
,
SOUND_DEVICE_PORTAUDIO
,
SOUND_DEVICE_PULSEAUDIO
};
static
int
handle_type
=
SOUND_DEVICE_CLOSED
;
static
int
handle_rc
;
#ifdef WITH_PULSEAUDIO
struct
pulseaudio_api_struct
{
pa_simple
*
(
*
simple_new
)(
const
char
*
server
,
const
char
*
name
,
pa_stream_direction_t
dir
,
const
char
*
dev
,
const
char
*
stream_name
,
const
pa_sample_spec
*
ss
,
const
pa_channel_map
*
map
,
const
pa_buffer_attr
*
attr
,
int
*
error
);
int
(
*
simple_write
)(
simple
*
s
,
const
void
*
data
,
size_t
bytes
,
int
*
error
);
int
(
*
simple_drain
)(
pa_simple
*
s
,
int
*
error
);
void
(
*
simple_free
)(
pa_simple
*
s
);
};
struct
pulseaudio_api_struct
pu_api
=
NULL
;
static
pa_simple
*
pu_handle
;
#endif
#ifdef WITH_PORTAUDIO
static
PaStream
*
portaudio_stream
;
static
int
portaudio_buf_len
=
0
;
...
...
@@ -365,6 +384,47 @@ DLLCALL xptone_open_locked(void)
return
(
TRUE
);
}
#ifdef WITH_PULSEAUDIO
if
(
!
pulseaudio_device_open_failed
)
{
if
(
pu_api
==
NULL
)
{
dll_handle
dl
=
NULL
;
const
char
*
libnames
[]
=
{
"pulse"
,
NULL
};
if
(((
pu_api
=
(
struct
pulseaudio_api_struct
*
)
malloc
(
sizeof
(
struct
pulseaudio_api_struct
)))
==
NULL
)
||
((
dl
=
xp_dlopen
(
libnames
,
RTLD_LAZY
,
0
))
==
NULL
)
||
((
pu_api
->
simple_new
=
xp_dlsym
(
dl
,
pa_simple_new
))
==
NULL
)
||
((
pu_api
->
simple_write
=
xp_dlsym
(
dl
,
pa_simple_write
))
==
NULL
)
||
((
pu_api
->
simple_drain
=
xp_dlsym
(
dl
,
pa_simple_drain
))
==
NULL
)
||
((
pu_api
->
simple_fre
=
xp_dlsym
(
dl
,
pa_simple_free
))
==
NULL
)
)
{
if
(
dl
)
xp_dlclose
(
dl
);
free
(
pu_api
);
pu_api
=
NULL
;
}
if
(
pu_api
==
NULL
)
{
pulseaudio_device_open_failed
=
TRUE
;
}
}
if
(
pu_api
!=
NULL
)
{
if
(
!
pulseaudio_initialized
)
{
pa_sample_spec
ss
;
ss
.
format
=
PA_SAMPLE_U8
;
ss
.
rate
=
22050
;
ss
.
channels
=
1
;
if
((
pu_handle
=
pu_api
->
simple_new
(
NULL
,
"XPBeep"
,
PA_STREAM_PLAYBACK
,
NULL
,
"Beeps and Boops"
,
&
ss
,
NULL
,
NULL
,
NULL
))
==
NULL
)
pulseaudio_device_open_failed
=
TRUE
;
else
pulseaudio_initialized
=
TRUE
;
}
if
(
pulseaudio_initialized
)
{
handle_type
=
SOUND_DEVICE_PORTAUDIO
;
handle_rc
++
;
return
(
TRUE
);
}
}
}
#endif
#ifdef WITH_PORTAUDIO
if
(
!
portaudio_device_open_failed
)
{
if
(
pa_api
==
NULL
)
{
...
...
@@ -599,6 +659,14 @@ xptone_complete_locked(void)
if
(
handle_type
==
SOUND_DEVICE_CLOSED
)
{
return
;
}
#ifdef WITH_PULSEAUDIO
else
if
(
handle
->
type
==
SOUND_DEVICE_PULSEAUDIO
)
{
int
err
;
pu_api
.
simple_drain
(
pu_handle
,
&
err
);
}
#endif
#ifdef WITH_PORTAUDIO
else
if
(
handle_type
==
SOUND_DEVICE_PORTAUDIO
)
{
pa_api
->
stop
(
portaudio_stream
);
...
...
@@ -672,6 +740,12 @@ BOOL DLLCALL xptone_close_locked(void)
}
#endif
#ifdef WITH_PULSEAUDIO
if
(
handle_type
==
SOUND_DEVICE_PULSEAUDIO
)
{
pu_api
->
simple_free
(
pu_handle
);
}
#endif
#ifdef WITH_SDL_AUDIO
if
(
handle_type
==
SOUND_DEVICE_SDL
)
{
xpbeep_sdl
.
CloseAudio
();
...
...
@@ -708,6 +782,9 @@ BOOL DLLCALL xptone_close_locked(void)
#ifdef WITH_PORTAUDIO
portaudio_device_open_failed
=
FALSE
;
#endif
#ifdef WITH_PULSEAUDIO
pulseaudio_device_open_failed
=
FALSE
;
#endif
return
(
TRUE
);
}
...
...
@@ -769,6 +846,13 @@ do_xp_play_sample(const unsigned char *sampo, size_t sz, int *freed)
samp
=
sampo
;
}
#ifdef WITH_PULSEAUDIO
if
(
handle_type
==
SOUND_DEVICE_PULSEAUDIO
)
{
int
err
;
pu_api
->
simple_write
(
pu_handle
,
sampo
,
sz
,
&
err
);
}
#endif
#ifdef WITH_PORTAUDIO
if
(
handle_type
==
SOUND_DEVICE_PORTAUDIO
)
{
if
(
pa_api
->
ver
>=
1899
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment