summaryrefslogtreecommitdiff
Diffstat
-rw-r--r--Android.mk1
-rwxr-xr-xamadec/Android.mk282
-rw-r--r--amadec/acodec_lib_50/libstagefright_soft_dcvdec.so80
-rw-r--r--amadec/acodec_lib_50/libstagefright_soft_dtshd.so85
-rw-r--r--amadec/acodec_lib_50/libstagefright_soft_truehddec.so41
-rw-r--r--amadec/acodec_lib_android_n/libstagefright_soft_dcvdec.so109
-rw-r--r--amadec/acodec_lib_android_n/libstagefright_soft_dtshd.so272
-rw-r--r--amadec/acodec_lib_android_n/libstagefright_soft_truehddec.so87
-rwxr-xr-xamadec/acodec_lib_mx/libstagefright_soft_ddpdec.so113
-rwxr-xr-xamadec/acodec_lib_mx/libstagefright_soft_dtshd.so121
-rw-r--r--amadec/adec-armdec-mgt.h57
-rw-r--r--amadec/adec-external-ctrl.c899
-rw-r--r--amadec/adec-ffmpeg-mgt.c1550
-rw-r--r--amadec/adec-internal-mgt.c772
-rw-r--r--amadec/adec-message.c156
-rw-r--r--amadec/adec-message.h61
-rwxr-xr-xamadec/adec-pts-mgt.c1107
-rw-r--r--amadec/adec-pts-mgt.h82
-rw-r--r--amadec/adec-wfd-out.cpp361
-rw-r--r--amadec/adec-wfd.c811
-rw-r--r--amadec/adec_omx_brige.c284
-rw-r--r--amadec/adec_omx_brige.h56
-rw-r--r--amadec/adec_read.c200
-rw-r--r--amadec/adec_reg.h76
-rw-r--r--amadec/adec_write.c189
-rw-r--r--amadec/adec_write.h42
-rw-r--r--amadec/audio-dec.h314
-rw-r--r--amadec/audio_out/alsa-out.c1082
-rw-r--r--amadec/audio_out/aml_resample.c708
-rw-r--r--amadec/audio_out/aml_resample.h86
-rwxr-xr-xamadec/audio_out/android-out.cpp1640
-rw-r--r--amadec/audiodsp_update_format.c188
-rw-r--r--amadec/dsp/audiodsp-ctl.c471
-rw-r--r--amadec/dts_enc.c209
-rw-r--r--amadec/dts_enc.h11
-rw-r--r--amadec/dts_transenc_api.c143
-rw-r--r--amadec/dts_transenc_api.h19
-rw-r--r--amadec/feeder.c231
-rw-r--r--amadec/feeder.h26
-rw-r--r--amadec/include/adec-external-ctrl.h63
-rwxr-xr-xamadec/include/adec-macros.h41
-rw-r--r--amadec/include/adec-types.h53
-rwxr-xr-xamadec/include/alsa-out.h26
-rw-r--r--amadec/include/audio-out.h41
-rw-r--r--amadec/include/audiodsp.h142
-rw-r--r--amadec/include/audiodsp_update_format.h25
-rw-r--r--amadec/include/log-print.h26
-rwxr-xr-xamadec/omx_audio/ALAC_mediasource.cpp205
-rw-r--r--amadec/omx_audio/ALAC_mediasource.h62
-rwxr-xr-xamadec/omx_audio/ASF_mediasource.cpp184
-rw-r--r--amadec/omx_audio/ASF_mediasource.h127
-rwxr-xr-xamadec/omx_audio/Android.mk34
-rwxr-xr-xamadec/omx_audio/DDP_mediasource.cpp528
-rw-r--r--amadec/omx_audio/DDP_mediasource.h141
-rw-r--r--amadec/omx_audio/DTSHD_mediasource.cpp316
-rw-r--r--amadec/omx_audio/DTSHD_mediasource.h74
-rwxr-xr-xamadec/omx_audio/MP3_mediasource.cpp579
-rw-r--r--amadec/omx_audio/MP3_mediasource.h80
-rw-r--r--amadec/omx_audio/THD_mediasource.cpp229
-rw-r--r--amadec/omx_audio/THD_mediasource.h74
-rwxr-xr-xamadec/omx_audio/Vorbis_mediasource.cpp245
-rw-r--r--amadec/omx_audio/Vorbis_mediasource.h58
-rw-r--r--amadec/omx_audio/adec_omx.cpp421
-rw-r--r--amadec/omx_audio/adec_omx.h71
-rwxr-xr-xamadec/omx_audio/audio_mediasource.cpp37
-rw-r--r--amadec/omx_audio/audio_mediasource.h46
-rw-r--r--amadec/omx_audio/audio_medissource.h137
-rw-r--r--amadec/pcmenc_api.c147
-rw-r--r--amadec/pcmenc_api.h25
-rw-r--r--amadec/spdif_api.c306
-rw-r--r--amadec/spdif_api.h26
-rwxr-xr-xaudio_codec/Android.mk1
-rw-r--r--audio_codec/config.mk10
-rwxr-xr-xaudio_codec/libadpcm/Android.mk12
-rw-r--r--audio_codec/libadpcm/adpcm.h346
-rw-r--r--audio_codec/libadpcm/adpcm_decode.c841
-rwxr-xr-xaudio_codec/libamr/Android.mk25
-rwxr-xr-xaudio_codec/libamr/Makefile5
-rw-r--r--audio_codec/libamr/amr_decode.c186
-rw-r--r--audio_codec/libamr/amr_decode.h8
-rwxr-xr-xaudio_codec/libamr/dec.h18
-rw-r--r--audio_codec/libamr/dec_acelp.c620
-rwxr-xr-xaudio_codec/libamr/dec_acelp.h17
-rw-r--r--audio_codec/libamr/dec_dtx.c683
-rw-r--r--audio_codec/libamr/dec_dtx.h49
-rw-r--r--audio_codec/libamr/dec_gain.c853
-rw-r--r--audio_codec/libamr/dec_gain.h28
-rw-r--r--audio_codec/libamr/dec_if.c834
-rwxr-xr-xaudio_codec/libamr/dec_if.h23
-rw-r--r--audio_codec/libamr/dec_lpc.c789
-rw-r--r--audio_codec/libamr/dec_lpc.h25
-rw-r--r--audio_codec/libamr/dec_main.c842
-rw-r--r--audio_codec/libamr/dec_main.h57
-rw-r--r--audio_codec/libamr/dec_rom.c2114
-rw-r--r--audio_codec/libamr/dec_util.c1304
-rw-r--r--audio_codec/libamr/dec_util.h33
-rw-r--r--audio_codec/libamr/if_rom.c1030
-rwxr-xr-xaudio_codec/libamr/if_rom.h70
-rw-r--r--audio_codec/libamr/interf_dec.c906
-rw-r--r--audio_codec/libamr/interf_dec.h56
-rw-r--r--audio_codec/libamr/interf_rom.h1788
-rw-r--r--audio_codec/libamr/rom_dec.h13274
-rw-r--r--audio_codec/libamr/sp_dec.c6078
-rw-r--r--audio_codec/libamr/sp_dec.h83
-rwxr-xr-xaudio_codec/libamr/typedef.h17
-rwxr-xr-xaudio_codec/libape/Android.mk28
-rw-r--r--audio_codec/libape/Ape_decoder.h216
-rw-r--r--audio_codec/libape/amlogic_r30813_audio_ape_lib.c1
-rw-r--r--audio_codec/libape/apedec.c1120
-rw-r--r--audio_codec/libcook/Android.mk28
-rw-r--r--audio_codec/libcook/aac_bitstream.h133
-rw-r--r--audio_codec/libcook/aac_decode.h148
-rw-r--r--audio_codec/libcook/aac_reorder.h53
-rw-r--r--audio_codec/libcook/assembly.h119
-rw-r--r--audio_codec/libcook/challenge.h132
-rw-r--r--audio_codec/libcook/codec_defines.h93
-rw-r--r--audio_codec/libcook/coder.h287
-rw-r--r--audio_codec/libcook/cook_codec.h30
-rw-r--r--audio_codec/libcook/cook_decode.c624
-rw-r--r--audio_codec/libcook/cook_decode.h35
-rw-r--r--audio_codec/libcook/ga_config.h86
-rw-r--r--audio_codec/libcook/gecko2codec.c833
-rw-r--r--audio_codec/libcook/gecko2codec.h60
-rw-r--r--audio_codec/libcook/helix_config.h92
-rw-r--r--audio_codec/libcook/helix_mime_types.h56
-rw-r--r--audio_codec/libcook/helix_result.h107
-rw-r--r--audio_codec/libcook/helix_types.h305
-rw-r--r--audio_codec/libcook/helix_utils.h106
-rw-r--r--audio_codec/libcook/md5.h113
-rw-r--r--audio_codec/libcook/memory_utils.c100
-rw-r--r--audio_codec/libcook/memory_utils.h58
-rw-r--r--audio_codec/libcook/pack_utils.c306
-rw-r--r--audio_codec/libcook/pack_utils.h93
-rw-r--r--audio_codec/libcook/packet_defines.h48
-rw-r--r--audio_codec/libcook/ra8lbr_decode.c378
-rw-r--r--audio_codec/libcook/ra8lbr_decode.h161
-rw-r--r--audio_codec/libcook/ra_backend.h94
-rw-r--r--audio_codec/libcook/ra_bitpack.c197
-rw-r--r--audio_codec/libcook/ra_buffers.c127
-rw-r--r--audio_codec/libcook/ra_category.c298
-rw-r--r--audio_codec/libcook/ra_couple.c224
-rw-r--r--audio_codec/libcook/ra_decode.c321
-rw-r--r--audio_codec/libcook/ra_decode.h183
-rw-r--r--audio_codec/libcook/ra_depack.c230
-rw-r--r--audio_codec/libcook/ra_depack.h177
-rw-r--r--audio_codec/libcook/ra_depack_internal.c1710
-rw-r--r--audio_codec/libcook/ra_depack_internal.h232
-rw-r--r--audio_codec/libcook/ra_envelope.c123
-rw-r--r--audio_codec/libcook/ra_fft.c368
-rw-r--r--audio_codec/libcook/ra_format_info.h60
-rw-r--r--audio_codec/libcook/ra_gainctrl.c584
-rw-r--r--audio_codec/libcook/ra_huffman.c86
-rw-r--r--audio_codec/libcook/ra_hufftabs.c244
-rw-r--r--audio_codec/libcook/ra_mlt.c357
-rw-r--r--audio_codec/libcook/ra_sqvh.c431
-rw-r--r--audio_codec/libcook/ra_trigtabs.c932
-rw-r--r--audio_codec/libcook/rasl.c376
-rw-r--r--audio_codec/libcook/rasl.h71
-rw-r--r--audio_codec/libcook/rdtpck.h153
-rw-r--r--audio_codec/libcook/rm_error.h54
-rw-r--r--audio_codec/libcook/rm_error_default.c58
-rw-r--r--audio_codec/libcook/rm_error_default.h53
-rw-r--r--audio_codec/libcook/rm_io_default.c101
-rw-r--r--audio_codec/libcook/rm_io_default.h49
-rw-r--r--audio_codec/libcook/rm_memory.h54
-rw-r--r--audio_codec/libcook/rm_memory_default.c54
-rw-r--r--audio_codec/libcook/rm_memory_default.h46
-rw-r--r--audio_codec/libcook/rm_packet.c117
-rw-r--r--audio_codec/libcook/rm_packet.h80
-rw-r--r--audio_codec/libcook/rm_parse.h302
-rw-r--r--audio_codec/libcook/rm_parser.c649
-rw-r--r--audio_codec/libcook/rm_parser_internal.c3342
-rw-r--r--audio_codec/libcook/rm_parser_internal.h420
-rw-r--r--audio_codec/libcook/rm_property.c105
-rw-r--r--audio_codec/libcook/rm_property.h107
-rw-r--r--audio_codec/libcook/rm_stream.c356
-rw-r--r--audio_codec/libcook/rm_stream.h115
-rw-r--r--audio_codec/libcook/rm_stream_internal.h77
-rw-r--r--audio_codec/libcook/rv20backend.h69
-rw-r--r--audio_codec/libcook/rv30backend.h68
-rw-r--r--audio_codec/libcook/rv_backend.h84
-rw-r--r--audio_codec/libcook/rv_backend_types.h198
-rw-r--r--audio_codec/libcook/rv_decode.h208
-rw-r--r--audio_codec/libcook/rv_decode_message.h492
-rw-r--r--audio_codec/libcook/rv_depack.c271
-rw-r--r--audio_codec/libcook/rv_depack.h162
-rw-r--r--audio_codec/libcook/rv_depack_internal.c1071
-rw-r--r--audio_codec/libcook/rv_depack_internal.h171
-rw-r--r--audio_codec/libcook/rv_format_info.h91
-rw-r--r--audio_codec/libcook/statname.h118
-rw-r--r--audio_codec/libcook/stream_hdr_structs.h66
-rw-r--r--audio_codec/libcook/stream_hdr_utils.c136
-rw-r--r--audio_codec/libcook/stream_hdr_utils.h77
-rw-r--r--audio_codec/libcook/string_utils.c87
-rw-r--r--audio_codec/libcook/string_utils.h62
-rw-r--r--audio_codec/libcook/tngpkt.h400
-rwxr-xr-xaudio_codec/libfaad/Android.mk101
-rwxr-xr-xaudio_codec/libfaad/Makefile130
-rw-r--r--audio_codec/libfaad/analysis.h52
-rwxr-xr-xaudio_codec/libfaad/audio.d3
-rw-r--r--audio_codec/libfaad/bits.c261
-rwxr-xr-xaudio_codec/libfaad/bits.d18
-rw-r--r--audio_codec/libfaad/bits.h446
-rw-r--r--audio_codec/libfaad/cfft.c988
-rw-r--r--audio_codec/libfaad/cfft.h55
-rw-r--r--audio_codec/libfaad/cfft_tab.h1816
-rw-r--r--audio_codec/libfaad/codebook/hcb.h140
-rw-r--r--audio_codec/libfaad/codebook/hcb_1.h186
-rw-r--r--audio_codec/libfaad/codebook/hcb_10.h312
-rw-r--r--audio_codec/libfaad/codebook/hcb_11.h415
-rw-r--r--audio_codec/libfaad/codebook/hcb_2.h185
-rw-r--r--audio_codec/libfaad/codebook/hcb_3.h196
-rw-r--r--audio_codec/libfaad/codebook/hcb_4.h199
-rw-r--r--audio_codec/libfaad/codebook/hcb_5.h196
-rw-r--r--audio_codec/libfaad/codebook/hcb_6.h182
-rw-r--r--audio_codec/libfaad/codebook/hcb_7.h162
-rw-r--r--audio_codec/libfaad/codebook/hcb_8.h173
-rw-r--r--audio_codec/libfaad/codebook/hcb_9.h372
-rw-r--r--audio_codec/libfaad/codebook/hcb_sf.h276
-rw-r--r--audio_codec/libfaad/common.c558
-rw-r--r--audio_codec/libfaad/common.h453
-rw-r--r--audio_codec/libfaad/decoder.c2266
-rw-r--r--audio_codec/libfaad/drc.c173
-rw-r--r--audio_codec/libfaad/drc.h49
-rw-r--r--audio_codec/libfaad/drm_dec.c912
-rw-r--r--audio_codec/libfaad/drm_dec.h99
-rw-r--r--audio_codec/libfaad/error.c72
-rw-r--r--audio_codec/libfaad/error.h44
-rw-r--r--audio_codec/libfaad/filtbank.c408
-rw-r--r--audio_codec/libfaad/filtbank.h61
-rw-r--r--audio_codec/libfaad/fixed.h287
-rw-r--r--audio_codec/libfaad/hcr.c422
-rw-r--r--audio_codec/libfaad/helixaac/aaccommon.h210
-rw-r--r--audio_codec/libfaad/helixaac/aacdec.c508
-rw-r--r--audio_codec/libfaad/helixaac/aacdec.h206
-rw-r--r--audio_codec/libfaad/helixaac/aactabs.c157
-rw-r--r--audio_codec/libfaad/helixaac/assembly.h631
-rw-r--r--audio_codec/libfaad/helixaac/assembly_mw.h743
-rw-r--r--audio_codec/libfaad/helixaac/bitstream.c261
-rw-r--r--audio_codec/libfaad/helixaac/bitstream.h74
-rw-r--r--audio_codec/libfaad/helixaac/buffers.c140
-rw-r--r--audio_codec/libfaad/helixaac/coder.h369
-rw-r--r--audio_codec/libfaad/helixaac/dct4.c337
-rw-r--r--audio_codec/libfaad/helixaac/decelmnt.c445
-rw-r--r--audio_codec/libfaad/helixaac/dequant.c379
-rw-r--r--audio_codec/libfaad/helixaac/fft.c391
-rw-r--r--audio_codec/libfaad/helixaac/filefmt.c539
-rw-r--r--audio_codec/libfaad/helixaac/huffman_helix.c450
-rw-r--r--audio_codec/libfaad/helixaac/hufftabs.c177
-rw-r--r--audio_codec/libfaad/helixaac/imdct.c596
-rw-r--r--audio_codec/libfaad/helixaac/noiseless.c513
-rw-r--r--audio_codec/libfaad/helixaac/pns_helix.c371
-rw-r--r--audio_codec/libfaad/helixaac/sbr.c433
-rw-r--r--audio_codec/libfaad/helixaac/sbr.h380
-rw-r--r--audio_codec/libfaad/helixaac/sbrfft.c368
-rw-r--r--audio_codec/libfaad/helixaac/sbrfreq.c673
-rw-r--r--audio_codec/libfaad/helixaac/sbrhfadj.c882
-rw-r--r--audio_codec/libfaad/helixaac/sbrhfgen.c655
-rw-r--r--audio_codec/libfaad/helixaac/sbrhuff.c494
-rw-r--r--audio_codec/libfaad/helixaac/sbrimdct.c447
-rw-r--r--audio_codec/libfaad/helixaac/sbrmath.c198
-rw-r--r--audio_codec/libfaad/helixaac/sbrqmf.c648
-rw-r--r--audio_codec/libfaad/helixaac/sbrside.c634
-rw-r--r--audio_codec/libfaad/helixaac/sbrtabs.c400
-rw-r--r--audio_codec/libfaad/helixaac/statname.h115
-rw-r--r--audio_codec/libfaad/helixaac/stproc.c251
-rw-r--r--audio_codec/libfaad/helixaac/tns_helix.c307
-rw-r--r--audio_codec/libfaad/helixaac/trigtabs.c1000
-rw-r--r--audio_codec/libfaad/helixaac/trigtabs_fltgen.c357
-rw-r--r--audio_codec/libfaad/huffman.c582
-rw-r--r--audio_codec/libfaad/huffman.h47
-rw-r--r--audio_codec/libfaad/ic_predict.c258
-rw-r--r--audio_codec/libfaad/ic_predict.h252
-rw-r--r--audio_codec/libfaad/iq_table.h16456
-rw-r--r--audio_codec/libfaad/is.c106
-rw-r--r--audio_codec/libfaad/is.h67
-rw-r--r--audio_codec/libfaad/kbd_win.h2294
-rw-r--r--audio_codec/libfaad/libaacdec.c544
-rw-r--r--audio_codec/libfaad/libaacdec.h64
-rwxr-xr-xaudio_codec/libfaad/libfaad2.def14
-rw-r--r--audio_codec/libfaad/lt_predict.c205
-rw-r--r--audio_codec/libfaad/lt_predict.h66
-rw-r--r--audio_codec/libfaad/mdct.c307
-rw-r--r--audio_codec/libfaad/mdct.h48
-rw-r--r--audio_codec/libfaad/mdct_tab.h3639
-rw-r--r--audio_codec/libfaad/mp4.c307
-rw-r--r--audio_codec/libfaad/mp4.h52
-rw-r--r--audio_codec/libfaad/ms.c71
-rw-r--r--audio_codec/libfaad/ms.h44
-rw-r--r--audio_codec/libfaad/neaacdec.h257
-rw-r--r--audio_codec/libfaad/output.c583
-rw-r--r--audio_codec/libfaad/output.h48
-rw-r--r--audio_codec/libfaad/pns.c273
-rw-r--r--audio_codec/libfaad/pns.h58
-rw-r--r--audio_codec/libfaad/ps_dec.c1905
-rw-r--r--audio_codec/libfaad/ps_dec.h151
-rw-r--r--audio_codec/libfaad/ps_syntax.c532
-rw-r--r--audio_codec/libfaad/ps_tables.h547
-rw-r--r--audio_codec/libfaad/pulse.c59
-rw-r--r--audio_codec/libfaad/pulse.h43
-rw-r--r--audio_codec/libfaad/rvlc.c524
-rw-r--r--audio_codec/libfaad/rvlc.h55
-rw-r--r--audio_codec/libfaad/sbr_dct.c2267
-rw-r--r--audio_codec/libfaad/sbr_dct.h52
-rw-r--r--audio_codec/libfaad/sbr_dec.c679
-rw-r--r--audio_codec/libfaad/sbr_dec.h253
-rw-r--r--audio_codec/libfaad/sbr_e_nf.c475
-rw-r--r--audio_codec/libfaad/sbr_e_nf.h50
-rw-r--r--audio_codec/libfaad/sbr_fbt.c737
-rw-r--r--audio_codec/libfaad/sbr_fbt.h55
-rw-r--r--audio_codec/libfaad/sbr_hfadj.c1644
-rw-r--r--audio_codec/libfaad/sbr_hfadj.h56
-rw-r--r--audio_codec/libfaad/sbr_hfgen.c647
-rw-r--r--audio_codec/libfaad/sbr_hfgen.h49
-rw-r--r--audio_codec/libfaad/sbr_huff.c344
-rw-r--r--audio_codec/libfaad/sbr_huff.h46
-rw-r--r--audio_codec/libfaad/sbr_noise.h564
-rw-r--r--audio_codec/libfaad/sbr_qmf.c614
-rw-r--r--audio_codec/libfaad/sbr_qmf.h55
-rw-r--r--audio_codec/libfaad/sbr_qmf_c.h368
-rw-r--r--audio_codec/libfaad/sbr_syntax.c893
-rw-r--r--audio_codec/libfaad/sbr_syntax.h68
-rw-r--r--audio_codec/libfaad/sbr_tf_grid.c247
-rw-r--r--audio_codec/libfaad/sbr_tf_grid.h47
-rw-r--r--audio_codec/libfaad/sine_win.h4296
-rw-r--r--audio_codec/libfaad/specrec.c1249
-rw-r--r--audio_codec/libfaad/specrec.h49
-rw-r--r--audio_codec/libfaad/ssr.c170
-rw-r--r--audio_codec/libfaad/ssr.h59
-rw-r--r--audio_codec/libfaad/ssr_fb.c191
-rw-r--r--audio_codec/libfaad/ssr_fb.h53
-rw-r--r--audio_codec/libfaad/ssr_ipqf.c171
-rw-r--r--audio_codec/libfaad/ssr_ipqf.h46
-rw-r--r--audio_codec/libfaad/ssr_win.h635
-rw-r--r--audio_codec/libfaad/structs.h513
-rw-r--r--audio_codec/libfaad/syntax.c2539
-rw-r--r--audio_codec/libfaad/syntax.h129
-rw-r--r--audio_codec/libfaad/tns.c304
-rw-r--r--audio_codec/libfaad/tns.h51
-rwxr-xr-xaudio_codec/libflac/Android.mk22
-rw-r--r--audio_codec/libflac/avcodec.h337
-rw-r--r--audio_codec/libflac/bswap.h94
-rw-r--r--audio_codec/libflac/codec.h36
-rw-r--r--audio_codec/libflac/codec_message.h109
-rw-r--r--audio_codec/libflac/common.h356
-rw-r--r--audio_codec/libflac/crc.c146
-rw-r--r--audio_codec/libflac/crc.h46
-rw-r--r--audio_codec/libflac/flac.c43
-rw-r--r--audio_codec/libflac/flac.h124
-rw-r--r--audio_codec/libflac/flac_decode.c943
-rw-r--r--audio_codec/libflac/flacdata.c38
-rw-r--r--audio_codec/libflac/flacdata.h29
-rw-r--r--audio_codec/libflac/get_bits.h564
-rw-r--r--audio_codec/libflac/golomb.h585
-rw-r--r--audio_codec/libflac/internal.h195
-rw-r--r--audio_codec/libflac/intreadwrite.h390
-rw-r--r--audio_codec/libflac/mathops.h78
-rw-r--r--audio_codec/libflac/types.h49
-rwxr-xr-xaudio_codec/liblpcm/Android.mk13
-rw-r--r--audio_codec/liblpcm/lpcm_decode.c437
-rwxr-xr-xaudio_codec/libmad/Android.mk13
-rwxr-xr-xaudio_codec/libmad/D.dat607
-rw-r--r--audio_codec/libmad/bit.c244
-rw-r--r--audio_codec/libmad/bit.h47
-rw-r--r--audio_codec/libmad/config.h133
-rw-r--r--audio_codec/libmad/decoder.c1102
-rw-r--r--audio_codec/libmad/decoder.h91
-rw-r--r--audio_codec/libmad/fixed.c85
-rw-r--r--audio_codec/libmad/fixed.h499
-rw-r--r--audio_codec/libmad/frame.c525
-rw-r--r--audio_codec/libmad/frame.h118
-rw-r--r--audio_codec/libmad/global.h58
-rw-r--r--audio_codec/libmad/huffman.c3109
-rw-r--r--audio_codec/libmad/huffman.h66
-rwxr-xr-xaudio_codec/libmad/imdct_l_arm.S1000
-rwxr-xr-xaudio_codec/libmad/imdct_s.dat62
-rw-r--r--audio_codec/libmad/layer12.c552
-rwxr-xr-xaudio_codec/libmad/layer12.h31
-rw-r--r--audio_codec/libmad/layer3.c2742
-rwxr-xr-xaudio_codec/libmad/layer3.h30
-rw-r--r--audio_codec/libmad/mad.h966
-rwxr-xr-xaudio_codec/libmad/qc_table.dat77
-rwxr-xr-xaudio_codec/libmad/rq_table.dat8747
-rwxr-xr-xaudio_codec/libmad/sf_table.dat106
-rw-r--r--audio_codec/libmad/stream.c185
-rw-r--r--audio_codec/libmad/stream.h111
-rw-r--r--audio_codec/libmad/synth.c921
-rw-r--r--audio_codec/libmad/synth.h69
-rw-r--r--audio_codec/libmad/timer.c493
-rw-r--r--audio_codec/libmad/timer.h100
-rw-r--r--audio_codec/libmad/version.c91
-rw-r--r--audio_codec/libmad/version.h47
-rwxr-xr-xaudio_codec/libpcm/Android.mk11
-rw-r--r--audio_codec/libpcm/intreadwrite.h390
-rw-r--r--audio_codec/libpcm/pcm_decode.c780
-rw-r--r--audio_codec/libraac/Android.mk51
-rw-r--r--audio_codec/libraac/aac_bitstream.c200
-rw-r--r--audio_codec/libraac/aac_bitstream.h133
-rw-r--r--audio_codec/libraac/aac_decode.h148
-rw-r--r--audio_codec/libraac/aac_decode_main.c396
-rw-r--r--audio_codec/libraac/aac_reorder.c85
-rw-r--r--audio_codec/libraac/aac_reorder.h53
-rw-r--r--audio_codec/libraac/aaccommon.h200
-rw-r--r--audio_codec/libraac/aacdec.c607
-rw-r--r--audio_codec/libraac/aacdec.h200
-rw-r--r--audio_codec/libraac/aactabs.c157
-rw-r--r--audio_codec/libraac/assembly.h147
-rw-r--r--audio_codec/libraac/bitstream.c451
-rw-r--r--audio_codec/libraac/bitstream.h76
-rw-r--r--audio_codec/libraac/buffers.c132
-rw-r--r--audio_codec/libraac/coder.h370
-rw-r--r--audio_codec/libraac/dct4.c339
-rw-r--r--audio_codec/libraac/decelmnt.c451
-rw-r--r--audio_codec/libraac/dequant.c382
-rw-r--r--audio_codec/libraac/fft.c393
-rw-r--r--audio_codec/libraac/filefmt.c531
-rw-r--r--audio_codec/libraac/ga_config.c209
-rw-r--r--audio_codec/libraac/ga_config.h86
-rw-r--r--audio_codec/libraac/huffman.c449
-rw-r--r--audio_codec/libraac/hufftabs.c177
-rw-r--r--audio_codec/libraac/imdct.c598
-rw-r--r--audio_codec/libraac/include/challenge.h132
-rw-r--r--audio_codec/libraac/include/codec_defines.h93
-rw-r--r--audio_codec/libraac/include/gecko2codec.h60
-rw-r--r--audio_codec/libraac/include/helix_config.h92
-rw-r--r--audio_codec/libraac/include/helix_mime_types.h56
-rw-r--r--audio_codec/libraac/include/helix_result.h107
-rw-r--r--audio_codec/libraac/include/helix_types.h305
-rw-r--r--audio_codec/libraac/include/helix_utils.h106
-rw-r--r--audio_codec/libraac/include/md5.h113
-rw-r--r--audio_codec/libraac/include/memory_utils.h58
-rw-r--r--audio_codec/libraac/include/pack_utils.h93
-rw-r--r--audio_codec/libraac/include/packet_defines.h48
-rw-r--r--audio_codec/libraac/include/ra8lbr_decode.h161
-rw-r--r--audio_codec/libraac/include/ra_backend.h94
-rw-r--r--audio_codec/libraac/include/ra_decode.h183
-rw-r--r--audio_codec/libraac/include/ra_depack.h177
-rw-r--r--audio_codec/libraac/include/ra_format_info.h60
-rw-r--r--audio_codec/libraac/include/rasl.h71
-rw-r--r--audio_codec/libraac/include/rdtpck.h153
-rw-r--r--audio_codec/libraac/include/rm_error.h54
-rw-r--r--audio_codec/libraac/include/rm_error_default.h53
-rw-r--r--audio_codec/libraac/include/rm_io_default.h49
-rw-r--r--audio_codec/libraac/include/rm_memory.h54
-rw-r--r--audio_codec/libraac/include/rm_memory_default.h46
-rw-r--r--audio_codec/libraac/include/rm_packet.h80
-rw-r--r--audio_codec/libraac/include/rm_parse.h302
-rw-r--r--audio_codec/libraac/include/rm_property.h107
-rw-r--r--audio_codec/libraac/include/rm_stream.h115
-rw-r--r--audio_codec/libraac/include/rm_stream_internal.h77
-rw-r--r--audio_codec/libraac/include/rv20backend.h69
-rw-r--r--audio_codec/libraac/include/rv30backend.h68
-rw-r--r--audio_codec/libraac/include/rv_backend.h84
-rw-r--r--audio_codec/libraac/include/rv_backend_types.h198
-rw-r--r--audio_codec/libraac/include/rv_decode.h208
-rw-r--r--audio_codec/libraac/include/rv_decode_message.h492
-rw-r--r--audio_codec/libraac/include/rv_depack.h162
-rw-r--r--audio_codec/libraac/include/rv_format_info.h91
-rw-r--r--audio_codec/libraac/include/statname.h118
-rw-r--r--audio_codec/libraac/include/stream_hdr_structs.h66
-rw-r--r--audio_codec/libraac/include/stream_hdr_utils.h77
-rw-r--r--audio_codec/libraac/include/string_utils.h62
-rw-r--r--audio_codec/libraac/include/tngpkt.h400
-rw-r--r--audio_codec/libraac/memory_utils.c100
-rw-r--r--audio_codec/libraac/noiseless.c503
-rw-r--r--audio_codec/libraac/pack_utils.c306
-rw-r--r--audio_codec/libraac/pns.c369
-rw-r--r--audio_codec/libraac/ra_depack.c230
-rw-r--r--audio_codec/libraac/ra_depack_internal.c1713
-rw-r--r--audio_codec/libraac/ra_depack_internal.h232
-rw-r--r--audio_codec/libraac/raac_decode.c854
-rw-r--r--audio_codec/libraac/raac_decode.h37
-rw-r--r--audio_codec/libraac/rm_error_default.c60
-rw-r--r--audio_codec/libraac/rm_io_default.c101
-rw-r--r--audio_codec/libraac/rm_memory_default.c54
-rw-r--r--audio_codec/libraac/rm_packet.c117
-rw-r--r--audio_codec/libraac/rm_parser.c649
-rw-r--r--audio_codec/libraac/rm_parser_internal.c3342
-rw-r--r--audio_codec/libraac/rm_parser_internal.h420
-rw-r--r--audio_codec/libraac/rm_property.c105
-rw-r--r--audio_codec/libraac/rm_stream.c356
-rw-r--r--audio_codec/libraac/rv_depack.c271
-rw-r--r--audio_codec/libraac/rv_depack_internal.c1071
-rw-r--r--audio_codec/libraac/rv_depack_internal.h171
-rw-r--r--audio_codec/libraac/sbr.c431
-rw-r--r--audio_codec/libraac/sbr.h381
-rwxr-xr-xaudio_codec/libraac/sbrcov.s164
-rw-r--r--audio_codec/libraac/sbrfft.c368
-rw-r--r--audio_codec/libraac/sbrfreq.c667
-rw-r--r--audio_codec/libraac/sbrhfadj.c877
-rw-r--r--audio_codec/libraac/sbrhfgen.c646
-rw-r--r--audio_codec/libraac/sbrhuff.c492
-rw-r--r--audio_codec/libraac/sbrimdct.c447
-rw-r--r--audio_codec/libraac/sbrmath.c198
-rw-r--r--audio_codec/libraac/sbrqmf.c643
-rwxr-xr-xaudio_codec/libraac/sbrqmfak.s182
-rwxr-xr-xaudio_codec/libraac/sbrqmfsk.s130
-rw-r--r--audio_codec/libraac/sbrside.c615
-rw-r--r--audio_codec/libraac/sbrtabs.c400
-rw-r--r--audio_codec/libraac/statname.h115
-rw-r--r--audio_codec/libraac/stproc.c252
-rw-r--r--audio_codec/libraac/stream_hdr_utils.c136
-rw-r--r--audio_codec/libraac/string_utils.c87
-rw-r--r--audio_codec/libraac/tns.c307
-rw-r--r--audio_codec/libraac/trigtabs.c1000
-rw-r--r--audio_codec/libraac/trigtabs_fltgen.c357
-rwxr-xr-xaudio_codec/wfd_aac_decoder/Android.mk23
-rw-r--r--audio_codec/wfd_aac_decoder/aaccommon.h210
-rw-r--r--audio_codec/wfd_aac_decoder/aacdec.c508
-rw-r--r--audio_codec/wfd_aac_decoder/aacdec.h206
-rw-r--r--audio_codec/wfd_aac_decoder/aactabs.c157
-rw-r--r--audio_codec/wfd_aac_decoder/assembly.h640
-rw-r--r--audio_codec/wfd_aac_decoder/assembly_mw.h743
-rw-r--r--audio_codec/wfd_aac_decoder/bitstream.c261
-rw-r--r--audio_codec/wfd_aac_decoder/bitstream.h74
-rw-r--r--audio_codec/wfd_aac_decoder/buffers.c140
-rw-r--r--audio_codec/wfd_aac_decoder/coder.h369
-rw-r--r--audio_codec/wfd_aac_decoder/dct4.c337
-rw-r--r--audio_codec/wfd_aac_decoder/decelmnt.c445
-rw-r--r--audio_codec/wfd_aac_decoder/dequant.c379
-rw-r--r--audio_codec/wfd_aac_decoder/fft.c391
-rw-r--r--audio_codec/wfd_aac_decoder/filefmt.c539
-rw-r--r--audio_codec/wfd_aac_decoder/helix_aac_decode.c548
-rw-r--r--audio_codec/wfd_aac_decoder/huffman.c450
-rw-r--r--audio_codec/wfd_aac_decoder/hufftabs.c177
-rw-r--r--audio_codec/wfd_aac_decoder/imdct.c596
-rw-r--r--audio_codec/wfd_aac_decoder/noiseless.c513
-rw-r--r--audio_codec/wfd_aac_decoder/pns.c371
-rw-r--r--audio_codec/wfd_aac_decoder/sbr.c434
-rw-r--r--audio_codec/wfd_aac_decoder/sbr.h380
-rw-r--r--audio_codec/wfd_aac_decoder/sbrfft.c368
-rw-r--r--audio_codec/wfd_aac_decoder/sbrfreq.c673
-rw-r--r--audio_codec/wfd_aac_decoder/sbrhfadj.c882
-rw-r--r--audio_codec/wfd_aac_decoder/sbrhfgen.c655
-rw-r--r--audio_codec/wfd_aac_decoder/sbrhuff.c494
-rw-r--r--audio_codec/wfd_aac_decoder/sbrimdct.c447
-rw-r--r--audio_codec/wfd_aac_decoder/sbrmath.c198
-rw-r--r--audio_codec/wfd_aac_decoder/sbrqmf.c648
-rw-r--r--audio_codec/wfd_aac_decoder/sbrside.c634
-rw-r--r--audio_codec/wfd_aac_decoder/sbrtabs.c400
-rw-r--r--audio_codec/wfd_aac_decoder/statname.h115
-rw-r--r--audio_codec/wfd_aac_decoder/stproc.c251
-rw-r--r--audio_codec/wfd_aac_decoder/tns.c307
-rw-r--r--audio_codec/wfd_aac_decoder/trigtabs.c1000
-rw-r--r--audio_codec/wfd_aac_decoder/trigtabs_fltgen.c357
545 files changed, 230976 insertions, 0 deletions
diff --git a/amadec/audio_out/alsa-out.c b/amadec/audio_out/alsa-out.c
new file mode 100644
index 0000000..388e516
--- a/dev/null
+++ b/amadec/audio_out/alsa-out.c
@@ -0,0 +1,1082 @@
+/**
+ * \file alsa-out.c
+ * \brief Functions of Auduo output control for Linux Platform
+ * \version 1.0.0
+ * \date 2011-03-08
+ */
+/* Copyright (C) 2007-2011, Amlogic Inc.
+ * All right reserved
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <linux/soundcard.h>
+//#include <config.h>
+#include <asoundlib.h>
+
+#include <audio-dec.h>
+#include <adec-pts-mgt.h>
+#include <log-print.h>
+#include <alsa-out.h>
+#include <amthreadpool.h>
+#include <cutils/properties.h>
+
+
+#define USE_INTERPOLATION
+
+static snd_pcm_sframes_t (*readi_func)(snd_pcm_t *handle, void *buffer, snd_pcm_uframes_t size);
+static snd_pcm_sframes_t (*writei_func)(snd_pcm_t *handle, const void *buffer, snd_pcm_uframes_t size);
+static snd_pcm_sframes_t (*readn_func)(snd_pcm_t *handle, void **bufs, snd_pcm_uframes_t size);
+static snd_pcm_sframes_t (*writen_func)(snd_pcm_t *handle, void **bufs, snd_pcm_uframes_t size);
+
+static float alsa_default_vol = 1.0;
+static int hdmi_out = 0;
+static int fragcount = 16;
+static snd_pcm_uframes_t chunk_size = 1024;
+static char output_buffer[64 * 1024];
+static unsigned char decode_buffer[OUTPUT_BUFFER_SIZE + 64];
+#define PERIOD_SIZE 1024
+#define PERIOD_NUM 4
+
+#ifdef USE_INTERPOLATION
+static int pass1_history[8][8];
+#pragma align_to(64,pass1_history)
+static int pass2_history[8][8];
+#pragma align_to(64,pass2_history)
+static short pass1_interpolation_output[0x4000];
+#pragma align_to(64,pass1_interpolation_output)
+static short interpolation_output[0x8000];
+#pragma align_to(64,interpolation_output)
+static int tv_mode = 0;
+static int getprop_bool(const char * path)
+{
+ char buf[PROPERTY_VALUE_MAX];
+ int ret = -1;
+ ret = property_get(path, buf, NULL);
+ if (ret > 0) {
+ if (strcasecmp(buf,"true") == 0 || strcmp(buf,"1") == 0)
+ return 1;
+ }
+ return 0;
+}
+static inline short CLIPTOSHORT(int x)
+{
+ short res;
+#if 0
+ __asm__ __volatile__(
+ "min r0, %1, 0x7fff\r\n"
+ "max r0, r0, -0x8000\r\n"
+ "mov %0, r0\r\n"
+ :"=r"(res)
+ :"r"(x)
+ :"r0"
+ );
+#else
+ if (x > 0x7fff) {
+ res = 0x7fff;
+ } else if (x < -0x8000) {
+ res = -0x8000;
+ } else {
+ res = x;
+ }
+#endif
+ return res;
+}
+
+static int set_sysfs_type(const char *path, const char *type)
+{
+ int ret = -1;
+ int fd = open(path, O_CREAT | O_RDWR | O_TRUNC, 0644);
+ if (fd >= 0) {
+ char set_type[10] = {0};
+ int length = snprintf(set_type, sizeof(set_type), "%s", type);
+ if (length > 0)
+ ret = write(fd, set_type, length);
+ adec_print("%s , %s\n", path, set_type);
+ close(fd);
+ }else{
+ adec_print("open hdmi-tx node:%s failed!\n", path);
+ }
+ return ret;
+}
+
+
+static void pcm_interpolation(int interpolation, unsigned num_channel, unsigned num_sample, short *samples)
+{
+ int i, k, l, ch;
+ int *s;
+ short *d;
+ for (ch = 0; ch < num_channel; ch++) {
+ s = pass1_history[ch];
+ if (interpolation < 2) {
+ d = interpolation_output;
+ } else {
+ d = pass1_interpolation_output;
+ }
+ for (i = 0, k = l = ch; i < num_sample; i++, k += num_channel) {
+ s[0] = s[1];
+ s[1] = s[2];
+ s[2] = s[3];
+ s[3] = s[4];
+ s[4] = s[5];
+ s[5] = samples[k];
+ d[l] = s[2];
+ l += num_channel;
+ d[l] = CLIPTOSHORT((150 * (s[2] + s[3]) - 25 * (s[1] + s[4]) + 3 * (s[0] + s[5]) + 128) >> 8);
+ l += num_channel;
+ }
+ if (interpolation >= 2) {
+ s = pass2_history[ch];
+ d = interpolation_output;
+ for (i = 0, k = l = ch; i < num_sample * 2; i++, k += num_channel) {
+ s[0] = s[1];
+ s[1] = s[2];
+ s[2] = s[3];
+ s[3] = s[4];
+ s[4] = s[5];
+ s[5] = pass1_interpolation_output[k];
+ d[l] = s[2];
+ l += num_channel;
+ d[l] = CLIPTOSHORT((150 * (s[2] + s[3]) - 25 * (s[1] + s[4]) + 3 * (s[0] + s[5]) + 128) >> 8);
+ l += num_channel;
+ }
+ }
+ }
+}
+#endif
+
+
+static int set_params(alsa_param_t *alsa_params)
+{
+ snd_pcm_hw_params_t *hwparams;
+ snd_pcm_sw_params_t *swparams;
+ // snd_pcm_uframes_t buffer_size;
+ // snd_pcm_uframes_t boundary;
+ // unsigned int period_time = 0;
+ // unsigned int buffer_time = 0;
+ snd_pcm_uframes_t bufsize;
+ int err;
+ unsigned int rate;
+ snd_pcm_uframes_t start_threshold, stop_threshold;
+ snd_pcm_hw_params_alloca(&hwparams);
+ snd_pcm_sw_params_alloca(&swparams);
+
+ err = snd_pcm_hw_params_any(alsa_params->handle, hwparams);
+ if (err < 0) {
+ adec_print("Broken configuration for this PCM: no configurations available");
+ return err;
+ }
+
+ err = snd_pcm_hw_params_set_access(alsa_params->handle, hwparams,
+ SND_PCM_ACCESS_RW_INTERLEAVED);
+ if (err < 0) {
+ adec_print("Access type not available");
+ return err;
+ }
+ if (tv_mode) {
+ alsa_params->format = SND_PCM_FORMAT_S32_LE;
+ }
+ err = snd_pcm_hw_params_set_format(alsa_params->handle,hwparams,alsa_params->format);
+ if (err < 0) {
+ adec_print("Sample format non available");
+ return err;
+ }
+ alsa_params->format = SND_PCM_FORMAT_S16_LE;
+ if (tv_mode) {
+ alsa_params->channelcount = 8;
+ }
+ err = snd_pcm_hw_params_set_channels(alsa_params->handle, hwparams, alsa_params->channelcount);
+ alsa_params->channelcount = 2;
+ if (err < 0) {
+ adec_print("Channels count non available");
+ return err;
+ }
+
+ rate = alsa_params->rate;
+ err = snd_pcm_hw_params_set_rate_near(alsa_params->handle, hwparams, &alsa_params->rate, 0);
+ assert(err >= 0);
+#if 0
+ err = snd_pcm_hw_params_get_buffer_time_max(hwparams, &buffer_time, 0);
+ assert(err >= 0);
+ if (buffer_time > 500000) {
+ buffer_time = 500000;
+ }
+
+ period_time = buffer_time / 4;
+
+ err = snd_pcm_hw_params_set_period_time_near(handle, hwparams,
+ &period_time, 0);
+ assert(err >= 0);
+
+ err = snd_pcm_hw_params_set_buffer_time_near(handle, hwparams,
+ &buffer_time, 0);
+ assert(err >= 0);
+
+#endif
+ alsa_params->bits_per_sample = snd_pcm_format_physical_width(alsa_params->format);
+ //bits_per_frame = bits_per_sample * hwparams.realchanl;
+ alsa_params->bits_per_frame = alsa_params->bits_per_sample * alsa_params->channelcount;
+ adec_print("bits_per_sample %d,bits_per_frame %d\n",alsa_params->bits_per_sample,alsa_params->bits_per_frame);
+ bufsize = PERIOD_NUM * PERIOD_SIZE;
+
+ if (tv_mode) {
+ set_sysfs_type("/sys/class/amhdmitx/amhdmitx0/aud_output_chs", "2:1");
+ }
+
+ err = snd_pcm_hw_params_set_buffer_size_near(alsa_params->handle, hwparams, &bufsize);
+ if (err < 0) {
+ adec_print("Unable to set buffer size \n");
+ return err;
+ }
+ err = snd_pcm_hw_params_set_period_size_near(alsa_params->handle, hwparams, &chunk_size, NULL);
+ if (err < 0) {
+ adec_print("Unable to set period size \n");
+ return err;
+ }
+
+ //err = snd_pcm_hw_params_set_periods_near(handle, hwparams, &fragcount, NULL);
+ //if (err < 0) {
+ // adec_print("Unable to set periods \n");
+ // return err;
+ //}
+
+ err = snd_pcm_hw_params(alsa_params->handle, hwparams);
+ if (err < 0) {
+ adec_print("Unable to install hw params:");
+ return err;
+ }
+
+ err = snd_pcm_hw_params_get_buffer_size(hwparams, &bufsize);
+ if (err < 0) {
+ adec_print("Unable to get buffersize \n");
+ return err;
+ }
+ alsa_params->buffer_size = bufsize * alsa_params->bits_per_frame / 8;
+
+#if 1
+ err = snd_pcm_sw_params_current(alsa_params->handle, swparams);
+ if (err < 0) {
+ adec_print("??Unable to get sw-parameters\n");
+ return err;
+ }
+
+ //err = snd_pcm_sw_params_get_boundary(swparams, &boundary);
+ //if (err < 0){
+ // adec_print("Unable to get boundary\n");
+ // return err;
+ //}
+
+ //err = snd_pcm_sw_params_set_start_threshold(handle, swparams, bufsize);
+ //if (err < 0) {
+ // adec_print("Unable to set start threshold \n");
+ // return err;
+ //}
+
+ //err = snd_pcm_sw_params_set_stop_threshold(handle, swparams, buffer_size);
+ //if (err < 0) {
+ // adec_print("Unable to set stop threshold \n");
+ // return err;
+ //}
+
+ // err = snd_pcm_sw_params_set_silence_size(handle, swparams, buffer_size);
+ // if (err < 0) {
+ // adec_print("Unable to set silence size \n");
+ // return err;
+ // }
+
+ err = snd_pcm_sw_params(alsa_params->handle, swparams);
+ if (err < 0) {
+ adec_print("Unable to get sw-parameters\n");
+ return err;
+ }
+
+ //snd_pcm_sw_params_free(swparams);
+#endif
+
+
+ //chunk_bytes = chunk_size * bits_per_frame / 8;
+
+ return 0;
+}
+
+static int alsa_get_hdmi_state()
+{
+ return 0;
+#if 0
+ int fd = -1, err = 0, state = 0;
+ unsigned fileSize = 32;
+ char *read_buf = NULL;
+ static const char *const HDMI_STATE_PATH = "/sys/class/switch/hdmi/state";
+
+ fd = open(HDMI_STATE_PATH, O_RDONLY);
+ if (fd < 0) {
+ adec_print("ERROR: failed to open config file %s error: %d\n", HDMI_STATE_PATH, errno);
+ close(fd);
+ return -EINVAL;
+ }
+
+ read_buf = (char *)malloc(fileSize);
+ if (!read_buf) {
+ adec_print("Failed to malloc read_buf");
+ goto OUT;
+ }
+ memset(read_buf, 0x0, fileSize);
+ err = read(fd, read_buf, fileSize);
+ if (fd < 0) {
+ adec_print("ERROR: failed to read config file %s error: %d\n", HDMI_STATE_PATH, errno);
+ goto OUT;
+ }
+
+ if (*read_buf == '1') {
+ state = 1;
+ }
+
+OUT:
+ free(read_buf);
+ close(fd);
+ return state;
+#endif
+}
+
+static int alsa_get_aml_card()
+{
+ int card = -1, err = 0;
+ int fd = -1;
+ unsigned fileSize = 512;
+ char *read_buf = NULL, *pd = NULL;
+ static const char *const SOUND_CARDS_PATH = "/proc/asound/cards";
+ fd = open(SOUND_CARDS_PATH, O_RDONLY);
+ if (fd < 0) {
+ adec_print("ERROR: failed to open config file %s error: %d\n", SOUND_CARDS_PATH, errno);
+ close(fd);
+ return -EINVAL;
+ }
+
+ read_buf = (char *)malloc(fileSize);
+ if (!read_buf) {
+ adec_print("Failed to malloc read_buf");
+ close(fd);
+ return -ENOMEM;
+ }
+ memset(read_buf, 0x0, fileSize);
+ err = read(fd, read_buf, fileSize);
+ if (fd < 0) {
+ adec_print("ERROR: failed to read config file %s error: %d\n", SOUND_CARDS_PATH, errno);
+ free(read_buf);
+ close(fd);
+ return -EINVAL;
+ }
+ pd = strstr(read_buf, "AML");
+ card = *(pd - 3) - '0';
+
+OUT:
+ free(read_buf);
+ close(fd);
+ return card;
+}
+
+static int alsa_get_spdif_port()
+{
+/* for pcm output,i2s/958 share the same data from i2s,so always use device 0 as i2s output */
+ return 0;
+ int port = -1, err = 0;
+ int fd = -1;
+ unsigned fileSize = 512;
+ char *read_buf = NULL, *pd = NULL;
+ static const char *const SOUND_PCM_PATH = "/proc/asound/pcm";
+ fd = open(SOUND_PCM_PATH, O_RDONLY);
+ if (fd < 0) {
+ adec_print("ERROR: failed to open config file %s error: %d\n", SOUND_PCM_PATH, errno);
+ close(fd);
+ return -EINVAL;
+ }
+
+ read_buf = (char *)malloc(fileSize);
+ if (!read_buf) {
+ adec_print("Failed to malloc read_buf");
+ close(fd);
+ return -ENOMEM;
+ }
+ memset(read_buf, 0x0, fileSize);
+ err = read(fd, read_buf, fileSize);
+ if (fd < 0) {
+ adec_print("ERROR: failed to read config file %s error: %d\n", SOUND_PCM_PATH, errno);
+ free(read_buf);
+ close(fd);
+ return -EINVAL;
+ }
+ pd = strstr(read_buf, "SPDIF");
+ if (!pd) {
+ goto OUT;
+ }
+ adec_print("%s \n", pd);
+
+ port = *(pd - 3) - '0';
+ adec_print("%s \n", (pd - 3));
+
+OUT:
+ free(read_buf);
+ close(fd);
+ return port;
+}
+
+static size_t pcm_write(alsa_param_t * alsa_param, u_char * data, size_t count)
+{
+ snd_pcm_sframes_t r;
+ size_t result = 0;
+ int i;
+ short *sample = (short*)data;
+ /*
+ if (count < chunk_size) {
+ snd_pcm_format_set_silence(hwparams.format, data + count * bits_per_frame / 8, (chunk_size - count) * hwparams.channels);
+ count = chunk_size;
+ }
+ */
+ /* volume control for bootplayer */
+ if (alsa_default_vol != 1.0) {
+ for (i = 0;i < count*2;i++) {
+ sample[i] = (short)(alsa_default_vol*(float)sample[i]);
+ }
+ }
+ // dump pcm data here
+#if 0
+ FILE *fp1=fopen("/data/audio_out.pcm","a+");
+ if (fp1) {
+ int flen=fwrite((char *)data,1,count*2*2,fp1);
+ adec_print("flen = %d---outlen=%d ", flen, count*2*2);
+ fclose(fp1);
+ }else{
+ adec_print("could not open file:audio_out.pcm");
+ }
+#endif
+ int *tmp_buffer = NULL;
+ int bits_per_frame = alsa_param->bits_per_frame;
+ if (tv_mode) {
+ tmp_buffer = (int*)malloc(count*8*4);
+ if (tmp_buffer == NULL) {
+ adec_print("malloc tmp_buffer failed\n");
+ return -1;
+ }
+ int i;
+ int out_frames = count;
+ short *in_buffer = (short*)data;
+ for (i = 0; i < out_frames; i ++) {
+ tmp_buffer[8*i] = ((int)(in_buffer[2*i])) << 16;
+ tmp_buffer[8*i + 1] = ((int)(in_buffer[2*i + 1])) << 16;
+ tmp_buffer[8*i + 2] = ((int)(in_buffer[2*i])) << 16;
+ tmp_buffer[8*i + 3] = ((int)(in_buffer[2*i + 1])) << 16;
+ tmp_buffer[8*i + 4] = 0;
+ tmp_buffer[8*i + 5] = 0;
+ tmp_buffer[8*i + 6] = 0;
+ tmp_buffer[8*i + 7] = 0;
+ }
+ data = (char*)tmp_buffer;
+ bits_per_frame = bits_per_frame*8;//8ch,32bit
+ }
+ while (count > 0) {
+ r = writei_func(alsa_param->handle, data, count);
+
+ if (r == -EINTR) {
+ r = 0;
+ }
+ if (r == -ESTRPIPE) {
+ while ((r = snd_pcm_resume(alsa_param->handle)) == -EAGAIN) {
+ amthreadpool_thread_usleep(1000);
+ }
+ }
+
+ if (r < 0) {
+ printf("xun in\n");
+ if ((r = snd_pcm_prepare(alsa_param->handle)) < 0) {
+ result = 0;
+ goto done;
+ }
+ }
+
+ if (r > 0) {
+ result += r;
+ count -= r;
+ data += r * bits_per_frame / 8;
+ }
+ }
+done:
+ if (tmp_buffer) {
+ free(tmp_buffer);
+ }
+ return result;
+}
+
+static unsigned oversample_play(alsa_param_t * alsa_param, char * src, unsigned count)
+{
+ int frames = 0;
+ int ret, i;
+ unsigned short * to, *from;
+ to = (unsigned short *)output_buffer;
+ from = (unsigned short *)src;
+
+ if (alsa_param->realchanl == 2) {
+ if (alsa_param->oversample == -1) {
+ frames = count * 8 / alsa_param->bits_per_frame;
+ frames = frames & (~(32 - 1));
+ for (i = 0; i < (frames * 2); i += 4) { // i for sample
+ *to++ = *from++;
+ *to ++ = *from++;
+ from += 2;
+ }
+ ret = pcm_write(alsa_param, output_buffer, frames / 2);
+ ret = ret * alsa_param->bits_per_frame / 8;
+ ret = ret * 2;
+ } else if (alsa_param->oversample == 1) {
+ frames = count * 8 / alsa_param->bits_per_frame;
+ frames = frames & (~(16 - 1));
+#ifdef USE_INTERPOLATION
+ pcm_interpolation(1, alsa_param->realchanl, frames, (short*)src);
+ memcpy(output_buffer, interpolation_output, (frames * alsa_param->bits_per_frame / 4));
+#else
+ short l, r;
+ for (i = 0; i < (frames * 2); i += 2) {
+ l = *from++;
+ r = *from++;
+ *to++ = l;
+ *to++ = r;
+ *to++ = l;
+ *to++ = r;
+ }
+#endif
+ ret = pcm_write(alsa_param, output_buffer, frames * 2);
+ ret = ret * alsa_param->bits_per_frame / 8;
+ ret = ret / 2;
+ } else if (alsa_param->oversample == 2) {
+ frames = count * 8 / alsa_param->bits_per_frame;
+ frames = frames & (~(8 - 1));
+#ifdef USE_INTERPOLATION
+ pcm_interpolation(2, alsa_param->realchanl, frames, (short*)src);
+ memcpy(output_buffer, interpolation_output, (frames * alsa_param->bits_per_frame / 2));
+#else
+ short l, r;
+ for (i = 0; i < (frames * 2); i += 2) {
+ l = *from++;
+ r = *from++;
+ *to++ = l;
+ *to++ = r;
+ *to++ = l;
+ *to++ = r;
+ *to++ = l;
+ *to++ = r;
+ *to++ = l;
+ *to++ = r;
+ }
+#endif
+ ret = pcm_write(alsa_param, output_buffer, frames * 4);
+ ret = ret * alsa_param->bits_per_frame / 8;
+ ret = ret / 4;
+ }
+ } else if (alsa_param->realchanl == 1) {
+ if (alsa_param->oversample == -1) {
+ frames = count * 8 / alsa_param->bits_per_frame;
+ frames = frames & (~(32 - 1));
+ for (i = 0; i < (frames * 2); i += 2) {
+ *to++ = *from;
+ *to++ = *from++;
+ from++;
+ }
+ ret = pcm_write(alsa_param, output_buffer, frames);
+ ret = ret * alsa_param->bits_per_frame / 8;
+ } else if (alsa_param->oversample == 0) {
+ frames = count * 8 / (alsa_param->bits_per_frame >> 1);
+ frames = frames & (~(16 - 1));
+ for (i = 0; i < (frames); i++) {
+ *to++ = *from;
+ *to++ = *from++;
+ }
+ ret = pcm_write(alsa_param, output_buffer, frames);
+ ret = ret * (alsa_param->bits_per_frame) / 8;
+ ret = ret / 2;
+ } else if (alsa_param->oversample == 1) {
+ frames = count * 8 / (alsa_param->bits_per_frame >> 1);
+ frames = frames & (~(8 - 1));
+#ifdef USE_INTERPOLATION
+ pcm_interpolation(1, alsa_param->realchanl, frames, (short*)src);
+ from = (unsigned short*)interpolation_output;
+ for (i = 0; i < (frames * 2); i++) {
+ *to++ = *from;
+ *to++ = *from++;
+ }
+#else
+ for (i = 0; i < (frames); i++) {
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from++;
+ }
+#endif
+ ret = pcm_write(alsa_param, output_buffer, frames * 2);
+ ret = ret * (alsa_param->bits_per_frame) / 8;
+ ret = ret / 4;
+ } else if (alsa_param->oversample == 2) {
+ frames = count * 8 / (alsa_param->bits_per_frame >> 1);
+ frames = frames & (~(8 - 1));
+#ifdef USE_INTERPOLATION
+ pcm_interpolation(2, alsa_param->realchanl, frames, (short*)src);
+ from = (unsigned short*)interpolation_output;
+ for (i = 0; i < (frames * 4); i++) {
+ *to++ = *from;
+ *to++ = *from++;
+ }
+#else
+ for (i = 0; i < (frames); i++) {
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from;
+ *to++ = *from++;
+ }
+#endif
+ ret = pcm_write(alsa_param, output_buffer, frames * 4);
+ ret = ret * (alsa_param->bits_per_frame) / 8;
+ ret = ret / 8;
+ }
+ }
+
+ return ret;
+}
+
+static int alsa_play(alsa_param_t * alsa_param, char * data, unsigned len)
+{
+ size_t l = 0, r;
+
+ if (!alsa_param->flag) {
+ l = len * 8 / alsa_param->bits_per_frame;
+ l = l & (~(32 - 1)); /*driver only support 32 frames each time */
+ r = pcm_write(alsa_param, data, l);
+ r = r * alsa_param->bits_per_frame / 8;
+ } else {
+ r = oversample_play(alsa_param, data, len);
+ }
+
+ return r ;
+}
+
+static int alsa_swtich_port(alsa_param_t *alsa_params, int card, int port)
+{
+ char dev[10] = {0};
+ adec_print("card = %d, port = %d\n", card, port);
+ sprintf(dev, "hw:%d,%d", (card >= 0) ? card : 0, (port >= 0) ? port : 0);
+ pthread_mutex_lock(&alsa_params->playback_mutex);
+ snd_pcm_drop(alsa_params->handle);
+ snd_pcm_close(alsa_params->handle);
+ alsa_params->handle = NULL;
+ int err = snd_pcm_open(&alsa_params->handle, dev, SND_PCM_STREAM_PLAYBACK, 0);
+
+ if (err < 0) {
+ adec_print("audio open error: %s", snd_strerror(err));
+ pthread_mutex_unlock(&alsa_params->playback_mutex);
+ return -1;
+ }
+
+ set_params(alsa_params);
+ pthread_mutex_unlock(&alsa_params->playback_mutex);
+
+ return 0;
+}
+
+static void *alsa_playback_loop(void *args)
+{
+ int len = 0;
+ int len2 = 0;
+ int offset = 0;
+ aml_audio_dec_t *audec;
+ alsa_param_t *alsa_params;
+ unsigned char *buffer = (unsigned char *)(((unsigned long)decode_buffer + 32) & (~0x1f));
+
+ char value[PROPERTY_VALUE_MAX]={0};
+ audec = (aml_audio_dec_t *)args;
+ alsa_params = (alsa_param_t *)audec->aout_ops.private_data;
+
+ // bootplayer default volume configuration
+ if (property_get("media.amplayer.boot_vol",value,NULL) > 0) {
+ alsa_default_vol = atof(value);
+ if (alsa_default_vol < 0.0 || alsa_default_vol > 1.0 ) {
+ adec_print("wrong alsa default volume %f, set to 1.0 \n",alsa_default_vol);
+ alsa_default_vol = 1.0;
+ }
+ }
+ adec_print("alsa default volume %f \n",alsa_default_vol);
+ /* pthread_mutex_init(&alsa_params->playback_mutex, NULL);
+ pthread_cond_init(&alsa_params->playback_cond, NULL);*/
+
+ while (!alsa_params->wait_flag && alsa_params->stop_flag == 0) {
+ amthreadpool_thread_usleep(10000);
+ }
+
+ adec_print("alsa playback loop start to run !\n");
+
+ while (!alsa_params->stop_flag) {
+#if 0
+ if (hdmi_out == 0) {
+ adec_print("===dynmiac get hdmi plugin state===\n");
+ if (alsa_get_hdmi_state() == 1) {
+ if (alsa_swtich_port(alsa_params, alsa_get_aml_card(), alsa_get_spdif_port()) == -1) {
+ adec_print("switch to hdmi port failed.\n");
+ goto exit;
+ }
+
+ hdmi_out = 1;
+ adec_print("[%s,%d]get hdmi device, use hdmi device \n", __FUNCTION__, __LINE__);
+ }
+ } else if (alsa_get_hdmi_state() == 0) {
+ if (alsa_swtich_port(alsa_params, alsa_get_aml_card(), 0) == -1) {
+ adec_print("switch to default port failed.\n");
+ goto exit;
+ }
+
+ hdmi_out = 0;
+ adec_print("[%s,%d]get default device, use default device \n", __FUNCTION__, __LINE__);
+ }
+#endif
+ while ((len < (128 * 2)) && (!alsa_params->stop_flag)) {
+ if (offset > 0) {
+ memcpy(buffer, buffer + offset, len);
+ }
+ len2 = audec->adsp_ops.dsp_read(&audec->adsp_ops, (buffer + len), (OUTPUT_BUFFER_SIZE - len));
+ len = len + len2;
+ offset = 0;
+ }
+ audec->pcm_bytes_readed += len;
+ while (alsa_params->pause_flag) {
+ amthreadpool_thread_usleep(10000);
+ }
+ if (alsa_params->stop_flag) {
+ goto exit;
+ }
+ adec_refresh_pts(audec);
+
+ len2 = alsa_play(alsa_params, (buffer + offset), len);
+ if (len2 >= 0) {
+ len -= len2;
+ offset += len2;
+ } else {
+ len = 0;
+ offset = 0;
+ }
+ }
+exit:
+ adec_print("Exit alsa playback loop !\n");
+ pthread_exit(NULL);
+ return NULL;
+}
+
+/**
+ * \brief output initialization
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ */
+int alsa_init(struct aml_audio_dec* audec)
+{
+ adec_print("alsa out init");
+ char sound_card_dev[10] = {0};
+ int sound_card_id = 0;
+ int sound_dev_id = 0;
+ int err;
+ pthread_t tid;
+ alsa_param_t *alsa_param;
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+ tv_mode = getprop_bool("ro.platform.has.tvuimode");
+ alsa_param = (alsa_param_t *)malloc(sizeof(alsa_param_t));
+ if (!alsa_param) {
+ adec_print("alloc alsa_param failed, not enough memory!");
+ return -1;
+ }
+ memset(alsa_param, 0, sizeof(alsa_param_t));
+
+ if (audec->samplerate >= (88200 + 96000) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = -1;
+ alsa_param->rate = 48000;
+ } else if (audec->samplerate >= (64000 + 88200) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = -1;
+ alsa_param->rate = 44100;
+ } else if (audec->samplerate >= (48000 + 64000) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = -1;
+ alsa_param->rate = 32000;
+ } else if (audec->samplerate >= (44100 + 48000) / 2) {
+ alsa_param->oversample = 0;
+ alsa_param->rate = 48000;
+ if (audec->channels == 1) {
+ alsa_param->flag = 1;
+ } else if (audec->channels == 2) {
+ alsa_param->flag = 0;
+ }
+ } else if (audec->samplerate >= (32000 + 44100) / 2) {
+ alsa_param->oversample = 0;
+ alsa_param->rate = 44100;
+ if (audec->channels == 1) {
+ alsa_param->flag = 1;
+ } else if (audec->channels == 2) {
+ alsa_param->flag = 0;
+ }
+ } else if (audec->samplerate >= (24000 + 32000) / 2) {
+ alsa_param->oversample = 0;
+ alsa_param->rate = 32000;
+ if (audec->channels == 1) {
+ alsa_param->flag = 1;
+ } else if (audec->channels == 2) {
+ alsa_param->flag = 0;
+ }
+ } else if (audec->samplerate >= (22050 + 24000) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = 1;
+ alsa_param->rate = 48000;
+ } else if (audec->samplerate >= (16000 + 22050) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = 1;
+ alsa_param->rate = 44100;
+ } else if (audec->samplerate >= (12000 + 16000) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = 1;
+ alsa_param->rate = 32000;
+ } else if (audec->samplerate >= (11025 + 12000) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = 2;
+ alsa_param->rate = 48000;
+ } else if (audec->samplerate >= (8000 + 11025) / 2) {
+ alsa_param->flag = 1;
+ alsa_param->oversample = 2;
+ alsa_param->rate = 44100;
+ } else {
+ alsa_param->flag = 1;
+ alsa_param->oversample = 2;
+ alsa_param->rate = 32000;
+ }
+
+ alsa_param->channelcount = 2;
+ alsa_param->realchanl = audec->channels;
+ //alsa_param->rate = audec->samplerate;
+ alsa_param->format = SND_PCM_FORMAT_S16_LE;
+ alsa_param->wait_flag = 0;
+
+#ifdef USE_INTERPOLATION
+ memset(pass1_history, 0, 64 * sizeof(int));
+ memset(pass2_history, 0, 64 * sizeof(int));
+#endif
+
+ sound_card_id = alsa_get_aml_card();
+ if (sound_card_id < 0) {
+ sound_card_id = 0;
+ adec_print("get aml card fail, use default \n");
+ }
+#if 0
+ if (alsa_get_hdmi_state() == 1) {
+ sound_dev_id = alsa_get_spdif_port();
+ if (sound_dev_id < 0) {
+ sound_dev_id = 0;
+ adec_print("get aml card device fail, use default \n");
+ } else {
+ hdmi_out = 1;
+ }
+ adec_print("get hdmi device, use hdmi device \n");
+ }
+#endif
+ sprintf(sound_card_dev, "hw:%d,%d", sound_card_id, sound_dev_id);
+ err = snd_pcm_open(&alsa_param->handle, sound_card_dev, SND_PCM_STREAM_PLAYBACK, 0);
+ if (err < 0) {
+ adec_print("audio open error: %s", snd_strerror(err));
+ return -1;
+ }
+ readi_func = snd_pcm_readi;
+ writei_func = snd_pcm_writei;
+ readn_func = snd_pcm_readn;
+ writen_func = snd_pcm_writen;
+
+ set_params(alsa_param);
+
+ out_ops->private_data = (void *)alsa_param;
+
+ /*TODO: create play thread */
+ pthread_mutex_init(&alsa_param->playback_mutex, NULL);
+ pthread_cond_init(&alsa_param->playback_cond, NULL);
+ err = amthreadpool_pthread_create(&tid, NULL, (void *)alsa_playback_loop, (void *)audec);
+ if (err != 0) {
+ adec_print("alsa_playback_loop thread create failed!");
+ snd_pcm_close(alsa_param->handle);
+ return -1;
+ }
+ pthread_setname_np(tid, "ALSAOUTLOOP");
+
+ adec_print("Create alsa playback loop thread success ! tid = %d\n", tid);
+
+ alsa_param->playback_tid = tid;
+
+ return 0;
+}
+
+/**
+ * \brief start output
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ *
+ * Call alsa_start(), then the callback will start being called.
+ */
+int alsa_start(struct aml_audio_dec* audec)
+{
+ adec_print("alsa out start!\n");
+
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+ alsa_param_t *alsa_param = (alsa_param_t *)out_ops->private_data;
+
+ pthread_mutex_lock(&alsa_param->playback_mutex);
+ adec_print("yvonne pthread_cond_signalalsa_param->wait_flag=1\n");
+ alsa_param->wait_flag = 1; //yvonneadded
+ pthread_cond_signal(&alsa_param->playback_cond);
+ pthread_mutex_unlock(&alsa_param->playback_mutex);
+ adec_print("exit alsa out start!\n");
+
+ return 0;
+}
+
+/**
+ * \brief pause output
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ */
+int alsa_pause(struct aml_audio_dec* audec)
+{
+ adec_print("alsa out pause\n");
+
+ int res;
+ alsa_param_t *alsa_params;
+
+ alsa_params = (alsa_param_t *)audec->aout_ops.private_data;
+ pthread_mutex_lock(&alsa_params->playback_mutex);
+
+ alsa_params->pause_flag = 1;
+ while ((res = snd_pcm_pause(alsa_params->handle, 1)) == -EAGAIN) {
+ sleep(1);
+ }
+ pthread_mutex_unlock(&alsa_params->playback_mutex);
+ adec_print("exit alsa out pause\n");
+
+ return res;
+}
+
+/**
+ * \brief resume output
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ */
+int alsa_resume(struct aml_audio_dec* audec)
+{
+ adec_print("alsa out rsume\n");
+
+ int res;
+ alsa_param_t *alsa_params;
+
+ alsa_params = (alsa_param_t *)audec->aout_ops.private_data;
+ pthread_mutex_lock(&alsa_params->playback_mutex);
+
+ alsa_params->pause_flag = 0;
+ while ((res = snd_pcm_pause(alsa_params->handle, 0)) == -EAGAIN) {
+ sleep(1);
+ }
+ pthread_mutex_unlock(&alsa_params->playback_mutex);
+
+ return res;
+}
+
+/**
+ * \brief stop output
+ * \param audec pointer to audec
+ * \return 0 on success otherwise negative error code
+ */
+int alsa_stop(struct aml_audio_dec* audec)
+{
+ adec_print("enter alsa out stop\n");
+
+ alsa_param_t *alsa_params;
+
+ alsa_params = (alsa_param_t *)audec->aout_ops.private_data;
+ pthread_mutex_lock(&alsa_params->playback_mutex);
+ alsa_params->pause_flag = 0;
+ alsa_params->stop_flag = 1;
+ //alsa_params->wait_flag = 0;
+ pthread_cond_signal(&alsa_params->playback_cond);
+ amthreadpool_pthread_join(alsa_params->playback_tid, NULL);
+ pthread_cond_destroy(&alsa_params->playback_cond);
+
+
+ snd_pcm_drop(alsa_params->handle);
+ snd_pcm_close(alsa_params->handle);
+ pthread_mutex_unlock(&alsa_params->playback_mutex);
+ pthread_mutex_destroy(&alsa_params->playback_mutex);
+
+ free(alsa_params);
+ audec->aout_ops.private_data = NULL;
+ adec_print("exit alsa out stop\n");
+
+ return 0;
+}
+
+static int alsa_get_space(alsa_param_t * alsa_param)
+{
+ snd_pcm_status_t *status;
+ int ret;
+ int bits_per_sample = alsa_param->bits_per_sample;
+ snd_pcm_status_alloca(&status);
+ if ((ret = snd_pcm_status(alsa_param->handle, status)) < 0) {
+ adec_print("Cannot get pcm status \n");
+ return 0;
+ }
+ ret = snd_pcm_status_get_avail(status) * alsa_param->bits_per_sample / 8;
+ if (ret > alsa_param->buffer_size) {
+ ret = alsa_param->buffer_size;
+ }
+ return ret;
+}
+
+/**
+ * \brief get output latency in ms
+ * \param audec pointer to audec
+ * \return output latency
+ */
+unsigned long alsa_latency(struct aml_audio_dec* audec)
+{
+ int buffered_data;
+ int sample_num;
+ alsa_param_t *alsa_param = (alsa_param_t *)audec->aout_ops.private_data;
+ int bits_per_sample = alsa_param->bits_per_sample;
+ if (tv_mode) {
+ bits_per_sample = bits_per_sample*4;
+ }
+ buffered_data = alsa_param->buffer_size - alsa_get_space(alsa_param);
+ sample_num = buffered_data / (alsa_param->channelcount * (bits_per_sample / 8)); /*16/2*/
+ return ((sample_num * 1000) / alsa_param->rate);
+}
+
+static int alsa_mute(struct aml_audio_dec* audec, adec_bool_t en)
+{
+ return 0;
+}
+/**
+ * \brief get output handle
+ * \param audec pointer to audec
+ */
+void get_output_func(struct aml_audio_dec* audec)
+{
+ audio_out_operations_t *out_ops = &audec->aout_ops;
+
+ out_ops->init = alsa_init;
+ out_ops->start = alsa_start;
+ out_ops->pause = alsa_pause;
+ out_ops->resume = alsa_resume;
+ out_ops->mute = alsa_mute;
+ out_ops->stop = alsa_stop;
+ out_ops->latency = alsa_latency;
+}