Commit 3e43a499 authored by jehan's avatar jehan
Browse files

Merge branch 'fast-io-unit'

Conflicts:
	src/msiounit.c
parents 6b90c8b6 d3995a09
......@@ -131,6 +131,7 @@ struct _MSSndCard{
char *id;
unsigned int capabilities;
void *data;
int preferred_sample_rate;
};
/**
......@@ -425,6 +426,26 @@ MS2_PUBLIC int ms_snd_card_set_control(MSSndCard *obj, MSSndCardControlElem e, i
*/
MS2_PUBLIC int ms_snd_card_get_control(MSSndCard *obj, MSSndCardControlElem e);
/**
* Get preferred sample rate
*
* @param obj A sound card object.
*
* Returns: return sample rate in khz
*/
MS2_PUBLIC int ms_snd_card_get_preferred_sample_rate(const MSSndCard *obj);
/**
* set preferred sample rate. The underlying card will try to avoid any resampling for this samplerate.
*
* @param obj A sound card object.
* @param rate sampling rate.
*
* Returns: 0 if successfull, <0 otherwise.
*/
MS2_PUBLIC int ms_snd_card_set_preferred_sample_rate(MSSndCard *obj,int rate);
/**
* Create a alsa card with user supplied pcm name and mixer name.
* @param pcmdev The pcm device name following alsa conventions (ex: plughw:0)
......
......@@ -114,7 +114,7 @@ libmediastreamer_la_SOURCES+=macsnd.c
endif
if BUILD_IOSIOUNIT
libmediastreamer_la_SOURCES+=msiounit.c
libmediastreamer_la_SOURCES+=msiounit.m
endif
if BUILD_MACAQSND
......
......@@ -76,13 +76,40 @@ static float gain_volume_out=1.0;
static bool gain_changed_in = true;
static bool gain_changed_out = true;
const char* aq_format_error(OSStatus status) {
switch (status) {
case kAudioQueueErr_InvalidBuffer: return "kAudioQueueErr_InvalidBuffer";
case kAudioQueueErr_BufferEmpty: return"kAudioQueueErr_BufferEmpty";
case kAudioQueueErr_DisposalPending: return"kAudioQueueErr_DisposalPending";
case kAudioQueueErr_InvalidProperty: return"kAudioQueueErr_InvalidProperty";
case kAudioQueueErr_InvalidPropertySize: return"kAudioQueueErr_InvalidPropertySize";
case kAudioQueueErr_InvalidParameter: return"kAudioQueueErr_InvalidParameter";
case kAudioQueueErr_CannotStart: return"kAudioQueueErr_CannotStart";
case kAudioQueueErr_InvalidDevice: return"kAudioQueueErr_InvalidDevice";
case kAudioQueueErr_BufferInQueue: return"kAudioQueueErr_BufferInQueue";
case kAudioQueueErr_InvalidRunState: return"kAudioQueueErr_InvalidRunState";
case kAudioQueueErr_InvalidQueueType: return"kAudioQueueErr_InvalidQueueType";
case kAudioQueueErr_Permissions: return"kAudioQueueErr_Permissions";
case kAudioQueueErr_InvalidPropertyValue: return"kAudioQueueErr_InvalidPropertyValue";
case kAudioQueueErr_PrimeTimedOut: return"kAudioQueueErr_PrimeTimedOut";
case kAudioQueueErr_CodecNotFound: return"kAudioQueueErr_CodecNotFound";
case kAudioQueueErr_InvalidCodecAccess: return"kAudioQueueErr_InvalidCodecAccess";
case kAudioQueueErr_QueueInvalidated: return"kAudioQueueErr_QueueInvalidated";
case kAudioQueueErr_RecordUnderrun: return"kAudioQueueErr_RecordUnderrun";
case kAudioQueueErr_EnqueueDuringReset: return"kAudioQueueErr_EnqueueDuringReset";
case kAudioQueueErr_InvalidOfflineMode: return"kAudioQueueErr_InvalidOfflineMode";
default:
return "unkown error code";
}
}
#ifdef __ios
#define CFStringRef void *
#define CFRelease(A) {}
#define CFStringGetCString(A, B, LEN, encoding) {}
#define CFStringCreateCopy(A, B) NULL
#define check_aqresult(aq,method) \
if (aq!=0) ms_error("AudioQueue error for %s: ret=%li",method,aq)
if (aq!=0) ms_error("AudioQueue error for %s: ret=%s",method,aq_format_error(aq))
#endif
typedef struct AQData {
......@@ -734,10 +761,11 @@ static void aq_start_r(MSFilter * f)
setupRead(f);
aqresult = AudioQueueStart(d->readQueue, NULL); // start time. NULL means ASAP.
if (aqresult != noErr) {
ms_error("AudioQueueStart -read- %ld", aqresult);
check_aqresult(aqresult,"AudioQueueStart - read");
if (aqresult == noErr) {
d->read_started = TRUE;
}
d->read_started = TRUE;
}
}
......@@ -882,7 +910,7 @@ static void aq_put(MSFilter * f, mblk_t * m)
(d->writeBufferByteSize * d->writeAudioFormat.mSampleRate / 1) /
d->devicewriteFormat.mSampleRate /
d->devicewriteFormat.mChannelsPerFrame;
if (d->write_started == FALSE && d->bufferizer->size >= len) {
if (d->write_started == FALSE && d->bufferizer->size >= len && d->curWriteBuffer<4) {
AudioQueueBufferRef curbuf = d->writeBuffers[d->curWriteBuffer];
#if 0
OSStatus err;
......@@ -914,10 +942,11 @@ static void aq_put(MSFilter * f, mblk_t * m)
OSStatus err;
err = AudioQueueStart(d->writeQueue, NULL // start time. NULL means ASAP.
);
if (err != noErr) {
ms_error("AudioQueueStart -write- %ld", err);
}
d->write_started = TRUE;
check_aqresult(err, "AudioQueueStart -write-");
if (err == noErr) {
d->write_started = TRUE;
}
}
}
......
......@@ -461,10 +461,12 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char
/* create ticker */
stream->ticker=ms_ticker_new();
ms_ticker_stop(stream->ticker); /*to make sure all filters are started after preprocessed this is very useful for filter sharing resource in both filter graph*/
ms_ticker_set_name(stream->ticker,"Audio MSTicker");
ms_ticker_set_priority(stream->ticker,__ms_get_default_prio(FALSE));
ms_ticker_attach(stream->ticker,stream->soundread);
ms_ticker_attach(stream->ticker,stream->rtprecv);
ms_ticker_start(stream->ticker);
stream->start_time=ms_time(NULL);
stream->is_beginning=TRUE;
......
This diff is collapsed.
......@@ -226,6 +226,15 @@ void ms_snd_card_destroy(MSSndCard *obj){
ms_free(obj);
}
int ms_snd_card_get_preferred_sample_rate(const MSSndCard *obj) {
return obj->preferred_sample_rate;
}
int ms_snd_card_set_preferred_sample_rate(MSSndCard *obj,int rate) {
obj->preferred_sample_rate=rate;
return 0;
}
#ifdef __linux
#ifndef __ALSA_ENABLED__
MSSndCard * ms_alsa_card_new_custom(const char *pcmdev, const char *mixdev){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment