if ( oChannels > 0 ) {\r
\r
result = probeDeviceOpen( oParams->deviceId, OUTPUT, oChannels, oParams->firstChannel,\r
- sampleRate, format, bufferFrames, options );\r
+ sampleRate, format, bufferFrames, options, oParams->deviceName );\r
if ( result == false ) error( RtError::SYSTEM_ERROR );\r
}\r
\r
if ( iChannels > 0 ) {\r
\r
result = probeDeviceOpen( iParams->deviceId, INPUT, iChannels, iParams->firstChannel,\r
- sampleRate, format, bufferFrames, options );\r
+ sampleRate, format, bufferFrames, options, iParams->deviceName );\r
if ( result == false ) {\r
if ( oChannels > 0 ) closeStream();\r
error( RtError::SYSTEM_ERROR );\r
bool RtApi :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,\r
unsigned int firstChannel, unsigned int sampleRate,\r
RtAudioFormat format, unsigned int *bufferSize,\r
- RtAudio::StreamOptions *options )\r
+ RtAudio::StreamOptions *options, const std::string &deviceName )\r
{\r
// MUST be implemented in subclasses!\r
return FAILURE;\r
bool RtApiCore :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,\r
unsigned int firstChannel, unsigned int sampleRate,\r
RtAudioFormat format, unsigned int *bufferSize,\r
- RtAudio::StreamOptions *options )\r
+ RtAudio::StreamOptions *options, const std::string &deviceName )\r
{\r
// Get device ID\r
unsigned int nDevices = getDeviceCount();\r
bool RtApiJack :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,\r
unsigned int firstChannel, unsigned int sampleRate,\r
RtAudioFormat format, unsigned int *bufferSize,\r
- RtAudio::StreamOptions *options )\r
+ RtAudio::StreamOptions *options, const std::string &aDeviceName )\r
{\r
JackHandle *handle = (JackHandle *) stream_.apiHandle;\r
\r
client = handle->client;\r
}\r
\r
+ std::string deviceName = aDeviceName;\r
const char **ports;\r
- std::string port, previousPort, deviceName;\r
- unsigned int nPorts = 0, nDevices = 0;\r
- ports = jack_get_ports( client, NULL, NULL, 0 );\r
- if ( ports ) {\r
- // Parse the port names up to the first colon (:).\r
- size_t iColon = 0;\r
- do {\r
- port = (char *) ports[ nPorts ];\r
- iColon = port.find(":");\r
- if ( iColon != std::string::npos ) {\r
- port = port.substr( 0, iColon );\r
- if ( port != previousPort ) {\r
- if ( nDevices == device ) deviceName = port;\r
- nDevices++;\r
- previousPort = port;\r
- }\r
+ if ( deviceName.size() == 0 ) {\r
+ std::string port, previousPort, deviceName;\r
+ unsigned int nPorts = 0, nDevices = 0;\r
+ ports = jack_get_ports( client, NULL, NULL, 0 );\r
+ if ( ports ) {\r
+ // Parse the port names up to the first colon (:).\r
+ size_t iColon = 0;\r
+ do {\r
+ port = (char *) ports[ nPorts ];\r
+ iColon = port.find(":");\r
+ if ( iColon != std::string::npos ) {\r
+ port = port.substr( 0, iColon );\r
+ if ( port != previousPort ) {\r
+ if ( nDevices == device ) deviceName = port;\r
+ nDevices++;\r
+ previousPort = port;\r
+ }\r
+ }\r
+ } while ( ports[++nPorts] );\r
+ free( ports );\r
+ }\r
+ if ( device >= nDevices ) {\r
+ errorText_ = "RtApiJack::probeDeviceOpen: device ID is invalid!";\r
+ return FAILURE;\r
}\r
- } while ( ports[++nPorts] );\r
- free( ports );\r
- }\r
-\r
- if ( device >= nDevices ) {\r
- errorText_ = "RtApiJack::probeDeviceOpen: device ID is invalid!";\r
- return FAILURE;\r
}\r
\r
// Count the available ports containing the client name as device\r
bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,\r
unsigned int firstChannel, unsigned int sampleRate,\r
RtAudioFormat format, unsigned int *bufferSize,\r
- RtAudio::StreamOptions *options )\r
+ RtAudio::StreamOptions *options, const std::string &deviceName )\r
{\r
// For ASIO, a duplex stream MUST use the same driver.\r
if ( mode == INPUT && stream_.mode == OUTPUT && stream_.device[0] != device ) {\r
bool RtApiDs :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,\r
unsigned int firstChannel, unsigned int sampleRate,\r
RtAudioFormat format, unsigned int *bufferSize,\r
- RtAudio::StreamOptions *options )\r
+ RtAudio::StreamOptions *options, const std::string &deviceName )\r
{\r
if ( channels + firstChannel > 2 ) {\r
errorText_ = "RtApiDs::probeDeviceOpen: DirectSound does not support more than 2 channels per device.";\r
bool RtApiAlsa :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,\r
unsigned int firstChannel, unsigned int sampleRate,\r
RtAudioFormat format, unsigned int *bufferSize,\r
- RtAudio::StreamOptions *options )\r
+ RtAudio::StreamOptions *options, const std::string &deviceName )\r
\r
{\r
#if defined(__RTAUDIO_DEBUG__)\r
\r
if ( options && options->flags & RTAUDIO_ALSA_USE_DEFAULT )\r
snprintf(name, sizeof(name), "%s", "default");\r
-// snprintf(name, sizeof(name), "%s", "dmix:0,0");\r
+ else if ( deviceName.size() > 0 )\r
+ snprintf(name, sizeof(name), "%s", deviceName.c_str());\r
else {\r
// Count cards and devices\r
card = -1;\r
bool RtApiOss :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,\r
unsigned int firstChannel, unsigned int sampleRate,\r
RtAudioFormat format, unsigned int *bufferSize,\r
- RtAudio::StreamOptions *options )\r
+ RtAudio::StreamOptions *options, const std::string &deviceName )\r
{\r
int mixerfd = open( "/dev/mixer", O_RDWR, 0 );\r
if ( mixerfd == -1 ) {\r
unsigned int deviceId; /*!< Device index (0 to getDeviceCount() - 1). */
unsigned int nChannels; /*!< Number of channels. */
unsigned int firstChannel; /*!< First channel index on device (default = 0). */
+ std::string deviceName; /*!< Device name to use instead of using deviceId (ALSA, JACK). */
// Default constructor.
StreamParameters()
virtual bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
unsigned int firstChannel, unsigned int sampleRate,
RtAudioFormat format, unsigned int *bufferSize,
- RtAudio::StreamOptions *options );
+ RtAudio::StreamOptions *options, const std::string &deviceName );
//! A protected function used to increment the stream time.
void tickStreamTime( void );
bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
unsigned int firstChannel, unsigned int sampleRate,
RtAudioFormat format, unsigned int *bufferSize,
- RtAudio::StreamOptions *options );
+ RtAudio::StreamOptions *options, const std::string &deviceName );
static const char* getErrorCode( OSStatus code );
};
bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
unsigned int firstChannel, unsigned int sampleRate,
RtAudioFormat format, unsigned int *bufferSize,
- RtAudio::StreamOptions *options );
+ RtAudio::StreamOptions *options, const std::string &deviceName );
};
#endif
bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
unsigned int firstChannel, unsigned int sampleRate,
RtAudioFormat format, unsigned int *bufferSize,
- RtAudio::StreamOptions *options );
+ RtAudio::StreamOptions *options, const std::string &deviceName );
};
#endif
bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
unsigned int firstChannel, unsigned int sampleRate,
RtAudioFormat format, unsigned int *bufferSize,
- RtAudio::StreamOptions *options );
+ RtAudio::StreamOptions *options, const std::string &deviceName );
};
#endif
bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
unsigned int firstChannel, unsigned int sampleRate,
RtAudioFormat format, unsigned int *bufferSize,
- RtAudio::StreamOptions *options );
+ RtAudio::StreamOptions *options, const std::string &deviceName );
};
#endif
bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
unsigned int firstChannel, unsigned int sampleRate,
RtAudioFormat format, unsigned int *bufferSize,
- RtAudio::StreamOptions *options );
+ RtAudio::StreamOptions *options, const std::string &deviceName );
};
#endif
bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
unsigned int firstChannel, unsigned int sampleRate,
RtAudioFormat format, unsigned int *bufferSize,
- RtAudio::StreamOptions *options ) { return false; };
+ RtAudio::StreamOptions *options, const std::string &deviceName )
+ { return false; };
};
#endif
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();
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 );
}
// 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;
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( ¶meters, NULL, RTAUDIO_SINT16,