/src/vlc/modules/codec/spdif.c
Line | Count | Source |
1 | | /***************************************************************************** |
2 | | * spdif.c: S/PDIF pass-though decoder |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2016 VLC authors and VideoLAN |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify it |
7 | | * under the terms of the GNU Lesser General Public License as published by |
8 | | * the Free Software Foundation; either version 2.1 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
19 | | *****************************************************************************/ |
20 | | |
21 | | #ifdef HAVE_CONFIG_H |
22 | | # include "config.h" |
23 | | #endif |
24 | | |
25 | | #include <vlc_common.h> |
26 | | #include <vlc_plugin.h> |
27 | | #include <vlc_aout.h> |
28 | | #include <vlc_codec.h> |
29 | | #include <vlc_modules.h> |
30 | | |
31 | | static int OpenDecoder(vlc_object_t *); |
32 | | |
33 | 150 | vlc_module_begin() |
34 | 75 | set_subcategory(SUBCAT_INPUT_ACODEC) |
35 | 75 | set_description(N_("S/PDIF pass-through decoder")) |
36 | 75 | set_capability("audio decoder", 120) |
37 | 75 | set_callback(OpenDecoder) |
38 | 75 | vlc_module_end() |
39 | | |
40 | | static int |
41 | | DecodeBlock(decoder_t *p_dec, block_t *p_block) |
42 | 0 | { |
43 | 0 | if (p_block != NULL) |
44 | 0 | decoder_QueueAudio( p_dec, p_block ); |
45 | 0 | return VLCDEC_SUCCESS; |
46 | 0 | } |
47 | | |
48 | | static int |
49 | | OpenDecoder(vlc_object_t *p_this) |
50 | 2.49M | { |
51 | 2.49M | decoder_t *p_dec = (decoder_t*)p_this; |
52 | | |
53 | 2.49M | switch (p_dec->fmt_in->i_codec) |
54 | 2.49M | { |
55 | 139k | case VLC_CODEC_MPGA: |
56 | 139k | case VLC_CODEC_MP2: |
57 | 184k | case VLC_CODEC_MP3: |
58 | | /* Disabled by default */ |
59 | 184k | if (!p_dec->obj.force) |
60 | 184k | return VLC_EGENERIC; |
61 | 0 | break; |
62 | 17.7k | case VLC_CODEC_A52: |
63 | 73.9k | case VLC_CODEC_EAC3: |
64 | 74.1k | case VLC_CODEC_MLP: |
65 | 77.7k | case VLC_CODEC_TRUEHD: |
66 | 103k | case VLC_CODEC_DTS: |
67 | 103k | case VLC_CODEC_SPDIFL: |
68 | 103k | case VLC_CODEC_SPDIFB: |
69 | | /* Enabled by default */ |
70 | 103k | break; |
71 | 2.20M | default: |
72 | 2.20M | return VLC_EGENERIC; |
73 | 2.49M | } |
74 | | |
75 | | /* Set output properties */ |
76 | 103k | p_dec->fmt_out.i_codec = p_dec->fmt_in->i_codec; |
77 | 103k | p_dec->fmt_out.audio = p_dec->fmt_in->audio; |
78 | 103k | p_dec->fmt_out.i_profile = p_dec->fmt_in->i_profile; |
79 | 103k | p_dec->fmt_out.audio.i_format = p_dec->fmt_out.i_codec; |
80 | | |
81 | 103k | if (decoder_UpdateAudioFormat(p_dec)) |
82 | 103k | return VLC_EGENERIC; |
83 | | |
84 | 0 | p_dec->pf_decode = DecodeBlock; |
85 | 0 | p_dec->pf_flush = NULL; |
86 | |
|
87 | 0 | return VLC_SUCCESS; |
88 | 103k | } |