Changeset ab07cf0 in mainline


Ignore:
Timestamp:
2012-07-13T16:11:05Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
13df13c8
Parents:
6424800
Message:

hound: Use buffer position in source available data.

Location:
uspace/srv/audio/hound
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/audio/hound/audio_client.c

    r6424800 rab07cf0  
    139139        }
    140140        void *old_buffer = source->available_data.base;
     141        source->available_data.position = buffer;
    141142        source->available_data.base = buffer;
    142143        source->available_data.size = size;
  • uspace/srv/audio/hound/audio_device.c

    r6424800 rab07cf0  
    187187                        if (dev->buffer.position) {
    188188                                dev->buffer.position +=
    189                                     dev->buffer.size / BUFFER_BLOCKS;
     189                                    (dev->buffer.size / BUFFER_BLOCKS);
    190190                        }
    191                         if (!dev->buffer.position ||
    192                             dev->buffer.position >=
    193                                 dev->buffer.base + dev->buffer.size)
     191                        if ((!dev->buffer.position) ||
     192                            (dev->buffer.position >=
     193                                (dev->buffer.base + dev->buffer.size)))
    194194                        {
    195195                                dev->buffer.position = dev->buffer.base;
     
    202202                        log_verbose("Playback terminated!");
    203203                        return;
    204                         break;
    205204                }
    206205                case PCM_EVENT_RECORDING_DONE: {
     206                        //TODO implement
    207207                        break;
    208208                }
    209209                case PCM_EVENT_RECORDING_TERMINATED:
    210210                        log_verbose("Recording terminated!");
    211                         break;
    212                 }
    213 
    214         }
    215         //TODO implement
     211                        return;
     212                }
     213
     214        }
    216215}
    217216
  • uspace/srv/audio/hound/audio_format.c

    r6424800 rab07cf0  
    5555                return EINVAL;
    5656        const size_t sample_size = pcm_sample_format_size(f->sample_format);
    57         if (!(size % sample_size == 0))
     57        if ((size % sample_size) != 0)
    5858                return EINVAL;
    5959
     
    6565        const type *src_buff = src; \
    6666        type *dst_buff = dst; \
    67         for (size_t i = 0; i < size / sample_size; ++i) { \
    68                 type a = type ## _ ## endian ##2host(dst_buff[i]); \
    69                 type b = type ## _ ## endian ##2host(src_buff[i]); \
    70                 type c = a + b; \
     67        for (size_t i = 0; i < size / sizeof(type); ++i) { \
     68                const type a = type ## _ ## endian ##2host(dst_buff[i]); \
     69                const type b = type ## _ ## endian ##2host(src_buff[i]); \
     70                const type c = a + b; \
    7171                dst_buff[i] = host2 ## type ## _ ## endian(c); \
    7272        } \
  • uspace/srv/audio/hound/audio_source.c

    r6424800 rab07cf0  
    6464        source->format = *f;
    6565        source->available_data.base = NULL;
     66        source->available_data.position = NULL;
    6667        source->available_data.size = 0;
    6768        log_verbose("Initialized source (%p) '%s'", source, source->name);
     
    119120                return ENOTSUP;
    120121        }
    121         if (source->available_data.base == NULL ||
     122        if (source->available_data.position == NULL ||
    122123            source->available_data.size == 0) {
    123124                int ret = EOVERFLOW; /* In fact this is underflow... */
     
    125126                        ret = source->update_available_data(source, size);
    126127                if (ret != EOK) {
    127                         log_debug("No data to add");
     128                        log_debug("No data to add to %p(%zu)", buffer, size);
    128129                        return ret;
    129130                }
     
    132133        const size_t real_size = min(size, source->available_data.size);
    133134        const int ret =
    134             audio_format_mix(buffer, source->available_data.base, real_size, f);
     135            audio_format_mix(buffer, source->available_data.position, real_size, f);
    135136        if (ret != EOK) {
    136                 log_debug("Mixing failed");
     137                log_debug("Mixing failed %p <= %p, %zu",
     138                    buffer, source->available_data.position, real_size);
    137139                return ret;
    138140        }
    139         source->available_data.base += real_size;
     141
     142        source->available_data.position += real_size;
    140143        source->available_data.size -= real_size;
     144
     145        log_verbose("Mixing successful %p <= %p, %zu",
     146            buffer, source->available_data.position, real_size);
     147
    141148        buffer += real_size;
    142149        size -= real_size;
  • uspace/srv/audio/hound/audio_source.h

    r6424800 rab07cf0  
    5656        struct audio_sink *connected_sink;
    5757        struct {
     58                void *position;
    5859                void *base;
    5960                size_t size;
Note: See TracChangeset for help on using the changeset viewer.