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
67c642c9
Commit
67c642c9
authored
Sep 08, 2008
by
Eric Wong
Committed by
Max Kellermann
Sep 08, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alsa: avoid unnecessary heap usage if we don't set a device name
parent
f1f1104b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
audioOutput_alsa.c
src/audioOutputs/audioOutput_alsa.c
+12
-11
No files found.
src/audioOutputs/audioOutput_alsa.c
View file @
67c642c9
...
...
@@ -23,6 +23,8 @@
#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
static
const
char
default_device
[]
=
"default"
;
#define MPD_ALSA_BUFFER_TIME_US 500000
/* the default period time of xmms is 50 ms, so let's use that as well.
* a user can tweak this parameter via the "period_time" config parameter.
...
...
@@ -39,7 +41,7 @@ typedef snd_pcm_sframes_t alsa_writei_t(snd_pcm_t * pcm, const void *buffer,
snd_pcm_uframes_t
size
);
typedef
struct
_AlsaData
{
char
*
device
;
c
onst
c
har
*
device
;
snd_pcm_t
*
pcmHandle
;
alsa_writei_t
*
writei
;
unsigned
int
buffer_time
;
...
...
@@ -52,7 +54,7 @@ static AlsaData *newAlsaData(void)
{
AlsaData
*
ret
=
xmalloc
(
sizeof
(
AlsaData
));
ret
->
device
=
NULL
;
ret
->
device
=
default_device
;
ret
->
pcmHandle
=
NULL
;
ret
->
writei
=
snd_pcm_writei
;
ret
->
useMmap
=
0
;
...
...
@@ -64,9 +66,8 @@ static AlsaData *newAlsaData(void)
static
void
freeAlsaData
(
AlsaData
*
ad
)
{
if
(
ad
->
device
)
free
(
ad
->
device
);
if
(
ad
->
device
&&
ad
->
device
!=
default_device
)
xfree
(
ad
->
device
);
free
(
ad
);
}
...
...
@@ -76,9 +77,10 @@ static int alsa_initDriver(struct audio_output *audioOutput,
AlsaData
*
ad
=
newAlsaData
();
if
(
param
)
{
BlockParam
*
bp
=
getBlockParam
(
param
,
"device"
);
ad
->
device
=
bp
?
xstrdup
(
bp
->
value
)
:
xstrdup
(
"default"
);
BlockParam
*
bp
;
if
((
bp
=
getBlockParam
(
param
,
"device"
)))
ad
->
device
=
xstrdup
(
bp
->
value
);
ad
->
useMmap
=
getBoolBlockParam
(
param
,
"use_mmap"
,
1
);
if
(
ad
->
useMmap
==
CONF_BOOL_UNSET
)
ad
->
useMmap
=
0
;
...
...
@@ -86,8 +88,7 @@ static int alsa_initDriver(struct audio_output *audioOutput,
ad
->
buffer_time
=
atoi
(
bp
->
value
);
if
((
bp
=
getBlockParam
(
param
,
"period_time"
)))
ad
->
period_time
=
atoi
(
bp
->
value
);
}
else
ad
->
device
=
xstrdup
(
"default"
);
}
audioOutput
->
data
=
ad
;
return
0
;
...
...
@@ -104,8 +105,8 @@ static int alsa_testDefault(void)
{
snd_pcm_t
*
handle
;
int
ret
=
snd_pcm_open
(
&
handle
,
"default"
,
SND_PCM_STREAM_PLAYBACK
,
SND_PCM_NONBLOCK
);
int
ret
=
snd_pcm_open
(
&
handle
,
default_device
,
SND_PCM_STREAM_PLAYBACK
,
SND_PCM_NONBLOCK
);
snd_config_update_free_global
();
if
(
ret
)
{
...
...
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