Changeset f0a647c in mainline
- Timestamp:
- 2013-04-11T00:18:22Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c799138
- Parents:
- 876f5561
- Location:
- uspace/srv/audio/hound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/audio/hound/audio_source.c
r876f5561 rf0a647c 65 65 source->update_available_data = update_available_data; 66 66 source->format = *f; 67 source->available_data.base = NULL;68 source->available_data.position = NULL;69 source->available_data.size = 0;70 67 log_verbose("Initialized source (%p) '%s'", source, source->name); 71 68 return EOK; … … 79 76 } 80 77 81 int audio_source_add_self(audio_source_t *source, void *buffer, size_t size,82 const pcm_format_t *f)83 {84 assert(source);85 if (!buffer) {86 log_debug("Non-existent buffer");87 return EBADMEM;88 }89 if (!f || size == 0) {90 log_debug("No format or zero size");91 }92 if (size % (pcm_sample_format_size(f->sample_format) * f->channels)) {93 log_debug("Buffer does not fit integer number of frames");94 return EINVAL;95 }96 if (source->format.sampling_rate != f->sampling_rate) {97 log_debug("Resampling is not supported, yet");98 return ENOTSUP;99 }100 const size_t src_frame_size = pcm_format_frame_size(&source->format);101 const size_t dst_frames = size / pcm_format_frame_size(f);102 103 if (source->available_data.position == NULL ||104 source->available_data.size == 0) {105 int ret = EOVERFLOW; /* In fact this is underflow... */106 if (source->update_available_data)107 ret = source->update_available_data(source,108 dst_frames * src_frame_size);109 if (ret != EOK) {110 log_debug("No data to add to %p(%zu)", buffer, size);111 return ret;112 }113 }114 115 const int ret = pcm_format_convert_and_mix(buffer, size,116 source->available_data.position, source->available_data.size,117 &source->format, f);118 if (ret != EOK) {119 log_debug("Mixing failed %p <= %p, frames: %zu",120 buffer, source->available_data.position, dst_frames);121 return ret;122 }123 124 source->available_data.position += (dst_frames * src_frame_size);125 source->available_data.size -= (dst_frames * src_frame_size);126 return EOK;127 }128 129 78 /** 130 79 * @} -
uspace/srv/audio/hound/audio_source.h
r876f5561 rf0a647c 40 40 #include <pcm/format.h> 41 41 42 struct audio_sink;43 42 typedef struct audio_source audio_source_t; 44 43 … … 51 50 int (*connection_change)(audio_source_t *source, bool added); 52 51 int (*update_available_data)(audio_source_t *source, size_t size); 53 struct {54 void *position;55 void *base;56 size_t size;57 } available_data;58 52 }; 59 53 … … 68 62 const pcm_format_t *f); 69 63 void audio_source_fini(audio_source_t *source); 70 //int audio_source_connected(audio_source_t *source, struct audio_sink *sink);71 int audio_source_add_self(audio_source_t *source, void *buffer, size_t size,72 const pcm_format_t *f);73 64 static inline const pcm_format_t *audio_source_format(const audio_source_t *s) 74 65 {
Note:
See TracChangeset
for help on using the changeset viewer.