Changeset 4389076 in mainline
- Timestamp:
- 2013-04-05T15:45:01Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 60e5696d
- Parents:
- 02ead2e
- Location:
- uspace
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/wavplay/main.c
r02ead2e r4389076 46 46 #include "wave.h" 47 47 48 #define BUFFER_SIZE ( 4* 1024)48 #define BUFFER_SIZE (32 * 1024) 49 49 50 50 … … 74 74 } 75 75 hound_context_t *hound = hound_context_create_playback(filename, 76 format, 0);76 format, BUFFER_SIZE * 2); 77 77 if (!hound) { 78 78 printf("Failed to create HOUND context\n"); … … 258 258 return 1; 259 259 } 260 if (direct) 260 if (direct) { 261 261 return dplay(device, file); 262 else 262 } else { 263 return hplay(file); 263 264 return play_hound(file); 264 hplay(file);265 } 265 266 } 266 267 /** -
uspace/srv/audio/hound/connection.c
r02ead2e r4389076 86 86 if (!data) 87 87 return EBADMEM; 88 return audio_source_add_self(connection->source, data, size, &format); 88 size_t needed_frames = pcm_format_size_to_frames(size, &format); 89 if (needed_frames > audio_pipe_frames(&connection->fifo) && 90 connection->source->update_available_data) { 91 log_debug("Asking source to provide more data"); 92 connection->source->update_available_data( 93 connection->source, size); 94 } 95 log_verbose("Data available after update: %zu", 96 audio_pipe_bytes(&connection->fifo)); 97 ssize_t ret = 98 audio_pipe_mix_data(&connection->fifo, data, size, &format); 99 if (ret != (ssize_t)size) 100 log_warning("Connection failed to provide enough data %zd/%zu", 101 ret, size); 102 return ret > 0 ? EOK : ret; 89 103 } 90 104 -
uspace/srv/audio/hound/main.c
r02ead2e r4389076 41 41 #include <str_error.h> 42 42 #include <hound/server.h> 43 43 #include <hound/protocol.h> 44 44 45 45 #include "hound.h" … … 51 51 #include "audio_client.h" 52 52 #include "log.h" 53 54 extern hound_server_iface_t hound_iface; 53 55 54 56 static hound_t hound; … … 64 66 } 65 67 66 static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)67 {68 async_answer_0(iid, EOK);69 70 LIST_INITIALIZE(local_playback);71 LIST_INITIALIZE(local_recording);72 pcm_format_t format = {0};73 const char *name = NULL;74 async_sess_t *sess = NULL;75 76 while (1) {77 ipc_call_t call;78 ipc_callid_t callid = async_get_call(&call);79 switch (IPC_GET_IMETHOD(call)) {80 case HOUND_REGISTER_PLAYBACK: {81 hound_server_get_register_params(&name, &sess,82 &format.channels, &format.sampling_rate,83 &format.sample_format);84 audio_client_t *client =85 audio_client_get_playback(name, &format, sess);86 free(name);87 if (!client) {88 log_error("Failed to create playback client");89 async_answer_0(callid, ENOMEM);90 break;91 }92 int ret = hound_add_source(&hound, &client->source);93 if (ret != EOK){94 audio_client_destroy(client);95 log_error("Failed to add audio source: %s",96 str_error(ret));97 async_answer_0(callid, ret);98 break;99 }100 log_info("Added audio client %p '%s'",101 client, client->name);102 async_answer_0(callid, EOK);103 list_append(&client->link, &local_playback);104 break;105 }106 case HOUND_REGISTER_RECORDING: {107 hound_server_get_register_params(&name, &sess,108 &format.channels, &format.sampling_rate,109 &format.sample_format);110 audio_client_t *client =111 audio_client_get_recording(name, &format, sess);112 free(name);113 if (!client) {114 log_error("Failed to create recording client");115 async_answer_0(callid, ENOMEM);116 break;117 }118 int ret = hound_add_sink(&hound, &client->sink);119 if (ret != EOK){120 audio_client_destroy(client);121 log_error("Failed to add audio sink: %s",122 str_error(ret));123 async_answer_0(callid, ret);124 break;125 }126 async_answer_0(callid, EOK);127 list_append(&client->link, &local_recording);128 break;129 }130 case HOUND_UNREGISTER_PLAYBACK: {131 const char *name = NULL;132 hound_server_get_unregister_params(&name);133 int ret = ENOENT;134 list_foreach_safe(local_playback, it, next) {135 audio_client_t *client =136 audio_client_list_instance(it);137 log_fatal("UNREGISTER_PLAYBACK %p", client);138 if (str_cmp(client->name, name) == 0) {139 ret = hound_remove_source(&hound,140 &client->source);141 if (ret == EOK) {142 list_remove(&client->link);143 audio_client_destroy(client);144 }145 break;146 }147 }148 free(name);149 async_answer_0(callid, ret);150 break;151 }152 case HOUND_UNREGISTER_RECORDING: {153 const char *name = NULL;154 hound_server_get_unregister_params(&name);155 int ret = ENOENT;156 list_foreach(local_recording, it) {157 audio_client_t *client =158 audio_client_list_instance(it);159 if (str_cmp(client->name, name) == 0) {160 ret = hound_remove_sink(&hound,161 &client->sink);162 if (ret == EOK) {163 list_remove(&client->link);164 audio_client_destroy(client);165 }166 break;167 }168 }169 free(name);170 async_answer_0(callid, ret);171 break;172 }173 case HOUND_CONNECT: {174 const char *source = NULL, *sink = NULL;175 hound_server_get_connection_params(&source, &sink);176 const int ret = hound_connect(&hound, source, sink);177 if (ret != EOK)178 log_error("Failed to connect '%s' to '%s': %s",179 source, sink, str_error(ret));180 free(source);181 free(sink);182 async_answer_0(callid, ret);183 break;184 }185 case HOUND_DISCONNECT: {186 const char *source = NULL, *sink = NULL;187 hound_server_get_connection_params(&source, &sink);188 const int ret = hound_disconnect(&hound, source, sink);189 if (ret != EOK)190 log_error("Failed to disconnect '%s' from '%s'"191 ": %s", source, sink, str_error(ret));192 free(source);193 free(sink);194 async_answer_0(callid, ret);195 break;196 }197 default:198 log_debug("Got unknown method %u",199 IPC_GET_IMETHOD(call));200 async_answer_0(callid, ENOTSUP);201 break;202 case 0:203 while(!list_empty(&local_recording)) {204 audio_client_t *client =205 audio_client_list_instance(206 list_first(&local_recording));207 list_remove(&client->link);208 hound_remove_sink(&hound, &client->sink);209 audio_client_destroy(client);210 }211 while(!list_empty(&local_playback)) {212 audio_client_t *client =213 audio_client_list_instance(214 list_first(&local_playback));215 list_remove(&client->link);216 log_fatal("CASE 0 %p", client);217 hound_remove_source(&hound, &client->source);218 audio_client_destroy(client);219 }220 return;221 }222 }223 }224 225 68 int main(int argc, char **argv) 226 69 { … … 234 77 } 235 78 236 async_set_client_connection(client_connection); 79 hound_iface.server = &hound; 80 hound_service_set_server_iface(&hound_iface); 81 async_set_client_connection(hound_connection_handler); 237 82 238 83 service_id_t id = 0;
Note:
See TracChangeset
for help on using the changeset viewer.