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
7f183f68
Commit
7f183f68
authored
Mar 05, 2005
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
now alsa plugin should work
git-svn-id:
https://svn.musicpd.org/mpd/trunk@3009
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
d1a4bb38
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
audioOutput_alsa.c
src/audioOutputs/audioOutput_alsa.c
+13
-7
No files found.
src/audioOutputs/audioOutput_alsa.c
View file @
7f183f68
...
...
@@ -46,6 +46,7 @@ typedef struct _AlsaData {
snd_pcm_t
*
pcm_handle
;
int
mmap
;
alsa_writei_t
*
writei
;
int
sampleSize
;
}
AlsaData
;
static
AlsaData
*
newAlsaData
()
{
...
...
@@ -122,10 +123,10 @@ static int alsa_openDevice(AudioOutput * audioOutput)
goto
error
;
}
err
=
snd_pcm_nonblock
(
ad
->
pcm_handle
,
0
);
if
(
err
<
0
)
goto
error
;
/*
err = snd_pcm_nonblock(ad->pcm_handle, 0);
if(err < 0) goto error;
*/
/
/ configure HW params
/
* configure HW params */
snd_pcm_hw_params_alloca
(
&
hwparams
);
err
=
snd_pcm_hw_params_any
(
ad
->
pcm_handle
,
hwparams
);
...
...
@@ -148,7 +149,7 @@ static int alsa_openDevice(AudioOutput * audioOutput)
err
=
snd_pcm_hw_params_set_access
(
ad
->
pcm_handle
,
hwparams
,
SND_PCM_ACCESS_RW_INTERLEAVED
);
if
(
err
<
0
)
goto
error
;
ad
->
writei
=
snd_pcm_
mmap_
writei
;
ad
->
writei
=
snd_pcm_writei
;
}
err
=
snd_pcm_hw_params_set_format
(
ad
->
pcm_handle
,
hwparams
,
bitformat
);
...
...
@@ -160,7 +161,7 @@ static int alsa_openDevice(AudioOutput * audioOutput)
}
err
=
snd_pcm_hw_params_set_channels
(
ad
->
pcm_handle
,
hwparams
,
(
unsigned
int
)
audioFormat
->
channels
);
audioFormat
->
channels
);
if
(
err
<
0
)
{
ERROR
(
"Alsa device
\"
%s
\"
does not support %i channels: "
"%s
\n
"
,
ad
->
device
,
(
int
)
audioFormat
->
channels
,
...
...
@@ -193,7 +194,7 @@ static int alsa_openDevice(AudioOutput * audioOutput)
err
=
snd_pcm_hw_params_get_period_size
(
hwparams
,
&
alsa_period_size
,
0
);
if
(
err
<
0
)
goto
error
;
/
/ configure SW params
/
* configure SW params */
snd_pcm_sw_params_alloca
(
&
swparams
);
snd_pcm_sw_params_current
(
ad
->
pcm_handle
,
swparams
);
...
...
@@ -204,6 +205,8 @@ static int alsa_openDevice(AudioOutput * audioOutput)
err
=
snd_pcm_sw_params
(
ad
->
pcm_handle
,
swparams
);
if
(
err
<
0
)
goto
error
;
ad
->
sampleSize
=
(
audioFormat
->
bits
/
8
)
*
audioFormat
->
channels
;
audioOutput
->
open
=
1
;
return
0
;
...
...
@@ -213,6 +216,7 @@ error:
snd_strerror
(
-
err
));
fail:
if
(
ad
->
pcm_handle
)
snd_pcm_close
(
ad
->
pcm_handle
);
ad
->
pcm_handle
=
NULL
;
audioOutput
->
open
=
0
;
return
-
1
;
}
...
...
@@ -245,6 +249,8 @@ static int alsa_playAudio(AudioOutput * audioOutput, char * playChunk,
AlsaData
*
ad
=
audioOutput
->
data
;
int
ret
;
size
/=
ad
->
sampleSize
;
while
(
size
>
0
)
{
ret
=
ad
->
writei
(
ad
->
pcm_handle
,
playChunk
,
size
);
...
...
@@ -257,7 +263,7 @@ static int alsa_playAudio(AudioOutput * audioOutput, char * playChunk,
alsa_closeDevice
(
audioOutput
);
return
-
1
;
}
playChunk
+=
ret
;
playChunk
+=
ret
*
ad
->
sampleSize
;
size
-=
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