My suggestion is something like this:
diff -urN DirectFB-0.9.25.orig/src/core/screens.c
DirectFB-0.9.25/src/core/screens.c
--- DirectFB-0.9.25.orig/src/core/screens.c 2006-07-26 16:21:53.000000000
+0100
+++ DirectFB-0.9.25/src/core/screens.c 2006-07-26 16:27:07.000000000 +0100
@@ -151,6 +151,7 @@
/* Initialize mixers. */
if (shared->description.mixers) {
int i;
+ int index = 0;
D_ASSERT( funcs->InitMixer != NULL );
D_ASSERT( funcs->SetMixerConfig != NULL );
@@ -158,21 +159,27 @@
shared->mixers = SHCALLOC( pool, shared->description.mixers,
sizeof(CoreScreenMixer) );
for (i=0; i<shared->description.mixers; i++) {
- funcs->InitMixer( screen,
- screen->driver_data,
- shared->screen_data, i,
- &shared->mixers[i].description,
- &shared->mixers[i].configuration );
- funcs->SetMixerConfig( screen,
- screen->driver_data,
- shared->screen_data, i,
- &shared->mixers[i].configuration
);
+ ret = funcs->InitMixer( screen,
+ screen->driver_data,
+ shared->screen_data, i,
+
&shared->mixers[index].description,
+
&shared->mixers[index].configuration );
+ if(ret == DFB_OK)
+ {
+ funcs->SetMixerConfig( screen,
+ screen->driver_data,
+ shared->screen_data, i,
+
&shared->mixers[index].configuration );
+ index++;
+ }
+ shared->description.mixers = index;
}
}
/* Initialize encoders. */
if (shared->description.encoders) {
int i;
+ int index = 0;
D_ASSERT( funcs->InitEncoder != NULL );
D_ASSERT( funcs->SetEncoderConfig != NULL );
@@ -180,21 +187,27 @@
shared->encoders = SHCALLOC( pool,
shared->description.encoders,
sizeof(CoreScreenEncoder) );
for (i=0; i<shared->description.encoders; i++) {
- funcs->InitEncoder( screen,
- screen->driver_data,
- shared->screen_data, i,
- &shared->encoders[i].description,
- &shared->encoders[i].configuration
);
- funcs->SetEncoderConfig( screen,
- screen->driver_data,
- shared->screen_data, i,
-
&shared->encoders[i].configuration );
+ ret = funcs->InitEncoder( screen,
+ screen->driver_data,
+ shared->screen_data, i,
+
&shared->encoders[index].description,
+
&shared->encoders[index].configuration );
+ if(ret == DFB_OK)
+ {
+ funcs->SetEncoderConfig( screen,
+ screen->driver_data,
+ shared->screen_data, i,
+
&shared->encoders[index].configuration );
+ index++;
+ }
+ shared->description.encoders = index;
}
}
/* Initialize outputs. */
if (shared->description.outputs) {
int i;
+ int index = 0;
D_ASSERT( funcs->InitOutput != NULL );
D_ASSERT( funcs->SetOutputConfig != NULL );
@@ -202,15 +215,20 @@
shared->outputs = SHCALLOC( pool,
shared->description.outputs,
sizeof(CoreScreenOutput) );
for (i=0; i<shared->description.outputs; i++) {
- funcs->InitOutput( screen,
- screen->driver_data,
- shared->screen_data, i,
- &shared->outputs[i].description,
- &shared->outputs[i].configuration );
- funcs->SetOutputConfig( screen,
- screen->driver_data,
- shared->screen_data, i,
-
&shared->outputs[i].configuration );
+ ret = funcs->InitOutput( screen,
+ screen->driver_data,
+ shared->screen_data, i,
+
&shared->outputs[index].description,
+
&shared->outputs[index].configuration );
+ if(ret == DFB_OK)
+ {
+ funcs->SetOutputConfig( screen,
+ screen->driver_data,
+ shared->screen_data, i,
+
&shared->outputs[index].configuration );
+ index++;
+ }
+ shared->description.outputs = index;
}
}
This way the description is actually an indication of live encoders / mixers
/ outputs in the system instead of the requested ones. There should be no
memory leak as the SHFREE will clear up the MALLOC properly. Obviously
there could be more malloced than is used but i do not think that is a
problem.
What do people think?
This is based on the official 0.9.25.1 release and if you guys like it maybe
it can be put in, If it is out of date I could update the patch to the
latest CVS version but i need to know what you think!
Cheers
Dan
--
View this message in context:
http://www.nabble.com/Problems-with-multiple-Encoders-when-setting-screen-Description-tf2004220.html#a5516609
Sent from the DirectFB Dev forum at Nabble.com.
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev