// +----------------------------------------------------------+
// | Soundcard |
- // +----------------------------------------------------------+
-
- obj->card = 0;
- obj->device = 0;
-
- // +----------------------------------------------------------+
- // | Soundcard Name |
// +----------------------------------------------------------+
obj->deviceName = (char *) NULL;
// +----------------------------------------------------------+
// | Soundcard |
- // +----------------------------------------------------------+
-
- obj->card = 0;
- obj->device = 0;
-
- // +----------------------------------------------------------+
- // | Soundcard Name |
// +----------------------------------------------------------+
obj->deviceName = (char *) NULL;
// +----------------------------------------------------------+
// | Soundcard |
- // +----------------------------------------------------------+
-
- obj->card = 0;
- obj->device = 0;
-
- // +----------------------------------------------------------+
- // | Soundcard Name |
// +----------------------------------------------------------+
obj->deviceName = (char *) NULL;
// +----------------------------------------------------------+
// | Soundcard |
- // +----------------------------------------------------------+
-
- obj->card = 0;
- obj->device = 0;
-
- // +----------------------------------------------------------+
- // | Soundcard Name |
// +----------------------------------------------------------+
obj->deviceName = (char *) NULL;
interface_obj * interface_construct_soundcard(const unsigned int card, const unsigned int device) {
- interface_obj * obj;
+ char * deviceName = (char *) malloc(sizeof(char) * 1024);
- obj = (interface_obj *) malloc(sizeof(interface_obj));
+ sprintf(deviceName, "hw:%u,%u", card, device);
- // +----------------------------------------------------------+
- // | Type |
- // +----------------------------------------------------------+
-
- obj->type = interface_soundcard;
-
- // +----------------------------------------------------------+
- // | Blackhole |
- // +----------------------------------------------------------+
-
- // (Empty)
-
- // +----------------------------------------------------------+
- // | File |
- // +----------------------------------------------------------+
-
- obj->fileName = (char *) NULL;
-
- // +----------------------------------------------------------+
- // | Socket |
- // +----------------------------------------------------------+
-
- obj->ip = (char *) NULL;
- obj->port = 0;
-
- // +----------------------------------------------------------+
- // | Soundcard |
- // +----------------------------------------------------------+
-
- obj->card = card;
- obj->device = device;
-
- // +----------------------------------------------------------+
- // | Soundcard Name |
- // +----------------------------------------------------------+
-
- sprintf(obj->deviceName, "hw:%u,%u", card, device);
-
- // +----------------------------------------------------------+
- // | Terminal |
- // +----------------------------------------------------------+
-
- // (Empty)
-
- return obj;
+ return interface_construct_soundcard_by_name(deviceName);
}
- interface_obj * interface_construct_soundcard_name(char * deviceName) {
+ interface_obj * interface_construct_soundcard_by_name(char * deviceName) {
interface_obj * obj;
// | Type |
// +----------------------------------------------------------+
- obj->type = interface_soundcard_name;
+ obj->type = interface_soundcard;
// +----------------------------------------------------------+
// | Blackhole |
// | Soundcard |
// +----------------------------------------------------------+
- obj->card = 0;
- obj->device = 0;
-
- // +----------------------------------------------------------+
- // | Soundcard Name |
- // +----------------------------------------------------------+
-
obj->deviceName = deviceName;
// +----------------------------------------------------------+
// | Soundcard |
// +----------------------------------------------------------+
- obj->card = 0;
- obj->device = 0;
-
- // +----------------------------------------------------------+
- // | Soundcard Name |
- // +----------------------------------------------------------+
-
obj->deviceName = (char *) NULL;
// +----------------------------------------------------------+
// | Soundcard |
// +----------------------------------------------------------+
- if (obj->type == interface_soundcard) {
-
- clone->card = obj->card;
- clone->device = obj->device;
-
- }
-
- // +----------------------------------------------------------+
- // | Soundcard Name |
- // +----------------------------------------------------------+
-
- if (obj->type == interface_soundcard) {
- clone->deviceName = obj->deviceName;
- }
+ if (obj->type == interface_soundcard) {
+ clone->deviceName = obj->deviceName;
+ }
// +----------------------------------------------------------+
// | Terminal |
}
+ /* Will propably be freed somewhere else. Which is a bit ugly.
+ if (obj->deviceName != NULL) {
+
+ free((void *) obj->deviceName);
+
+ }
+ */
+
if (obj->ip != NULL) {
free((void *) obj->ip);
case interface_soundcard:
- printf("type = soundcard, card = %u, device = %u\n",obj->card,obj->device);
-
- break;
-
- case interface_soundcard_name:
-
printf("type = soundcard_name, devicename = %s\n",obj->deviceName);
break;
((obj->interface->type == interface_soundcard) && (obj->format->type == format_binary_int08)) ||
((obj->interface->type == interface_soundcard) && (obj->format->type == format_binary_int16)) ||
((obj->interface->type == interface_soundcard) && (obj->format->type == format_binary_int24)) ||
- ((obj->interface->type == interface_soundcard) && (obj->format->type == format_binary_int32)) ||
- ((obj->interface->type == interface_soundcard_name) && (obj->format->type == format_binary_int08)) ||
- ((obj->interface->type == interface_soundcard_name) && (obj->format->type == format_binary_int16)) ||
- ((obj->interface->type == interface_soundcard_name) && (obj->format->type == format_binary_int24)) ||
- ((obj->interface->type == interface_soundcard_name) && (obj->format->type == format_binary_int32)))) {
+ ((obj->interface->type == interface_soundcard) && (obj->format->type == format_binary_int32)))) {
printf("Source hops: Invalid interface and/or format.\n");
exit(EXIT_FAILURE);
snd_pcm_hw_params_t * hw_params;
snd_pcm_format_t format;
int err;
- char * tmpStr;
switch (obj->format->type) {
}
- tmpStr = (char *) malloc(sizeof(char) * 1024);
- tmpStr = obj->interface->deviceName;
- //sprintf(tmpStr, "hw:%u,%u", obj->interface->card, obj->interface->device);
- if ((err = snd_pcm_open(&(obj->ch), tmpStr, SND_PCM_STREAM_CAPTURE, 0)) < 0) {
- printf("Source hops: Cannot open audio device %s: %s\n",tmpStr, snd_strerror(err));
+ if ((err = snd_pcm_open(&(obj->ch), obj->interface->deviceName, SND_PCM_STREAM_CAPTURE, 0)) < 0) {
+ printf("Source hops: Cannot open audio device %s: %s\n",obj->interface->deviceName, snd_strerror(err));
exit(EXIT_FAILURE);
}
- free((void *) tmpStr);
-
if ((err = snd_pcm_hw_params_malloc(&hw_params)) < 0) {
printf("Source hops: Cannot allocate hardware parameter structure: %s\n", snd_strerror(err));
exit(EXIT_FAILURE);