summaryrefslogtreecommitdiffstats
path: root/src/modules/dcc/gsmcodec.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2026-02-27 11:19:29 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2026-03-01 10:58:12 +0900
commit46844a0acfb65f6bf319b02064f2d425aab0b600 (patch)
treeb23133eb1274fb27bdf286a7a68166659a5f678a /src/modules/dcc/gsmcodec.cpp
parenteba1651fe3e71f0c650a2159446b0817f1e04593 (diff)
downloadkvirc-feat/use-libgsm-dev.tar.gz
kvirc-feat/use-libgsm-dev.zip
Use direct dependency on libgsm instead of loading it at runtime if availablefeat/use-libgsm-dev
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'src/modules/dcc/gsmcodec.cpp')
-rw-r--r--src/modules/dcc/gsmcodec.cpp55
1 files changed, 7 insertions, 48 deletions
diff --git a/src/modules/dcc/gsmcodec.cpp b/src/modules/dcc/gsmcodec.cpp
index 58af1473..e5145f81 100644
--- a/src/modules/dcc/gsmcodec.cpp
+++ b/src/modules/dcc/gsmcodec.cpp
@@ -23,67 +23,26 @@
#define _GSMCODEC_CPP_
#include "gsmcodec.h"
+#include "gsm.h"
#ifdef COMPILE_USE_GSM
-#include <dlfcn.h>
-
#define GSM_PACKED_FRAME_SIZE_IN_BYTES 33
#define GSM_UNPACKED_FRAME_SIZE_IN_BYTES 320
#define GSM_UNPACKED_FRAME_SIZE_IN_SHORTS 160
-void * (*gsm_session_create)() = 0;
-void (*gsm_session_destroy)(void *) = 0;
-void (*gsm_session_encode)(void *,short *,unsigned char *) = 0;
-int (*gsm_session_decode)(void *,unsigned char *,short *) = 0;
-
-
-void * g_pGSMCodecLibraryHandle = 0;
-
-bool kvi_gsm_codec_init()
-{
- if(g_pGSMCodecLibraryHandle)return true; // Already initialized
-
- g_pGSMCodecLibraryHandle = dlopen("libgsm.so",RTLD_NOW | RTLD_GLOBAL);
- if(!g_pGSMCodecLibraryHandle)return false; // no way to open it
-
- gsm_session_create = (void * (*)()) dlsym(g_pGSMCodecLibraryHandle,"gsm_create");
- gsm_session_destroy = (void (*)(void *)) dlsym(g_pGSMCodecLibraryHandle,"gsm_destroy");
- gsm_session_encode = (void (*)(void *,short *,unsigned char *)) dlsym(g_pGSMCodecLibraryHandle,"gsm_encode");
- gsm_session_decode = (int (*)(void *,unsigned char *,short *)) dlsym(g_pGSMCodecLibraryHandle,"gsm_decode");
-
- if(! (gsm_session_create && gsm_session_destroy && gsm_session_encode && gsm_session_decode))
- {
- dlclose(g_pGSMCodecLibraryHandle);
- g_pGSMCodecLibraryHandle = 0;
- return false;
- }
- return true;
-}
-
-void kvi_gsm_codec_done()
-{
- if(g_pGSMCodecLibraryHandle)
- {
- dlclose(g_pGSMCodecLibraryHandle);
- g_pGSMCodecLibraryHandle = 0;
- }
-}
-
-
-
KviDccVoiceGsmCodec::KviDccVoiceGsmCodec()
: KviDccVoiceCodec()
{
- m_pEncodeState = gsm_session_create();
- m_pDecodeState = gsm_session_create();
+ m_pEncodeState = gsm_create();
+ m_pDecodeState = gsm_create();
m_szName = "gsm (compression 33:320)";
}
KviDccVoiceGsmCodec::~KviDccVoiceGsmCodec()
{
- gsm_session_destroy(m_pEncodeState);
- gsm_session_destroy(m_pDecodeState);
+ gsm_destroy(m_pEncodeState);
+ gsm_destroy(m_pDecodeState);
}
void KviDccVoiceGsmCodec::encode(KviDataBuffer * signal,KviDataBuffer * stream)
@@ -101,7 +60,7 @@ void KviDccVoiceGsmCodec::encode(KviDataBuffer * signal,KviDataBuffer * stream)
while(ptr != endPtr)
{
- gsm_session_encode(m_pEncodeState,(short *)ptr,stream->data() + uFrameOffset);
+ gsm_encode(m_pEncodeState,(short *)ptr,stream->data() + uFrameOffset);
ptr += GSM_UNPACKED_FRAME_SIZE_IN_BYTES;
uFrameOffset += GSM_PACKED_FRAME_SIZE_IN_BYTES;
}
@@ -129,7 +88,7 @@ void KviDccVoiceGsmCodec::decode(KviDataBuffer * stream,KviDataBuffer * signal)
// or a broken frame...
// but if we receive broken frames over DCC...well....better
// check the hardware...or the remote codec as well...
- gsm_session_decode(m_pDecodeState,ptr,(short *)(signal->data() + uSignalOffset));
+ gsm_decode(m_pDecodeState,ptr,(short *)(signal->data() + uSignalOffset));
ptr += GSM_PACKED_FRAME_SIZE_IN_BYTES;
uSignalOffset += GSM_UNPACKED_FRAME_SIZE_IN_BYTES;
}