Ignore:
Timestamp:
2013-03-16T18:38:27Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9df99a17
Parents:
92b59c7
Message:

libdrv: Add open default device helper function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_audio_pcm.c

    r92b59c7 r6606378  
    9494 */
    9595
     96/**
     97 * Open audio session with the first registered device.
     98 *
     99 * @return Pointer to a new audio device session, NULL on failure.
     100 */
     101audio_pcm_sess_t *audio_pcm_open_default(void)
     102{
     103        static bool resolved = false;
     104        static category_id_t pcm_id = 0;
     105        if (!resolved) {
     106                const int ret = loc_category_get_id("audio-pcm", &pcm_id,
     107                    IPC_FLAG_BLOCKING);
     108                if (ret != EOK)
     109                        return NULL;
     110                resolved = true;
     111        }
     112
     113        service_id_t *svcs = NULL;
     114        size_t count = 0;
     115        const int ret = loc_category_get_svcs(pcm_id, &svcs, &count);
     116        if (ret != EOK)
     117                return NULL;
     118
     119        audio_pcm_sess_t *session = NULL;
     120        if (count)
     121                session = audio_pcm_open_service(svcs[0]);
     122        free(svcs);
     123        return session;
     124}
    96125/**
    97126 * Open audio session with device identified by location service string.
Note: See TracChangeset for help on using the changeset viewer.