Changeset 389ef25 in mainline
- Timestamp:
- 2012-07-17T06:53:55Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 950110ee
- Parents:
- bb67def
- Location:
- uspace/srv/audio/hound
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/audio/hound/audio_client.c
rbb67def r389ef25 80 80 init_common(client, name, f, sess); 81 81 audio_sink_init(&client->sink, name, client, 82 client_sink_connection_change, f);82 client_sink_connection_change, NULL, f); 83 83 client->is_recording = true; 84 84 return client; -
uspace/srv/audio/hound/audio_device.c
rbb67def r389ef25 51 51 static int device_source_connection_callback(audio_source_t *source); 52 52 static void device_event_callback(ipc_callid_t iid, ipc_call_t *icall, void *arg); 53 static int device_check_format(audio_sink_t* sink); 53 54 static int get_buffer(audio_device_t *dev); 54 55 static int release_buffer(audio_device_t *dev); … … 68 69 69 70 audio_sink_init(&dev->sink, name, dev, device_sink_connection_callback, 70 &AUDIO_FORMAT_ANY);71 device_check_format, &AUDIO_FORMAT_ANY); 71 72 audio_source_init(&dev->source, name, dev, 72 73 device_source_connection_callback, NULL, &AUDIO_FORMAT_ANY); … … 222 223 } 223 224 } 225 static int device_check_format(audio_sink_t* sink) 226 { 227 assert(sink); 228 audio_device_t *dev = sink->private_data; 229 assert(dev); 230 log_verbose("Checking format on sink %s", sink->name); 231 return audio_pcm_test_format(dev->sess, &sink->format.channels, 232 &sink->format.sampling_rate, &sink->format.sample_format); 233 } 224 234 225 235 static int get_buffer(audio_device_t *dev) -
uspace/srv/audio/hound/audio_sink.c
rbb67def r389ef25 46 46 int audio_sink_init(audio_sink_t *sink, const char *name, 47 47 void *private_data, int (*connection_change)(audio_sink_t *, bool), 48 const audio_format_t *f)48 int (*check_format)(audio_sink_t *sink), const audio_format_t *f) 49 49 { 50 50 assert(sink); … … 59 59 sink->format = *f; 60 60 sink->connection_change = connection_change; 61 sink->check_format = check_format; 61 62 log_verbose("Initialized sink (%p) '%s'", sink, sink->name); 62 63 return EOK; … … 70 71 sink->name = NULL; 71 72 } 72 73 73 74 74 int audio_sink_add_source(audio_sink_t *sink, audio_source_t *source) … … 85 85 /* Set audio format according to the first source */ 86 86 if (audio_format_is_any(&sink->format)) { 87 /* Source does not care */ 88 if (audio_format_is_any(&source->format)) { 89 log_verbose("Set default format for sink %s.", 90 sink->name); 91 sink->format = AUDIO_FORMAT_DEFAULT; 92 } else { 93 log_verbose("Set format based on the first " 94 "source(%s): %u channel(s), %uHz, %s for " 95 "sink %s.", source->name, 96 source->format.channels, 97 source->format.sampling_rate, 98 pcm_sample_format_str( 99 source->format.sample_format), 100 sink->name); 101 sink->format = source->format; 102 } 87 int ret = audio_sink_set_format(sink, &source->format); 88 if (ret != EOK) 89 return ret; 103 90 } 104 91 } … … 120 107 source->name, sink->name); 121 108 109 return EOK; 110 } 111 112 int audio_sink_set_format(audio_sink_t *sink, const audio_format_t *format) 113 { 114 assert(sink); 115 assert(format); 116 if (!audio_format_is_any(&sink->format)) { 117 log_debug("Sink %s already has a format", sink->name); 118 return EEXISTS; 119 } 120 const audio_format_t old_format; 121 122 if (audio_format_is_any(format)) { 123 log_verbose("Setting DEFAULT format for sink %s", sink->name); 124 sink->format = AUDIO_FORMAT_DEFAULT; 125 } else { 126 sink->format = *format; 127 } 128 if (sink->check_format) { 129 const int ret = sink->check_format(sink); 130 if (ret != EOK && ret != ELIMIT) { 131 log_debug("Format check failed on sink %s", sink->name); 132 sink->format = old_format; 133 return ret; 134 } 135 } 136 log_verbose("Set format for sink %s: %u channel(s), %uHz, %s", 137 sink->name, format->channels, format->sampling_rate, 138 pcm_sample_format_str(format->sample_format)); 122 139 return EOK; 123 140 } -
uspace/srv/audio/hound/audio_sink.h
rbb67def r389ef25 54 54 void *private_data; 55 55 int (*connection_change)(audio_sink_t *, bool); 56 int (*check_format)(audio_sink_t *); 56 57 }; 57 58 … … 63 64 int audio_sink_init(audio_sink_t *sink, const char *name, 64 65 void *private_data, int (*connection_change)(audio_sink_t *, bool), 65 const audio_format_t *f);66 int (*check_format)(audio_sink_t *), const audio_format_t *f); 66 67 void audio_sink_fini(audio_sink_t *sink); 67 68 69 int audio_sink_set_format(audio_sink_t *sink, const audio_format_t *format); 68 70 int audio_sink_add_source(audio_sink_t *sink, audio_source_t *source); 69 71 int audio_sink_remove_source(audio_sink_t *sink, audio_source_t *source);
Note:
See TracChangeset
for help on using the changeset viewer.