dtmf: Use GSlice for internal event structures

This commit is contained in:
Olivier Crête 2009-08-11 16:39:42 -04:00
parent 195be0da01
commit e9f782544e
2 changed files with 17 additions and 17 deletions

View file

@ -482,7 +482,7 @@ gst_dtmf_src_add_start_event (GstDTMFSrc * dtmfsrc, gint event_number,
gint event_volume)
{
GstDTMFSrcEvent *event = g_malloc (sizeof (GstDTMFSrcEvent));
GstDTMFSrcEvent *event = g_slice_new0 (GstDTMFSrcEvent);
event->event_type = DTMF_EVENT_TYPE_START;
event->sample = 0;
event->event_number = CLAMP (event_number, MIN_EVENT, MAX_EVENT);
@ -495,7 +495,7 @@ static void
gst_dtmf_src_add_stop_event (GstDTMFSrc * dtmfsrc)
{
GstDTMFSrcEvent *event = g_malloc (sizeof (GstDTMFSrcEvent));
GstDTMFSrcEvent *event = g_slice_new0 (GstDTMFSrcEvent);
event->event_type = DTMF_EVENT_TYPE_STOP;
event->sample = 0;
event->event_number = 0;
@ -658,7 +658,7 @@ gst_dtmf_src_create (GstBaseSrc * basesrc, guint64 offset,
break;
}
if (event)
g_free (event);
g_slice_free (GstDTMFSrcEvent, event);
} else if (dtmfsrc->last_event->packet_count * dtmfsrc->interval >=
MIN_DUTY_CYCLE) {
event = g_async_queue_try_pop (dtmfsrc->event_queue);
@ -673,7 +673,7 @@ gst_dtmf_src_create (GstBaseSrc * basesrc, guint64 offset,
case DTMF_EVENT_TYPE_STOP:
gst_dtmf_src_set_stream_lock (dtmfsrc, FALSE);
g_free (dtmfsrc->last_event);
g_slice_free (GstDTMFSrcEvent, dtmfsrc->last_event);
dtmfsrc->last_event = NULL;
break;
case DTMF_EVENT_TYPE_PAUSE_TASK:
@ -692,7 +692,7 @@ gst_dtmf_src_create (GstBaseSrc * basesrc, guint64 offset,
break;
}
g_free (event);
g_slice_free (GstDTMFSrcEvent, event);
}
}
} while (dtmfsrc->last_event == NULL);
@ -748,7 +748,7 @@ paused:
GST_DEBUG_OBJECT (dtmfsrc, "Stopping current event");
/* Don't forget to release the stream lock */
gst_dtmf_src_set_stream_lock (dtmfsrc, FALSE);
g_free (dtmfsrc->last_event);
g_slice_free (GstDTMFSrcEvent, dtmfsrc->last_event);
dtmfsrc->last_event = NULL;
}
@ -772,7 +772,7 @@ gst_dtmf_src_unlock (GstBaseSrc * src)
GST_OBJECT_UNLOCK (dtmfsrc);
GST_DEBUG_OBJECT (dtmfsrc, "Pushing the PAUSE_TASK event on unlock request");
event = g_malloc (sizeof (GstDTMFSrcEvent));
event = g_slice_new0 (GstDTMFSrcEvent);
event->event_type = DTMF_EVENT_TYPE_PAUSE_TASK;
g_async_queue_push (dtmfsrc->event_queue, event);
@ -875,7 +875,7 @@ gst_dtmf_src_change_state (GstElement * element, GstStateChange transition)
event = g_async_queue_try_pop (dtmfsrc->event_queue);
while (event != NULL) {
g_free (event);
g_slice_free (GstDTMFSrcEvent, event);
event = g_async_queue_try_pop (dtmfsrc->event_queue);
}
no_preroll = TRUE;
@ -899,7 +899,7 @@ gst_dtmf_src_change_state (GstElement * element, GstStateChange transition)
event = g_async_queue_try_pop (dtmfsrc->event_queue);
while (event != NULL) {
g_free (event);
g_slice_free (GstDTMFSrcEvent, event);
event = g_async_queue_try_pop (dtmfsrc->event_queue);
}

View file

@ -305,9 +305,9 @@ static void
gst_rtp_dtmf_src_event_free (GstRTPDTMFSrcEvent * event)
{
if (event) {
g_free (event->payload);
event->payload = NULL;
g_free (event);
if (event->payload)
g_slice_free (GstRTPDTMFPayload, event->payload);
g_slice_free (GstRTPDTMFSrcEvent, event);
}
}
@ -568,10 +568,10 @@ gst_rtp_dtmf_src_add_start_event (GstRTPDTMFSrc * dtmfsrc, gint event_number,
gint event_volume)
{
GstRTPDTMFSrcEvent *event = g_malloc (sizeof (GstRTPDTMFSrcEvent));
GstRTPDTMFSrcEvent *event = g_slice_new0 (GstRTPDTMFSrcEvent);
event->event_type = RTP_DTMF_EVENT_TYPE_START;
event->payload = g_new0 (GstRTPDTMFPayload, 1);
event->payload = g_slice_new0 (GstRTPDTMFPayload);
event->payload->event = CLAMP (event_number, MIN_EVENT, MAX_EVENT);
event->payload->volume = CLAMP (event_volume, MIN_VOLUME, MAX_VOLUME);
event->payload->duration = dtmfsrc->interval * dtmfsrc->clock_rate / 1000;
@ -583,7 +583,7 @@ static void
gst_rtp_dtmf_src_add_stop_event (GstRTPDTMFSrc * dtmfsrc)
{
GstRTPDTMFSrcEvent *event = g_new0 (GstRTPDTMFSrcEvent, 1);
GstRTPDTMFSrcEvent *event = g_slice_new0 (GstRTPDTMFSrcEvent);
event->event_type = RTP_DTMF_EVENT_TYPE_STOP;
g_async_queue_push (dtmfsrc->event_queue, event);
@ -816,7 +816,7 @@ send_last:
/* Don't forget to release the stream lock */
gst_rtp_dtmf_src_set_stream_lock (dtmfsrc, FALSE);
g_free (dtmfsrc->payload);
g_slice_free (GstRTPDTMFPayload, dtmfsrc->payload);
dtmfsrc->payload = NULL;
dtmfsrc->last_packet = FALSE;
@ -1069,7 +1069,7 @@ gst_rtp_dtmf_src_unlock (GstBaseSrc * src)
GST_OBJECT_UNLOCK (dtmfsrc);
GST_DEBUG_OBJECT (dtmfsrc, "Pushing the PAUSE_TASK event on unlock request");
event = g_new0 (GstRTPDTMFSrcEvent, 1);
event = g_slice_new0 (GstRTPDTMFSrcEvent);
event->event_type = RTP_DTMF_EVENT_TYPE_PAUSE_TASK;
g_async_queue_push (dtmfsrc->event_queue, event);