Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
mediastreamer2
Commits
321a3f9d
Commit
321a3f9d
authored
Jan 21, 2016
by
Ghislain MARY
Browse files
Fix resampler configuration in media player.
parent
ef599c81
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/voip/msmediaplayer.c
View file @
321a3f9d
...
...
@@ -110,7 +110,7 @@ bool_t ms_media_player_open(MSMediaPlayer *obj, const char *filepath) {
wave_header_t
header
;
int
fd
;
char
*
tmp
;
ms_message
(
"Open
n
ing %s"
,
filepath
);
ms_message
(
"Opening %s"
,
filepath
);
if
(
access
(
filepath
,
F_OK
)
!=
0
)
{
ms_error
(
"Cannot open %s. File does not exist"
,
filepath
);
return
FALSE
;
...
...
@@ -341,19 +341,29 @@ static void _create_decoders(MSMediaPlayer *obj) {
}
static
void
_create_sinks
(
MSMediaPlayer
*
obj
)
{
int
sink_sample_rate
,
sample_rate
,
nchannels
;
int
sink_sample_rate
,
sample_rate
,
sink_nchannels
,
nchannels
;
bool_t
need_resampler
=
FALSE
;
if
(
obj
->
audio_pin_fmt
.
fmt
&&
obj
->
snd_card
)
{
sample_rate
=
obj
->
audio_pin_fmt
.
fmt
->
rate
;
nchannels
=
obj
->
audio_pin_fmt
.
fmt
->
nchannels
;
if
((
obj
->
audio_sink
=
ms_snd_card_create_writer
(
obj
->
snd_card
)))
{
if
(
ms_filter_call_method
(
obj
->
audio_sink
,
MS_FILTER_SET_SAMPLE_RATE
,
&
sample_rate
)
==
-
1
)
{
if
(
ms_filter_call_method
(
obj
->
audio_sink
,
MS_FILTER_SET_SAMPLE_RATE
,
&
sample_rate
)
==
-
1
)
{
ms_warning
(
"The sound card (%s) does not support %dHz"
,
obj
->
snd_card
->
name
,
sample_rate
);
ms_filter_call_method
(
obj
->
audio_sink
,
MS_FILTER_GET_SAMPLE_RATE
,
&
sink_sample_rate
);
need_resampler
=
TRUE
;
}
if
(
ms_filter_call_method
(
obj
->
audio_sink
,
MS_FILTER_SET_NCHANNELS
,
&
nchannels
)
==
-
1
)
{
ms_warning
(
"The sound card (%s) does not support %d channels"
,
obj
->
snd_card
->
name
,
nchannels
);
ms_filter_call_method
(
obj
->
audio_sink
,
MS_FILTER_GET_NCHANNELS
,
&
sink_nchannels
);
need_resampler
=
TRUE
;
}
if
(
need_resampler
==
TRUE
)
{
ms_message
(
"Resampling to %dHz"
,
sink_sample_rate
);
obj
->
resampler
=
ms_filter_new
(
MS_RESAMPLE_ID
);
ms_filter_call_method
(
obj
->
resampler
,
MS_FILTER_SET_SAMPLE_RATE
,
&
sample_rate
);
ms_filter_call_method
(
obj
->
resampler
,
MS_FILTER_SET_OUTPUT_SAMPLE_RATE
,
&
sink_sample_rate
);
ms_filter_call_method
(
obj
->
resampler
,
MS_FILTER_SET_NCHANNELS
,
&
nchannels
);
ms_filter_call_method
(
obj
->
resampler
,
MS_FILTER_SET_OUTPUT_NCHANNELS
,
&
sink_nchannels
);
}
ms_filter_call_method
(
obj
->
audio_sink
,
MS_FILTER_SET_NCHANNELS
,
&
nchannels
);
}
else
{
...
...
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