Changeset 3942:a160d7f5f19e in roaraudio
- Timestamp:
- 06/23/10 23:31:13 (14 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/stream.h
r3822 r3942 162 162 ssize_t roar_info2bitspersec (struct roar_audio_info * info); 163 163 164 int roar_profile2info (struct roar_audio_info * info, const char * profile); 165 ssize_t roar_profiles_list (const char ** list, size_t len, size_t offset); 166 164 167 #endif 165 168 -
libroar/stream.c
r3875 r3942 1011 1011 } 1012 1012 1013 static struct { 1014 const char * name; 1015 struct roar_audio_info info; 1016 } _libroar_aiprofiles[] = { 1017 {"default", {.rate = ROAR_RATE_DEFAULT, 1018 .bits = ROAR_BITS_DEFAULT, 1019 .channels = ROAR_CHANNELS_DEFAULT, 1020 .codec = ROAR_CODEC_DEFAULT}}, 1021 {"cd", {.rate = 44100, .bits = 16, .channels = 2, .codec = ROAR_CODEC_DEFAULT}}, 1022 {"cdr", {.rate = 44100, .bits = 16, .channels = 2, .codec = ROAR_CODEC_PCM_S_BE}}, 1023 {"dat", {.rate = 48000, .bits = 16, .channels = 2, .codec = ROAR_CODEC_PCM_S_LE}}, 1024 {"isdn-eu", {.rate = 8000, .bits = 8, .channels = 1, .codec = ROAR_CODEC_ALAW}}, 1025 {NULL, {.rate = 0, .bits = 0, .channels = 0, .codec = 0}} 1026 }; 1027 1028 int roar_profile2info (struct roar_audio_info * info, const char * profile) { 1029 int i; 1030 1031 for (i = 0; _libroar_aiprofiles[i].name != NULL; i++) { 1032 if ( !strcasecmp(_libroar_aiprofiles[i].name, profile) ) { 1033 memcpy(info, &(_libroar_aiprofiles[i].info), sizeof(struct roar_audio_info)); 1034 return 0; 1035 } 1036 } 1037 1038 return -1; 1039 } 1040 1041 ssize_t roar_profiles_list (const char ** list, size_t len, size_t offset) { 1042 size_t i; 1043 int idx = 0; 1044 1045 if ( list == NULL ) 1046 return -1; 1047 1048 if ( len == 0 ) 1049 return 0; 1050 1051 if ( offset >= (sizeof(_libroar_aiprofiles)/sizeof(*_libroar_aiprofiles)) ) 1052 return 0; 1053 1054 for (i = offset; _libroar_aiprofiles[i].name != NULL; i++) { 1055 list[idx++] = _libroar_aiprofiles[i].name; 1056 } 1057 1058 return idx; 1059 } 1060 1013 1061 //ll -
roarclients/roarctl.c
r3875 r3942 875 875 } 876 876 877 int show_aiprofile (const char * profile) { 878 struct roar_audio_info info; 879 880 if ( roar_profile2info(&info, profile) == -1 ) { 881 fprintf(stderr, "Error: unknown profile: %s\n", profile); 882 return -1; 883 } 884 885 printf("Profile Name : %s\n", profile); 886 printf("Profile sample rate : %i\n", info.rate); 887 printf("Profile bits : %i\n", info.bits); 888 printf("Profile channels : %i\n", info.channels); 889 printf("Profile codec : %2i (%s%s)\n", info.codec, roar_codec2str(info.codec), 890 info.codec == ROAR_CODEC_DEFAULT ? " native" : ""); 891 892 return 0; 893 } 894 895 int list_aiprofiles (void) { 896 const char * list[1024]; 897 ssize_t ret; 898 ssize_t i; 899 900 ret = roar_profiles_list(list, 1024, 0); 901 902 if ( ret == -1 ) { 903 fprintf(stderr, "Error: can not read list of profiles\n"); 904 return -1; 905 } 906 907 for (i = 0; i < ret; i++) { 908 printf("profile %lli:\n", (long long signed int)i); 909 show_aiprofile(list[i]); 910 } 911 912 return 0; 913 } 914 877 915 int main (int argc, char * argv[]) { 878 916 struct roar_connection con; … … 1073 1111 i++; 1074 1112 1113 1114 } else if ( !strcmp(k, "listprofiles") ) { 1115 if ( list_aiprofiles() == -1 ) { 1116 fprintf(stderr, "Error: can not list profiles\n"); 1117 } 1118 } else if ( !strcmp(k, "profileget") ) { 1119 i++; 1120 if ( show_aiprofile(argv[i]) == -1 ) { 1121 fprintf(stderr, "Error: can not get profile data\n"); 1122 } 1075 1123 } else { 1076 1124 fprintf(stderr, "Error: invalid command: %s\n", k);
Note: See TracChangeset
for help on using the changeset viewer.