X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fvorbis%2Fproducer_vorbis.c;h=e7dd3669327b3c432a3c94ace9611088110f80d8;hb=5ca02525045c7b3f6bb3ac33a903a1c88f8a2ea4;hp=3557cb4feeb6f0e24b03b32094a5780a61ea562c;hpb=94dce1aea965163f8dcd2f97271f2652abb0e62d;p=melted diff --git a/src/modules/vorbis/producer_vorbis.c b/src/modules/vorbis/producer_vorbis.c index 3557cb4..e7dd366 100644 --- a/src/modules/vorbis/producer_vorbis.c +++ b/src/modules/vorbis/producer_vorbis.c @@ -53,7 +53,7 @@ mlt_producer producer_vorbis_init( char *file ) if ( mlt_producer_init( this, NULL ) == 0 ) { // Get the properties - mlt_properties properties = mlt_producer_properties( this ); + mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); // Set the resource property (required for all producers) mlt_properties_set( properties, "resource", file ); @@ -113,7 +113,7 @@ static int producer_open( mlt_producer this, char *file ) if ( error == 0 ) { // Get the properties - mlt_properties properties = mlt_producer_properties( this ); + mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); // Assign the ov structure mlt_properties_set_data( properties, "ogg_vorbis_file", ov, 0, producer_file_close, NULL ); @@ -150,7 +150,7 @@ static int producer_open( mlt_producer this, char *file ) static double producer_time_of_frame( mlt_producer this, mlt_position position ) { // Get the properties - mlt_properties properties = mlt_producer_properties( this ); + mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); // Obtain the fps double fps = mlt_properties_get_double( properties, "fps" ); @@ -165,16 +165,16 @@ static double producer_time_of_frame( mlt_producer this, mlt_position position ) static int producer_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples ) { // Get the properties from the frame - mlt_properties frame_properties = mlt_frame_properties( frame ); + mlt_properties frame_properties = MLT_FRAME_PROPERTIES( frame ); // Obtain the frame number of this frame mlt_position position = mlt_properties_get_position( frame_properties, "vorbis_position" ); // Get the producer - mlt_producer this = mlt_properties_get_data( frame_properties, "vorbis_producer", NULL ); + mlt_producer this = mlt_frame_pop_audio( frame ); // Get the producer properties - mlt_properties properties = mlt_producer_properties( this ); + mlt_properties properties = MLT_PRODUCER_PROPERTIES( this ); // Get the ogg vorbis file OggVorbis_File *ov = mlt_properties_get_data( properties, "ogg_vorbis_file", NULL ); @@ -203,15 +203,11 @@ static int producer_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_form // Check for audio buffer and create if necessary if ( audio_buffer == NULL ) { - // Release pointer - void *release = NULL; - // Allocate the audio buffer - audio_buffer = mlt_pool_allocate( 131072 * sizeof( int16_t ), &release ); + audio_buffer = mlt_pool_alloc( 131072 * sizeof( int16_t ) ); // And store it on properties for reuse - mlt_properties_set_data( properties, "audio_buffer_release", release, 0, ( mlt_destructor )mlt_pool_release, NULL ); - mlt_properties_set_data( properties, "audio_buffer", audio_buffer, 0, NULL, NULL ); + mlt_properties_set_data( properties, "audio_buffer", audio_buffer, 0, mlt_pool_release, NULL ); } // Seek if necessary @@ -274,17 +270,14 @@ static int producer_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_form // Now handle the audio if we have enough if ( audio_used >= *samples ) { - void *release = NULL; - *buffer = mlt_pool_allocate( *samples * *channels * sizeof( int16_t ), &release ); + *buffer = mlt_pool_alloc( *samples * *channels * sizeof( int16_t ) ); memcpy( *buffer, audio_buffer, *samples * *channels * sizeof( int16_t ) ); audio_used -= *samples; memmove( audio_buffer, &audio_buffer[ *samples * *channels ], audio_used * *channels * sizeof( int16_t ) ); - mlt_properties_set_data( frame_properties, "audio_release", release, 0, ( mlt_destructor )mlt_pool_release, NULL ); - mlt_properties_set_data( frame_properties, "audio", *buffer, 0, NULL, NULL ); + mlt_properties_set_data( frame_properties, "audio", *buffer, 0, mlt_pool_release, NULL ); } else { - frame->get_audio = NULL; mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples ); audio_used = 0; } @@ -295,7 +288,6 @@ static int producer_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_form else { // Get silence and don't touch the context - frame->get_audio = NULL; *samples = mlt_sample_calculator( fps, *frequency, position ); mlt_frame_get_audio( frame, buffer, format, frequency, channels, samples ); } @@ -306,21 +298,6 @@ static int producer_get_audio( mlt_frame frame, int16_t **buffer, mlt_audio_form return 0; } -/** Set up audio handling. -*/ - -static void producer_set_up_audio( mlt_producer this, mlt_frame frame ) -{ - // Get the properties - mlt_properties properties = mlt_frame_properties( frame ); - - // Set the audio method - frame->get_audio = producer_get_audio; - - // Set the producer on the frame - mlt_properties_set_data( properties, "vorbis_producer", this, 0, NULL, NULL ); -} - /** Our get frame implementation. */ @@ -333,10 +310,11 @@ static int producer_get_frame( mlt_producer this, mlt_frame_ptr frame, int index mlt_frame_set_position( *frame, mlt_producer_position( this ) ); // Set the position of this producer - mlt_properties_set_position( mlt_frame_properties( *frame ), "vorbis_position", mlt_producer_get_in( this ) + mlt_producer_position( this ) ); + mlt_properties_set_position( MLT_FRAME_PROPERTIES( *frame ), "vorbis_position", mlt_producer_frame( this ) ); // Set up the audio - producer_set_up_audio( this, *frame ); + mlt_frame_push_audio( *frame, this ); + mlt_frame_push_audio( *frame, producer_get_audio ); // Calculate the next timecode mlt_producer_prepare_next( this );