Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 6606378 in mainline


Ignore:
Timestamp:
2013-03-16T18:38:27Z (9 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
9df99a17
Parents:
92b59c7
Message:

libdrv: Add open default device helper function.

Location:
uspace/lib/drv
Files:
2 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.
  • uspace/lib/drv/include/audio_pcm_iface.h

    r92b59c7 r6606378  
    6969
    7070audio_pcm_sess_t *audio_pcm_open(const char *);
     71audio_pcm_sess_t *audio_pcm_open_default(void);
    7172audio_pcm_sess_t *audio_pcm_open_service(service_id_t service);
    7273void audio_pcm_close(audio_pcm_sess_t *);
Note: See TracChangeset for help on using the changeset viewer.