diff --git a/configure b/configure
index 3fceb31..a0317d4 100755
|
a
|
b
|
HAVE_LIST=" |
| 1085 | 1085 | lrint |
| 1086 | 1086 | lrintf |
| 1087 | 1087 | lzo1x_999_compress |
| | 1088 | mach_semaphore_h |
| 1088 | 1089 | machine_ioctl_bt848_h |
| 1089 | 1090 | machine_ioctl_meteor_h |
| 1090 | 1091 | malloc_h |
| … |
… |
ffserver_extralibs='$ldl' |
| 1500 | 1501 | |
| 1501 | 1502 | doc_deps="texi2html" |
| 1502 | 1503 | |
| | 1504 | mach_semaphore_deps="mach_semaphore_h" |
| | 1505 | |
| 1503 | 1506 | # tests |
| 1504 | 1507 | |
| 1505 | 1508 | test_deps(){ |
| … |
… |
check_header soundcard.h |
| 2951 | 2954 | |
| 2952 | 2955 | enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound |
| 2953 | 2956 | |
| | 2957 | check_header mach/semaphore.h |
| | 2958 | |
| 2954 | 2959 | enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack |
| 2955 | 2960 | |
| 2956 | 2961 | enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio |
diff --git a/libavdevice/jack_audio.c b/libavdevice/jack_audio.c
index 9062e7f..274380d 100644
|
a
|
b
|
|
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | #include "config.h" |
| | 24 | #ifdef HAVE_MACH_SEMAPHORE_H |
| | 25 | #include <mach/task.h> |
| | 26 | #include <mach/semaphore.h> |
| | 27 | #endif |
| 24 | 28 | #include <semaphore.h> |
| | 29 | |
| 25 | 30 | #include <jack/jack.h> |
| 26 | 31 | |
| 27 | 32 | #include "libavutil/log.h" |
| … |
… |
|
| 38 | 43 | typedef struct { |
| 39 | 44 | jack_client_t * client; |
| 40 | 45 | int activated; |
| | 46 | #ifdef HAVE_MACH_SEMAPHORE_H |
| | 47 | semaphore_t packet_count; |
| | 48 | #else |
| 41 | 49 | sem_t packet_count; |
| | 50 | #endif |
| 42 | 51 | jack_nframes_t sample_rate; |
| 43 | 52 | jack_nframes_t buffer_size; |
| 44 | 53 | jack_port_t ** ports; |
| … |
… |
static int process_callback(jack_nframes_t nframes, void *arg) |
| 99 | 108 | |
| 100 | 109 | /* Send the now filled packet back, and increase packet counter */ |
| 101 | 110 | av_fifo_generic_write(self->filled_pkts, &pkt, sizeof(pkt), NULL); |
| | 111 | #ifdef HAVE_MACH_SEMAPHORE_H |
| | 112 | semaphore_signal(self->packet_count); |
| | 113 | #else |
| 102 | 114 | sem_post(&self->packet_count); |
| | 115 | #endif |
| 103 | 116 | |
| 104 | 117 | return 0; |
| 105 | 118 | } |
| … |
… |
static int start_jack(AVFormatContext *context, AVFormatParameters *params) |
| 150 | 163 | return AVERROR(EIO); |
| 151 | 164 | } |
| 152 | 165 | |
| | 166 | #ifdef HAVE_MACH_SEMAPHORE_H |
| | 167 | semaphore_create(TASK_NULL, &self->packet_count, 0, 0); |
| | 168 | #else |
| 153 | 169 | sem_init(&self->packet_count, 0, 0); |
| | 170 | #endif |
| 154 | 171 | |
| 155 | 172 | self->sample_rate = jack_get_sample_rate(self->client); |
| 156 | 173 | self->nports = params->channels; |
| … |
… |
static void stop_jack(JackData *self) |
| 212 | 229 | jack_deactivate(self->client); |
| 213 | 230 | jack_client_close(self->client); |
| 214 | 231 | } |
| | 232 | #ifdef HAVE_MACH_SEMAPHORE_H |
| | 233 | semaphore_destroy(TASK_NULL, self->packet_count); |
| | 234 | #else |
| 215 | 235 | sem_destroy(&self->packet_count); |
| | 236 | #endif |
| 216 | 237 | free_pkt_fifo(self->new_pkts); |
| 217 | 238 | free_pkt_fifo(self->filled_pkts); |
| 218 | 239 | av_freep(&self->ports); |
| … |
… |
static int audio_read_header(AVFormatContext *context, AVFormatParameters *param |
| 253 | 274 | static int audio_read_packet(AVFormatContext *context, AVPacket *pkt) |
| 254 | 275 | { |
| 255 | 276 | JackData *self = context->priv_data; |
| | 277 | #ifdef HAVE_MACH_SEMAPHORE_H |
| | 278 | mach_timespec_t timeout = {0, 0}; |
| | 279 | #else |
| 256 | 280 | struct timespec timeout = {0, 0}; |
| | 281 | #endif |
| 257 | 282 | int test; |
| 258 | 283 | |
| 259 | 284 | /* Activate the JACK client on first packet read. Activating the JACK client |
| … |
… |
static int audio_read_packet(AVFormatContext *context, AVPacket *pkt) |
| 274 | 299 | |
| 275 | 300 | /* Wait for a packet comming back from process_callback(), if one isn't available yet */ |
| 276 | 301 | timeout.tv_sec = av_gettime() / 1000000 + 2; |
| | 302 | #ifdef HAVE_MACH_SEMAPHORE_H |
| | 303 | if (semaphore_timedwait(self->packet_count, timeout)) { |
| | 304 | #else |
| 277 | 305 | if (sem_timedwait(&self->packet_count, &timeout)) { |
| | 306 | #endif |
| 278 | 307 | if (errno == ETIMEDOUT) { |
| 279 | 308 | av_log(context, AV_LOG_ERROR, |
| 280 | 309 | "Input error: timed out when waiting for JACK process callback output\n"); |