Skip to content

Commit

Permalink
Fix segfault with libao >= 1.0.0 (first attempt)
Browse files Browse the repository at this point in the history
git-svn-id: https://dvbcut.svn.sourceforge.net/svnroot/dvbcut/trunk@178 36490176-9c1c-0410-b649-dbf2af5787bf
  • Loading branch information
too-tired committed Apr 29, 2011
1 parent 10e9c45 commit af1fa5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2011-04-29 Michael Riepe <[email protected]>

* src/playaudio.cpp:
Fix segfault with libao >= 1.0.

2011-04-25 Michael Riepe <[email protected]>

* src/mpgfile.cpp:
Expand Down
7 changes: 5 additions & 2 deletions src/playaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

/* $Id$ */

#include <cstring>
#include <stdint.h>
#include <algorithm>
#include <string>
Expand All @@ -43,7 +44,7 @@ class audioout
ao_close(m_device);
}

void play(int channels, int samplerate, int16_t *data, int frames)
void play(int channels, int samplerate, int16_t *data, int bytes)
{
if ((not m_device) or channels!=m_channels or samplerate!=m_samplerate)
{
Expand All @@ -54,6 +55,8 @@ class audioout
}

ao_sample_format format;
// zero-initialize
memset(&format, 0, sizeof(format));

format.bits = 16;
format.channels = channels;
Expand All @@ -68,7 +71,7 @@ class audioout
throw dvbcut_exception("Error setting up audio output");
}

ao_play(m_device, (char*) data, frames);
ao_play(m_device, (char*) data, bytes);
}
};

Expand Down

0 comments on commit af1fa5c

Please sign in to comment.