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
96546c1a
Commit
96546c1a
authored
Jan 16, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/alsa: merged code into alsa_output_try_format()
Remove the debug log messages, because they are duplicate (see ao_open() in output_thread.c).
parent
579a8a96
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
51 deletions
+71
-51
alsa_plugin.c
src/output/alsa_plugin.c
+71
-51
No files found.
src/output/alsa_plugin.c
View file @
96546c1a
...
...
@@ -218,6 +218,48 @@ byteswap_bitformat(snd_pcm_format_t fmt)
}
/**
* Attempts to configure the specified sample format.
*/
static
int
alsa_output_try_format
(
snd_pcm_t
*
pcm
,
snd_pcm_hw_params_t
*
hwparams
,
struct
audio_format
*
audio_format
,
enum
sample_format
sample_format
)
{
snd_pcm_format_t
alsa_format
=
get_bitformat
(
sample_format
);
if
(
alsa_format
==
SND_PCM_FORMAT_UNKNOWN
)
return
-
EINVAL
;
int
err
=
snd_pcm_hw_params_set_format
(
pcm
,
hwparams
,
alsa_format
);
if
(
err
==
0
)
audio_format
->
format
=
sample_format
;
return
err
;
}
/**
* Attempts to configure the specified sample format with reversed
* host byte order.
*/
static
int
alsa_output_try_reverse
(
snd_pcm_t
*
pcm
,
snd_pcm_hw_params_t
*
hwparams
,
struct
audio_format
*
audio_format
,
enum
sample_format
sample_format
)
{
snd_pcm_format_t
alsa_format
=
byteswap_bitformat
(
get_bitformat
(
sample_format
));
if
(
alsa_format
==
SND_PCM_FORMAT_UNKNOWN
)
return
-
EINVAL
;
int
err
=
snd_pcm_hw_params_set_format
(
pcm
,
hwparams
,
alsa_format
);
if
(
err
==
0
)
{
audio_format
->
format
=
sample_format
;
audio_format
->
reverse_endian
=
true
;
}
return
err
;
}
/**
* Configure a sample format, and probe other formats if that fails.
*/
static
int
...
...
@@ -234,66 +276,44 @@ alsa_output_setup_format(snd_pcm_t *pcm, snd_pcm_hw_params_t *hwparams,
}
int
err
=
snd_pcm_hw_params_set_format
(
pcm
,
hwparams
,
bitformat
);
if
(
err
==
-
EINVAL
&&
byteswap_bitformat
(
bitformat
)
!=
SND_PCM_FORMAT_UNKNOWN
)
{
err
=
snd_pcm_hw_params_set_format
(
pcm
,
hwparams
,
byteswap_bitformat
(
bitformat
));
if
(
err
==
0
)
{
g_debug
(
"converting format %s to reverse-endian"
,
sample_format_to_string
(
audio_format
->
format
));
audio_format
->
reverse_endian
=
1
;
}
}
if
(
err
!=
-
EINVAL
)
return
err
;
if
(
err
==
-
EINVAL
&&
(
audio_format
->
format
==
SAMPLE_FORMAT_S24_P32
||
audio_format
->
format
==
SAMPLE_FORMAT_S16
))
{
/* fall back to 32 bit, let pcm_convert.c do the conversion */
err
=
snd_pcm_hw_params_set_format
(
pcm
,
hwparams
,
SND_PCM_FORMAT_S32
);
if
(
err
==
0
)
{
g_debug
(
"converting format %s to 32 bit
\n
"
,
sample_format_to_string
(
audio_format
->
format
));
audio_format
->
format
=
SAMPLE_FORMAT_S32
;
}
}
err
=
alsa_output_try_reverse
(
pcm
,
hwparams
,
audio_format
,
audio_format
->
format
);
if
(
err
!=
-
EINVAL
)
return
err
;
if
(
err
==
-
EINVAL
&&
(
audio_format
->
format
==
SAMPLE_FORMAT_S24_P32
||
audio_format
->
format
==
SAMPLE_FORMAT_S16
)
)
{
if
(
audio_format
->
format
==
SAMPLE_FORMAT_S24_P32
||
audio_format
->
format
==
SAMPLE_FORMAT_S16
)
{
/* fall back to 32 bit, let pcm_convert.c do the conversion */
err
=
snd_pcm_hw_params_set_format
(
pcm
,
hwparams
,
byteswap_bitformat
(
SND_PCM_FORMAT_S32
));
if
(
err
==
0
)
{
g_debug
(
"converting format %s to 32 bit backward-endian
\n
"
,
sample_format_to_string
(
audio_format
->
format
));
audio_format
->
format
=
SAMPLE_FORMAT_S32
;
audio_format
->
reverse_endian
=
1
;
}
}
if
(
err
==
-
EINVAL
&&
audio_format
->
format
!=
SAMPLE_FORMAT_S16
)
{
/* fall back to 16 bit, let pcm_convert.c do the conversion */
err
=
snd_pcm_hw_params_set_format
(
pcm
,
hwparams
,
SND_PCM_FORMAT_S16
)
;
if
(
err
==
0
)
{
g_debug
(
"converting format %s to 16 bit
\n
"
,
sample_format_to_string
(
audio_format
->
format
)
);
audio_format
->
format
=
SAMPLE_FORMAT_S16
;
}
err
=
alsa_output_try_format
(
pcm
,
hwparams
,
audio_format
,
SAMPLE_FORMAT_S24_P32
);
if
(
err
!=
-
EINVAL
)
return
err
;
err
=
alsa_output_try_reverse
(
pcm
,
hwparams
,
audio_format
,
SAMPLE_FORMAT_S24_P32
);
if
(
err
!=
-
EINVAL
)
return
err
;
}
if
(
err
==
-
EINVAL
&&
audio_format
->
format
!=
SAMPLE_FORMAT_S16
)
{
if
(
audio_format
->
format
!=
SAMPLE_FORMAT_S16
)
{
/* fall back to 16 bit, let pcm_convert.c do the conversion */
err
=
snd_pcm_hw_params_set_format
(
pcm
,
hwparams
,
byteswap_bitformat
(
SND_PCM_FORMAT_S16
));
if
(
err
==
0
)
{
g_debug
(
"converting format %s to 16 bit backward-endian
\n
"
,
sample_format_to_string
(
audio_format
->
format
));
audio_format
->
format
=
SAMPLE_FORMAT_S16
;
audio_format
->
reverse_endian
=
1
;
}
err
=
alsa_output_try_format
(
pcm
,
hwparams
,
audio_format
,
SAMPLE_FORMAT_S16
);
if
(
err
!=
-
EINVAL
)
return
err
;
err
=
alsa_output_try_reverse
(
pcm
,
hwparams
,
audio_format
,
SAMPLE_FORMAT_S16
);
if
(
err
!=
-
EINVAL
)
return
err
;
}
return
err
;
return
-
EINVAL
;
}
/**
...
...
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