Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
fe726228
Commit
fe726228
authored
Aug 26, 2014
by
Lukasz Marek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavd/alsa: implement get_device_list callbacks
Signed-off-by:
Lukasz Marek
<
lukasz.m.luki2@gmail.com
>
parent
7f7facde
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
0 deletions
+66
-0
alsa-audio-common.c
libavdevice/alsa-audio-common.c
+52
-0
alsa-audio-dec.c
libavdevice/alsa-audio-dec.c
+6
-0
alsa-audio-enc.c
libavdevice/alsa-audio-enc.c
+6
-0
alsa-audio.h
libavdevice/alsa-audio.h
+2
-0
No files found.
libavdevice/alsa-audio-common.c
View file @
fe726228
...
@@ -343,3 +343,55 @@ int ff_alsa_extend_reorder_buf(AlsaData *s, int min_size)
...
@@ -343,3 +343,55 @@ int ff_alsa_extend_reorder_buf(AlsaData *s, int min_size)
s
->
reorder_buf_size
=
size
;
s
->
reorder_buf_size
=
size
;
return
0
;
return
0
;
}
}
/* ported from alsa-utils/aplay.c */
int
ff_alsa_get_device_list
(
AVDeviceInfoList
*
device_list
,
snd_pcm_stream_t
stream_type
)
{
int
ret
=
0
;
void
**
hints
,
**
n
;
char
*
name
=
NULL
,
*
descr
=
NULL
,
*
io
=
NULL
,
*
tmp
;
AVDeviceInfo
*
new_device
=
NULL
;
const
char
*
filter
=
stream_type
==
SND_PCM_STREAM_PLAYBACK
?
"Output"
:
"Input"
;
if
(
snd_device_name_hint
(
-
1
,
"pcm"
,
&
hints
)
<
0
)
return
AVERROR_EXTERNAL
;
n
=
hints
;
while
(
*
n
&&
!
ret
)
{
name
=
snd_device_name_get_hint
(
*
n
,
"NAME"
);
descr
=
snd_device_name_get_hint
(
*
n
,
"DESC"
);
io
=
snd_device_name_get_hint
(
*
n
,
"IOID"
);
if
(
!
io
||
!
strcmp
(
io
,
filter
))
{
new_device
=
av_mallocz
(
sizeof
(
AVDeviceInfo
));
if
(
!
new_device
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
fail
;
}
new_device
->
device_name
=
av_strdup
(
name
);
if
((
tmp
=
strrchr
(
descr
,
'\n'
))
&&
tmp
[
1
])
new_device
->
device_description
=
av_strdup
(
&
tmp
[
1
]);
else
new_device
->
device_description
=
av_strdup
(
descr
);
if
(
!
new_device
->
device_description
||
!
new_device
->
device_name
)
{
ret
=
AVERROR
(
ENOMEM
);
goto
fail
;
}
if
((
ret
=
av_dynarray_add_nofree
(
&
device_list
->
devices
,
&
device_list
->
nb_devices
,
new_device
))
<
0
)
{
goto
fail
;
}
new_device
=
NULL
;
}
fail:
free
(
io
);
free
(
name
);
free
(
descr
);
n
++
;
}
if
(
new_device
)
{
av_free
(
new_device
->
device_description
);
av_free
(
new_device
->
device_name
);
av_free
(
new_device
);
}
snd_device_name_free_hint
(
hints
);
return
ret
;
}
libavdevice/alsa-audio-dec.c
View file @
fe726228
...
@@ -132,6 +132,11 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
...
@@ -132,6 +132,11 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
return
0
;
return
0
;
}
}
static
int
audio_get_device_list
(
AVFormatContext
*
h
,
AVDeviceInfoList
*
device_list
)
{
return
ff_alsa_get_device_list
(
device_list
,
SND_PCM_STREAM_CAPTURE
);
}
static
const
AVOption
options
[]
=
{
static
const
AVOption
options
[]
=
{
{
"sample_rate"
,
""
,
offsetof
(
AlsaData
,
sample_rate
),
AV_OPT_TYPE_INT
,
{.
i64
=
48000
},
1
,
INT_MAX
,
AV_OPT_FLAG_DECODING_PARAM
},
{
"sample_rate"
,
""
,
offsetof
(
AlsaData
,
sample_rate
),
AV_OPT_TYPE_INT
,
{.
i64
=
48000
},
1
,
INT_MAX
,
AV_OPT_FLAG_DECODING_PARAM
},
{
"channels"
,
""
,
offsetof
(
AlsaData
,
channels
),
AV_OPT_TYPE_INT
,
{.
i64
=
2
},
1
,
INT_MAX
,
AV_OPT_FLAG_DECODING_PARAM
},
{
"channels"
,
""
,
offsetof
(
AlsaData
,
channels
),
AV_OPT_TYPE_INT
,
{.
i64
=
2
},
1
,
INT_MAX
,
AV_OPT_FLAG_DECODING_PARAM
},
...
@@ -153,6 +158,7 @@ AVInputFormat ff_alsa_demuxer = {
...
@@ -153,6 +158,7 @@ AVInputFormat ff_alsa_demuxer = {
.
read_header
=
audio_read_header
,
.
read_header
=
audio_read_header
,
.
read_packet
=
audio_read_packet
,
.
read_packet
=
audio_read_packet
,
.
read_close
=
ff_alsa_close
,
.
read_close
=
ff_alsa_close
,
.
get_device_list
=
audio_get_device_list
,
.
flags
=
AVFMT_NOFILE
,
.
flags
=
AVFMT_NOFILE
,
.
priv_class
=
&
alsa_demuxer_class
,
.
priv_class
=
&
alsa_demuxer_class
,
};
};
libavdevice/alsa-audio-enc.c
View file @
fe726228
...
@@ -142,6 +142,11 @@ audio_get_output_timestamp(AVFormatContext *s1, int stream,
...
@@ -142,6 +142,11 @@ audio_get_output_timestamp(AVFormatContext *s1, int stream,
*
dts
=
s
->
timestamp
-
delay
;
*
dts
=
s
->
timestamp
-
delay
;
}
}
static
int
audio_get_device_list
(
AVFormatContext
*
h
,
AVDeviceInfoList
*
device_list
)
{
return
ff_alsa_get_device_list
(
device_list
,
SND_PCM_STREAM_PLAYBACK
);
}
static
const
AVClass
alsa_muxer_class
=
{
static
const
AVClass
alsa_muxer_class
=
{
.
class_name
=
"ALSA muxer"
,
.
class_name
=
"ALSA muxer"
,
.
item_name
=
av_default_item_name
,
.
item_name
=
av_default_item_name
,
...
@@ -159,6 +164,7 @@ AVOutputFormat ff_alsa_muxer = {
...
@@ -159,6 +164,7 @@ AVOutputFormat ff_alsa_muxer = {
.
write_packet
=
audio_write_packet
,
.
write_packet
=
audio_write_packet
,
.
write_trailer
=
ff_alsa_close
,
.
write_trailer
=
ff_alsa_close
,
.
write_uncoded_frame
=
audio_write_frame
,
.
write_uncoded_frame
=
audio_write_frame
,
.
get_device_list
=
audio_get_device_list
,
.
get_output_timestamp
=
audio_get_output_timestamp
,
.
get_output_timestamp
=
audio_get_output_timestamp
,
.
flags
=
AVFMT_NOFILE
,
.
flags
=
AVFMT_NOFILE
,
.
priv_class
=
&
alsa_muxer_class
,
.
priv_class
=
&
alsa_muxer_class
,
...
...
libavdevice/alsa-audio.h
View file @
fe726228
...
@@ -99,4 +99,6 @@ int ff_alsa_xrun_recover(AVFormatContext *s1, int err);
...
@@ -99,4 +99,6 @@ int ff_alsa_xrun_recover(AVFormatContext *s1, int err);
int
ff_alsa_extend_reorder_buf
(
AlsaData
*
s
,
int
size
);
int
ff_alsa_extend_reorder_buf
(
AlsaData
*
s
,
int
size
);
int
ff_alsa_get_device_list
(
AVDeviceInfoList
*
device_list
,
snd_pcm_stream_t
stream_type
);
#endif
/* AVDEVICE_ALSA_AUDIO_H */
#endif
/* AVDEVICE_ALSA_AUDIO_H */
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