Ignore:
File:
1 edited

Legend:

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

    rb7fd2a0 r7f9d97f3  
    5151#define BUFFER_PARTS   16
    5252
    53 static errno_t device_sink_connection_callback(audio_sink_t *sink, bool new);
    54 static errno_t device_source_connection_callback(audio_source_t *source, bool new);
     53static int device_sink_connection_callback(audio_sink_t *sink, bool new);
     54static int device_source_connection_callback(audio_source_t *source, bool new);
    5555static void device_event_callback(ipc_callid_t iid, ipc_call_t *icall, void *arg);
    56 static errno_t device_check_format(audio_sink_t* sink);
    57 static errno_t get_buffer(audio_device_t *dev);
    58 static errno_t release_buffer(audio_device_t *dev);
     56static int device_check_format(audio_sink_t* sink);
     57static int get_buffer(audio_device_t *dev);
     58static int release_buffer(audio_device_t *dev);
    5959static void advance_buffer(audio_device_t *dev, size_t size);
    6060static inline bool is_running(audio_device_t *dev)
     
    6262        assert(dev);
    6363        /* we release buffer on stop so this should be enough */
    64         return dev->buffer.base != NULL;
     64        return (bool)dev->buffer.base;
    6565}
    6666
     
    7272 * @return Error code.
    7373 */
    74 errno_t audio_device_init(audio_device_t *dev, service_id_t id, const char *name)
     74int audio_device_init(audio_device_t *dev, service_id_t id, const char *name)
    7575{
    7676        assert(dev);
     
    121121{
    122122        assert(dev);
    123         sysarg_t val;
    124         errno_t rc = audio_pcm_query_cap(dev->sess, AUDIO_CAP_CAPTURE, &val);
    125         if (rc == EOK && val)
     123        if (audio_pcm_query_cap(dev->sess, AUDIO_CAP_CAPTURE))
    126124                return &dev->source;
    127125        return NULL;
     
    137135{
    138136        assert(dev);
    139         sysarg_t val;
    140         errno_t rc = audio_pcm_query_cap(dev->sess, AUDIO_CAP_PLAYBACK, &val);
    141         if (rc == EOK && val)
     137        if (audio_pcm_query_cap(dev->sess, AUDIO_CAP_PLAYBACK))
    142138                return &dev->sink;
    143139        return NULL;
     
    153149 * connections.
    154150 */
    155 static errno_t device_sink_connection_callback(audio_sink_t* sink, bool new)
     151static int device_sink_connection_callback(audio_sink_t* sink, bool new)
    156152{
    157153        assert(sink);
     
    160156                log_verbose("First connection on device sink '%s'", sink->name);
    161157
    162                 errno_t ret = get_buffer(dev);
     158                int ret = get_buffer(dev);
    163159                if (ret != EOK) {
    164160                        log_error("Failed to get device buffer: %s",
     
    196192                log_verbose("Removed last connection on device sink '%s'",
    197193                    sink->name);
    198                 errno_t ret = audio_pcm_stop_playback(dev->sess);
     194                int ret = audio_pcm_stop_playback(dev->sess);
    199195                if (ret != EOK) {
    200196                        log_error("Failed to stop playback: %s",
     
    215211 * connections.
    216212 */
    217 static errno_t device_source_connection_callback(audio_source_t *source, bool new)
     213static int device_source_connection_callback(audio_source_t *source, bool new)
    218214{
    219215        assert(source);
    220216        audio_device_t *dev = source->private_data;
    221217        if (new && list_count(&source->connections) == 1) {
    222                 errno_t ret = get_buffer(dev);
     218                int ret = get_buffer(dev);
    223219                if (ret != EOK) {
    224220                        log_error("Failed to get device buffer: %s",
     
    244240        if (list_count(&source->connections) == 0) { /* Disconnected */
    245241                assert(!new);
    246                 errno_t ret = audio_pcm_stop_capture_immediate(dev->sess);
     242                int ret = audio_pcm_stop_capture_immediate(dev->sess);
    247243                if (ret != EOK) {
    248244                        log_error("Failed to start recording: %s",
     
    289285                        log_verbose("Capture terminated");
    290286                        dev->source.format = AUDIO_FORMAT_ANY;
    291                         const errno_t ret = release_buffer(dev);
     287                        const int ret = release_buffer(dev);
    292288                        if (ret != EOK) {
    293289                                log_error("Failed to release buffer: %s",
     
    300296                        log_verbose("Playback Terminated");
    301297                        dev->sink.format = AUDIO_FORMAT_ANY;
    302                         const errno_t ret = release_buffer(dev);
     298                        const int ret = release_buffer(dev);
    303299                        if (ret != EOK) {
    304300                                log_error("Failed to release buffer: %s",
     
    309305                }
    310306                case PCM_EVENT_FRAMES_CAPTURED: {
    311                         const errno_t ret = audio_source_push_data(&dev->source,
     307                        const int ret = audio_source_push_data(&dev->source,
    312308                            dev->buffer.position, dev->buffer.fragment_size);
    313309                        advance_buffer(dev, dev->buffer.fragment_size);
     
    329325 * @return Error code.
    330326 */
    331 static errno_t device_check_format(audio_sink_t* sink)
     327static int device_check_format(audio_sink_t* sink)
    332328{
    333329        assert(sink);
     
    347343 * @return Error code.
    348344 */
    349 static errno_t get_buffer(audio_device_t *dev)
     345static int get_buffer(audio_device_t *dev)
    350346{
    351347        assert(dev);
     
    362358        size_t preferred_size = 0;
    363359
    364         const errno_t ret = audio_pcm_get_buffer(dev->sess, &dev->buffer.base,
     360        const int ret = audio_pcm_get_buffer(dev->sess, &dev->buffer.base,
    365361            &preferred_size);
    366362        if (ret == EOK) {
     
    378374 * @return Error code.
    379375 */
    380 static errno_t release_buffer(audio_device_t *dev)
     376static int release_buffer(audio_device_t *dev)
    381377{
    382378        assert(dev);
    383379        assert(dev->buffer.base);
    384380
    385         const errno_t ret = audio_pcm_release_buffer(dev->sess);
     381        const int ret = audio_pcm_release_buffer(dev->sess);
    386382        if (ret == EOK) {
    387383                as_area_destroy(dev->buffer.base);
Note: See TracChangeset for help on using the changeset viewer.