Ignore:
Timestamp:
2012-08-30T11:41:48Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5eed99d
Parents:
ed3816d
Message:

audio, sb16: Add and implement API for playback/capture with or without fragments.

File:
1 edited

Legend:

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

    red3816d r92b638c  
    342342 * 0 to turn off event generation.
    343343 */
    344 int audio_pcm_start_playback(audio_pcm_sess_t *sess, unsigned frames,
     344int audio_pcm_start_playback_fragment(audio_pcm_sess_t *sess, unsigned frames,
    345345    unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
    346346{
     
    357357        return ret;
    358358}
    359 
    360 /**
    361  * Stop current playback.
     359/**
     360 * Stops playback after current fragment.
     361 *
     362 * @param sess Audio device session.
     363 *
     364 * @return Error code.
     365 */
     366int audio_pcm_last_playback_fragment(audio_pcm_sess_t *sess)
     367{
     368        async_exch_t *exch = async_exchange_begin(sess);
     369        const int ret = async_req_2_0(exch,
     370            DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
     371            IPC_M_AUDIO_PCM_STOP_PLAYBACK, false);
     372        async_exchange_end(exch);
     373        return ret;
     374}
     375
     376/**
     377 * Start playback on buffer from the current position.
     378 *
     379 * @param sess Audio device session.
     380 * @param channels Number of channels.
     381 * @param sample_rate Sampling rate (for one channel).
     382 * @param format Sample format.
     383 *
     384 * @return Error code.
     385 */
     386int audio_pcm_start_playback(audio_pcm_sess_t *sess,
     387    unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
     388{
     389        return audio_pcm_start_playback_fragment(
     390            sess, 0, channels, sample_rate, format);
     391}
     392
     393/**
     394 * Immediately stops current playback.
    362395 *
    363396 * @param sess Audio device session.
     
    368401{
    369402        async_exch_t *exch = async_exchange_begin(sess);
    370         const int ret = async_req_1_0(exch,
    371             DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
    372             IPC_M_AUDIO_PCM_STOP_PLAYBACK);
    373         async_exchange_end(exch);
    374         return ret;
    375 }
    376 
    377 /**
    378  * Start capture on buffer from position 0.
     403        const int ret = async_req_2_0(exch,
     404            DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
     405            IPC_M_AUDIO_PCM_STOP_PLAYBACK, true);
     406        async_exchange_end(exch);
     407        return ret;
     408}
     409
     410/**
     411 * Start capture on buffer from the current position.
    379412 *
    380413 * @param sess Audio device session.
     
    389422 * 0 to turn off event generation.
    390423 */
    391 int audio_pcm_start_capture(audio_pcm_sess_t *sess, unsigned frames,
     424int audio_pcm_start_capture_fragment(audio_pcm_sess_t *sess, unsigned frames,
    392425    unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
    393426{
     
    405438
    406439/**
    407  * Stop current playback.
     440 * Start capture on buffer from the current position.
     441 *
     442 * @param sess Audio device session.
     443 * @param channels Number of channels.
     444 * @param sample_rate Sampling rate (for one channel).
     445 * @param format Sample format.
     446 *
     447 * @return Error code.
     448 */
     449int audio_pcm_start_capture(audio_pcm_sess_t *sess,
     450    unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
     451{
     452        return audio_pcm_start_capture_fragment(
     453            sess, 0, channels, sample_rate, format);
     454}
     455
     456/**
     457 * Stops capture at the end of current fragment.
     458 *
     459 * Won't work if capture was started with fragment size 0.
     460 * @param sess Audio device session.
     461 *
     462 * @return Error code.
     463 */
     464int audio_pcm_last_capture_fragment(audio_pcm_sess_t *sess)
     465{
     466        async_exch_t *exch = async_exchange_begin(sess);
     467        const int ret = async_req_2_0(exch,
     468            DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
     469            IPC_M_AUDIO_PCM_STOP_CAPTURE, false);
     470        async_exchange_end(exch);
     471        return ret;
     472}
     473
     474/**
     475 * Immediately stops current capture.
    408476 *
    409477 * @param sess Audio device session.
     
    414482{
    415483        async_exch_t *exch = async_exchange_begin(sess);
    416         const int ret = async_req_1_0(exch,
    417             DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE), IPC_M_AUDIO_PCM_STOP_CAPTURE);
     484        const int ret = async_req_2_0(exch,
     485            DEV_IFACE_ID(AUDIO_PCM_BUFFER_IFACE),
     486            IPC_M_AUDIO_PCM_STOP_CAPTURE, true);
    418487        async_exchange_end(exch);
    419488        return ret;
     
    648717{
    649718        const audio_pcm_iface_t *pcm_iface = iface;
     719        const bool immediate = DEV_IPC_GET_ARG1(*call);
    650720
    651721        const int ret = pcm_iface->stop_playback ?
    652             pcm_iface->stop_playback(fun) : ENOTSUP;
     722            pcm_iface->stop_playback(fun, immediate) : ENOTSUP;
    653723        async_answer_0(callid, ret);
    654724}
     
    674744{
    675745        const audio_pcm_iface_t *pcm_iface = iface;
     746        const bool immediate = DEV_IPC_GET_ARG1(*call);
    676747
    677748        const int ret = pcm_iface->stop_capture ?
    678             pcm_iface->stop_capture(fun) : ENOTSUP;
     749            pcm_iface->stop_capture(fun, immediate) : ENOTSUP;
    679750        async_answer_0(callid, ret);
    680751}
Note: See TracChangeset for help on using the changeset viewer.