doc: add very basic libcdio documentation
[ffmpeg.git] / libavdevice / pulse_audio_enc.c
index b8c77db..bc4d1f0 100644 (file)
@@ -624,6 +624,7 @@ static int pulse_write_packet(AVFormatContext *h, AVPacket *pkt)
 {
     PulseData *s = h->priv_data;
     int ret;
+    int64_t writable_size;
 
     if (!pkt)
         return pulse_flash_stream(s);
@@ -646,7 +647,7 @@ static int pulse_write_packet(AVFormatContext *h, AVPacket *pkt)
         av_log(s, AV_LOG_ERROR, "PulseAudio stream is in invalid state.\n");
         goto fail;
     }
-    while (!pa_stream_writable_size(s->stream)) {
+    while (pa_stream_writable_size(s->stream) < s->minreq) {
         if (s->nonblocking) {
             pa_threaded_mainloop_unlock(s->mainloop);
             return AVERROR(EAGAIN);
@@ -658,6 +659,9 @@ static int pulse_write_packet(AVFormatContext *h, AVPacket *pkt)
         av_log(s, AV_LOG_ERROR, "pa_stream_write failed: %s\n", pa_strerror(ret));
         goto fail;
     }
+    if ((writable_size = pa_stream_writable_size(s->stream)) >= s->minreq)
+        avdevice_dev_to_app_control_message(h, AV_DEV_TO_APP_BUFFER_WRITABLE, &writable_size, sizeof(writable_size));
+
     pa_threaded_mainloop_unlock(s->mainloop);
 
     return 0;
@@ -677,7 +681,7 @@ static int pulse_write_frame(AVFormatContext *h, int stream_index,
                AVERROR(EINVAL) : 0;
 
     pkt.data     = (*frame)->data[0];
-    pkt.size     = (*frame)->nb_samples * av_get_bytes_per_sample((*frame)->format) * (*frame)->channels;
+    pkt.size     = (*frame)->nb_samples * av_get_bytes_per_sample((*frame)->format) * av_frame_get_channels(*frame);
     pkt.dts      = (*frame)->pkt_dts;
     pkt.duration = av_frame_get_pkt_duration(*frame);
     return pulse_write_packet(h, &pkt);