]> git.sesse.net Git - mlt/commitdiff
add support for audio scrubbing to audio-only consumers
authorDan Dennedy <dan@dennedy.org>
Sat, 23 Jun 2012 20:50:30 +0000 (13:50 -0700)
committerDan Dennedy <dan@dennedy.org>
Sat, 23 Jun 2012 20:50:30 +0000 (13:50 -0700)
src/modules/jackrack/consumer_jack.c
src/modules/jackrack/consumer_jack.yml
src/modules/rtaudio/consumer_rtaudio.cpp
src/modules/rtaudio/consumer_rtaudio.yml
src/modules/sdl/consumer_sdl_audio.c
src/modules/sdl/consumer_sdl_audio.yml

index ce18604e88ac703164e9b54e56d12a6cf2e83613..a9e363003561963103c41431a06bf5e0b428ed2d 100644 (file)
@@ -240,6 +240,8 @@ static int jack_process( jack_nframes_t frames, void * data )
                char *dest = jack_port_get_buffer( self->ports[i], frames );
 
                jack_ringbuffer_read( self->ringbuffers[i], dest, ring_size < jack_size ? ring_size : jack_size );
+               if ( ring_size < jack_size )
+                       memset( dest + ring_size, 0, jack_size - ring_size );
        }
 
        return error;
@@ -303,8 +305,10 @@ static int consumer_play_audio( consumer_jack self, mlt_frame frame, int init_au
        mlt_audio_format afmt = mlt_audio_float;
 
        // Set the preferred params of the test card signal
+       double speed = mlt_properties_get_double( MLT_FRAME_PROPERTIES(frame), "_speed" );
        int channels = mlt_properties_get_int( properties, "channels" );
        int frequency = mlt_properties_get_int( properties, "frequency" );
+       int scrub = mlt_properties_get_int( properties, "scrub_audio" );
        int samples = mlt_sample_calculator( mlt_properties_get_double( properties, "fps" ), frequency, self->counter++ );
        float *buffer;
 
@@ -324,12 +328,15 @@ static int consumer_play_audio( consumer_jack self, mlt_frame frame, int init_au
                init_audio = 0;
        }
 
-       if ( init_audio == 0 )
+       if ( init_audio == 0 && ( speed == 1.0 || speed == 0.0 ) )
        {
                int i;
                size_t mlt_size = samples * sizeof(float);
                float volume = mlt_properties_get_double( properties, "volume" );
 
+               if ( !scrub && speed == 0.0 )
+                       volume = 0.0;
+
                if ( volume != 1.0 )
                {
                        float *p = buffer;
index abef3aea569422f2bd757ddc95f6464f20a65650..1d9e48ee91847b8459c7793d69daa0e5657ad4ef 100644 (file)
@@ -15,20 +15,44 @@ parameters:
     type: integer
     minimum: 1
     default: 2
+
   - identifier: out_1
     title: Send L
     type: string
+
   - identifier: out_2
     title: Send R
     type: string
+
   - identifier: volume
     title: Volume
     type: float
     minimum: 0.0
     default: 1.0
+
   - identifier: refresh
     description: >
       Applications should set this to update the video frame when paused.
     type: integer
     minimum: 0
     maximum: 1
+
+  - identifier: audio_off
+    title: Audio off
+    type: integer
+    description: If 1, disable audio output
+    mutable: yes
+    minimum: 0
+    maximum: 1
+    default: 0
+    widget: checkbox
+
+  - identifier: scrub_audio
+    title: Audio scrubbing
+    type: integer
+    description: If enabled, sound is played even when the speed is not normal.
+    mutable: yes
+    minimum: 0
+    maximum: 1
+    default: 0
+    widget: checkbox
index 01f5955407bd4573fabedf26b8d797e1b4e02d1a..8c002125f6a313bcc2e6319e079d7b91417b4b8b 100644 (file)
@@ -389,6 +389,7 @@ public:
                // Set the preferred params of the test card signal
                int channels = mlt_properties_get_int( properties, "channels" );
                int frequency = mlt_properties_get_int( properties, "frequency" );
+               int scrub = mlt_properties_get_int( properties, "scrub_audio" );
                static int counter = 0;
                int samples = mlt_sample_calculator( mlt_properties_get_double( properties, "fps" ), frequency, counter++ );
                int16_t *pcm;
@@ -441,7 +442,7 @@ public:
                                pthread_cond_wait( &audio_cond, &audio_mutex );
                        if ( running )
                        {
-                               if ( mlt_properties_get_double( properties, "_speed" ) == 1 )
+                               if ( scrub || mlt_properties_get_double( properties, "_speed" ) == 1 )
                                        memcpy( &audio_buffer[ audio_avail ], pcm, bytes );
                                else
                                        memset( &audio_buffer[ audio_avail ], 0, bytes );
index 80ded0e1356ce8b5710c6468275c32bf7c71442b..c2b8cb21fcdf542c0c0cb1ad9b80b1feb3a6df4c 100644 (file)
@@ -42,3 +42,13 @@ parameters:
     type: integer
     minimum: 0
     maximum: 1
+
+  - identifier: scrub_audio
+    title: Audio scrubbing
+    type: integer
+    description: If enabled, sound is played even when the speed is not normal.
+    mutable: yes
+    minimum: 0
+    maximum: 1
+    default: 0
+    widget: checkbox
index 59b651bd6338c39d1e46e536ac20e77b15697b5a..266580e3d7ee1f3b493b301f5a6ba6c704b34eb2 100644 (file)
@@ -276,6 +276,7 @@ static int consumer_play_audio( consumer_sdl self, mlt_frame frame, int init_aud
        // Set the preferred params of the test card signal
        int channels = mlt_properties_get_int( properties, "channels" );
        int frequency = mlt_properties_get_int( properties, "frequency" );
+       int scrub = mlt_properties_get_int( properties, "scrub_audio" );
        static int counter = 0;
 
        int samples = mlt_sample_calculator( mlt_properties_get_double( self->properties, "fps" ), frequency, counter++ );
@@ -330,7 +331,7 @@ static int consumer_play_audio( consumer_sdl self, mlt_frame frame, int init_aud
                        pthread_cond_wait( &self->audio_cond, &self->audio_mutex );
                if ( self->running )
                {
-                       if ( mlt_properties_get_double( properties, "_speed" ) == 1 )
+                       if ( scrub || mlt_properties_get_double( properties, "_speed" ) == 1 )
                                memcpy( &self->audio_buffer[ self->audio_avail ], pcm, bytes );
                        else
                                memset( &self->audio_buffer[ self->audio_avail ], 0, bytes );
index 2e1d802c816e967377b153c2e3eae34a84de6041..834261fcaab0b7b0ce9bbdd2b3f86899a0ae61ad 100644 (file)
@@ -9,3 +9,40 @@ license: LGPLv2.1
 language: en
 tags:
   - Audio
+description: >
+  Simple DirectMedia Layer audio only output module.
+
+parameters:
+  - identifier: volume
+    title: Volume
+    type: float
+    description: Audio level factor.
+    mutable: yes
+
+  - identifier: audio_off
+    title: Audio off
+    type: integer
+    description: If 1, disable audio output
+    mutable: yes
+    minimum: 0
+    maximum: 1
+    default: 0
+    widget: checkbox
+
+  - identifier: audio_buffer
+    title: Audio buffer
+    type: integer
+    description: Size of the sdl audio buffer.
+    mutable: yes
+    default: 2048
+    minimum: 128
+
+  - identifier: scrub_audio
+    title: Audio scrubbing
+    type: integer
+    description: If enabled, sound is played even when the speed is not normal.
+    mutable: yes
+    minimum: 0
+    maximum: 1
+    default: 0
+    widget: checkbox