]> git.sesse.net Git - mlt/blobdiff - src/modules/rtaudio/consumer_rtaudio.cpp
Merge branch 'master' of github.com:mltframework/mlt
[mlt] / src / modules / rtaudio / consumer_rtaudio.cpp
index de786450d98d1a1ed75d66c2080c6ca3700dd194..01f5955407bd4573fabedf26b8d797e1b4e02d1a 100644 (file)
@@ -88,13 +88,10 @@ public:
                        return false;
                }
 
-               if ( !arg || !strcmp( arg, "" ) )
-               {
 #ifndef __LINUX_ALSA__
-                       device_id = rt.getDefaultOutputDevice();
+               device_id = rt.getDefaultOutputDevice();
 #endif
-               }
-               else if ( strcmp( arg, "default" ) )
+               if ( arg && strcmp( arg, "" ) && strcmp( arg, "default" ) )
                {
                        // Get device ID by name
                        unsigned int n = rt.getDeviceCount();
@@ -112,7 +109,7 @@ public:
                                        break;
                                }
                        }
-                       // Name selection failed, treat arg as numeric
+                       // Name selection failed, try arg as numeric
                        if ( i == n )
                                device_id = (int) strtol( arg, NULL, 0 );
                }
@@ -142,6 +139,9 @@ public:
                // Default audio buffer
                mlt_properties_set_int( properties, "audio_buffer", 1024 );
 
+               // Set the resource to the device name arg
+               mlt_properties_set( properties, "resource", arg );
+
                // Ensure we don't join on a non-running object
                joined = 1;
 
@@ -409,14 +409,15 @@ public:
                        parameters.nChannels = channels;
                        parameters.firstChannel = 0;
                        RtAudio::StreamOptions options;
-#ifdef __LINUX_ALSA__
+                       unsigned int bufferFrames = mlt_properties_get_int( properties, "audio_buffer" );
+
                        if ( device_id == -1 )
                        {
                                options.flags = RTAUDIO_ALSA_USE_DEFAULT;
                                parameters.deviceId = 0;
                        }
-#endif
-                       unsigned int bufferFrames = mlt_properties_get_int( properties, "audio_buffer" );
+                       if ( mlt_properties_get( properties, "resource" ) )
+                               parameters.deviceName = mlt_properties_get( properties, "resource" );
 
                        try {
                                rt.openStream( &parameters, NULL, RTAUDIO_SINT16,
@@ -639,7 +640,7 @@ mlt_consumer consumer_rtaudio_init( mlt_profile profile, mlt_service_type type,
        if ( rtaudio && !mlt_consumer_init( rtaudio->getConsumer(), rtaudio, profile ) )
        {
                // If initialises without error
-               if ( rtaudio->open( arg ) )
+               if ( rtaudio->open( arg? arg : getenv( "AUDIODEV" ) ) )
                {
                        // Setup callbacks
                        consumer = rtaudio->getConsumer();