Index: roarclients/roarmon.c
===================================================================
--- roarclients/roarmon.c	(revision 5381)
+++ roarclients/roarmon.c	(revision 5533)
@@ -37,5 +37,6 @@
         "  --bits  -B BITS      - Set bits per sample\n"
         "  --chans -C CHANNELS  - Set number of channels\n"
-        "  --codec    CODEC     - Set the codec\n"
+        "  --codec -E CODEC     - Set the codec\n"
+        "  --aiprofile PROFILE  - Set audio profile\n"
         "  --record             - Run in record mode (Wave Audio only)\n"
         "  --wave               - Output Wave Audio (PCM)\n"
@@ -54,8 +55,9 @@
 
 int main (int argc, char * argv[]) {
- int    rate     = -1;
- int    bits     = -1;
- int    channels = -1;
- int    codec    = -1;
+ struct roar_audio_info info = {
+  .rate = ROAR_AUDIO_INFO_INVALID,
+  .bits = ROAR_AUDIO_INFO_INVALID,
+  .channels = ROAR_AUDIO_INFO_INVALID,
+  .codec = ROAR_AUDIO_INFO_INVALID};
  int    dir      = ROAR_DIR_MONITOR;
  int    rel_id   = -1;
@@ -84,16 +86,22 @@
    server = argv[++i];
   } else if ( !strcmp(k, "--rate") || !strcmp(k, "-r") || !strcmp(k, "-R") ) {
-   rate = roar_str2rate(argv[++i]);
+   info.rate = roar_str2rate(argv[++i]);
   } else if ( !strcmp(k, "--bits") || !strcmp(k, "-B") ) {
-   bits = roar_str2bits(argv[++i]);
+   info.bits = roar_str2bits(argv[++i]);
   } else if ( !strcmp(k, "-b") ) {
-   bits = 8;
+   info.bits = 8;
   } else if ( !strcmp(k, "--channels") || !strcmp(k, "--chans") || !strcmp(k, "-C") ) {
-   channels = roar_str2channels(argv[++i]);
+   info.channels = roar_str2channels(argv[++i]);
   } else if ( !strcmp(k, "-m") ) {
-   channels = 1;
-  } else if ( !strcmp(k, "--codec") ) {
-   if ( (codec = roar_str2codec(argv[++i])) == -1 ) {
+   info.channels = 1;
+  } else if ( !strcmp(k, "--codec") || !strcmp(k, "-E") ) {
+   if ( (info.codec = roar_str2codec(argv[++i])) == ROAR_AUDIO_INFO_INVALID ) {
     fprintf(stderr, "Error: Unknown codec: %s\n", argv[i]);
+    return 1;
+   }
+
+  } else if ( !strcmp(k, "--aiprofile") ) {
+   if ( roar_profile2info(&info, argv[++i]) == -1 ) {
+    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error));
     return 1;
    }
@@ -140,40 +148,40 @@
   case ROAR_DIR_MONITOR:
   case ROAR_DIR_RECORD:
-    if ( rate     == -1 ) rate     = ROAR_RATE_DEFAULT;
-    if ( bits     == -1 ) bits     = ROAR_BITS_DEFAULT;
-    if ( channels == -1 ) channels = ROAR_CHANNELS_DEFAULT;
-    if ( codec    == -1 ) codec    = ROAR_CODEC_DEFAULT;
+    if ( info.rate      == ROAR_AUDIO_INFO_INVALID ) info.rate     = ROAR_RATE_DEFAULT;
+    if ( info.bits      == ROAR_AUDIO_INFO_INVALID ) info.bits     = ROAR_BITS_DEFAULT;
+    if ( info.channels  == ROAR_AUDIO_INFO_INVALID ) info.channels = ROAR_CHANNELS_DEFAULT;
+    if ( info.codec     == ROAR_AUDIO_INFO_INVALID ) info.codec    = ROAR_CODEC_DEFAULT;
    break;
   case ROAR_DIR_MIDI_OUT:
-    if ( rate     == -1 ) rate     = 0;
-    if ( bits     == -1 ) bits     = ROAR_MIDI_BITS;
-    if ( channels == -1 ) channels = ROAR_MIDI_CHANNELS_DEFAULT;
-    if ( codec    == -1 ) codec    = ROAR_CODEC_MIDI;
+    if ( info.rate      == ROAR_AUDIO_INFO_INVALID ) info.rate     = 0;
+    if ( info.bits      == ROAR_AUDIO_INFO_INVALID ) info.bits     = ROAR_MIDI_BITS;
+    if ( info.channels  == ROAR_AUDIO_INFO_INVALID ) info.channels = ROAR_MIDI_CHANNELS_DEFAULT;
+    if ( info.codec     == ROAR_AUDIO_INFO_INVALID ) info.codec    = ROAR_CODEC_MIDI;
    break;
   case ROAR_DIR_LIGHT_OUT:
-    if ( rate     == -1 ) rate     = 0;
-    if ( bits     == -1 ) bits     = ROAR_LIGHT_BITS;
-    if ( channels == -1 ) channels = 0;
-    if ( codec    == -1 ) codec    = ROAR_CODEC_DMX512;
+    if ( info.rate      == ROAR_AUDIO_INFO_INVALID ) info.rate     = 0;
+    if ( info.bits      == ROAR_AUDIO_INFO_INVALID ) info.bits     = ROAR_LIGHT_BITS;
+    if ( info.channels  == ROAR_AUDIO_INFO_INVALID ) info.channels = 0;
+    if ( info.codec     == ROAR_AUDIO_INFO_INVALID ) info.codec    = ROAR_CODEC_DMX512;
    break;
   case ROAR_DIR_COMPLEX_OUT:
-    if ( rate     == -1 ) rate     = ROAR_COMPLEX_RATE;
-    if ( bits     == -1 ) bits     = ROAR_COMPLEX_BITS;
-    if ( channels == -1 ) channels = ROAR_COMPLEX_CHANNELS;
-    if ( codec    == -1 ) codec    = ROAR_COMPLEX_CODEC;
+    if ( info.rate      == ROAR_AUDIO_INFO_INVALID ) info.rate     = ROAR_COMPLEX_RATE;
+    if ( info.bits      == ROAR_AUDIO_INFO_INVALID ) info.bits     = ROAR_COMPLEX_BITS;
+    if ( info.channels  == ROAR_AUDIO_INFO_INVALID ) info.channels = ROAR_COMPLEX_CHANNELS;
+    if ( info.codec     == ROAR_AUDIO_INFO_INVALID ) info.codec    = ROAR_COMPLEX_CODEC;
    break;
   case ROAR_DIR_RDTCS_OUT:
-    if ( rate     == -1 ) rate     = ROAR_RDTCS_RATE;
-    if ( bits     == -1 ) bits     = ROAR_RDTCS_BITS;
-    if ( channels == -1 ) channels = ROAR_RDTCS_CHANNELS;
-    if ( codec    == -1 ) codec    = ROAR_RDTCS_CODEC;
+    if ( info.rate      == ROAR_AUDIO_INFO_INVALID ) info.rate     = ROAR_RDTCS_RATE;
+    if ( info.bits      == ROAR_AUDIO_INFO_INVALID ) info.bits     = ROAR_RDTCS_BITS;
+    if ( info.channels  == ROAR_AUDIO_INFO_INVALID ) info.channels = ROAR_RDTCS_CHANNELS;
+    if ( info.codec     == ROAR_AUDIO_INFO_INVALID ) info.codec    = ROAR_RDTCS_CODEC;
    break;
   case ROAR_DIR_RAW_OUT:
   case ROAR_DIR_THRU:
   default:
-    if ( rate     == -1 ) rate     = 0;
-    if ( bits     == -1 ) bits     = 0;
-    if ( channels == -1 ) channels = 0;
-    if ( codec    == -1 ) codec    = ROAR_CODEC_DEFAULT;
+    if ( info.rate      == ROAR_AUDIO_INFO_INVALID ) info.rate     = 0;
+    if ( info.bits      == ROAR_AUDIO_INFO_INVALID ) info.bits     = 0;
+    if ( info.channels  == ROAR_AUDIO_INFO_INVALID ) info.channels = 0;
+    if ( info.codec     == ROAR_AUDIO_INFO_INVALID ) info.codec    = ROAR_CODEC_DEFAULT;
    break;
  }
@@ -184,5 +192,5 @@
  }
 
- if ( roar_stream_new(&s, rate, channels, bits, codec) == -1 ) {
+ if ( roar_stream_new(&s, info.rate, info.channels, info.bits, info.codec) == -1 ) {
   fprintf(stderr, "Error: can not create stream\n");
   roar_disconnect(&con);
