Commit 586cd55c authored by Ziirish's avatar Ziirish
Browse files

cleaning code (part 1)

parent f069e8f6
......@@ -40,14 +40,16 @@ gboolean run = FALSE;
//static CidMeasure *pMeasureTimer = NULL;
//extern gboolean bCurrentlyDownloading, bCurrentlyDownloadingXML;
///dcop amarok playlist addMediaList [ "file:///home/benjamin/Music/aboutagirl.mp3" ]
///dcop amarok playlist addMediaList
///[ "file:///home/benjamin/Music/aboutagirl.mp3" ]
gboolean
get_amarock_musicData (CidMainContainer **pCid)
{
CidMainContainer *cid = *pCid;
CIDError *error = NULL;
gint state = cid_console_get_int_with_error_full("dcop amarok player status",-1,&error);
gint state = cid_console_get_int_with_error_full(
"dcop amarok player status",-1,&error);
musicData.opening = TRUE;
......@@ -86,8 +88,10 @@ get_amarock_musicData (CidMainContainer **pCid)
gArtist = cid_console_get_string ("dcop amarok player artist");
gAlbum = cid_console_get_string ("dcop amarok player album");
gTitle = cid_console_get_string ("dcop amarok player title");
gPlayingURI = cid_console_get_string ("dcop amarok player encodedURL");
gCoverURI = cid_console_get_string ("dcop amarok player coverImage");
gPlayingURI = cid_console_get_string (
"dcop amarok player encodedURL");
gCoverURI = cid_console_get_string (
"dcop amarok player coverImage");
g_free (musicData.playing_cover);
if (gCoverURI == NULL)
......@@ -95,7 +99,8 @@ get_amarock_musicData (CidMainContainer **pCid)
else
musicData.playing_cover = g_strdup (gCoverURI);
if (musicData.playing_uri != NULL && strcmp (musicData.playing_uri,gPlayingURI)==0)
if (musicData.playing_uri != NULL &&
strcmp (musicData.playing_uri,gPlayingURI)==0)
{
g_free (gArtist);
g_free (gAlbum);
......@@ -116,7 +121,12 @@ get_amarock_musicData (CidMainContainer **pCid)
run = TRUE;
cid_info ("\nartist : %s\nalbum : %s\ntitle : %s\nsong uri : %s\ncover uri : %s",gArtist,gAlbum,gTitle,gPlayingURI,gCoverURI);
cid_info ("\nartist : %s\n\
album : %s\n\
title : %s\n\
song uri : %s\n\
cover uri : %s",
gArtist,gAlbum,gTitle,gPlayingURI,gCoverURI);
g_free (gArtist);
g_free (gAlbum);
g_free (gTitle);
......@@ -125,29 +135,6 @@ get_amarock_musicData (CidMainContainer **pCid)
return TRUE;
}
/*
gboolean
cid_download_amarok_cover (gpointer data)
{
cid->runtime->iCheckIter++;
if (cid->runtime->iCheckIter > cid->config->iTimeToWait)
{
if (pMeasureTimer)
{
if (cid_measure_is_running(pMeasureTimer))
cid_stop_measure_timer(pMeasureTimer);
if (cid_measure_is_active(pMeasureTimer))
cid_free_measure_timer(pMeasureTimer);
}
pMeasureTimer = cid_new_measure_timer (2 SECONDES, NULL, NULL, (CidUpdateTimerFunc) _cid_proceed_download_cover, NULL);
cid_launch_measure (pMeasureTimer);
return FALSE;
}
return TRUE;
}
*/
gchar *
cid_check_amarok_cover_exists (CidMainContainer **pCid, gchar *cURI)
{
......@@ -158,11 +145,15 @@ cid_check_amarok_cover_exists (CidMainContainer **pCid, gchar *cURI)
if (g_strcasecmp(cSplitedURI[0],"nocover")==0)
{
g_free (cRet);
cRet = cid_db_search_cover (pCid, musicData.playing_artist, musicData.playing_album);
cRet = cid_db_search_cover (pCid,
musicData.playing_artist,
musicData.playing_album);
if (cRet == NULL)
{
cid->runtime->iCheckIter = 0;
g_timeout_add (1000, (GSourceFunc) _check_cover_is_present, pCid);
g_timeout_add (1000,
(GSourceFunc) _check_cover_is_present,
pCid);
cRet = g_strdup(cid->config->cDefaultImage);
}
}
......@@ -188,7 +179,9 @@ cid_amarok_cover(CidMainContainer **pCid)
{
if (musicData.playing && musicData.playing_cover != NULL)
{
gchar *cCover = cid_check_amarok_cover_exists(pCid, musicData.playing_cover);
gchar *cCover = cid_check_amarok_cover_exists(
pCid,
musicData.playing_cover);
cid_display_image (cCover);
g_free (cCover);
}
......@@ -205,7 +198,11 @@ void
cid_amarok_pipe (CidMainContainer **pCid, gint iInter)
{
CidMainContainer *cid = *pCid;
cid->runtime->iPipe = g_timeout_add_full (G_PRIORITY_HIGH, iInter,(gpointer) cid_amarok_cover, pCid, NULL);
cid->runtime->iPipe = g_timeout_add_full (G_PRIORITY_HIGH,
iInter,
(gpointer) cid_amarok_cover,
pCid,
NULL);
}
void
......
......@@ -66,25 +66,44 @@ amarok_2_dbus_connect_to_bus (void)
g_type_init ();
if (dbus_is_enabled ())
{
// On se connecte au bus org.kde.amarok /Player org.freedesktop.MediaPlayer
dbus_proxy_player = (DBusGProxy *)(long) create_new_session_proxy ("org.kde.amarok",
// On se connecte au bus
// org.kde.amarok/Player org.freedesktop.MediaPlayer
dbus_proxy_player =
(DBusGProxy *)(long) create_new_session_proxy (
"org.kde.amarok",
"/Player",
"org.freedesktop.MediaPlayer");
// On s'abonne aux signaux
dbus_g_proxy_add_signal(dbus_proxy_player, "TrackChange",
dbus_g_type_get_map("GHashTable",G_TYPE_STRING, G_TYPE_VALUE),
G_TYPE_INVALID);
dbus_g_proxy_add_signal(dbus_proxy_player, "StatusChange",
dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID),
G_TYPE_INVALID);
dbus_g_proxy_add_signal(dbus_proxy_player,
"TrackChange",
dbus_g_type_get_map("GHashTable",
G_TYPE_STRING,
G_TYPE_VALUE),
G_TYPE_INVALID);
dbus_g_proxy_add_signal(dbus_proxy_player,
"StatusChange",
dbus_g_type_get_struct ("GValueArray",
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INVALID),
G_TYPE_INVALID);
// Puis on connecte les signaux a l'application pour les traiter un par un
dbus_g_proxy_connect_signal(dbus_proxy_player, "TrackChange",
G_CALLBACK(am_onChangeSong), NULL, NULL);
// Puis on connecte les signaux a l'application
// pour les traiter un par un
dbus_g_proxy_connect_signal(dbus_proxy_player,
"TrackChange",
G_CALLBACK(am_onChangeSong),
NULL,
NULL);
dbus_g_proxy_connect_signal(dbus_proxy_player, "StatusChange",
G_CALLBACK(am_onChangeState), NULL, NULL);
dbus_g_proxy_connect_signal(dbus_proxy_player,
"StatusChange",
G_CALLBACK(am_onChangeState),
NULL,
NULL);
return TRUE;
}
......@@ -97,13 +116,17 @@ amarok_2_dbus_disconnect_from_bus (void)
if (dbus_proxy_player != NULL)
{
// On se desabonne de tous les signaux
dbus_g_proxy_disconnect_signal(dbus_proxy_player, "TrackChange",
G_CALLBACK(am_onChangeSong), NULL);
cid_debug ("TrackChange deconnecte\n");
dbus_g_proxy_disconnect_signal(dbus_proxy_player,
"TrackChange",
G_CALLBACK(am_onChangeSong),
NULL);
cid_debug ("TrackChange disconnected");
dbus_g_proxy_disconnect_signal(dbus_proxy_player, "StatusChange",
G_CALLBACK(am_onChangeState), NULL);
cid_debug ("StatusChange deconnecte\n");
dbus_g_proxy_disconnect_signal(dbus_proxy_player,
"StatusChange",
G_CALLBACK(am_onChangeState),
NULL);
cid_debug ("StatusChange disconnected");
g_object_unref (dbus_proxy_player);
dbus_proxy_player = NULL;
......@@ -119,9 +142,9 @@ dbus_detect_amarok_2(void)
}
//*********************************************************************************
//**********************************************************************
// amarok_2_getPlaying() : Test si amarok2 joue de la musique ou non
//*********************************************************************************
//**********************************************************************
gboolean
amarok_2_getPlaying (void)
{
......@@ -130,16 +153,23 @@ amarok_2_getPlaying (void)
gint status = 100;
if (dbus_detect_amarok_2())
{
dbus_g_proxy_call (dbus_proxy_player, "GetStatus", NULL,
dbus_g_proxy_call (dbus_proxy_player,
"GetStatus",
NULL,
G_TYPE_INVALID,
dbus_g_type_get_struct ("GValueArray", G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID),
dbus_g_type_get_struct ("GValueArray",
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INVALID),
&s,
G_TYPE_INVALID);
v = g_value_array_get_nth(s, 0);
status = g_value_get_int(v);
}
cid_debug("Status : %i",status);
cid_debug ("Status : %i",status);
//switch (status) {
// case 0:
/// PLAY
......@@ -160,9 +190,9 @@ amarok_2_getPlaying (void)
}
//*********************************************************************************
//**********************************************************************
// amarok2_getPlayingUri() : Retourne l'adresse de la musique jouée
//*********************************************************************************
//**********************************************************************
gchar *
amarok_2_getPlayingUri(void)
{
......@@ -181,17 +211,22 @@ am_getSongInfos(void)
GHashTable *data_list = NULL;
GValue *value;
if(dbus_g_proxy_call (dbus_proxy_player, "GetMetadata", NULL,
G_TYPE_INVALID,
dbus_g_type_get_map("GHashTable",G_TYPE_STRING, G_TYPE_VALUE),
&data_list,
G_TYPE_INVALID)) {
if(dbus_g_proxy_call (dbus_proxy_player,
"GetMetadata", NULL,
G_TYPE_INVALID,
dbus_g_type_get_map("GHashTable",
G_TYPE_STRING,
G_TYPE_VALUE),
&data_list,
G_TYPE_INVALID))
{
// Tester si la table de hachage n'est pas vide
g_free (musicData.playing_artist);
value = (GValue *) g_hash_table_lookup(data_list, "artist");
if (value != NULL && G_VALUE_HOLDS_STRING(value))
musicData.playing_artist = g_strdup (g_value_get_string(value));
musicData.playing_artist =
g_strdup (g_value_get_string(value));
else
musicData.playing_artist = NULL;
cid_message ("playing_artist <- %s", musicData.playing_artist);
......@@ -199,7 +234,8 @@ am_getSongInfos(void)
g_free (musicData.playing_album);
value = (GValue *) g_hash_table_lookup(data_list, "album");
if (value != NULL && G_VALUE_HOLDS_STRING(value))
musicData.playing_album = g_strdup (g_value_get_string(value));
musicData.playing_album =
g_strdup (g_value_get_string(value));
else
musicData.playing_album = NULL;
cid_message ("playing_album <- %s", musicData.playing_album);
......@@ -207,12 +243,13 @@ am_getSongInfos(void)
g_free (musicData.playing_title);
value = (GValue *) g_hash_table_lookup(data_list, "title");
if (value != NULL && G_VALUE_HOLDS_STRING(value))
musicData.playing_title = g_strdup (g_value_get_string(value));
musicData.playing_title =
g_strdup (g_value_get_string(value));
else
musicData.playing_title = NULL;
cid_message ("playing_title <- %s", musicData.playing_title);
value = (GValue *) g_hash_table_lookup(data_list, "tracknumber");
value = (GValue *) g_hash_table_lookup(data_list,"tracknumber");
if (value != NULL && G_VALUE_HOLDS_UINT(value))
musicData.playing_track = g_value_get_uint(value);
else
......@@ -224,18 +261,21 @@ am_getSongInfos(void)
musicData.playing_duration = (g_value_get_int(value));
else
musicData.playing_duration = 0;
cid_message ("playing_duration <- %ds", musicData.playing_duration);
cid_message ("playing_duration <- %ds",
musicData.playing_duration);
g_free (musicData.playing_cover);
value = (GValue *) g_hash_table_lookup(data_list, "arturl");
if (value != NULL && G_VALUE_HOLDS_STRING(value))
{
//musicData.playing_cover = g_strdup (g_value_get_string(value));
//musicData.playing_cover =
// g_strdup (g_value_get_string(value));
GError *erreur = NULL;
const gchar *cString = g_value_get_string(value);
if (cString != NULL && strncmp (cString, "file://", 7) == 0)
{
musicData.playing_cover = g_filename_from_uri (cString, NULL, &erreur);
musicData.playing_cover =
g_filename_from_uri (cString, NULL, &erreur);
if (erreur != NULL)
{
cid_warning ("Attention : %s\n", erreur->message);
......@@ -263,29 +303,35 @@ am_getSongInfos(void)
}
//*********************************************************************************
//**********************************************************************
// am_onChangeSong() : Fonction executée à chaque changement de musique
//*********************************************************************************
//**********************************************************************
void
am_onChangeSong(DBusGProxy *player_proxy,GHashTable *data_list, gpointer data)
am_onChangeSong(DBusGProxy *player_proxy,
GHashTable *data_list,
gpointer data)
{
cid_display_image(cid_amarok_2_cover());
cid_animation(cid->config->iAnimationType);
}
//*********************************************************************************
//**********************************************************************
// am_onChangeState() : Fonction executée à chaque changement play/pause
//*********************************************************************************
//**********************************************************************
void
am_onChangeState(DBusGProxy *player_proxy, GValueArray *status, gpointer data)
am_onChangeState(DBusGProxy *player_proxy,
GValueArray *status,
gpointer data)
{
amarok_2_getPlaying();
cid_set_state_icon();
}
void
am_onCovertArtChanged(DBusGProxy *player_proxy,const gchar *cImageURI, gpointer data)
am_onCovertArtChanged(DBusGProxy *player_proxy,
const gchar *cImageURI,
gpointer data)
{
cid_debug ("%s (%s)",__func__,cImageURI);
g_free (musicData.playing_cover);
......
......@@ -35,14 +35,14 @@ G_BEGIN_DECLS
* recherche d'image
* @return URI de l'image à afficher
*/
gchar *cid_amarok_2_cover(void);
gchar *cid_amarok_2_cover (void);
/**
* Fonction permettant de se connecter
* au bus de amarok2
* @return VRAI ou FAUX
*/
gboolean amarok_2_dbus_connect_to_bus(void);
gboolean amarok_2_dbus_connect_to_bus (void);
/**
* Fonction permettant de se déconnecter
......@@ -55,25 +55,25 @@ void amarok_2_dbus_disconnect_from_bus (void);
* est lancé ou non
* @return VRAI ou FAUX en fonction
*/
gboolean dbus_detect_amarok_2(void);
gboolean dbus_detect_amarok_2 (void);
/**
* Test si amarok2 joue de la musique ou non
* @return VRAI ou FAUX
*/
gboolean amarok_2_getPlaying(void);
gboolean amarok_2_getPlaying (void);
/**
* renvoie l'URI du fichier en cours de lecture
* @return URI du fichier joué
*/
gchar *amarok_2_getPlayingUri(void);
gchar *amarok_2_getPlayingUri (void);
/**
* récupère l'ensemble des informations disponibles
* sur le fichier joué
*/
void am_getSongInfos(void);
void am_getSongInfos (void);
/**
* Fonction exécutée (automatiquement) au changement
......@@ -82,7 +82,9 @@ void am_getSongInfos(void);
* @param URI du fichier joué
* @param pointeur de données (non utilisé)
*/
void am_onChangeSong(DBusGProxy *player_proxy, GHashTable *data_list, gpointer data);
void am_onChangeSong (DBusGProxy *player_proxy,
GHashTable *data_list,
gpointer data);
/**
* Fonction exécutée (automatiquement) au changement d'état Play/Pause
......@@ -90,7 +92,9 @@ void am_onChangeSong(DBusGProxy *player_proxy, GHashTable *data_list, gpointer d
* @param flag on joue ou non
* @param pointeur de données (non utilisé)
*/
void am_onChangeState(DBusGProxy *player_proxy,GValueArray *status, gpointer data);
void am_onChangeState (DBusGProxy *player_proxy,
GValueArray *status,
gpointer data);
/**
* Fonction exécutée (automatiquement) à chaque changement d'URI
......@@ -99,7 +103,9 @@ void am_onChangeState(DBusGProxy *player_proxy,GValueArray *status, gpointer dat
* @param URI de la nouvelle image
* @param pointeur de données (non utilisé)
*/
void am_onCovertArtChanged(DBusGProxy *player_proxy,const gchar *cImageURI, gpointer data);
void am_onCovertArtChanged (DBusGProxy *player_proxy,
const gchar *cImageURI,
gpointer data);
/**
......
......@@ -28,22 +28,33 @@
///////////////
/// MEASURE ///
///////////////
#define cid_schedule_next_measure(pMeasureTimer) do {\
if (pMeasureTimer->iSidTimer == 0 && pMeasureTimer->iCheckInterval)\
pMeasureTimer->iSidTimer = g_timeout_add (pMeasureTimer->iCheckInterval, (GSourceFunc) _cid_timer, pMeasureTimer); } while (0)
#define cid_schedule_next_measure(pMeasureTimer) \
do { \
if (pMeasureTimer->iSidTimer == 0 && \
pMeasureTimer->iCheckInterval) \
pMeasureTimer->iSidTimer = \
g_timeout_add (pMeasureTimer->iCheckInterval, \
(GSourceFunc) _cid_timer, \
pMeasureTimer); \
} while (0)
#define cid_cancel_next_measure(pMeasureTimer) do {\
if (pMeasureTimer->iSidTimer != 0) {\
g_source_remove (pMeasureTimer->iSidTimer);\
pMeasureTimer->iSidTimer = 0; } } while (0)
#define cid_cancel_next_measure(pMeasureTimer) \
do { \
if (pMeasureTimer->iSidTimer != 0) { \
g_source_remove (pMeasureTimer->iSidTimer); \
pMeasureTimer->iSidTimer = 0; } \
} while (0)
#define cid_perform_measure_update(pMeasureTimer) do {\
gboolean bContinue = pMeasureTimer->update (pMeasureTimer->pUserData);\
if (! bContinue) {\
cid_cancel_next_measure (pMeasureTimer); }\
else {\
pMeasureTimer->iFrequencyState = CID_FREQUENCY_NORMAL;\
cid_schedule_next_measure (pMeasureTimer); } } while (0)
#define cid_perform_measure_update(pMeasureTimer) \
do { \
gboolean bContinue = \
pMeasureTimer->update (pMeasureTimer->pUserData); \
if (! bContinue) { \
cid_cancel_next_measure (pMeasureTimer); } \
else { \
pMeasureTimer->iFrequencyState = CID_FREQUENCY_NORMAL; \
cid_schedule_next_measure (pMeasureTimer); } \
} while (0)
static gboolean
_cid_timer (CidMeasure *pMeasureTimer)
......@@ -68,10 +79,12 @@ _cid_threaded_calculation (CidMeasure *pMeasureTimer)
static gboolean
_cid_check_for_redraw (CidMeasure *pMeasureTimer)
{
int iThreadIsRunning = g_atomic_int_get (&pMeasureTimer->iThreadIsRunning);
int iThreadIsRunning =
g_atomic_int_get (&pMeasureTimer->iThreadIsRunning);
if (! iThreadIsRunning)
{ // le thread a fini.
//\_______________________ On met a jour avec ces nouvelles donnees et on lance/arrete le timer.
//\__ On met a jour avec ces nouvelles donnees et on
//\__ lance/arrete le timer.
cid_perform_measure_update (pMeasureTimer);
pMeasureTimer->iSidTimerRedraw = 0;
......@@ -87,9 +100,18 @@ cid_launch_measure (CidMeasure *pMeasureTimer)
if (pMeasureTimer->read == NULL)
{ // pas de thread, tout est dans la fonction d'update.
cid_perform_measure_update (pMeasureTimer);
} else if (g_atomic_int_compare_and_exchange (&pMeasureTimer->iThreadIsRunning, 0, 1)) { // il etait egal a 0, on lui met 1 et on lance le thread.
}
else if (g_atomic_int_compare_and_exchange (
&pMeasureTimer->iThreadIsRunning,
0,
1))
{ // il etait egal a 0, on lui met 1 et on lance le thread.
GError *erreur = NULL;
GThread* pThread = g_thread_create ((GThreadFunc) _cid_threaded_calculation, pMeasureTimer, FALSE, &erreur);
GThread* pThread =
g_thread_create ((GThreadFunc) _cid_threaded_calculation,
pMeasureTimer,
FALSE,
&erreur);
if (erreur != NULL)
{ // on n'a pas pu lancer le thread.
cid_warning ("%s",erreur->message);
......@@ -98,10 +120,20 @@ cid_launch_measure (CidMeasure *pMeasureTimer)
}
if (pMeasureTimer->iSidTimerRedraw == 0)
pMeasureTimer->iSidTimerRedraw = g_timeout_add (MAX (150, MIN (0.15 * pMeasureTimer->iCheckInterval, 333)), (GSourceFunc) _cid_check_for_redraw, pMeasureTimer);
} else if (pMeasureTimer->iSidTimerRedraw != 0) { // le thread est deja fini.
pMeasureTimer->iSidTimerRedraw =
g_timeout_add (MAX (150,
MIN (
0.15*pMeasureTimer->iCheckInterval,
333)),
(GSourceFunc) _cid_check_for_redraw,
pMeasureTimer);
}
else if (pMeasureTimer->iSidTimerRedraw != 0)
{ // le thread est deja fini.
if (pMeasureTimer->iSidTimerRedraw != 0)
{ // on etait en attente de mise a jour, on fait la mise a jour tout de suite.
{
// on etait en attente de mise a jour,
// on fait la mise a jour tout de suite.
g_source_remove (pMeasureTimer->iSidTimerRedraw);
pMeasureTimer->iSidTimerRedraw = 0;
......@@ -126,11 +158,18 @@ _cid_one_shot_timer (CidMeasure *pMeasureTimer)
void
cid_launch_measure_delayed (CidMeasure *pMeasureTimer, double fDelay)
{
pMeasureTimer->iSidTimerRedraw = g_timeout_add (fDelay, (GSourceFunc) _cid_one_shot_timer, pMeasureTimer);
pMeasureTimer->iSidTimerRedraw =
g_timeout_add (fDelay,
(GSourceFunc) _cid_one_shot_timer,
pMeasureTimer);
}
CidMeasure *
cid_new_measure_timer (int iCheckInterval, CidAquisitionTimerFunc acquisition, CidReadTimerFunc read, CidUpdateTimerFunc update, gpointer pUserData)
cid_new_measure_timer (int iCheckInterval,
CidAquisitionTimerFunc acquisition,
CidReadTimerFunc read,
CidUpdateTimerFunc update,
gpointer pUserData)
{
CidMeasure *pMeasureTimer = g_new0 (CidMeasure, 1);
//if (read != NULL || acquisition != NULL)
......@@ -167,7 +206,8 @@ cid_stop_measure_timer (CidMeasure *pMeasureTimer)
_cid_pause_measure_timer (pMeasureTimer);
//cid_debug ("***on attend que le thread termine...(%d)", g_atomic_int_get (&pMeasureTimer->iThreadIsRunning));
//cid_debug ("***on attend que le thread termine...(%d)",
// g_atomic_int_get (&pMeasureTimer->iThreadIsRunning));
while (g_atomic_int_get (&pMeasureTimer->iThreadIsRunning) == 1)
{
cpt++;
......@@ -203,35 +243,46 @@ cid_measure_is_active (CidMeasure *pMeasureTimer)
gboolean
cid_measure_is_running (CidMeasure *pMeasureTimer)
{
return (pMeasureTimer != NULL && pMeasureTimer->iSidTimerRedraw != 0);
return (pMeasureTimer != NULL &&
pMeasureTimer->iSidTimerRedraw != 0);
}
static void
_cid_restart_timer_with_frequency (CidMeasure *pMeasureTimer, int iNewCheckInterval)
_cid_restart_timer_with_frequency (CidMeasure *pMeasureTimer,
int iNewCheckInterval)
{
gboolean bNeedsRestart = (pMeasureTimer->iSidTimer != 0);
_cid_pause_measure_timer (pMeasureTimer);
if (bNeedsRestart && iNewCheckInterval != 0)
pMeasureTimer->iSidTimer = g_timeout_add (iNewCheckInterval, (GSourceFunc) _cid_timer, pMeasureTimer);
pMeasureTimer->iSidTimer =
g_timeout_add (iNewCheckInterval,
(GSourceFunc) _cid_timer,
pMeasureTimer);
}
void
cid_change_measure_frequency (CidMeasure *pMeasureTimer, int iNewCheckInterval)
cid_change_measure_frequency (CidMeasure *pMeasureTimer,
int iNewCheckInterval)
{
g_return_if_fail (pMeasureTimer != NULL);
pMeasureTimer->iCheckInterval = iNewCheckInterval;
_cid_restart_timer_with_frequency (pMeasureTimer, iNewCheckInterval);
_cid_restart_timer_with_frequency (pMeasureTimer,
iNewCheckInterval);
}
void