Ticket #8148: dlopen-libmp3lame.patch
File dlopen-libmp3lame.patch, 13.9 KB (added by , 14 years ago) |
---|
-
configure
Implement support to use libmp3lame via dlopen ==========================================================================
a b 141 141 Supported bindings: perl, python 142 142 comma-separated list 143 143 --python=PATH Force a specific python executable to use [$python_default] 144 --enable-dlopen-libmp3lame enable libmp3lame use via dlopen [autodetect] 144 145 EOF 145 146 146 147 #following is ffmpeg's configure help text … … 1338 1339 dvdv 1339 1340 opengl 1340 1341 vdpau 1342 dlopen_libmp3lame 1341 1343 ' 1342 1344 1343 1345 CMDLINE_SELECT=" … … 2020 2022 fi 2021 2023 done 2022 2024 ;; 2025 --enable-dlopen-libmp3lame) 2026 dlopen_libmp3lame="yes" 2027 ;; 2028 --disable-dlopen-libmp3lame) 2029 dlopen_libmp3lame="no" 2030 ;; 2023 2031 --disable-devices) disable $INDEV_LIST $OUTDEV_LIST 2024 2032 ;; 2025 2033 --enable-debug=*) debuglevel="$optval" … … 3770 3778 enabled freetype2 || 3771 3779 die "ERROR! You must have FreeType installed to compile MythTV." 3772 3780 3773 enabled lamemp3 && check_lib2 lame/lame.h lame_init -lmp3lame -lm || 3774 die "ERROR! You must have the Lame MP3 encoding library installed to compile MythTV." 3781 # libmp3lame probe 3782 if test -z "$dlopen_libmp3lame" || test x"$dlopen_libmp3lame" = x"yes"; then 3783 { check_header lame/lame.h && 3784 enable dlopen_libmp3lame 3785 } || disable dlopen_libmp3lame 3786 else 3787 disable dlopen_libmp3lame 3788 fi 3789 3790 if disabled dlopen_libmp3lame; then 3791 enabled lamemp3 && check_lib2 lame/lame.h lame_init -lmp3lame -lm || 3792 die "ERROR! You must have the Lame MP3 encoding library or header installed to compile MythTV." 3793 fi 3775 3794 3776 3795 if $(pkg-config --atleast-version 4.4.0 QtWebKit) ; then 3777 3796 enable qtwebkit … … 4251 4270 echo "# Bindings" 4252 4271 echo "bindings_perl ${bindings_perl-no}" 4253 4272 echo "bindings_python ${bindings_python-no}" 4273 echo "dlopen libmp3lame ${dlopen_libmp3lame-no}" 4254 4274 echo "" 4255 4275 4256 4276 MYTH_CONFIG_H=libs/libmythdb/mythconfig.h … … 4564 4584 echo "CONFIG_OPENGL_LIBS=-lGL -lGLU" >> $MYTH_CONFIG_MAK 4565 4585 fi 4566 4586 4587 if enabled dlopen_libmp3lame; then 4588 echo "#define CONFIG_DLOPEN_LIBMP3LAME 1" >>$TMPH 4589 fi 4590 4567 4591 if test x"$CCONFIG" != x"" ; then 4568 4592 echo "CCONFIG=$CCONFIG" >> $MYTH_CONFIG_MAK 4569 4593 echo "#define MYTH_BUILD_CONFIG \"$CCONFIG\"" >>$TMPH -
new file libs/libmythtv/myth_mp3.h
- + 1 #ifndef MYTH_MP3_H 2 #define MYTH_MP3_H 3 4 #ifdef MMX 5 #undef MMX 6 #define MMXBLAH 7 #endif 8 #include <lame/lame.h> 9 #ifdef MMXBLAH 10 #define MMX 11 #undef MMXBLAH 12 #endif 13 14 typedef struct { 15 void *handle; 16 int CDECL (*lame_close)(lame_global_flags *); 17 lame_global_flags * CDECL (*lame_init)(void); 18 int CDECL (*lame_set_bWriteVbrTag)(lame_global_flags *, int); 19 int CDECL (*lame_set_quality)(lame_global_flags *, int); 20 int CDECL (*lame_set_compression_ratio)(lame_global_flags *, float); 21 int CDECL (*lame_set_mode)(lame_global_flags *, MPEG_mode); 22 int CDECL (*lame_set_num_channels)(lame_global_flags *, int); 23 int CDECL (*lame_set_in_samplerate)(lame_global_flags *, int); 24 int CDECL (*lame_init_params)(lame_global_flags *); 25 int CDECL (*lame_encode_buffer_interleaved)(lame_global_flags*,short int*,int, 26 unsigned char*,int); 27 int CDECL (*lame_encode_buffer)(lame_global_flags*,const short int*, 28 const short int*,const int,unsigned char*, 29 const int); 30 int CDECL (*lame_encode_flush_nogap)(lame_global_flags*,unsigned char*,int); 31 } MythMP3Context; 32 33 class MythMP3 34 { 35 public: 36 MythMP3(); 37 ~MythMP3(); 38 bool IsInitilized(); 39 int CDECL lame_close(lame_global_flags *); 40 lame_global_flags * CDECL lame_init(void); 41 int CDECL lame_set_bWriteVbrTag(lame_global_flags *, int); 42 int CDECL lame_set_quality(lame_global_flags *, int); 43 int CDECL lame_set_compression_ratio(lame_global_flags *, float); 44 int CDECL lame_set_mode(lame_global_flags *, MPEG_mode); 45 int CDECL lame_set_num_channels(lame_global_flags *, int); 46 int CDECL lame_set_in_samplerate(lame_global_flags *, int); 47 int CDECL lame_init_params(lame_global_flags *); 48 int CDECL lame_encode_buffer_interleaved( 49 lame_global_flags* gfp, 50 short int pcm[], 51 int num_samples, 52 unsigned char* mp3buf, 53 int mp3buf_size); 54 int CDECL lame_encode_buffer( 55 lame_global_flags* gfp, 56 const short int buffer_l [], 57 const short int buffer_r [], 58 const int nsamples, 59 unsigned char* mp3buf, 60 const int mp3buf_size); 61 int CDECL lame_encode_flush_nogap( 62 lame_global_flags * gfp, 63 unsigned char* mp3buf, 64 int size); 65 private: 66 MythMP3Context *s; 67 }; 68 69 #endif -
libs/libmythtv/libmythtv.pro
a b 52 52 using_mheg: LIBS += -L../libmythfreemheg -lmythfreemheg-$$LIBVERSION 53 53 using_live: LIBS += -L../libmythlivemedia -lmythlivemedia-$$LIBVERSION 54 54 using_hdhomerun: LIBS += -L../libmythhdhomerun -lmythhdhomerun-$$LIBVERSION 55 using_backend: LIBS += -lmp3lame55 using_backend:!using_dlopen_libmp3lame LIBS += -lmp3lame 56 56 LIBS += -lz $$EXTRA_LIBS $$QMAKE_LIBS_DYNLOAD 57 57 58 58 TARGETDEPS += ../libmyth/libmyth-$${MYTH_SHLIB_EXT} … … 432 432 using_ffmpeg_threads:DEFINES += USING_FFMPEG_THREADS 433 433 HEADERS += NuppelVideoRecorder.h fifowriter.h audioinput.h 434 434 SOURCES += NuppelVideoRecorder.cpp fifowriter.cpp audioinput.cpp 435 HEADERS += myth_mp3.h 436 SOURCES += myth_mp3.cpp 437 LIBS += -ldl 435 438 using_alsa { 436 439 HEADERS += audioinputalsa.h 437 440 SOURCES += audioinputalsa.cpp -
libs/libmythtv/NuppelVideoRecorder.cpp
a b 190 190 if (mp3buf) 191 191 delete [] mp3buf; 192 192 if (gf) 193 lame_close(gf);193 myth_mp3.lame_close(gf); 194 194 if (strm) 195 195 delete [] strm; 196 196 if (audio_device) … … 717 717 718 718 if (compressaudio) 719 719 { 720 gf = lame_init();721 lame_set_bWriteVbrTag(gf, 0);722 lame_set_quality(gf, mp3quality);723 lame_set_compression_ratio(gf, 11);724 lame_set_mode(gf, audio_channels == 2 ? STEREO : MONO);725 lame_set_num_channels(gf, audio_channels);726 lame_set_in_samplerate(gf, audio_samplerate);727 if ((tmp = lame_init_params(gf)) != 0)720 gf = myth_mp3.lame_init(); 721 myth_mp3.lame_set_bWriteVbrTag(gf, 0); 722 myth_mp3.lame_set_quality(gf, mp3quality); 723 myth_mp3.lame_set_compression_ratio(gf, 11); 724 myth_mp3.lame_set_mode(gf, audio_channels == 2 ? STEREO : MONO); 725 myth_mp3.lame_set_num_channels(gf, audio_channels); 726 myth_mp3.lame_set_in_samplerate(gf, audio_samplerate); 727 if ((tmp = myth_mp3.lame_init_params(gf)) != 0) 728 728 { 729 729 VERBOSE(VB_IMPORTANT, LOC_ERR + 730 QString("AudioInit(): lame_init_params error %1").arg(tmp));730 QString("AudioInit(): myth_mp3.lame_init_params error %1").arg(tmp)); 731 731 compressaudio = false; 732 732 } 733 733 … … 3194 3194 3195 3195 if (audio_channels == 2) 3196 3196 { 3197 lameret = lame_encode_buffer_interleaved(3197 lameret = myth_mp3.lame_encode_buffer_interleaved( 3198 3198 gf, (short int*) buf, sample_cnt, 3199 3199 (unsigned char*) mp3buf, mp3buf_size); 3200 3200 } 3201 3201 else 3202 3202 { 3203 lameret = lame_encode_buffer(3203 lameret = myth_mp3.lame_encode_buffer( 3204 3204 gf, (short int*) buf, (short int*) buf, sample_cnt, 3205 3205 (unsigned char*) mp3buf, mp3buf_size); 3206 3206 } … … 3213 3213 } 3214 3214 compressedsize = lameret; 3215 3215 3216 lameret = lame_encode_flush_nogap(gf, (unsigned char *)mp3gapless,3216 lameret = myth_mp3.lame_encode_flush_nogap(gf, (unsigned char *)mp3gapless, 3217 3217 7200); 3218 3218 if (lameret < 0) 3219 3219 { -
new file libs/libmythtv/myth_mp3.cpp
- + 1 extern "C" { 2 #include <dlfcn.h> 3 } 4 #include "mythconfig.h" 5 #include "myth_mp3.h" 6 7 #if (defined __APPLE__) 8 #define LIBMP3LAME "libmp3lame.dylib" 9 #else 10 #define LIBMP3LAME "libmp3lame.so.0" 11 #endif 12 13 MythMP3::MythMP3() 14 { 15 #ifndef CONFIG_DLOPEN_LIBMP3LAME 16 s = NULL; 17 #else 18 /* use the initializer function to initilize the libmp3lame library */ 19 const char* const libmp3lame = LIBMP3LAME; 20 s->handle = dlopen(libmp3lame, RTLD_LOCAL | RTLD_LAZY); 21 if (!s->handle) 22 return; 23 const char* err = 0; 24 #define TOSTRING(s) #s 25 #define init_sym(a, b) do { \ 26 const char* n = TOSTRING(lame_##b); \ 27 if (!err && !(s->lame_##b = (a)dlsym(s->handle, n))) { \ 28 err = n; \ 29 } \ 30 } while(0) 31 /* resolve function calls */ 32 init_sym(int CDECL (*)(lame_global_flags*), close); 33 init_sym(lame_global_flags * CDECL (*)(void), init); 34 init_sym(int CDECL (*)(lame_global_flags*, int), set_bWriteVbrTag); 35 init_sym(int CDECL (*)(lame_global_flags*, int), set_quality); 36 init_sym(int CDECL (*)(lame_global_flags*, float), set_compression_ratio); 37 init_sym(int CDECL (*)(lame_global_flags*, MPEG_mode), set_mode); 38 init_sym(int CDECL (*)(lame_global_flags*, int), set_num_channels); 39 init_sym(int CDECL (*)(lame_global_flags*, int), set_in_samplerate); 40 init_sym(int CDECL (*)(lame_global_flags*), init_params); 41 init_sym(int CDECL (*)(lame_global_flags*,short int*,int,unsigned char*, 42 int), 43 encode_buffer_interleaved); 44 init_sym(int CDECL (*)(lame_global_flags*,const short int*,const short int*, 45 const int,unsigned char*,const int), 46 encode_buffer); 47 init_sym(int CDECL (*)(lame_global_flags*,unsigned char*,int), 48 encode_flush_nogap); 49 if (err) 50 { 51 dlclose(s->handle); 52 s->handle = NULL; 53 return; 54 } 55 #endif /* CONFIG_DLOPEN_LIBMP3LAME */ 56 } 57 58 MythMP3::~MythMP3() 59 { 60 #ifdef CONFIG_DLOPEN_LIBMP3LAME 61 dlclose(s->handle); 62 #endif 63 } 64 65 bool MythMP3::IsInitilized() 66 { 67 #ifndef CONFIG_DLOPEN_LIBMP3LAME 68 return true; 69 #else 70 return (s->handle != NULL); 71 #endif 72 } 73 74 /* libmp3lame calls */ 75 lame_global_flags * CDECL MythMP3::lame_init(void) 76 { 77 #ifndef CONFIG_DLOPEN_LIBMP3LAME 78 return ::lame_init(); 79 #else 80 return (*s->lame_init)(); 81 #endif 82 } 83 84 int CDECL MythMP3::lame_close(lame_global_flags *a) 85 { 86 #ifndef CONFIG_DLOPEN_LIBMP3LAME 87 return ::lame_close(a); 88 #else 89 return (*s->lame_close)(a); 90 #endif 91 } 92 93 int CDECL MythMP3::lame_set_bWriteVbrTag(lame_global_flags *a, int b) 94 { 95 #ifndef CONFIG_DLOPEN_LIBMP3LAME 96 return ::lame_set_bWriteVbrTag(a,b); 97 #else 98 return (*s->lame_set_bWriteVbrTag)(a,b); 99 #endif 100 } 101 102 int CDECL MythMP3::lame_set_quality(lame_global_flags *a, int b) 103 { 104 #ifndef CONFIG_DLOPEN_LIBMP3LAME 105 return ::lame_set_quality(a,b); 106 #else 107 return (*s->lame_set_quality)(a,b); 108 #endif 109 } 110 111 int CDECL MythMP3::lame_set_compression_ratio(lame_global_flags *a, float b) 112 { 113 #ifndef CONFIG_DLOPEN_LIBMP3LAME 114 return ::lame_set_compression_ratio(a,b); 115 #else 116 return (*s->lame_set_compression_ratio)(a,b); 117 #endif 118 } 119 120 int CDECL MythMP3::lame_set_mode(lame_global_flags *a, MPEG_mode b) 121 { 122 #ifndef CONFIG_DLOPEN_LIBMP3LAME 123 return ::lame_set_mode(a,b); 124 #else 125 return (*s->lame_set_mode)(a,b); 126 #endif 127 } 128 129 int CDECL MythMP3::lame_set_num_channels(lame_global_flags *a, int b) 130 { 131 #ifndef CONFIG_DLOPEN_LIBMP3LAME 132 return ::lame_set_num_channels(a,b); 133 #else 134 return (*s->lame_set_num_channels)(a,b); 135 #endif 136 } 137 138 int CDECL MythMP3::lame_set_in_samplerate(lame_global_flags *a , int b) 139 { 140 #ifndef CONFIG_DLOPEN_LIBMP3LAME 141 return ::lame_set_in_samplerate(a,b); 142 #else 143 return (*s->lame_set_in_samplerate)(a,b); 144 #endif 145 } 146 147 int CDECL MythMP3::lame_init_params(lame_global_flags *a) 148 { 149 #ifndef CONFIG_DLOPEN_LIBMP3LAME 150 return ::lame_init_params(a); 151 #else 152 return (*s->lame_init_params)(a); 153 #endif 154 } 155 156 int CDECL MythMP3::lame_encode_buffer_interleaved( 157 lame_global_flags* gfp, 158 short int pcm[], 159 int num_samples, 160 unsigned char* mp3buf, 161 int mp3buf_size) 162 { 163 #ifndef CONFIG_DLOPEN_LIBMP3LAME 164 return ::lame_encode_buffer_interleaved(gfp,pcm,num_samples,mp3buf, 165 mp3buf_size); 166 #else 167 return (*s->lame_encode_buffer_interleaved)(gfp,pcm,num_samples,mp3buf, 168 mp3buf_size); 169 #endif 170 } 171 172 int CDECL MythMP3::lame_encode_buffer ( 173 lame_global_flags* gfp, 174 const short int buffer_l [], 175 const short int buffer_r [], 176 const int nsamples, 177 unsigned char* mp3buf, 178 const int mp3buf_size) 179 { 180 #ifndef CONFIG_DLOPEN_LIBMP3LAME 181 return ::lame_encode_buffer(gfp,buffer_l,buffer_r,nsamples,mp3buf, 182 mp3buf_size); 183 #else 184 return (*s->lame_encode_buffer)(gfp,buffer_l,buffer_r,nsamples,mp3buf, 185 mp3buf_size); 186 #endif 187 } 188 189 int CDECL MythMP3::lame_encode_flush_nogap( 190 lame_global_flags * gfp, 191 unsigned char* mp3buf, 192 int size) 193 { 194 #ifndef CONFIG_DLOPEN_LIBMP3LAME 195 return ::lame_encode_flush_nogap(gfp,mp3buf,size); 196 #else 197 return (*s->lame_encode_flush_nogap)(gfp,mp3buf,size); 198 #endif 199 } -
libs/libmythtv/NuppelVideoRecorder.h
a b 35 35 36 36 #include "mythexp.h" 37 37 38 #include "myth_mp3.h" 39 38 40 struct video_audio; 39 41 struct VBIData; 40 42 struct cc; … … 287 289 288 290 bool go7007; 289 291 bool resetcapture; 292 293 MythMP3 myth_mp3; 290 294 }; 291 295 292 296 #endif