Changeset 4388:2de43be17c40 in roaraudio
- Timestamp:
- 09/15/10 01:13:41 (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/hwmixer_oss.c
r4380 r4388 34 34 }; 35 35 36 static struct subdev_map { 37 const char * name; 38 struct subdev subdev; 39 } g_subdevs[] = { 40 {"Volume", {.bit = SOUND_MASK_VOLUME, .cmd_read = SOUND_MIXER_READ_VOLUME, .cmd_write = SOUND_MIXER_WRITE_VOLUME}}, 41 {NULL} 42 }; 43 44 static int hwmixer_oss_open_stream(struct hwmixer_stream * stream, int devmask, int sdevmask, char * basename, struct roar_keyval * subname) { 45 struct subdev * subdev; 46 struct subdev * source_subdev = NULL; 47 struct roar_stream_server * ss; 48 int i; 49 50 for (i = 0; g_subdevs[i].name != NULL; i++) { 51 if ( !strcasecmp(subname->key, g_subdevs[i].name) ) { 52 source_subdev = &(g_subdevs[i].subdev); 53 break; 54 } 55 } 56 57 if ( source_subdev == NULL ) 58 return -1; 59 60 if ( !(devmask & source_subdev->bit) ) 61 return -1; 62 63 subdev = roar_mm_malloc(sizeof(struct subdev)); 64 65 if ( subdev == NULL ) 66 return -1; 67 68 memcpy(subdev, source_subdev, sizeof(struct subdev)); 69 70 subdev->channels = sdevmask & subdev->bit ? 2 : 1; 71 72 stream->ud = subdev; 73 74 if (streams_get(stream->stream, &ss) != -1) { 75 ROAR_STREAM(ss)->info.channels = subdev->channels; 76 } else { 77 ROAR_WARN("hwmixer_dstr_open(*): can not get object for stream %i", stream->stream); 78 } 79 80 return 0; 81 } 82 36 83 int hwmixer_oss_open(struct hwmixer_stream * stream, char * drv, char * dev, int fh, char * basename, struct roar_keyval * subnames, size_t subnamelen) { 37 84 struct roar_vio_calls * vio = roar_mm_malloc(sizeof(struct roar_vio_calls)); 38 85 struct roar_vio_defaults def; 39 struct roar_stream_server * ss;40 86 struct roar_vio_sysio_ioctl ctl; 87 struct roar_keyval kv; 41 88 int devmask, sdevmask; 42 struct subdev * subdev = roar_mm_malloc(sizeof(struct subdev)); 43 44 if ( vio == NULL || subdev == NULL ) { 45 if ( vio != NULL ) 46 roar_mm_free(vio); 47 if ( subdev != NULL ) 48 roar_mm_free(subdev); 89 90 if ( vio == NULL ) { 49 91 return -1; 50 92 } … … 59 101 if ( dev == NULL ) { 60 102 roar_mm_free(vio); 61 roar_mm_free(subdev);62 103 return -1; 63 104 } … … 65 106 if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_FILE, O_RDWR, 0644) == -1 ) { 66 107 roar_mm_free(vio); 67 roar_mm_free(subdev);68 108 return -1; 69 109 } … … 71 111 if ( roar_vio_open_dstr(vio, dev, &def, 1) == -1 ) { 72 112 roar_mm_free(vio); 73 roar_mm_free(subdev);74 113 return -1; 75 114 } … … 77 116 if ( roar_vio_open_fh(vio, fh) == -1 ) { 78 117 roar_mm_free(vio); 79 roar_mm_free(subdev);80 118 return -1; 81 119 } … … 83 121 84 122 stream->baseud = vio; 85 stream->ud = subdev;86 123 87 124 ctl.cmd = SOUND_MIXER_READ_DEVMASK; … … 91 128 roar_vio_close(vio); 92 129 roar_mm_free(vio); 93 roar_mm_free(subdev);94 130 return -1; 95 131 } … … 102 138 } 103 139 104 memset(subdev, 0, sizeof(struct subdev)); 105 106 if ( devmask & SOUND_MASK_VOLUME ) { 107 subdev->bit = SOUND_MASK_VOLUME; 108 subdev->channels = sdevmask & SOUND_MASK_VOLUME ? 2 : 1; 109 subdev->cmd_read = SOUND_MIXER_READ_VOLUME; 110 subdev->cmd_write = SOUND_MIXER_WRITE_VOLUME; 111 } else { 140 kv.key = "Volume"; 141 kv.value = NULL; 142 143 if ( hwmixer_oss_open_stream(stream, devmask, sdevmask, basename, &kv) == -1 ) { 112 144 roar_vio_close(vio); 113 145 roar_mm_free(vio); 114 roar_mm_free(subdev); 115 return -1; 116 } 117 118 if (streams_get(stream->basestream, &ss) != -1) { 119 ROAR_STREAM(ss)->info.channels = 2; 120 } else { 121 ROAR_WARN("hwmixer_dstr_open(*): can not get object for basestream %i", stream->basestream); 122 } 146 return -1; 147 } 148 123 149 124 150 #ifdef TEST_HWMIXER_SUBSTREAMS
Note: See TracChangeset
for help on using the changeset viewer.