Changeset ec49085 in mainline
- Timestamp:
- 2012-07-12T17:21:08Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 992ef56
- Parents:
- 737b4c0
- Location:
- uspace/srv/audio/hound
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/audio/hound/audio_sink.c
r737b4c0 rec49085 150 150 list_foreach(sink->sources, it) { 151 151 audio_source_t *source = audio_source_list_instance(it); 152 assert(audio_format_same(&sink->format, audio_source_format(source))); 153 const void *source_buffer; 154 size_t source_buffer_size = size; 155 int ret = audio_source_get_buffer(source, &source_buffer, 156 &source_buffer_size); 157 if (ret != EOK) { 158 log_warning("Could not get buffer from source %s", 159 source->name); 160 continue; 161 } 162 assert(source_buffer_size == size); 163 ret = audio_format_mix(dest, source_buffer, size, &sink->format); 152 const int ret = 153 audio_source_add_self(source, dest, size, &sink->format); 164 154 if (ret != EOK) { 165 155 log_warning("Failed to mix source %s: %s", -
uspace/srv/audio/hound/audio_source.c
r737b4c0 rec49085 36 36 #include <assert.h> 37 37 #include <errno.h> 38 #include <macros.h> 38 39 #include <stdlib.h> 39 40 #include <str.h> … … 76 77 } 77 78 78 int audio_source_get_buffer(audio_source_t *source, const void **buffer, size_t *size) 79 int audio_source_add_self(audio_source_t *source, void *buffer, size_t size, 80 const audio_format_t *f) 79 81 { 80 82 assert(source); 81 if (!buffer || !size) { 82 log_debug("Incorrect parameters."); 83 if (!buffer) { 84 log_debug("Non-existent buffer"); 85 return EBADMEM; 86 } 87 if (!f || size == 0) { 88 log_debug("No format or zero size"); 89 } 90 if (size % (pcm_sample_format_size(f->sample_format) * f->channels)) { 91 log_debug("Buffer does not fit integer number of frames"); 83 92 return EINVAL; 84 93 } 85 if ( source->get_data.hook)86 source->get_data.hook(source->get_data.arg);87 if (!source->available.base || !source->available.size)88 return EOVERFLOW; /* In fact it's underflow */94 if (!audio_format_same(&source->format, f)) { 95 log_debug("Format conversion is not supported yet"); 96 return ENOTSUP; 97 } 89 98 90 const size_t requested_size = 91 (*size == 0) || (*size > source->available.size) 92 ? source->available.size : *size; 93 *buffer = source->available.base; 94 *size = requested_size; 95 source->available.size -= requested_size; 96 source->available.base += requested_size; 99 if (source->available.size == 0) { 100 log_debug("No data to add"); 101 return EOVERFLOW; /* In fact this is underflow... */ 102 } 103 104 const size_t real_size = min(size, source->available.size); 105 const int ret = 106 audio_format_mix(buffer, source->available.base, real_size, f); 107 if (ret != EOK) { 108 log_debug("Mixing failed"); 109 return ret; 110 } 111 source->available.base += real_size; 112 source->available.size -= real_size; 97 113 return EOK; 98 114 } 115 99 116 /** 100 117 * @} -
uspace/srv/audio/hound/audio_source.h
r737b4c0 rec49085 76 76 } 77 77 int audio_source_connected(audio_source_t *source, const audio_format_t *f); 78 int audio_source_get_buffer(audio_source_t *source, const void **buffer, size_t *size); 78 int audio_source_add_self(audio_source_t *source, void *buffer, size_t size, 79 const audio_format_t *f); 79 80 static inline const audio_format_t *audio_source_format(const audio_source_t *s) 80 81 {
Note:
See TracChangeset
for help on using the changeset viewer.