[MOVED FROM GST-P-FARSIGHT] Make dtmf src code nicer
20070916194101-3e2dc-a8be8c509c65400d1d3962da02e67d15d2054316.gz
This commit is contained in:
parent
8c5930fadb
commit
64efe461ff
@ -633,61 +633,72 @@ gst_dtmf_src_create (GstBaseSrc * basesrc, guint64 offset,
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
if (dtmfsrc->paused)
|
|
||||||
goto paused;
|
|
||||||
|
|
||||||
if (dtmfsrc->last_event == NULL) {
|
if (dtmfsrc->last_event == NULL) {
|
||||||
GST_DEBUG_OBJECT (dtmfsrc, "popping");
|
GST_DEBUG_OBJECT (dtmfsrc, "popping");
|
||||||
event = g_async_queue_pop (dtmfsrc->event_queue);
|
event = g_async_queue_pop (dtmfsrc->event_queue);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dtmfsrc, "popped %d", event->event_type);
|
GST_DEBUG_OBJECT (dtmfsrc, "popped %d", event->event_type);
|
||||||
|
|
||||||
if (event->event_type == DTMF_EVENT_TYPE_STOP) {
|
switch (event->event_type) {
|
||||||
GST_WARNING_OBJECT (dtmfsrc,
|
case DTMF_EVENT_TYPE_STOP:
|
||||||
"Received a DTMF stop event when already stopped");
|
GST_WARNING_OBJECT (dtmfsrc,
|
||||||
} else if (event->event_type == DTMF_EVENT_TYPE_START) {
|
"Received a DTMF stop event when already stopped");
|
||||||
gst_dtmf_prepare_timestamps (dtmfsrc);
|
break;
|
||||||
|
case DTMF_EVENT_TYPE_START:
|
||||||
|
gst_dtmf_prepare_timestamps (dtmfsrc);
|
||||||
|
|
||||||
/* Don't forget to get exclusive access to the stream */
|
/* Don't forget to get exclusive access to the stream */
|
||||||
gst_dtmf_src_set_stream_lock (dtmfsrc, TRUE);
|
gst_dtmf_src_set_stream_lock (dtmfsrc, TRUE);
|
||||||
|
|
||||||
event->packet_count = 0;
|
event->packet_count = 0;
|
||||||
dtmfsrc->last_event = event;
|
dtmfsrc->last_event = event;
|
||||||
} else if (event->event_type == DTMF_EVENT_TYPE_PAUSE_TASK) {
|
break;
|
||||||
/*
|
case DTMF_EVENT_TYPE_PAUSE_TASK:
|
||||||
* We're pushing it back because it has to stay in there until
|
/*
|
||||||
* the task is really paused (and the queue will then be flushed)
|
* We're pushing it back because it has to stay in there until
|
||||||
*/
|
* the task is really paused (and the queue will then be flushed)
|
||||||
GST_DEBUG_OBJECT (dtmfsrc, "pushing pause_task...");
|
*/
|
||||||
if (dtmfsrc->paused) {
|
GST_DEBUG_OBJECT (dtmfsrc, "pushing pause_task...");
|
||||||
|
GST_OBJECT_LOCK (dtmfsrc);
|
||||||
g_async_queue_push (dtmfsrc->event_queue, event);
|
if (dtmfsrc->paused) {
|
||||||
goto paused;
|
g_async_queue_push (dtmfsrc->event_queue, event);
|
||||||
}
|
goto paused_locked;
|
||||||
|
}
|
||||||
|
GST_OBJECT_UNLOCK (dtmfsrc);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (dtmfsrc->last_event->packet_count * dtmfsrc->interval >=
|
} else if (dtmfsrc->last_event->packet_count * dtmfsrc->interval >=
|
||||||
MIN_DUTY_CYCLE) {
|
MIN_DUTY_CYCLE) {
|
||||||
event = g_async_queue_try_pop (dtmfsrc->event_queue);
|
event = g_async_queue_try_pop (dtmfsrc->event_queue);
|
||||||
|
|
||||||
if (event != NULL) {
|
if (event != NULL) {
|
||||||
if (event->event_type == DTMF_EVENT_TYPE_START) {
|
|
||||||
GST_WARNING_OBJECT (dtmfsrc,
|
|
||||||
"Received two consecutive DTMF start events");
|
|
||||||
} else if (event->event_type == DTMF_EVENT_TYPE_STOP) {
|
|
||||||
gst_dtmf_src_set_stream_lock (dtmfsrc, FALSE);
|
|
||||||
|
|
||||||
g_free (dtmfsrc->last_event);
|
switch (event->event_type) {
|
||||||
dtmfsrc->last_event = NULL;
|
case DTMF_EVENT_TYPE_START:
|
||||||
} else if (event->event_type == DTMF_EVENT_TYPE_PAUSE_TASK) {
|
GST_WARNING_OBJECT (dtmfsrc,
|
||||||
/*
|
"Received two consecutive DTMF start events");
|
||||||
* We're pushing it back because it has to stay in there until
|
break;
|
||||||
* the task is really paused (and the queue will then be flushed)
|
case DTMF_EVENT_TYPE_STOP:
|
||||||
*/
|
gst_dtmf_src_set_stream_lock (dtmfsrc, FALSE);
|
||||||
GST_DEBUG_OBJECT (dtmfsrc, "pushing pause_task...");
|
|
||||||
if (dtmfsrc->paused) {
|
g_free (dtmfsrc->last_event);
|
||||||
g_async_queue_push (dtmfsrc->event_queue, event);
|
dtmfsrc->last_event = NULL;
|
||||||
goto paused;
|
break;
|
||||||
}
|
case DTMF_EVENT_TYPE_PAUSE_TASK:
|
||||||
|
/*
|
||||||
|
* We're pushing it back because it has to stay in there until
|
||||||
|
* the task is really paused (and the queue will then be flushed)
|
||||||
|
*/
|
||||||
|
GST_DEBUG_OBJECT (dtmfsrc, "pushing pause_task...");
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (dtmfsrc);
|
||||||
|
if (dtmfsrc->paused) {
|
||||||
|
g_async_queue_push (dtmfsrc->event_queue, event);
|
||||||
|
goto paused_locked;
|
||||||
|
}
|
||||||
|
GST_OBJECT_UNLOCK (dtmfsrc);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -730,6 +741,9 @@ gst_dtmf_src_create (GstBaseSrc * basesrc, guint64 offset,
|
|||||||
GST_DEBUG_OBJECT (dtmfsrc, "returning a buffer");
|
GST_DEBUG_OBJECT (dtmfsrc, "returning a buffer");
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
|
paused_locked:
|
||||||
|
GST_OBJECT_UNLOCK (dtmfsrc);
|
||||||
|
|
||||||
paused:
|
paused:
|
||||||
|
|
||||||
if (dtmfsrc->last_event) {
|
if (dtmfsrc->last_event) {
|
||||||
@ -811,12 +825,6 @@ gst_dtmf_src_change_state (GstElement * element, GstStateChange transition)
|
|||||||
goto failure;
|
goto failure;
|
||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dtmfsrc, "PLAYING TO PAUSED");
|
|
||||||
|
|
||||||
no_preroll = TRUE;
|
|
||||||
break;
|
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||||
GST_DEBUG_OBJECT (dtmfsrc, "Flushing event queue");
|
GST_DEBUG_OBJECT (dtmfsrc, "Flushing event queue");
|
||||||
/* Flushing the event queue */
|
/* Flushing the event queue */
|
||||||
@ -827,8 +835,6 @@ gst_dtmf_src_change_state (GstElement * element, GstStateChange transition)
|
|||||||
event = g_async_queue_try_pop (dtmfsrc->event_queue);
|
event = g_async_queue_try_pop (dtmfsrc->event_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Indicate that we don't do PRE_ROLL */
|
|
||||||
no_preroll = TRUE;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user