Commit 070237de authored by David Fuhrmann's avatar David Fuhrmann

qtsound: fix crashes and some other issues

- do not misuse a block_t as a plain array
- use correct size of buffers
- do not overwrite buffer pointers of the second block_t, instead
copy the data

close #7886
parent 5d11e669
...@@ -131,7 +131,7 @@ vlc_module_end () ...@@ -131,7 +131,7 @@ vlc_module_end ()
/* /*
* Allocate storage for the interleaved audio data * Allocate storage for the interleaved audio data
*/ */
rawAudioData = block_Alloc(totalDataSize * sizeof(float)); rawAudioData = malloc(totalDataSize);
if (NULL == rawAudioData) { if (NULL == rawAudioData) {
msg_Err(p_qtsound, "Raw audiodata could not be allocated"); msg_Err(p_qtsound, "Raw audiodata could not be allocated");
return; return;
...@@ -181,10 +181,7 @@ vlc_module_end () ...@@ -181,10 +181,7 @@ vlc_module_end ()
- (void)freeAudioMem - (void)freeAudioMem
{ {
@synchronized (self) { FREENULL(rawAudioData);
if (rawAudioData)
block_Release(rawAudioData);
}
} }
- (mtime_t)getCurrentPts - (mtime_t)getCurrentPts
...@@ -499,41 +496,40 @@ static void Close(vlc_object_t *p_this) ...@@ -499,41 +496,40 @@ static void Close(vlc_object_t *p_this)
static int Demux(demux_t *p_demux) static int Demux(demux_t *p_demux)
{ {
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
block_t *p_blocka; block_t *p_blocka = nil;
NSAutoreleasePool *pool; NSAutoreleasePool *pool;
p_blocka = block_Alloc(p_sys->i_audio_max_buffer_size);
if(!p_blocka) {
msg_Err(p_demux, "cannot get audio block");
return 0;
}
@synchronized (p_sys->audiooutput) { @synchronized (p_sys->audiooutput) {
if ([p_sys->audiooutput checkCurrentAudioBuffer]) { if ([p_sys->audiooutput checkCurrentAudioBuffer]) {
p_blocka->i_buffer = p_blocka->i_size = [p_sys->audiooutput getCurrentTotalDataSize]; unsigned i_buffer_size = [p_sys->audiooutput getCurrentTotalDataSize];
p_blocka->p_buffer = p_blocka->p_start = [p_sys->audiooutput getCurrentAudioBufferData]; p_blocka = block_Alloc(i_buffer_size);
if(!p_blocka) {
msg_Err(p_demux, "cannot get audio block");
return 0;
}
memcpy(p_blocka->p_buffer, [p_sys->audiooutput getCurrentAudioBufferData], i_buffer_size);
p_blocka->i_nb_samples = [p_sys->audiooutput getNumberOfSamples]; p_blocka->i_nb_samples = [p_sys->audiooutput getNumberOfSamples];
p_blocka->i_pts = [p_sys->audiooutput getCurrentPts]; p_blocka->i_pts = [p_sys->audiooutput getCurrentPts];
[p_sys->audiooutput freeAudioMem];
} }
} }
if(!p_blocka->i_pts) { if (p_blocka) {
// Nothing to transfer yet, just forget if (!p_blocka->i_pts) {
block_Release(p_blocka); // Nothing to transfer yet, just forget
msleep(10000); msleep(10000);
return 1; return 1;
} }
if(p_blocka) {
es_out_Control(p_demux->out, ES_OUT_SET_PCR, p_blocka->i_pts); es_out_Control(p_demux->out, ES_OUT_SET_PCR, p_blocka->i_pts);
es_out_Send(p_demux->out, p_sys->p_es_audio, p_blocka); es_out_Send(p_demux->out, p_sys->p_es_audio, p_blocka);
} }
@synchronized (p_sys->audiooutput) {
[p_sys->audiooutput freeAudioMem];
}
return 1; return 1;
} }
......
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