Commit 085f64d4 authored by Sandrine Avakian's avatar Sandrine Avakian

Audio filters update : replacing ms_filter_new/ ms_filter_new_from_desc by...

Audio filters update : replacing ms_filter_new/ ms_filter_new_from_desc by ms_factory_create_filter/ms_factory_create_filter_from_desc.
Fixing small issue in audio stream.c and text stream (Windows crash on audio_stream_stop and text_stream_stop).
parent de6228c7
......@@ -1093,7 +1093,7 @@ MSFilterDesc aq_write_desc = {
MSFilter *ms_aq_read_new(MSSndCard * card)
{
MSFilter *f = ms_filter_new_from_desc(&aq_read_desc);
MSFilter *f = ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card), &aq_read_desc);
AqSndDsCard *wc = (AqSndDsCard *) card->data;
AQData *d = (AQData *) f->data;
d->uidname = NULL;
......@@ -1109,7 +1109,7 @@ MSFilter *ms_aq_read_new(MSSndCard * card)
MSFilter *ms_aq_write_new(MSSndCard * card)
{
MSFilter *f = ms_filter_new_from_desc(&aq_write_desc);
MSFilter *f = ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card), &aq_write_desc);
AqSndDsCard *wc = (AqSndDsCard *) card->data;
AQData *d = (AQData *) f->data;
d->uidname = NULL;
......
......@@ -186,11 +186,11 @@ static void arts_card_detect(MSSndCardManager *m){
}
static MSFilter * arts_card_create_reader(MSSndCard *card){
return ms_filter_new(MS_ARTS_READ_ID);
return ms_factory_create_filter(ms_snd_card_factory_get(card), MS_ARTS_READ_ID);
}
static MSFilter * arts_card_create_writer(MSSndCard *card){
return ms_filter_new(MS_ARTS_WRITE_ID);
return ms_factory_create_filter(ms_snd_card_factory_get(card), MS_ARTS_WRITE_ID);
}
MSSndCardDesc arts_card_desc={
......
......@@ -921,7 +921,7 @@ MSFilterDesc au_write_desc={
static MSFilter *ms_au_read_new(MSSndCard *mscard){
ms_debug("ms_au_read_new");
au_card_t* card=(au_card_t*)(mscard->data);
MSFilter *f=ms_filter_new_from_desc(&au_read_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(mscard), &au_read_desc);
au_filter_read_data_t *d=ms_new0(au_filter_read_data_t,1);
qinit(&d->rq);
d->readTimeStamp.mSampleTime=-1;
......@@ -935,7 +935,7 @@ static MSFilter *ms_au_read_new(MSSndCard *mscard){
static MSFilter *ms_au_write_new(MSSndCard *mscard){
ms_debug("ms_au_write_new");
au_card_t* card=(au_card_t*)(mscard->data);
MSFilter *f=ms_filter_new_from_desc(&au_write_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(mscard), &au_write_desc);
au_filter_write_data_t *d=ms_new0(au_filter_write_data_t,1);
d->bufferizer= ms_bufferizer_new();
ms_mutex_init(&d->mutex,NULL);
......
......@@ -543,14 +543,14 @@ MSFilterDesc oss_write_desc={
};
MSFilter *ms_oss_read_new(MSSndCard *card){
MSFilter *f=ms_filter_new_from_desc(&oss_read_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card),&oss_read_desc);
f->data=card;
return f;
}
MSFilter *ms_oss_write_new(MSSndCard *card){
MSFilter *f=ms_filter_new_from_desc(&oss_write_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card),&oss_write_desc);
f->data=card;
return f;
}
......
......@@ -580,14 +580,14 @@ MSFilterDesc pasnd_write_desc={
};
MSFilter *ms_pasnd_read_new(MSSndCard *card){
MSFilter *f=ms_filter_new_from_desc(&pasnd_read_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card), &pasnd_read_desc);
f->data=card;
return f;
}
MSFilter *ms_pasnd_write_new(MSSndCard *card){
MSFilter *f=ms_filter_new_from_desc(&pasnd_write_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card), &pasnd_write_desc);
f->data=card;
return f;
}
......
......@@ -798,7 +798,7 @@ static MSFilterDesc pulse_write_desc={
static MSFilter *pulse_card_create_reader(MSSndCard *card) {
PAData *card_data = (PAData *)card->data;
MSFilter *f=ms_filter_new_from_desc (&pulse_read_desc);
MSFilter *f=ms_factory_create_filter_from_desc((card), &pulse_read_desc);
Stream *s = (Stream *)f->data;
s->dev = ms_strdup(card_data->pa_id_source); /* add pulse audio card id to connect the stream to the correct card */
return f;
......@@ -806,7 +806,7 @@ static MSFilter *pulse_card_create_reader(MSSndCard *card) {
static MSFilter *pulse_card_create_writer(MSSndCard *card) {
PAData *card_data = (PAData *)card->data;
MSFilter *f=ms_filter_new_from_desc (&pulse_write_desc);
MSFilter *f=ms_factory_create_filter_from_desc((card), &pulse_write_desc);
Stream *s = (Stream *)f->data;
s->dev = ms_strdup(card_data->pa_id_sink); /* add pulse audio card id to connect the stream to the correct card */
return f;
......
......@@ -94,7 +94,7 @@ static int ms_qsa_read_set_sample_rate(MSFilter *f, void *arg);
*****************************************************************************/
static MSFilter * ms_qsa_read_new(MSSndCard *card) {
MSFilter *f = ms_filter_new_from_desc(&ms_qsa_read_desc);
MSFilter *f = ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card), &ms_qsa_read_desc);
MSQSAReadData *d = (MSQSAReadData *)f->data;
snd_pcm_t *handle;
int err;
......@@ -408,7 +408,7 @@ static int ms_qsa_write_set_sample_rate(MSFilter *f, void *arg);
*****************************************************************************/
static MSFilter * ms_qsa_write_new(MSSndCard *card) {
MSFilter *f = ms_filter_new_from_desc(&ms_qsa_write_desc);
MSFilter *f = ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card), &ms_qsa_write_desc);
MSQSAWriteData *d = (MSQSAWriteData *)f->data;
snd_pcm_t *handle;
int err;
......
......@@ -956,14 +956,14 @@ MSFilterDesc winsnd_write_desc={
};
MSFilter *ms_winsnd_read_new(MSSndCard *card){
MSFilter *f=ms_filter_new_from_desc(&winsnd_read_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card),&winsnd_read_desc);
f->data=card;
return f;
}
MSFilter *ms_winsnd_write_new(MSSndCard *card){
MSFilter *f=ms_filter_new_from_desc(&winsnd_write_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card),&winsnd_write_desc);
f->data=card;
return f;
}
......
......@@ -1573,7 +1573,7 @@ MSFilterDesc winsnd_write_desc={
};
MSFilter *ms_winsnd_read_new(MSSndCard *card){
MSFilter *f=ms_filter_new_from_desc(&winsnd_read_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card), &winsnd_read_desc);
WinSndCard *wc=(WinSndCard*)card->data;
WinSnd *d=(WinSnd*)f->data;
d->dev_id=wc->in_devid;
......@@ -1582,7 +1582,7 @@ MSFilter *ms_winsnd_read_new(MSSndCard *card){
MSFilter *ms_winsnd_write_new(MSSndCard *card){
MSFilter *f=ms_filter_new_from_desc(&winsnd_write_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card), &winsnd_write_desc);
WinSndCard *wc=(WinSndCard*)card->data;
WinSnd *d=(WinSnd*)f->data;
d->dev_id=wc->out_devid;
......
......@@ -713,7 +713,7 @@ MSFilterDesc winsnd_write_desc={
};
MSFilter *ms_winsnd_read_new(MSSndCard *card){
MSFilter *f=ms_filter_new_from_desc(&winsnd_read_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card), &winsnd_read_desc);
WinSndCard *wc=(WinSndCard*)card->data;
WinSnd *d=(WinSnd*)f->data;
d->dev_id=wc->in_devid;
......@@ -722,7 +722,7 @@ MSFilter *ms_winsnd_read_new(MSSndCard *card){
MSFilter *ms_winsnd_write_new(MSSndCard *card){
MSFilter *f=ms_filter_new_from_desc(&winsnd_write_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card), &winsnd_write_desc);
WinSndCard *wc=(WinSndCard*)card->data;
WinSnd *d=(WinSnd*)f->data;
d->dev_id=wc->out_devid;
......
......@@ -32,13 +32,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <msacm.h>
#include <dsound.h>
#include <dsconf.h>
#include <dsconf.h>
const GUID GUID_DSCFX_MS_AEC = {0xcdebb919, 0x379a, 0x488a, {0x87, 0x65, 0xf5, 0x3c, 0xfd, 0x36, 0xde, 0x40}};
const GUID GUID_DSCFX_CLASS_AEC = {0xBF963D80L, 0xC559, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
const GUID CLSID_DirectSoundPrivate= { 0x11ab3ec0, 0x25ec, 0x11d1, {0xa4, 0xd8, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca}};
const GUID DSPROPSETID_DirectSoundDevice = {0x84624f82, 0x25ec, 0x11d1, {0xa4, 0xd8, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca}};
const GUID CLSID_DirectSoundPrivate= { 0x11ab3ec0, 0x25ec, 0x11d1, {0xa4, 0xd8, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca}};
const GUID DSPROPSETID_DirectSoundDevice = {0x84624f82, 0x25ec, 0x11d1, {0xa4, 0xd8, 0x0, 0xc0, 0x4f, 0xc2, 0x8a, 0xca}};
#define WINSNDDS_MINIMUMBUFFER 5
......@@ -67,73 +67,73 @@ typedef struct WinSndDsCard{
int removed;
}WinSndDsCard;
static BOOL GetWaveIdFromDSoundGUID( GUID i_sGUID, DWORD *dwWaveID)
{
LPKSPROPERTYSET pKsPropertySet = NULL;
LPCLASSFACTORY pClassFactory = NULL;
HRESULT hr;
BOOL retval = FALSE;
PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA psDirectSoundDeviceDescription = NULL;
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA sDirectSoundDeviceDescription;
memset(&sDirectSoundDeviceDescription,0,sizeof(sDirectSoundDeviceDescription));
hr = ms_DllGetClassObject (CLSID_DirectSoundPrivate, IID_IClassFactory, (LPVOID *)&pClassFactory );
if(SUCCEEDED(hr))
{
hr = pClassFactory->CreateInstance ( NULL, IID_IKsPropertySet, (LPVOID *)&pKsPropertySet );
}
// Release the class factory
if(pClassFactory)
{
pClassFactory->Release();
}
if(SUCCEEDED(hr))
{
ULONG ulBytesReturned = 0;
sDirectSoundDeviceDescription.DeviceId = i_sGUID;
// On the first call the final size is unknown so pass the size of the struct in order to receive
// "Type" and "DataFlow" values, ulBytesReturned will be populated with bytes required for struct+strings.
hr = pKsPropertySet->Get(DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
NULL,
0,
&sDirectSoundDeviceDescription,
sizeof(sDirectSoundDeviceDescription),
&ulBytesReturned
);
if (ulBytesReturned)
{
// On the first call it notifies us of the required amount of memory in order to receive the strings.
// Allocate the required memory, the strings will be pointed to the memory space directly after the struct.
psDirectSoundDeviceDescription = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA)new BYTE[ulBytesReturned];
*psDirectSoundDeviceDescription = sDirectSoundDeviceDescription;
hr = pKsPropertySet->Get(DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
NULL,
0,
psDirectSoundDeviceDescription,
ulBytesReturned,
&ulBytesReturned
);
*dwWaveID = psDirectSoundDeviceDescription->WaveDeviceId;
delete [] psDirectSoundDeviceDescription;
retval = TRUE;
}
pKsPropertySet->Release();
}
return retval;
}
static BOOL GetWaveIdFromDSoundGUID( GUID i_sGUID, DWORD *dwWaveID)
{
LPKSPROPERTYSET pKsPropertySet = NULL;
LPCLASSFACTORY pClassFactory = NULL;
HRESULT hr;
BOOL retval = FALSE;
PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA psDirectSoundDeviceDescription = NULL;
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA sDirectSoundDeviceDescription;
memset(&sDirectSoundDeviceDescription,0,sizeof(sDirectSoundDeviceDescription));
hr = ms_DllGetClassObject (CLSID_DirectSoundPrivate, IID_IClassFactory, (LPVOID *)&pClassFactory );
if(SUCCEEDED(hr))
{
hr = pClassFactory->CreateInstance ( NULL, IID_IKsPropertySet, (LPVOID *)&pKsPropertySet );
}
// Release the class factory
if(pClassFactory)
{
pClassFactory->Release();
}
if(SUCCEEDED(hr))
{
ULONG ulBytesReturned = 0;
sDirectSoundDeviceDescription.DeviceId = i_sGUID;
// On the first call the final size is unknown so pass the size of the struct in order to receive
// "Type" and "DataFlow" values, ulBytesReturned will be populated with bytes required for struct+strings.
hr = pKsPropertySet->Get(DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
NULL,
0,
&sDirectSoundDeviceDescription,
sizeof(sDirectSoundDeviceDescription),
&ulBytesReturned
);
if (ulBytesReturned)
{
// On the first call it notifies us of the required amount of memory in order to receive the strings.
// Allocate the required memory, the strings will be pointed to the memory space directly after the struct.
psDirectSoundDeviceDescription = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA)new BYTE[ulBytesReturned];
*psDirectSoundDeviceDescription = sDirectSoundDeviceDescription;
hr = pKsPropertySet->Get(DSPROPSETID_DirectSoundDevice,
DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
NULL,
0,
psDirectSoundDeviceDescription,
ulBytesReturned,
&ulBytesReturned
);
*dwWaveID = psDirectSoundDeviceDescription->WaveDeviceId;
delete [] psDirectSoundDeviceDescription;
retval = TRUE;
}
pKsPropertySet->Release();
}
return retval;
}
static void winsnddscard_set_level(MSSndCard *card, MSSndCardMixerElem e, int percent){
WinSndDsCard *d=(WinSndDsCard*)card->data;
......@@ -1848,7 +1848,7 @@ MSFilterDesc winsndds_write_desc={
};
MSFilter *ms_winsndds_read_new(MSSndCard *card){
MSFilter *f=ms_filter_new_from_desc(&winsndds_read_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card), &winsndds_read_desc);
WinSndDsCard *wc=(WinSndDsCard*)card->data;
WinSndDs *d=(WinSndDs*)f->data;
d->dev_id=wc->in_devid;
......@@ -1859,7 +1859,7 @@ MSFilter *ms_winsndds_read_new(MSSndCard *card){
MSFilter *ms_winsndds_write_new(MSSndCard *card){
MSFilter *f=ms_filter_new_from_desc(&winsndds_write_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_snd_card_factory_get(card), &winsndds_write_desc);
WinSndDsCard *wc=(WinSndDsCard*)card->data;
WinSndDs *d=(WinSndDs*)f->data;
d->dev_id=wc->out_devid;
......
......@@ -129,6 +129,7 @@ void ms_snd_card_manager_prepend_cards(MSSndCardManager *m, MSList *l) {
else m->cards = lcopy;
for (elem = l; elem != NULL; elem = elem->next) {
MSSndCard *card = (MSSndCard *)elem->data;
ms_snd_card_set_manager(m, card);
ms_message("Card '%s' added", ms_snd_card_get_string_id(card));
}
}
......
......@@ -418,7 +418,7 @@ MSFilterDesc ms_bb10_capture_desc = {
MS_FILTER_DESC_EXPORT(ms_bb10_capture_desc)
static MSFilter *bb10camera_create_reader(MSWebCam *obj) {
MSFilter *f = ms_filter_new_from_desc(&ms_bb10_capture_desc);
MSFilter *f = ms_factory_create_filter_from_desc(ms_web_cam_factory_get(obj), &ms_bb10_capture_desc);
BB10Capture *d = (BB10Capture*) f->data;
if (strcmp(obj->name, "BB10 Rear Camera") == 0) {
d->camera = CAMERA_UNIT_REAR;
......
......@@ -770,7 +770,7 @@ static void ms_v4ios_cam_init(MSWebCam *cam) {
static MSFilter *ms_v4ios_create_reader(MSWebCam *obj) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
MSFilter *f= ms_filter_new_from_desc(&ms_ioscapture_desc);
MSFilter *f= ms_factory_create_filter_from_desc(ms_web_cam_factory_get(obj),(&ms_ioscapture_desc);
[((IOSCapture*)f->data) openDevice:obj->data];
[pool drain];
return f;
......
......@@ -154,7 +154,6 @@ static void mire_cam_init(MSWebCam *cam){
}
static MSFilter *mire_create_reader(MSWebCam *obj, MSFactory * factory){
//return ms_filter_new_from_desc(&ms_mire_desc);
return ms_factory_create_filter_from_desc(factory, &ms_mire_desc);
}
......
......@@ -1022,7 +1022,7 @@ MSFilterDesc ms_v4l_desc={
MS_FILTER_DESC_EXPORT(ms_v4l_desc)
static MSFilter *v4l_create_reader(MSWebCam *obj){
MSFilter *f=ms_filter_new_from_desc(&ms_v4l_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_web_cam_factory_get(obj),(&ms_v4l_desc);
V4lState *s=(V4lState*)f->data;
v4l_set_devfile(f,obj->name);
s->force_v1=TRUE;
......
......@@ -852,7 +852,7 @@ MSFilterDesc ms_v4l2_desc={
MS_FILTER_DESC_EXPORT(ms_v4l2_desc)
static MSFilter *msv4l2_create_reader(MSWebCam *obj){
MSFilter *f=ms_filter_new(MS_V4L2_CAPTURE_ID);
MSFilter *f=ms_factory_create_filter(ms_web_cam_factory_get(obj),(MS_V4L2_CAPTURE_ID);
msv4l2_set_devfile(f,obj->name);
return f;
}
......
......@@ -510,9 +510,6 @@ static void static_image_cam_init(MSWebCam *cam){
}
//static MSFilter *static_image_create_reader(MSWebCam *obj){
// return ms_filter_new_from_desc(&ms_static_image_desc);
//}
static MSFilter *static_image_create_reader(MSWebCam *obj, MSFactory* factory){
return ms_factory_create_filter_from_desc(factory, &ms_static_image_desc);
......
......@@ -474,7 +474,7 @@ static void ms_vfw_cam_init(MSWebCam *cam){
static MSFilter *ms_vfw_create_reader(MSWebCam *obj){
MSFilter *f= ms_filter_new_from_desc(&ms_vfw_desc);
MSFilter *f= ms_factory_create_filter_from_desc(ms_web_cam_factory_get(obj), (&ms_vfw_desc);
VfwState *s=(VfwState*)f->data;
s->eng=(VfwEngine*)obj->data;
return f;
......
......@@ -1417,7 +1417,7 @@ MSFilterDesc ms_v4w_desc={
MS_FILTER_DESC_EXPORT(ms_v4w_desc)
static MSFilter *vfw_create_reader(MSWebCam *obj){
MSFilter *f=ms_filter_new_from_desc(&ms_v4w_desc);
MSFilter *f=ms_factory_create_filter_from_desc(ms_web_cam_factory_get(obj), (&ms_v4w_desc);
v4w_set_name(f,obj->name);
return f;
}
......
......@@ -53,7 +53,6 @@ MSAudioConference * ms_audio_conference_new(const MSAudioConferenceParams *param
ms_ticker_set_name(obj->ticker,"Audio conference MSTicker");
ms_ticker_set_priority(obj->ticker,__ms_get_default_prio(FALSE));
obj->mixer = ms_factory_create_filter(factory, MS_AUDIO_MIXER_ID);
//obj->mixer=ms_filter_new(MS_AUDIO_MIXER_ID);
obj->params=*params;
ms_filter_call_method(obj->mixer,MS_AUDIO_MIXER_ENABLE_CONFERENCE_MODE,&tmp);
ms_filter_call_method(obj->mixer,MS_FILTER_SET_SAMPLE_RATE,&obj->params.samplerate);
......
......@@ -1669,8 +1669,9 @@ void audio_stream_stop(AudioStream * stream){
* When the filter are destroyed, all their pending events in the event queue will be cancelled*/
evq = ms_factory_get_event_queue(stream->ms.factory);
if (evq) ms_event_queue_pump(evq);
audio_stream_free(stream);
ms_factory_log_statistics(stream->ms.factory);
audio_stream_free(stream);
// ms_filter_log_statistics();
}
......
......@@ -164,9 +164,9 @@ void text_stream_stop(TextStream *stream) {
ms_connection_helper_unlink(&h, stream->rttsink, 0, -1);
}
}
text_stream_free(stream);
ms_factory_log_statistics(stream->ms.factory);
text_stream_free(stream);
}
void text_stream_iterate(TextStream *stream) {
......
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