• Home
  • Raw
  • Download

Lines Matching refs:alsa

101 static gboolean gst_alsasink_acceptcaps (GstAlsaSink * alsa, GstCaps * caps);
276 GST_WARNING_OBJECT (alsa, "Error %d (%s) calling " #call, err, snd_strerror (err)); \
347 gst_alsasink_acceptcaps (GstAlsaSink * alsa, GstCaps * caps) in gst_alsasink_acceptcaps() argument
349 GstPad *pad = GST_BASE_SINK (alsa)->sinkpad; in gst_alsasink_acceptcaps()
403 GstAlsaSink *alsa = GST_ALSA_SINK (sink); in gst_alsasink_query() local
412 ret = gst_alsasink_acceptcaps (alsa, caps); in gst_alsasink_query()
425 set_hwparams (GstAlsaSink * alsa) in set_hwparams() argument
434 GST_DEBUG_OBJECT (alsa, "Negotiating to %d channels @ %d Hz (format = %s) " in set_hwparams()
435 "SPDIF (%d)", alsa->channels, alsa->rate, in set_hwparams()
436 snd_pcm_format_name (alsa->format), alsa->iec958); in set_hwparams()
439 CHECK (snd_pcm_hw_params_any (alsa->handle, params), no_config); in set_hwparams()
441 CHECK (snd_pcm_hw_params_set_access (alsa->handle, params, alsa->access), in set_hwparams()
444 if (alsa->iec958) { in set_hwparams()
446 if (snd_pcm_hw_params_set_format (alsa->handle, params, alsa->format) < 0) { in set_hwparams()
447 alsa->format = SND_PCM_FORMAT_S16_LE; in set_hwparams()
448 alsa->need_swap = TRUE; in set_hwparams()
449 GST_DEBUG_OBJECT (alsa, "falling back to little endian with swapping"); in set_hwparams()
451 alsa->need_swap = FALSE; in set_hwparams()
454 CHECK (snd_pcm_hw_params_set_format (alsa->handle, params, alsa->format), in set_hwparams()
457 CHECK (snd_pcm_hw_params_set_channels (alsa->handle, params, alsa->channels), in set_hwparams()
460 rrate = alsa->rate; in set_hwparams()
461 CHECK (snd_pcm_hw_params_set_rate_near (alsa->handle, params, &rrate, NULL), in set_hwparams()
471 GST_DEBUG_OBJECT (alsa, "buffer time %u, min %u, max %u", in set_hwparams()
472 alsa->buffer_time, min, max); in set_hwparams()
477 GST_DEBUG_OBJECT (alsa, "period time %u, min %u, max %u", in set_hwparams()
478 alsa->period_time, min, max); in set_hwparams()
483 GST_DEBUG_OBJECT (alsa, "periods min %u, max %u", min, max); in set_hwparams()
488 if (!alsa->iec958) { in set_hwparams()
494 if (alsa->buffer_time != -1 && alsa->period_time != -1) { in set_hwparams()
495 if (((err = snd_pcm_hw_params_set_period_time_near (alsa->handle, in set_hwparams()
496 params, &alsa->period_time, NULL)) >= 0) in set_hwparams()
498 snd_pcm_hw_params_set_buffer_time_near (alsa->handle, in set_hwparams()
499 params, &alsa->buffer_time, NULL)) >= 0)) { in set_hwparams()
500 GST_DEBUG_OBJECT (alsa, "period time %u buffer time %u set correctly", in set_hwparams()
501 alsa->period_time, alsa->buffer_time); in set_hwparams()
507 if (((err = snd_pcm_hw_params_set_buffer_time_near (alsa->handle, in set_hwparams()
508 params, &alsa->buffer_time, NULL)) >= 0) in set_hwparams()
510 snd_pcm_hw_params_set_period_time_near (alsa->handle, in set_hwparams()
511 params, &alsa->period_time, NULL)) >= 0)) { in set_hwparams()
512 GST_DEBUG_OBJECT (alsa, "buffer time %u period time %u set correctly", in set_hwparams()
513 alsa->buffer_time, alsa->period_time); in set_hwparams()
519 if (alsa->period_time != -1) { in set_hwparams()
523 snd_pcm_hw_params_set_period_time_near (alsa->handle, params, in set_hwparams()
524 &alsa->period_time, NULL)) < 0) { in set_hwparams()
525 GST_DEBUG_OBJECT (alsa, "Unable to set period time %i for playback: %s", in set_hwparams()
526 alsa->period_time, snd_strerror (err)); in set_hwparams()
528 GST_DEBUG_OBJECT (alsa, "period time %u set correctly", in set_hwparams()
529 alsa->period_time); in set_hwparams()
533 if (alsa->buffer_time != -1) { in set_hwparams()
537 snd_pcm_hw_params_set_buffer_time_near (alsa->handle, params, in set_hwparams()
538 &alsa->buffer_time, NULL)) < 0) { in set_hwparams()
539 GST_DEBUG_OBJECT (alsa, "Unable to set buffer time %i for playback: %s", in set_hwparams()
540 alsa->buffer_time, snd_strerror (err)); in set_hwparams()
542 GST_DEBUG_OBJECT (alsa, "buffer time %u set correctly", in set_hwparams()
543 alsa->buffer_time); in set_hwparams()
552 CHECK (snd_pcm_hw_params_set_buffer_size_near (alsa->handle, params, in set_hwparams()
554 CHECK (snd_pcm_hw_params_set_period_size_near (alsa->handle, params, in set_hwparams()
560 GST_DEBUG_OBJECT (alsa, "Not setting period time and buffer time"); in set_hwparams()
564 CHECK (snd_pcm_hw_params (alsa->handle, params), set_hw_params); in set_hwparams()
566 CHECK (snd_pcm_hw_params_get_buffer_size (params, &alsa->buffer_size), in set_hwparams()
568 CHECK (snd_pcm_hw_params_get_period_size (params, &alsa->period_size, in set_hwparams()
571 GST_DEBUG_OBJECT (alsa, "buffer size %lu, period size %lu", alsa->buffer_size, in set_hwparams()
572 alsa->period_size); in set_hwparams()
575 alsa->hw_support_pause = snd_pcm_hw_params_can_pause (params); in set_hwparams()
576 GST_DEBUG_OBJECT (alsa, "Hw support pause: %s", in set_hwparams()
577 alsa->hw_support_pause ? "yes" : "no"); in set_hwparams()
583 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in set_hwparams()
590 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in set_hwparams()
596 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in set_hwparams()
604 if ((alsa->channels) == 1) in set_hwparams()
606 if ((alsa->channels) == 2) in set_hwparams()
608 if ((alsa->channels) > 2) in set_hwparams()
612 alsa->channels); in set_hwparams()
613 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, ("%s", msg), in set_hwparams()
620 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in set_hwparams()
622 alsa->rate, snd_strerror (err))); in set_hwparams()
627 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in set_hwparams()
633 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in set_hwparams()
639 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in set_hwparams()
651 set_swparams (GstAlsaSink * alsa) in set_swparams() argument
659 CHECK (snd_pcm_sw_params_current (alsa->handle, params), no_config); in set_swparams()
662 CHECK (snd_pcm_sw_params_set_start_threshold (alsa->handle, params, in set_swparams()
663 (alsa->buffer_size / alsa->period_size) * alsa->period_size), in set_swparams()
667 CHECK (snd_pcm_sw_params_set_avail_min (alsa->handle, params, in set_swparams()
668 alsa->period_size), set_avail); in set_swparams()
674 CHECK (snd_pcm_sw_params_set_xfer_align (alsa->handle, params, 1), set_align); in set_swparams()
678 CHECK (snd_pcm_sw_params (alsa->handle, params), set_sw_params); in set_swparams()
686 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in set_swparams()
694 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in set_swparams()
702 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in set_swparams()
710 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in set_swparams()
718 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in set_swparams()
726 alsasink_parse_spec (GstAlsaSink * alsa, GstAudioRingBufferSpec * spec) in alsasink_parse_spec() argument
729 alsa->iec958 = FALSE; in alsasink_parse_spec()
735 alsa->format = SND_PCM_FORMAT_U8; in alsasink_parse_spec()
738 alsa->format = SND_PCM_FORMAT_S8; in alsasink_parse_spec()
741 alsa->format = SND_PCM_FORMAT_S16_LE; in alsasink_parse_spec()
744 alsa->format = SND_PCM_FORMAT_S16_BE; in alsasink_parse_spec()
747 alsa->format = SND_PCM_FORMAT_U16_LE; in alsasink_parse_spec()
750 alsa->format = SND_PCM_FORMAT_U16_BE; in alsasink_parse_spec()
753 alsa->format = SND_PCM_FORMAT_S24_LE; in alsasink_parse_spec()
756 alsa->format = SND_PCM_FORMAT_S24_BE; in alsasink_parse_spec()
759 alsa->format = SND_PCM_FORMAT_U24_LE; in alsasink_parse_spec()
762 alsa->format = SND_PCM_FORMAT_U24_BE; in alsasink_parse_spec()
765 alsa->format = SND_PCM_FORMAT_S32_LE; in alsasink_parse_spec()
768 alsa->format = SND_PCM_FORMAT_S32_BE; in alsasink_parse_spec()
771 alsa->format = SND_PCM_FORMAT_U32_LE; in alsasink_parse_spec()
774 alsa->format = SND_PCM_FORMAT_U32_BE; in alsasink_parse_spec()
777 alsa->format = SND_PCM_FORMAT_S24_3LE; in alsasink_parse_spec()
780 alsa->format = SND_PCM_FORMAT_S24_3BE; in alsasink_parse_spec()
783 alsa->format = SND_PCM_FORMAT_U24_3LE; in alsasink_parse_spec()
786 alsa->format = SND_PCM_FORMAT_U24_3BE; in alsasink_parse_spec()
789 alsa->format = SND_PCM_FORMAT_S20_3LE; in alsasink_parse_spec()
792 alsa->format = SND_PCM_FORMAT_S20_3BE; in alsasink_parse_spec()
795 alsa->format = SND_PCM_FORMAT_U20_3LE; in alsasink_parse_spec()
798 alsa->format = SND_PCM_FORMAT_U20_3BE; in alsasink_parse_spec()
801 alsa->format = SND_PCM_FORMAT_S18_3LE; in alsasink_parse_spec()
804 alsa->format = SND_PCM_FORMAT_S18_3BE; in alsasink_parse_spec()
807 alsa->format = SND_PCM_FORMAT_U18_3LE; in alsasink_parse_spec()
810 alsa->format = SND_PCM_FORMAT_U18_3BE; in alsasink_parse_spec()
813 alsa->format = SND_PCM_FORMAT_FLOAT_LE; in alsasink_parse_spec()
816 alsa->format = SND_PCM_FORMAT_FLOAT_BE; in alsasink_parse_spec()
819 alsa->format = SND_PCM_FORMAT_FLOAT64_LE; in alsasink_parse_spec()
822 alsa->format = SND_PCM_FORMAT_FLOAT64_BE; in alsasink_parse_spec()
829 alsa->format = SND_PCM_FORMAT_A_LAW; in alsasink_parse_spec()
832 alsa->format = SND_PCM_FORMAT_MU_LAW; in alsasink_parse_spec()
838 alsa->format = SND_PCM_FORMAT_S16_BE; in alsasink_parse_spec()
839 alsa->iec958 = TRUE; in alsasink_parse_spec()
845 alsa->rate = GST_AUDIO_INFO_RATE (&spec->info); in alsasink_parse_spec()
846 alsa->channels = GST_AUDIO_INFO_CHANNELS (&spec->info); in alsasink_parse_spec()
847 alsa->buffer_time = spec->buffer_time; in alsasink_parse_spec()
848 alsa->period_time = spec->latency_time; in alsasink_parse_spec()
849 alsa->access = SND_PCM_ACCESS_RW_INTERLEAVED; in alsasink_parse_spec()
851 if (spec->type == GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW && alsa->channels < 9) in alsasink_parse_spec()
853 (alsa)->ringbuffer, alsa_position[alsa->channels - 1]); in alsasink_parse_spec()
867 GstAlsaSink *alsa; in gst_alsasink_open() local
870 alsa = GST_ALSA_SINK (asink); in gst_alsasink_open()
874 CHECK (snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_PLAYBACK, in gst_alsasink_open()
876 GST_LOG_OBJECT (alsa, "Opened device %s", alsa->device); in gst_alsasink_open()
884 GST_ELEMENT_ERROR (alsa, RESOURCE, BUSY, in gst_alsasink_open()
887 ("Device '%s' is busy", alsa->device)); in gst_alsasink_open()
889 GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_WRITE, in gst_alsasink_open()
891 ("Playback open error on device '%s': %s", alsa->device, in gst_alsasink_open()
901 GstAlsaSink *alsa; in gst_alsasink_prepare() local
904 alsa = GST_ALSA_SINK (asink); in gst_alsasink_prepare()
906 if (alsa->iec958) { in gst_alsasink_prepare()
907 snd_pcm_close (alsa->handle); in gst_alsasink_prepare()
908 alsa->handle = gst_alsa_open_iec958_pcm (GST_OBJECT (alsa), alsa->device); in gst_alsasink_prepare()
909 if (G_UNLIKELY (!alsa->handle)) { in gst_alsasink_prepare()
914 if (!alsasink_parse_spec (alsa, spec)) in gst_alsasink_prepare()
917 CHECK (set_hwparams (alsa), hw_params_failed); in gst_alsasink_prepare()
918 CHECK (set_swparams (alsa), sw_params_failed); in gst_alsasink_prepare()
920 alsa->bpf = GST_AUDIO_INFO_BPF (&spec->info); in gst_alsasink_prepare()
921 spec->segsize = alsa->period_size * alsa->bpf; in gst_alsasink_prepare()
922 spec->segtotal = alsa->buffer_size / alsa->period_size; in gst_alsasink_prepare()
929 snd_pcm_dump_hw_setup (alsa->handle, out_buf); in gst_alsasink_prepare()
931 GST_DEBUG_OBJECT (alsa, "Hardware setup: \n%s", msg); in gst_alsasink_prepare()
934 snd_pcm_dump_sw_setup (alsa->handle, out_buf); in gst_alsasink_prepare()
936 GST_DEBUG_OBJECT (alsa, "Software setup: \n%s", msg); in gst_alsasink_prepare()
941 alsa_detect_channels_mapping (GST_OBJECT (alsa), alsa->handle, spec, in gst_alsasink_prepare()
942 alsa->channels, GST_AUDIO_BASE_SINK (alsa)->ringbuffer); in gst_alsasink_prepare()
950 GST_ELEMENT_ERROR (alsa, RESOURCE, OPEN_WRITE, (NULL), in gst_alsasink_prepare()
956 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in gst_alsasink_prepare()
962 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in gst_alsasink_prepare()
968 GST_ELEMENT_ERROR (alsa, RESOURCE, SETTINGS, (NULL), in gst_alsasink_prepare()
977 GstAlsaSink *alsa; in gst_alsasink_unprepare() local
979 alsa = GST_ALSA_SINK (asink); in gst_alsasink_unprepare()
981 snd_pcm_drop (alsa->handle); in gst_alsasink_unprepare()
982 snd_pcm_hw_free (alsa->handle); in gst_alsasink_unprepare()
990 GstAlsaSink *alsa = GST_ALSA_SINK (asink); in gst_alsasink_close() local
993 if (alsa->handle) { in gst_alsasink_close()
994 snd_pcm_close (alsa->handle); in gst_alsasink_close()
995 alsa->handle = NULL; in gst_alsasink_close()
997 gst_caps_replace (&alsa->cached_caps, NULL); in gst_alsasink_close()
1008 xrun_recovery (GstAlsaSink * alsa, snd_pcm_t * handle, gint err) in xrun_recovery() argument
1010 GST_WARNING_OBJECT (alsa, "xrun recovery %d: %s", err, g_strerror (-err)); in xrun_recovery()
1015 GST_WARNING_OBJECT (alsa, in xrun_recovery()
1018 gst_audio_base_sink_report_device_failure (GST_AUDIO_BASE_SINK (alsa)); in xrun_recovery()
1027 GST_WARNING_OBJECT (alsa, in xrun_recovery()
1032 gst_audio_base_sink_report_device_failure (GST_AUDIO_BASE_SINK (alsa)); in xrun_recovery()
1041 GstAlsaSink *alsa; in gst_alsasink_write() local
1046 alsa = GST_ALSA_SINK (asink); in gst_alsasink_write()
1048 if (alsa->iec958 && alsa->need_swap) { in gst_alsasink_write()
1060 cptr = length / alsa->bpf; in gst_alsasink_write()
1066 err = snd_pcm_wait (alsa->handle, (4 * alsa->period_time / 1000)); in gst_alsasink_write()
1071 err = snd_pcm_writei (alsa->handle, ptr, cptr); in gst_alsasink_write()
1081 } else if (xrun_recovery (alsa, alsa->handle, err) < 0) { in gst_alsasink_write()
1091 } else if (err == 0 && alsa->hw_support_pause) { in gst_alsasink_write()
1093 if (snd_pcm_state (alsa->handle) == SND_PCM_STATE_PAUSED) in gst_alsasink_write()
1098 ptr += snd_pcm_frames_to_bytes (alsa->handle, err); in gst_alsasink_write()
1103 return length - (cptr * alsa->bpf); in gst_alsasink_write()
1122 GstAlsaSink *alsa; in gst_alsasink_delay() local
1126 alsa = GST_ALSA_SINK (asink); in gst_alsasink_delay()
1129 if (alsa->is_paused == TRUE) { in gst_alsasink_delay()
1130 delay = alsa->pos_in_buffer; in gst_alsasink_delay()
1131 alsa->is_paused = FALSE; in gst_alsasink_delay()
1132 alsa->after_paused = TRUE; in gst_alsasink_delay()
1134 if (alsa->after_paused == TRUE) { in gst_alsasink_delay()
1135 delay = alsa->pos_in_buffer; in gst_alsasink_delay()
1136 alsa->after_paused = FALSE; in gst_alsasink_delay()
1138 res = snd_pcm_delay (alsa->handle, &delay); in gst_alsasink_delay()
1144 GST_DEBUG_OBJECT (alsa, "snd_pcm_delay returned %d", res); in gst_alsasink_delay()
1149 GST_WARNING_OBJECT (alsa, "snd_pcm_delay returned negative delay"); in gst_alsasink_delay()
1159 GstAlsaSink *alsa; in gst_alsasink_pause() local
1163 alsa = GST_ALSA_SINK (asink); in gst_alsasink_pause()
1165 if (alsa->hw_support_pause == TRUE) { in gst_alsasink_pause()
1167 snd_pcm_delay (alsa->handle, &delay); in gst_alsasink_pause()
1168 alsa->pos_in_buffer = delay; in gst_alsasink_pause()
1169 CHECK (snd_pcm_pause (alsa->handle, 1), pause_error); in gst_alsasink_pause()
1170 GST_DEBUG_OBJECT (alsa, "pause done"); in gst_alsasink_pause()
1171 alsa->is_paused = TRUE; in gst_alsasink_pause()
1181 GST_ERROR_OBJECT (alsa, "alsa-pause: pcm pause error: %s", in gst_alsasink_pause()
1191 GstAlsaSink *alsa; in gst_alsasink_resume() local
1194 alsa = GST_ALSA_SINK (asink); in gst_alsasink_resume()
1196 if (alsa->hw_support_pause == TRUE) { in gst_alsasink_resume()
1198 CHECK (snd_pcm_pause (alsa->handle, 0), resume_error); in gst_alsasink_resume()
1199 GST_DEBUG_OBJECT (alsa, "resume done"); in gst_alsasink_resume()
1207 GST_ERROR_OBJECT (alsa, "alsa-resume: pcm resume error: %s", in gst_alsasink_resume()
1217 GstAlsaSink *alsa; in gst_alsasink_stop() local
1220 alsa = GST_ALSA_SINK (asink); in gst_alsasink_stop()
1223 GST_DEBUG_OBJECT (alsa, "drop"); in gst_alsasink_stop()
1224 CHECK (snd_pcm_drop (alsa->handle), drop_error); in gst_alsasink_stop()
1225 GST_DEBUG_OBJECT (alsa, "prepare"); in gst_alsasink_stop()
1226 CHECK (snd_pcm_prepare (alsa->handle), prepare_error); in gst_alsasink_stop()
1227 GST_DEBUG_OBJECT (alsa, "stop done"); in gst_alsasink_stop()
1235 GST_ERROR_OBJECT (alsa, "alsa-stop: pcm drop error: %s", in gst_alsasink_stop()
1242 GST_ERROR_OBJECT (alsa, "alsa-stop: pcm prepare error: %s", in gst_alsasink_stop()
1252 GstAlsaSink *alsa; in gst_alsasink_payload() local
1254 alsa = GST_ALSA_SINK (sink); in gst_alsasink_payload()
1256 if (alsa->iec958) { in gst_alsasink_payload()