X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_deque.c;h=6deecffaf261fedd0b492d4d8f58dab469055f25;hb=affb93ab169aadfa61a659982327e6d069e377ae;hp=d5ec8d807b179a2a7deaece42290b94d37276c70;hpb=1b9e19bba9f837a56cc70072c21342028a3b96bb;p=melted diff --git a/src/framework/mlt_deque.c b/src/framework/mlt_deque.c index d5ec8d8..6deecff 100644 --- a/src/framework/mlt_deque.c +++ b/src/framework/mlt_deque.c @@ -29,6 +29,7 @@ typedef union { void *addr; int value; + double floating; } deque_entry; @@ -216,6 +217,75 @@ int mlt_deque_peek_front_int( mlt_deque this ) return this->count > 0 ? this->list[ 0 ].value : 0; } +/** Push an item to the end. +*/ + +int mlt_deque_push_back_double( mlt_deque this, double item ) +{ + int error = mlt_deque_allocate( this ); + + if ( error == 0 ) + this->list[ this->count ++ ].floating = item; + + return error; +} + +/** Pop an item. +*/ + +double mlt_deque_pop_back_double( mlt_deque this ) +{ + return this->count > 0 ? this->list[ -- this->count ].floating : 0; +} + +/** Queue an item at the start. +*/ + +int mlt_deque_push_front_double( mlt_deque this, double item ) +{ + int error = mlt_deque_allocate( this ); + + if ( error == 0 ) + { + memmove( &this->list[ 1 ], this->list, ( this->count ++ ) * sizeof( deque_entry ) ); + this->list[ 0 ].floating = item; + } + + return error; +} + +/** Remove an item from the start. +*/ + +double mlt_deque_pop_front_double( mlt_deque this ) +{ + double item = 0; + + if ( this->count > 0 ) + { + item = this->list[ 0 ].floating; + memmove( this->list, &this->list[ 1 ], ( -- this->count ) * sizeof( deque_entry ) ); + } + + return item; +} + +/** Inquire on item at back of deque but don't remove. +*/ + +double mlt_deque_peek_back_double( mlt_deque this ) +{ + return this->count > 0 ? this->list[ this->count - 1 ].floating : 0; +} + +/** Inquire on item at front of deque but don't remove. +*/ + +double mlt_deque_peek_front_double( mlt_deque this ) +{ + return this->count > 0 ? this->list[ 0 ].floating : 0; +} + /** Close the queue. */